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?

Thank you,

Kyriakos

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?

-fuse-ld=path/to/arm-none-eabi-ld

Hi Jon,

I tried this and I am getting:

/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/bin/ld: cannot find -lc
/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/bin/ld: cannot find -lm
clang-6.0: error: ld.lld command failed with exit code 1 (use -v to see invocation)

Is this similar to this bug?

https://www.mail-archive.com/llvm-bugs@lists.llvm.org/msg14451.html

Kind Regards,

Kyriakos

I’d need your entire clang invocation, plus ‘-v’. Jon

Here it is:

clang -v -fuse-ld=/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/bin/ld -target arm-none-eabi -isystem /usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include/ --static -mthumb -mcpu=cortex-m3 -D__USE_LPCOPEN -D__CODE_RED -D__REDLIB__ -DCHIP_LPC175X_6X -DCORE_M3 -ffunction-sections -fdata-sections /home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0/config/arm/chips/lpc175x_6x/crp.c /home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0/config/arm/chips/lpc175x_6x/custom_clocking.c -nostdlib -L/home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0/config/arm/chips/lpc175x_6x -L/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include -llpc_chip_175x_6x -T /home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0/config/arm/chips/lpc175x_6x/standalone.ld -Wl,–gc-sections -Wl,–start-group -lc -lm -Wl,–end-group conftest.c

clang version 6.0.0 (trunk 318625)
Target: arm-none–eabi
Thread model: posix
InstalledDir: /home/kg8280/work/programs/llvmCompilers/llvm5/build/bin
“/home/kg8280/work/programs/llvmCompilers/llvm5/build/bin/clang-6.0” -cc1 -triple thumbv7m-none–eabi -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name crp.c -static-define -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -nostdsysteminc -target-cpu cortex-m3 -target-feature +soft-float-abi -target-feature -crc -target-feature -dsp -target-feature -ras -target-feature -dotprod -target-feature -hwdiv-arm -target-feature +hwdiv -target-feature +strict-align -target-abi aapcs -mfloat-abi soft -fallow-half-arguments-and-returns -dwarf-column-info -debugger-tuning=gdb -v -ffunction-sections -fdata-sections -resource-dir /home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0 -isystem /usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include/ -D __USE_LPCOPEN -D __CODE_RED -D REDLIB -D CHIP_LPC175X_6X -D CORE_M3 -internal-isystem /home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/include -internal-isystem include -fdebug-compilation-dir /home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0 -ferror-limit 19 -fmessage-length 185 -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -o /tmp/crp-e2143b.o -x c /home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0/config/arm/chips/lpc175x_6x/crp.c
clang -cc1 version 6.0.0 based upon LLVM 6.0.0svn default target arm-none–eabi
ignoring duplicate directory “/home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/include”
#include “…” search starts here:
#include <…> search starts here:
/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include
/home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/include
include
End of search list.
“/home/kg8280/work/programs/llvmCompilers/llvm5/build/bin/clang-6.0” -cc1 -triple thumbv7m-none–eabi -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name custom_clocking.c -static-define -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -nostdsysteminc -target-cpu cortex-m3 -target-feature +soft-float-abi -target-feature -crc -target-feature -dsp -target-feature -ras -target-feature -dotprod -target-feature -hwdiv-arm -target-feature +hwdiv -target-feature +strict-align -target-abi aapcs -mfloat-abi soft -fallow-half-arguments-and-returns -dwarf-column-info -debugger-tuning=gdb -v -ffunction-sections -fdata-sections -resource-dir /home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0 -isystem /usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include/ -D __USE_LPCOPEN -D __CODE_RED -D REDLIB -D CHIP_LPC175X_6X -D CORE_M3 -internal-isystem /home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/include -internal-isystem include -fdebug-compilation-dir /home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0 -ferror-limit 19 -fmessage-length 185 -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -o /tmp/custom_clocking-9db145.o -x c /home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0/config/arm/chips/lpc175x_6x/custom_clocking.c
clang -cc1 version 6.0.0 based upon LLVM 6.0.0svn default target arm-none–eabi
ignoring duplicate directory “/home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/include”
#include “…” search starts here:
#include <…> search starts here:
/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include
/home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/include
include
End of search list.
“/home/kg8280/work/programs/llvmCompilers/llvm5/build/bin/clang-6.0” -cc1 -triple thumbv7m-none–eabi -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name conftest.c -static-define -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -nostdsysteminc -target-cpu cortex-m3 -target-feature +soft-float-abi -target-feature -crc -target-feature -dsp -target-feature -ras -target-feature -dotprod -target-feature -hwdiv-arm -target-feature +hwdiv -target-feature +strict-align -target-abi aapcs -mfloat-abi soft -fallow-half-arguments-and-returns -dwarf-column-info -debugger-tuning=gdb -v -ffunction-sections -fdata-sections -resource-dir /home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0 -isystem /usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include/ -D __USE_LPCOPEN -D __CODE_RED -D REDLIB -D CHIP_LPC175X_6X -D CORE_M3 -internal-isystem /home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/include -internal-isystem include -fdebug-compilation-dir /home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0 -ferror-limit 19 -fmessage-length 185 -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -o /tmp/conftest-22236c.o -x c conftest.c
clang -cc1 version 6.0.0 based upon LLVM 6.0.0svn default target arm-none–eabi
ignoring duplicate directory “/home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/include”
#include “…” search starts here:
#include <…> search starts here:
/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include
/home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/include
include
End of search list.
“/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/bin/ld” /tmp/crp-e2143b.o /tmp/custom_clocking-9db145.o -llpc_chip_175x_6x --gc-sections --start-group -lc -lm --end-group /tmp/conftest-22236c.o -Bstatic -L/home/kg8280/work/programs/llvmCompilers/llvm5/build/lib/clang/6.0.0/lib/baremetal -L/home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0/config/arm/chips/lpc175x_6x -L/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include -T /home/kg8280/work/PapersOnProgress/RAC/beebs-lpc1115_hardware_llvm5.0/config/arm/chips/lpc175x_6x/standalone.ld -o a.out
/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/bin/ld: cannot find -lc
/usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/bin/ld: cannot find -lm
clang-6.0: error: ld.lld command failed with exit code 1 (use -v to see invocation)

And where do your -lc / -lm live? I don’t see a --sysroot=. Jon –

Hi Jonathan,

I manage to configure and build by specifying were the libraries are by using the -L option.

Thank you very much!,

Kyriakos