Error during build: "as: unrecognized option '--text-section-literals'"
Bad-ptr opened this issue · comments
cd ~/Projects/
git clone --recurse-submodules https://github.com/nodemcu/nodemcu-firmware.git
docker run --rm --name 'nmcu-build' -it -v ~/Projects/nodemcu-firmware:/opt/nodemcu-firmware marcelstoer/nodemcu-build /bin/bash
cd /opt/nodemcu-firmware
build
Expected behavior
OK, build completed
Actual behavior
make[1]: Entering directory '/opt/nodemcu-firmware/app'
make[2]: Entering directory '/opt/nodemcu-firmware/app/user'
DEPEND: CC app/user/user_main.c
DEPEND: CC app/user/dbg_printf.c
CC app/user/dbg_printf.c
as: unrecognized option '--text-section-literals'
../../Makefile:422: recipe for target '.output/eagle/debug/obj/dbg_printf.o' failed
make[2]: *** [.output/eagle/debug/obj/dbg_printf.o] Error 1
make[2]: Leaving directory '/opt/nodemcu-firmware/app/user'
../Makefile:380: recipe for target '.subdirs' failed
make[1]: *** [.subdirs] Error 2
make[1]: Leaving directory '/opt/nodemcu-firmware/app'
Makefile:380: recipe for target '.subdirs' failed
make: *** [.subdirs] Error 2
make: Leaving directory '/opt/nodemcu-firmware'
(looking at the Makefile it's not needed)
This can be resolved with script:
add_to_path=''
find /opt/nodemcu-firmware/tools/toolchains/esp8266-linux-x86_64-*/bin \
| while read -r ffile
do
if [ -d "$ffile" ]
then
continue
fi
dir=`dirname "$ffile"`
add_to_path="$dir"
file=`basename "$ffile"`
nfile=`echo "$file"|cut -b 18-`
if [ -n "$nfile" ]
then
cp "$dir/$file" "$dir/$nfile"
fi
done
export PATH="${add_to_path}:${PATH}"
Explanation:
This error "as: unrecognized option '--text-section-literals'" happens because it tries to use 'system' assembler, while it must use assember for esp8266.
To resolve this we go to /opt/nodemcu-firmware/tools/toolchains/esp8266-linux-x86_64-*/bin
, and strip the starting part xtensa-lx106-elf-
of all files in the directory. Then we add this directory to PATH.
But then I get:
nodemcu.c:25:22: fatal error: platform.h: No such file or directory
lnodemcu.c:25:22: fatal error: platform.h: No such file or directory
loadlib.c:63:19: fatal error: dlfcn.h: No such file or directory
May be now it needs the 'system' compilers, not for esp ones.
OK, looks like if I run (just build command, rather than /bin/bash and then build from inside)
docker run --rm --name 'nmcu-build' -it -v ~/Projects/nodemcu-firmware/nodemcu-firmware:/opt/nodemcu-firmware marcelstoer/nodemcu-build build
Then build succeeds.