Open Quuxplusone opened 8 years ago
On a second look at the linker invocation command, it appears to try and link libm statically itself, as seen in the following part:
/usr/lib/libmvec_nonshared.a /usr/lib/libmvec.a /usr/lib/libm.a /tools/bin/../lib/clang/3.9.0/lib/linux/libclang_rt.builtins-x86_64.a -lc
However, for some reason, it isn't being picked up since it's before libclang_rt.builtins-x86_64.a. This might be ld.bfd bug, but then again, it can be solved by swapping
/tools/bin/../lib/clang/3.9.0/lib/linux/libclang_rt.builtins-x86_64.a and
/usr/lib/libmvec_nonshared.a /usr/lib/libmvec.a /usr/lib/libm.a
on the linker command line. Anyways, this might result in increased binary size, so is there a way to build clang runtime as a shared library and link to shared libm (doesn't have to be solved by this bug and doesn't even have to make it to 3.9).
Perhaps cbieneman can comment? (Also PR28681 might be in the same neighbourhood.)
Armin: is this something that has changed since the 3.8 release? I.e., is it a regression?
I can't tell, I haven't used compiler-rt with 3.8.
Where did you get your clang from? If you built it yourself do you happen to know the configuration command line you used?
Looking into this a bit more. Those symbols are expected to be unresolved in the builtin library, which means the problem is likely either in the driver or the linker.
(In reply to comment #4)
> Where did you get your clang from? If you built it yourself do you happen to
> know the configuration command line you used?
https://github.com/elkrejzi/system-management/blob/master/buildscripts/buildllvm#L156
Add -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release to these flags.
clang was patched to explicitly use compiler-rt and some other paths which are
unrelated
https://github.com/elkrejzi/system-management/blob/master/patches/clang-runtime.patch
Not treating as a 3.9 blocker. I don't think this is a regression.
I don't think this is actually a bug in our compiler. gnutools::linker::ConstructJob unconditionally adds -lm, to linker invocations.
The out-of-tree patches being used seem to be adding support for a new linux distribution, and it looks like there isn't a proper code path in the clang Tools/Toolchains code.
Someone who actually knows the clang driver would be better suited to diagnose and advise, but I agree with Hans' assessment that this isn't a regression and shouldn't block the release.
(In reply to comment #8)
> I don't think this is actually a bug in our compiler.
> gnutools::linker::ConstructJob unconditionally adds -lm, to linker
> invocations.
>
Yes, I can see that. See the original post for linker invocation command.
The issue is that -lm needs to be added *after* compiler-rt libraries for it to
be picked up correctly. Why? No idea.
Attached file_28652.txt
(502 bytes, text/plain): Potential fix on trunk
I stumbled across this old bug because we're hitting this issue as well. Chris, I took your patch and applied it in https://reviews.llvm.org/D49330. In the past two years since this bug was filed, have you just been working around by manually adding -lm when using compiler-rt?
(In reply to Jordan Rupprecht from comment #11)
> I stumbled across this old bug because we're hitting this issue as well.
> Chris, I took your patch and applied it in https://reviews.llvm.org/D49330.
> In the past two years since this bug was filed, have you just been working
> around by manually adding -lm when using compiler-rt?
Yes, I created a linker script, as seen here:
https://github.com/elkrejzi/pacman/blob/master/pkgbuild/llvm/PKGBUILD#L272
file_28652.txt
(502 bytes, text/plain)