Search code examples
compilationembeddedclangllvm-clangcortex-m

How to configure clang to use arm-none-eabi linker


I am trying to configure the last version of clang (6.0) to use the arm-none-eabi linker instead of the ld.lld but clang is always ignoring everything and keep asking for the ld.lld one. I am trying to build for cortex-m3 (lpx1769 board). How do I force clang to use the linker I want.

-fuse-ld=ld is also not working, so does clang no longer allow the use of any other linker?


Solution

  • So the answer was to use the flag:

    -fuse-ld=path/to/linker-to-be-used

    Remember that if you passing this flag to clang it will cause a warning that clang will not use this flag (only the linker stage will do). Thus if you compiling with -Werror, the warning will be turned into an error.

    Moreover, because you are cross-compiling probably you will need to let the linker know where to find the target-specific libraries needed using the -L option. See this for more info:

    https://clang.llvm.org/docs/CrossCompilation.html