Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By davydnorris
#56044 OK so the story continues...

I took what I had learned from building jcmvbkbc/crosstool-NG, namely:
1) Turn off precompiled headers
2) Turn off TUI in gdb
3) Errors but finishes when building gcc 4.8.5
4) No errors when building gcc 5.2.0

and tried to carry them over to pfalcon/esp-open-sdk. I made the changes and tried to build with gcc 4.8.5. I got the same xgcc:spawn File not found... errors when building but crosstool-NG finished. It then choked on SDK 2.0.0 and I found out that Espressif have changed and moved the SDK2 file. The new SDK name and location is:

Code: Select allVENDOR_SDK_ZIP_2.0.0 = ESP8266_NONOS_SDK_V2.0.0_16_08_10.zip
VENDOR_SDK_DIR_2.0.0 = ESP8266_NONOS_SDK_V2.0.0_16_08_10
.
.
.
ESP8266_NONOS_SDK_V2.0.0_16_08_10.zip:
   wget --content-disposition "http://bbs.espressif.com/download/file.php?id=1690"


So I fixed that and built again and this time I got through to building libhal and my xtensa cross-gcc would not compile the library. It had problems looking for liblto_plugin.so - but this is strange because I am building on Cygwin64 so the dynamic library should be cyglto_plugin-0.dll!!

After looking at everything I found the reason for the xgcc:spawn error was the same thing - it could not find liblto_plugin.so and so some things did not build. I looked more and found that there was no entry for Cygwin64 in gcc/config.hosts, only Cygwin32.

SO I have made a patch file and added it to the project, and tomorrow I will try to build clean again. This time I think I will be close!!!

Here is the patch file if anybody wants it - I should submit it to esp-open-sdk or even crosstool-NG but I am not sure how.

--------- 1200-cygwin64.patch ------------
Code: Select alldiff -durN a/gcc/config.host b/gcc/config.host
--- a/gcc/config.host   2016-10-04 18:01:56.180731000 +1100
+++ b/gcc/config.host   2016-10-04 17:50:36.127000000 +1100
@@ -221,6 +221,13 @@
     host_exeext=.exe
     host_lto_plugin_soname=cyglto_plugin-0.dll
     ;;
+  x86_64-*-cygwin*)
+    host_xm_file=i386/xm-cygwin.h
+    out_host_hook_obj=host-cygwin.o
+    host_xmake_file="${host_xmake_file} i386/x-cygwin"
+    host_exeext=.exe
+    host_lto_plugin_soname=cyglto_plugin-0.dll
+    ;;
   i[34567]86-*-mingw32*)
     host_xm_file=i386/xm-mingw32.h
     host_xmake_file="${host_xmake_file} i386/x-mingw32"
User avatar
By davydnorris
#56175 So after adding that Cygwin64 patch, I got a completed build! No errors reported either!

But now I am having fun integrating it into my Windows based Eclipse environment :-( I can run it as a pure Makefile based project, but I want to integrate it as a proper Cross compile and it's failing.

I'm using Eclipse Neon.1, which supposedly automatically picks up the compiler details by running the tools on an empty C/C++ file, but it's coming up with errors.

I have set my PATH inside Eclipse to: D:\esp8266\xtensa-lx106-elf\bin;C:\cygwin64\bin so it picks up the toolchain and also Cygwin's make, and I changed the CDT Cross GCC Built-in Compiler Settings under the list of providers to be: xtensa-lx106-elf-${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"

I turned on the Console output to see what was happening and this is what I get for the gcc discovery part:

Code: Select all16:45:22 **** Running scanner discovery: CDT Cross GCC Built-in Compiler Settings ****
xtensa-lx106-elf-gcc -E -P -v -dD C:/workspaces/esp/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c
Using built-in specs.
COLLECT_GCC=/usr/bin/xtensa-lx106-elf-gcc
Target: xtensa-lx106-elf
Configured with: /cygdrive/d/Data/git/esp-open-sdk/crosstool-NG/.build/src/gcc-4.8.5/configure --build=x86_64-build_unknown-cygwin --host=x86_64-build_unknown-cygwin --target=xtensa-lx106-elf --prefix=/cygdrive/d/esp8266/xtensa-lx106-elf --with-local-prefix=/cygdrive/d/esp8266/xtensa-lx106-elf/xtensa-lx106-elf/sysroot --with-sysroot=/cygdrive/d/esp8266/xtensa-lx106-elf/xtensa-lx106-elf/sysroot --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG crosstool-ng-1.22.0-55-gecfc19a' --disable-__cxa_atexit --enable-cxx-flags='-fno-exceptions -fno-rtti' --with-gmp=/cygdrive/d/Data/git/esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-mpfr=/cygdrive/d/Data/git/esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-mpc=/cygdrive/d/Data/git/esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-isl=/cygdrive/d/Data/git/esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-cloog=/cygdrive/d/Data/git/esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-libelf=/cygdrive/d/Data/git/esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/buildtools --enable-lto --enable-target-optspace --without-long-double-128 --disable-libgomp --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-nls --disable-libstdcxx-pch --disable-multilib --enable-languages=c,c++
Thread model: single
gcc version 4.8.5 (crosstool-NG crosstool-ng-1.22.0-55-gecfc19a)
COLLECT_GCC_OPTIONS='-E' '-P' '-v' '-dD'
 cc1 -E -quiet -v -P -iprefix /usr/bin/../lib/gcc/xtensa-lx106-elf/4.8.5/ C:/workspaces/esp/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c -dD
xtensa-lx106-elf-gcc: error: spawn: No such file or directory

16:45:22 Build Finished (took 170ms)


So you can see it seems to be executing just fine, but choking when it tries to spawn the cc1.

***UPDATE***
OK so I just looked and there is no /usr/bin/../lib/gcc/xtensa-lx106-elf/4.8.5 in the built toolchain!! cc1.exe is actually in D:\esp8266\xtensa-lx106-elf\libexec\gcc\xtensa-lx106-elf\4.8.5

So it looks like something is still screwed up in the toolchain build somewhere

PS: If anybody has any ideas or comments, please jump in! I don't know if anybody is even interested in my struggle or is finding it useful (or good for a laugh!)
User avatar
By jcmvbkbc
#56196
davydnorris wrote:
Code: Select all16:45:22 **** Running scanner discovery: CDT Cross GCC Built-in Compiler Settings ****
xtensa-lx106-elf-gcc -E -P -v -dD C:/workspaces/esp/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c
Using built-in specs.
COLLECT_GCC=/usr/bin/xtensa-lx106-elf-gcc
Target: xtensa-lx106-elf
Configured with: ...
Thread model: single
gcc version 4.8.5 (crosstool-NG crosstool-ng-1.22.0-55-gecfc19a)
COLLECT_GCC_OPTIONS='-E' '-P' '-v' '-dD'
 cc1 -E -quiet -v -P -iprefix /usr/bin/../lib/gcc/xtensa-lx106-elf/4.8.5/ C:/workspaces/esp/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c -dD
xtensa-lx106-elf-gcc: error: spawn: No such file or directory

16:45:22 Build Finished (took 170ms)


So you can see it seems to be executing just fine, but choking when it tries to spawn the cc1.

***UPDATE***
OK so I just looked and there is no /usr/bin/../lib/gcc/xtensa-lx106-elf/4.8.5 in the built toolchain!! cc1.exe is actually in D:\esp8266\xtensa-lx106-elf\libexec\gcc\xtensa-lx106-elf\4.8.5

gcc didn't seem to search for cc1 under /usr/bin/../lib/gcc/xtensa-lx106-elf/4.8.5, it passed it as an -iprefix parameter to it. When I run the same command on linux gcc invokes cc1 by its full path though.
User avatar
By davydnorris
#56213
jcmvbkbc wrote:
davydnorris wrote:
Code: Select all16:45:22 **** Running scanner discovery: CDT Cross GCC Built-in Compiler Settings ****
xtensa-lx106-elf-gcc -E -P -v -dD C:/workspaces/esp/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c
Using built-in specs.
COLLECT_GCC=/usr/bin/xtensa-lx106-elf-gcc
Target: xtensa-lx106-elf
Configured with: ...
Thread model: single
gcc version 4.8.5 (crosstool-NG crosstool-ng-1.22.0-55-gecfc19a)
COLLECT_GCC_OPTIONS='-E' '-P' '-v' '-dD'
 cc1 -E -quiet -v -P -iprefix /usr/bin/../lib/gcc/xtensa-lx106-elf/4.8.5/ C:/workspaces/esp/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c -dD
xtensa-lx106-elf-gcc: error: spawn: No such file or directory

16:45:22 Build Finished (took 170ms)


So you can see it seems to be executing just fine, but choking when it tries to spawn the cc1.

***UPDATE***
OK so I just looked and there is no /usr/bin/../lib/gcc/xtensa-lx106-elf/4.8.5 in the built toolchain!! cc1.exe is actually in D:\esp8266\xtensa-lx106-elf\libexec\gcc\xtensa-lx106-elf\4.8.5

gcc didn't seem to search for cc1 under /usr/bin/../lib/gcc/xtensa-lx106-elf/4.8.5, it passed it as an -iprefix parameter to it. When I run the same command on linux gcc invokes cc1 by its full path though.


Thanks for the feedback - that's really useful to know. Based on that info I started googling and have found a few leads to chase up, and it does look like it's possibly Windows path related, but at least I now have a direction to chase!

Thanks also for all your work on the xtensa specific crosstools-NG in your project. You may want to add my changes from my last post to your Git project - that's the updated SDK name and URL, and the Cygwin64 specific patch. I don't suppose you know what the diffs between your current and open-esp-sdk are? Can I just update the submodule in open-esp-sdk to your HEAD?

I've submitted the Cygwin64 patch to the upstream crosstool-NG project too BTW