How to fix “unrecognized option '-plugin`” when using gdc to compile D program?

家住魔仙堡 提交于 2019-12-06 05:02:53

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/27813341/how-to-fix-unrecognized-option-plugin-when-using-gdc-to-compile-d-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!