Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang passes --plugin-opt=Os to the linker #34868

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR35895
Status NEW
Importance P enhancement
Reported by Rui Ueyama (ruiu@google.com)
Reported on 2018-01-10 16:58:30 -0800
Last modified on 2018-04-02 16:29:04 -0700
Version unspecified
Hardware PC Windows NT
CC ditaliano@apple.com, grimar@accesssoftek.com, llvm-bugs@lists.llvm.org, pawel_sikora@zoho.com, rafael@espindo.la
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Clang passes -plugin-opt=Os to lld when LTO is enabled and -Os is passed. lld
does not recognize the flag. It shows the following error message:

  ld.lld: error: --plugin-opt: number expected, but got 's'
Quuxplusone commented 6 years ago

there's no Os for LTO, as far as I can tell. So you can probably ignore?

Quuxplusone commented 6 years ago

What I do not understand is that gold plugin doesn't take -plugin-opt=Os as well.

https://github.com/llvm-project/llvm-project-20170507/blob/f3e906e172cc0bd090b6358859946c99851a9a41/llvm/tools/gold/gold-plugin.cpp#L232

How does it work?

Quuxplusone commented 6 years ago
Should it work with gold ? Does not work for me, looks like expected behavior
actually:

~/LLVM/build_goldplugin/bin/clang -fuse-ld=gold -Os -flto=thin 1.cpp -o out -v

...

 "/usr/local/bin/ld.gold" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o out /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7.2.0/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/7.2.0 -L/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../.. -L/home/umb/LLVM/build_goldplugin/bin/../lib -L/lib -L/usr/lib -plugin /home/umb/LLVM/build_goldplugin/bin/../lib/LLVMgold.so -plugin-opt=mcpu=x86-64 -plugin-opt=Os -plugin-opt=thinlto /tmp/1-f9536b.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/7.2.0/crtend.o /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../x86_64-linux-gnu/crtn.o
/usr/local/bin/ld.gold: fatal error: Optimization level must be between 0 and 3
clang-7.0: error: linker command failed with exit code 1 (use -v to see
invocation)
Quuxplusone commented 6 years ago

Is there any issue here? Seems invalid for me.

Quuxplusone commented 6 years ago

Lets reassign to clang for now as both lld and the gold plugin reject this.