SmingHub / Sming

Sming - powerful open source framework simplifying the creation of embedded C++ applications.
https://sming.readthedocs.io
GNU Lesser General Public License v3.0
1.47k stars 347 forks source link

Compiler command on FreeBSD #2275

Closed kmihaylov closed 3 years ago

kmihaylov commented 3 years ago

Hello, on FreeBSD they use the GCC version as a suffix, e.g. gcc9. When trying to build some of the samples I stuck here:

Building /opt/Sming/Sming/out/Esp8266/debug/tools/esptool2 /opt/Sming/Sming/out/Esp8266/debug/lib/clib-rboot-MD5.a
CC esptool2.c
gcc -O2 -Wall -std=c99 -c esptool2.c -o /opt/Sming/Sming/out/Esp8266/debug/build/rboot/rboot-MD5/esptool2/esptool2.o
gmake[3]: gcc: No such file or directory
gmake[3]: *** [Makefile:19: /opt/Sming/Sming/out/Esp8266/debug/build/rboot/rboot-MD5/esptool2/esptool2.o] Грешка 127
gmake[2]: *** [/opt/Sming/Sming/Components/rboot/component.mk:21: /opt/Sming/Sming/out/Esp8266/debug/tools/esptool2] Грешка 2
gmake[1]: *** [/opt/Sming/Sming/project.mk:430: rboot-build] Грешка 2
gmake[1]: излизане от директория „/opt/Sming/samples/Basic_Serial“
gmake: *** [/opt/Sming/Sming/project.mk:22: all] Грешка 2

I tried export COMPILE=gcc9 or COMPILE=gcc9 gmake w/o success. Would you please point me how to instruct (g)make for the proper compiler command?

mikee47 commented 3 years ago

Linux does the same but there should be links (see below) created either as part of the install or using a tool such as update-alternatives. Unfortunately I don't have a FreeBSD system to check this on...

/usr/bin
lrwxrwxrwx  1 root   root           5 Mar 20  2020  cpp -> cpp-9
lrwxrwxrwx  1 root   root          22 Aug  8  2020  cpp-9 -> x86_64-linux-gnu-cpp-9
lrwxrwxrwx  1 root   root           5 Mar 20  2020  g++ -> g++-9
lrwxrwxrwx  1 root   root          22 Aug  8  2020  g++-9 -> x86_64-linux-gnu-g++-9
lrwxrwxrwx  1 root   root           5 Mar 20  2020  gcc -> gcc-9
lrwxrwxrwx  1 root   root          22 Aug  8  2020  gcc-9 -> x86_64-linux-gnu-gcc-9
lrwxrwxrwx  1 root   root           8 Mar 20  2020  gcc-ar -> gcc-ar-9
lrwxrwxrwx  1 root   root          25 Aug  8  2020  gcc-ar-9 -> x86_64-linux-gnu-gcc-ar-9
lrwxrwxrwx  1 root   root           8 Mar 20  2020  gcc-nm -> gcc-nm-9
lrwxrwxrwx  1 root   root          25 Aug  8  2020  gcc-nm-9 -> x86_64-linux-gnu-gcc-nm-9
lrwxrwxrwx  1 root   root          12 Mar 20  2020  gcc-ranlib -> gcc-ranlib-9
lrwxrwxrwx  1 root   root          29 Aug  8  2020  gcc-ranlib-9 -> x86_64-linux-gnu-gcc-ranlib-9
-rwxr-xr-x  1 root   root        3477 Aug  4  2020  gcore
lrwxrwxrwx  1 root   root           6 Mar 20  2020  gcov -> gcov-9
lrwxrwxrwx  1 root   root          23 Aug  8  2020  gcov-9 -> x86_64-linux-gnu-gcov-9
lrwxrwxrwx  1 root   root          11 Mar 20  2020  gcov-dump -> gcov-dump-9
lrwxrwxrwx  1 root   root          28 Aug  8  2020  gcov-dump-9 -> x86_64-linux-gnu-gcov-dump-9
lrwxrwxrwx  1 root   root          11 Mar 20  2020  gcov-tool -> gcov-tool-9
lrwxrwxrwx  1 root   root          28 Aug  8  2020  gcov-tool-9 -> x86_64-linux-gnu-gcov-tool-9
slaff commented 3 years ago

I tried export COMPILE=gcc9 or COMPILE=gcc9 gmake w/o success.

Try export CC=gcc9 and CXX=gcc9++. Or whatever the name of the C++ compiler is. You can also test it from a sample application by passing the compilers as arguments to make. Example:

cd $SMING_HOME/../samples/Basic_Blink
make CC=gcc9 CXX=gcc9++
kmihaylov commented 3 years ago

@mikee47 I thought that update-alternatives tool would be best on FreeBSD, but it doesn't exist. https://forums.freebsd.org/threads/linux-update-alternatives-equivalent-on-freebsd.79316/

I'll go with symlink for now, however I believe it would be better if make could be instructed for the proper compiler command. PS: I did the link and the sample compiles fine.

@slaff I think I tried that (I passed the parameters in front of gmake not after it), w/o success (I'll re-check it again in a while). Also I think gcc is needed only once, at initializing Sming tools, since after that the xtensa compiler is used for the actual work. Give me few tens of minutes to figure it out and test my build system on FreeBSD 12.2 since it took me some 2 weeks trying to static-build EQT's binutins (w/o success, I omitted the LDFLAGS=-static).

https://github.com/earlephilhower/esp-quick-toolchain/issues/28

mikee47 commented 3 years ago

I don't suppose the MacOS/darwin tools work on clean FreeBSD ?

kmihaylov commented 3 years ago

Although MacOS is a fork of FreeBSD I think the tools and also some system internals are different, for example on FreeBSD the USB serial is /dev/ttyU0, but on MacOS (judging from the documentation) is /dev/tty.usbserial. Therefore I think the differences are more than expected.

I'm not aware with XCode and Homebrew. On FreeBSD I use binary packages. I'll try to make a quick PR for the docs.

With ESP8266 Sming and FreeBSD are good together, but I'm scared of what would be with esp-idf. :(

mikee47 commented 3 years ago

Also I think gcc is needed only once, at initializing Sming tools, since after that the xtensa compiler is used for the actual work.

It's also required for Host emulator builds - I consider this an essential part of my development and testing process :-)

May I suggest (for now at least) simply editing the Sming/Arch/Host/build.mk file and adjust the tool specs. as required?

kmihaylov commented 3 years ago

Thanks for the suggestion. I don't use the Host arch, but if in need I'll know the place!

kmihaylov commented 3 years ago

I'm closing this as insignificant issue.