Shanks0224 opened a new pull request, #22612: URL: https://github.com/apache/nuttx/pull/22612
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary Fixes for building with the Cadence xt-clang toolchain (`CONFIG_XTENSA_TOOLCHAIN_XCLANG`) and the related Clang options: - **Link the toolchain libraries found by xt-clang in CMake.** `platform.cmake` gets the full paths of libgcc and the other toolchain libraries from the compiler driver. With xt-clang it then searched for each of these paths again below the directory reported by `--show-config=config`, which only works with bare library names: with full paths nothing is found and the libraries are not linked. The driver already returns the libraries of the selected core, so add them as for the other toolchains. - **Disable `-Watomic-alignment` for xt-clang** in the Make toolchain files, as is already done for xcc. Like xcc, xt-clang warns about every atomic access wider than the lock-free size of the core. - **Disable `-Watomic-alignment` in the common warning options** of the CMake and lx7 Make toolchain files. The CMake file disabled it for xcc only, so an xt-clang CMake build of code that uses C11 atomics (for example FFmpeg's libavutil) warns on each 4-byte atomic access. GCC does not have this warning and ignores the unknown `-Wno-` option. - **Fix the KASAN compiler options for Clang.** The toolchain files tested `CONFIG_ARM_TOOLCHAIN_CLANG`, which is never set on Xtensa, so a Clang build got the GCC `--param` options. Test `CONFIG_ARCH_TOOLCHAIN_CLANG` and pass each parameter as an LLVM option with its leading `-` (`-mllvm -<param>` in Make, `-mllvm=-<param>` in CMake). - **Build C++ with `-femulated-tls` for xcc and xt-clang**, so that `thread_local` variables go through `__emutls_get_address()`, which NuttX provides (libs/libc/tls). - **Ignore the unused KASAN options when linking with Clang** in CMake: Clang reports the KASAN `-mllvm` options as unused at the link step, which fails with `-Werror`: ``` clang-15: error: argument unused during compilation: '-mllvm -asan-globals=0' [-Werror,-Wunused-command-line-argument] ``` ## Impact Xtensa only. Except for the common `-Wno-atomic-alignment`, all changes apply only with `CONFIG_XTENSA_TOOLCHAIN_XCC`, `CONFIG_XTENSA_TOOLCHAIN_XCLANG` or `CONFIG_ARCH_TOOLCHAIN_CLANG`, which no in-tree configuration selects. With the Espressif GCC toolchain the KASAN options, the libraries and the other flags do not change. ## Testing No in-tree board uses xt-clang and I do not have an xt-clang toolchain for an in-tree core, so the xt-clang paths are not tested. With the Espressif toolchain (xtensa-esp-elf 14.2.0): - Each commit builds esp32s3-devkit:nsh without warnings; esp32-devkitc:nsh builds without warnings and without "unrecognized command-line option" notes. - esp32s3-devkit:nsh + `CONFIG_MM_KASAN=y CONFIG_MM_KASAN_INSTRUMENT_ALL=y` builds with Make and with CMake, with the same warnings as master. Not tested on real hardware. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
