Open Lqs66 opened 1 year ago
What are you cross compiling for, and why are you not using waf?
CC=clang CXX=clang++ CXXFLAGS="-O0 -g --target=arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include-fixed -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ./waf configure --board=CUAVv5
I actually use waf and I use "CC=clang CXX=clang++ CXXFLAGS="-O0 -g --target=arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include-fixed -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ./waf configure --board=CUAVv5" to configure it. I chose clang for compilation because I needed to use llvm's static analysis capabilities.
CC=clang CXX=clang++ CXXFLAGS="-O0 -g --target=arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include-fixed -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ./waf configure --board=CUAVv5
I actually use waf and I use "CC=clang CXX=clang++ CXXFLAGS="-O0 -g --target=arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include-fixed -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ./waf configure --board=CUAVv5" to configure it. I chose clang for compilation because I needed to use llvm's static analysis capabilities.
I see that you have cross posted between the forums, here, and discourse.
https://discuss.ardupilot.org/t/problems-with-compilation/108985/8
Please avoid spamming all the places for support; let's follow up in the discourse thread.
Tagging this for wiki needed. The wiki instructions for building on Ubuntu 22 with clang do not work. It's missing packages from the default install like clang. It's not specific to cross-compile, it doesn't work even on native compilation following BUILD.md.
CC=clang CXX=clang++ CXXFLAGS="-O0 -g --target=arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include-fixed -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ./waf configure --board=CUAVv5
I actually use waf and I use "CC=clang CXX=clang++ CXXFLAGS="-O0 -g --target=arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include-fixed -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ./waf configure --board=CUAVv5" to configure it. I chose clang for compilation because I needed to use llvm's static analysis capabilities.
I see that you have cross posted between the forums, here, and discourse.
https://discuss.ardupilot.org/t/problems-with-compilation/108985/8
Please avoid spamming all the places for support; let's follow up in the discourse thread.
Sorry, I'll undo what I did on discord.
Clang compilation is only working for SITL and Linux build.
If you just want static analysis, just build SITL, beside of the os layer, the vehicle code is the same so you will be able to do the analysis you want.
Clang compilation is only working for SITL and Linux build.
If you just want static analysis, just build SITL, beside of the os layer, the vehicle code is the same so you will be able to do the analysis you want.
Still, I would like to know the reason for this error.
…/…/libraries/AP_HAL_ChibiOS/UARTDriver.cpp:466:9: fatal error: use of undeclared identifier ‘vprintf_console_hook’ vprintf_console_hook = hal_console_vprintf; ^ 6 warnings and 1 error generated.
Clang compilation is only working for SITL and Linux build.
If you just want static analysis, just build SITL, beside of the os layer, the vehicle code is the same so you will be able to do the analysis you want.
By "linux build" do you mean the navio2 board? Can clang be used to cross-compile raspberry pi + navio2?
I have been failing for 4 days, long hours, can't figure this out. So many errors in compiling. Now at this one. If we want more than 3 temp sensors we have to figure this out to enable the AP macro.
I have been failing for 4 days, long hours, can't figure this out. So many errors in compiling. Now at this one. If we want more than 3 temp sensors we have to figure this out to enable the AP macro.
Indeed clang can only be used for linux builds such as raspberry pi etc. If you want to build non-sitl I recommend navio2.
Bug report
To implement clang cross-compile ardupilot, you need to specify for clang the header files and libraries to be used for arm-none-eabi-gcc compilation, for this I configured and compiled with the following command:
CC=clang CXX=clang++ CXXFLAGS="-O0 -g --target=arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/include-fixed -I/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ./waf configure --board=CUAVv5
The following error occurs:
Thereupon I removed the -mno-thumb-interwork compilation option from CUAVv5_cache.py and continued compiling, and again the following error occurred:
I further modified CUAVv5_cache.py to include '--sysroot=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/... /arm-none-eabi' was removed to continue compiling and ended up with the following error:
I changed "off_t AP_Filesystem_FATFS::lseek(int fileno, off_t position, int whence)" to "int32_t AP_Filesystem_FATFS::lseek(int fileno, int32_t position, int whence)". FATFS::lseek(int fileno, int32_t position, int whence)" to "int32_t AP_Filesystem_FATFS::lseek(int fileno, int32_t position, int whence)", you can continue to compile until the following error occurs:
Obviously so far the cross compilation is failing.
Platform [ ] All [ ] AntennaTracker [*] Copter [ ] Plane [ ] Rover [ ] Submarine