Bug 230137 - cc: -flto link option is broken: unrecognized option '-plugin'
Summary: cc: -flto link option is broken: unrecognized option '-plugin'
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.2-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-toolchain (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-29 05:20 UTC by Yuri Victorovich
Modified: 2018-08-02 02:45 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer 2018-07-29 05:20:09 UTC
How to reproduce:
1. Create a file x.c with this line: void f() { }

2. Run this command:
> cc -c -emit-llvm x.c -o x.o && cc -shared -flto x.o -o x.so

3. Observe the error:
> /usr/bin/ld: unrecognized option '-plugin'
> /usr/bin/ld: use the --help option for usage information
> cc: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 1 Conrad Meyer freebsd_committer 2018-07-29 16:46:41 UTC
This is expected on 11.x.  The base linker is still the ancient GPL2 ld.bfd from 2008.  I don't think we will switch linkers on stable/11.  12.0 should have llvm's lld linker, at least on amd64, which may enable LTO (if it works).
Comment 2 Yuri Victorovich freebsd_committer 2018-07-29 16:56:26 UTC
Ok, then feel free to close it if this is an expected behavior.
Comment 3 Ed Maste freebsd_committer 2018-07-30 00:24:34 UTC
You can give this a try:
% cc -c -emit-llvm x.c -o x.o && cc -fuse-ld=lld -shared -flto x.o -o x.so
Comment 4 Yuri Victorovich freebsd_committer 2018-07-30 00:33:02 UTC
(In reply to Ed Maste from comment #3)

This works, thanks!

One project used -flto, this is how I found this problem.