5

I download the GDC for Linux, and try to build a simple D Program. After executing "gdc hello.d -o hello ", it outputs:

[root@localhost nan]# gdc hello.d -o hello
/usr/bin/ld: unrecognized option '-plugin'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status

Then I use "gdc -v hello.d -o hello" command, and try to find the root cause. It displays:

......
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /home/nan/x86_64-gdcproject-linux-gnu/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/collect2 -plugin /home/nan/x86_64-gdcproject-linux-gnu/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/liblto_plugin.so -plugin-opt=/home/nan/x86_64-gdcproject-linux-gnu/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccWgsSJO.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o hello /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /home/nan/x86_64-gdcproject-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/crtbegin.o -L/home/nan/x86_64-gdcproject-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0 -L/home/nan/x86_64-gdcproject-linux-gnu/bin/../lib/gcc -L/lib/../lib64 -L/usr/lib/../lib64 -L/home/nan/x86_64-gdcproject-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../.. /tmp/ccEygjf5.o -lgphobos2 -lm -lpthread -lrt -lgcc_s -lgcc -lc -lgcc_s -lgcc /home/nan/x86_64-gdcproject-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/crtend.o /usr/lib/../lib64/crtn.o

It seems that collect2 doesn't recognize "-plugin" option. I try to google it, but can't find any valuable information. Could anyone give some suggestions? Thanks very much in advance!

Nan Xiao
  • 16,671
  • 18
  • 103
  • 164

1 Answers1

5

This is probabbly cause because gdc wac compiled against differnt GCC (same version but with different compile flags (some plugins may missing)) than yours distro gcc.

Sometimes is possible to install missing plugin or install different gcc. Or you can use

-fno-use-linker-plugin

as jpf suggest

Community
  • 1
  • 1
Kozzi11
  • 2,413
  • 12
  • 17
  • 2
    We compile on debian wheezy which has support for linker plugins enabled and gcc therefore defaults to use linker plugins. It's generally a good idea to install binutils/gcc/gdc from the same source (preferable linux distribution packages) because of such issues. As a workaround I could probably explicitly disable linker plugin support for the binary releases on gdcproject.org. Linker plugin support is required for LTO but right now we don't support LTO anyway. – jpf Jan 07 '15 at 17:54
  • I'm helping to sort out LTO issues on Arch Linux ARM. If anyone can shed some light on this gdc build config issue, https://github.com/truedat101/dlang-sv-community/issues/44#issuecomment-466103564 , the problems seem similar in nature, how GDC was configured. Disabling the linker plugin causes a different issue. – truedat101 Mar 03 '19 at 18:02