Thread overview
Pass parameter to gcc linker
Oct 05, 2020
Oleg B
Oct 05, 2020
kinke
Oct 05, 2020
Oleg B
October 05, 2020
Hello

I need to pass parameter to gcc then cross build D code for ARM.
In my case I have some missversions (I think) in cross compile tool stack: sysroot builded with unknown (for me) compiler, I use compiler with exact glibc version but with other build flags, and may be something else.

Problem: then I try to build my D code I get this kinds of errors:

/arm-gcc/bin/../lib/gcc/arm-linux-gnueabihf/8.2.1/../../../../arm-linux-gnueabihf/bin/ld.gold: error: /arm-gcc/bin/../libexec/gcc/arm-linux-gnueabihf/8.2.1/liblto_plugin.so: not configured to support 64-bit little-endian object
/arm-gcc/bin/../lib/gcc/arm-linux-gnueabihf/8.2.1/../../../../arm-linux-gnueabihf/bin/ld.gold: error: cannot find -lugin
/arm-gcc/bin/../lib/gcc/arm-linux-gnueabihf/8.2.1/../../../../arm-linux-gnueabihf/bin/ld.gold: error: cannot find -lugin-opt=/arm-gcc/bin/../libexec/gcc/arm-linux-gnueabihf/8.2.1/lto-wrapper
/arm-gcc/bin/../lib/gcc/arm-linux-gnueabihf/8.2.1/../../../../arm-linux-gnueabihf/bin/ld.gold: error: cannot find -lugin-opt=-fresolution=/tmp/cc89QFF3.res
...

I found only one resolution of problem: in ldc2.conf I select custom script for `-gcc` switch instead of direct compiler name

custom script disable lto for gcc call:

#!/bin/bash
arm-linux-gnueabihf-gcc -fno-lto $@

how to pass `-fno-lto` to gcc without "custom-script-hacking"?
As I know ldc used gcc only for linkage, but `-L-fno-lto` don't has effect.

gcc from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads

ldc 1.22.0 from github
October 05, 2020
Use -Xcc for linker driver flags (cc), not -L (for the actual linker, ld).
October 05, 2020
On Monday, 5 October 2020 at 19:12:14 UTC, kinke wrote:
> Use -Xcc for linker driver flags (cc), not -L (for the actual linker, ld).

Thanks!