On Mon, Oct 3, 2016 at 10:54 PM, Teresa Johnson <tejohnson at google.com> wrote:> > Aha - finally reproduced! The difference is using ld.bfd not > ld.gold. With that I get the same failure (using 3.9 to build 3.9 > sources):Thanks a lot! [...]> I am not sure what the official support story is for LLVMgold.so and > ld.bfd. As mentioned earlier, the LLVM site indicates it should use > the gold linker. Can you use that while I try to figure out whether > this is something that should be supported/working?I'm probably confused but I was under the impression that I am using ld.gold due to the use of llvm-ar and llvm-ranlib and having enabled ThinLTO, which, if not strictly required with ld.bfd >=2.26, prefers ld.gold. Anyway, if I extend CFLAGS and CXXFLAGS with -fuse-ld=gold, then ld.gold terminates with /usr/bin/ld.gold: fatal error: --plugin-opt requires --plugin According to the manpage the compile driver, if passed -fuse-ld=gold, will use ld.gold, so I added that to CFLAGS and CXXFLAGS before running cmake. The above was how far I got without further insight what I might have missed. I also tried setting LD=ld.gold, but that wasn't really respected by cmake, judging by how the ld actually used complained about the unsupport -Wl options (those which you suggested for aggressive pruning and which are not universal). Which are: -Wl,--gc-sections -Wl,-plugin-opt,-function-sections -Wl,-plugin-opt,-data-sections" What's the right way to enable ld.gold explicitly when configuring llvm with cmake?
For clang build, cmake flags: -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold \ -DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=gold \ -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=gold \ David On Mon, Oct 3, 2016 at 5:04 PM, Carsten Mattner via llvm-dev < llvm-dev at lists.llvm.org> wrote:> On Mon, Oct 3, 2016 at 10:54 PM, Teresa Johnson <tejohnson at google.com> > wrote: > > > > Aha - finally reproduced! The difference is using ld.bfd not > > ld.gold. With that I get the same failure (using 3.9 to build 3.9 > > sources): > > Thanks a lot! > > [...] > > > I am not sure what the official support story is for LLVMgold.so and > > ld.bfd. As mentioned earlier, the LLVM site indicates it should use > > the gold linker. Can you use that while I try to figure out whether > > this is something that should be supported/working? > > I'm probably confused but I was under the impression that I am using > ld.gold due to the use of llvm-ar and llvm-ranlib and having enabled > ThinLTO, which, if not strictly required with ld.bfd >=2.26, prefers > ld.gold. > > Anyway, if I extend CFLAGS and CXXFLAGS with -fuse-ld=gold, then > ld.gold terminates with > > /usr/bin/ld.gold: fatal error: --plugin-opt requires --plugin > > According to the manpage the compile driver, if passed -fuse-ld=gold, > will use ld.gold, so I added that to CFLAGS and CXXFLAGS before > running cmake. The above was how far I got without further insight > what I might have missed. > > I also tried setting LD=ld.gold, but that wasn't really respected by > cmake, judging by how the ld actually used complained about the > unsupport -Wl options (those which you suggested for aggressive > pruning and which are not universal). > > Which are: > -Wl,--gc-sections > -Wl,-plugin-opt,-function-sections > -Wl,-plugin-opt,-data-sections" > > What's the right way to enable ld.gold explicitly when configuring > llvm with cmake? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161003/af6b2836/attachment.html>
On Mon, Oct 3, 2016 at 5:04 PM, Carsten Mattner <carstenmattner at gmail.com> wrote:> On Mon, Oct 3, 2016 at 10:54 PM, Teresa Johnson <tejohnson at google.com> > wrote: > > > > Aha - finally reproduced! The difference is using ld.bfd not > > ld.gold. With that I get the same failure (using 3.9 to build 3.9 > > sources): > > Thanks a lot! > > [...] > > > I am not sure what the official support story is for LLVMgold.so and > > ld.bfd. As mentioned earlier, the LLVM site indicates it should use > > the gold linker. Can you use that while I try to figure out whether > > this is something that should be supported/working? > > I'm probably confused but I was under the impression that I am using > ld.gold due to the use of llvm-ar and llvm-ranlib and having enabled > ThinLTO, which, if not strictly required with ld.bfd >=2.26, prefers > ld.gold. >llvm-ar and llvm-ranlib are separate tools from ld.gold. And by using them instead of system ar and ranlib, you don't need to ensure they use the LLVMgold.so plugin, because they invoke LLVM libraries directly. I poked around a little on the web a bit and it looks like the ld.bfd support for using LLVMgold.so is fairly recent (probably why David says it needs to be >= 2.26). However, they may still be resolving issues with supporting the LLVMgold.so plugin. Definitely using LLVMgold.so with ld.gold is much better tested (and possibly much better supported from the LLVM side).> Anyway, if I extend CFLAGS and CXXFLAGS with -fuse-ld=gold, then > ld.gold terminates with > > /usr/bin/ld.gold: fatal error: --plugin-opt requires --plugin >Is this during cmake or during the build of bin/lldb? But yeah, that is an aggravating issue with gold - it won't simply ignore -plugin-opt when the plugin is not being invoked, which has given me issues as well trying to run cmake configuration with -plugin-opt. Looks like -fuse-ld=gold is somehow passing in a -plugin-opt? Oh, maybe it is the plugin-opts below (see my next comment).> According to the manpage the compile driver, if passed -fuse-ld=gold, > will use ld.gold, so I added that to CFLAGS and CXXFLAGS before > running cmake. The above was how far I got without further insight > what I might have missed. > > I also tried setting LD=ld.gold, but that wasn't really respected by > cmake, judging by how the ld actually used complained about the > unsupport -Wl options (those which you suggested for aggressive > pruning and which are not universal). > > Which are: > -Wl,--gc-sections > -Wl,-plugin-opt,-function-sections > -Wl,-plugin-opt,-data-sections" >Did you set these via the cmake command? Maybe these are the options giving the above error actually (if during cmake). In that case, edit the CMakeCache.txt and add them there after running cmake.> What's the right way to enable ld.gold explicitly when configuring > llvm with cmake? >If you get rid of the above -plugin-opt from the cmake command (and maybe add to CMakeCache.txt after running cmake), does it work ok with -fuse-ld=gold (possibly specify this on the *LINKER_FLAGS instead as David suggests in his reply)? Another possibility, which is what I did to force usage of ld.bfd, is to set your PATH to somewhere that ld -> ld.gold before running the "ninja bin/lldb" Teresa -- Teresa Johnson | Software Engineer | tejohnson at google.com | 408-460-2413 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161003/8eb5b4e6/attachment-0001.html>
On Tue, Oct 4, 2016 at 2:22 AM, Xinliang David Li <xinliangli at gmail.com> wrote:> For clang build, cmake flags: > > -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold \ > -DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=gold \ > -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=gold \Thanks, this didn't break the cmake run. I've been successfully using LDFLAGS, CXXFLAGS, CPPFLAGS, CFLAGS. It works, but now I wonder if it's safer to pass those via a -DCMAKE_CXXFLAGS. Any idea? If so, what are the LLVM CMake variables to set ldflags, cxxflags, cppflags, cflags?
On Tue, Oct 4, 2016 at 2:31 AM, Teresa Johnson <tejohnson at google.com> wrote:> > > On Mon, Oct 3, 2016 at 5:04 PM, Carsten Mattner <carstenmattner at gmail.com> > wrote: > > > > On Mon, Oct 3, 2016 at 10:54 PM, Teresa Johnson <tejohnson at google.com> > > wrote: > > > > > > Aha - finally reproduced! The difference is using ld.bfd not > > > ld.gold. With that I get the same failure (using 3.9 to build > > > 3.9 sources): > > > > Thanks a lot! > > > > [...] > > > > > I am not sure what the official support story is for LLVMgold.so > > > and ld.bfd. As mentioned earlier, the LLVM site indicates it > > > should use the gold linker. Can you use that while I try to > > > figure out whether this is something that should be > > > supported/working? > > > > I'm probably confused but I was under the impression that I am > > using ld.gold due to the use of llvm-ar and llvm-ranlib and having > > enabled ThinLTO, which, if not strictly required with ld.bfd > > >=2.26, prefers ld.gold. > > > llvm-ar and llvm-ranlib are separate tools from ld.gold. And by > using them instead of system ar and ranlib, you don't need to ensure > they use the LLVMgold.so plugin, because they invoke LLVM libraries > directly. > > I poked around a little on the web a bit and it looks like the > ld.bfd support for using LLVMgold.so is fairly recent (probably why > David says it needs to be >= 2.26). However, they may still be > resolving issues with supporting the LLVMgold.so plugin. Definitely > using LLVMgold.so with ld.gold is much better tested (and possibly > much better supported from the LLVM side).Thanks.> > Anyway, if I extend CFLAGS and CXXFLAGS with -fuse-ld=gold, then > > ld.gold terminates with > > > > /usr/bin/ld.gold: fatal error: --plugin-opt requires --plugin > > > Is this during cmake or during the build of bin/lldb?cmake.> But yeah, that is an aggravating issue with gold - it won't simply > ignore -plugin-opt when the plugin is not being invoked, which has > given me issues as well trying to run cmake configuration with > -plugin-opt. Looks like -fuse-ld=gold is somehow passing in a > -plugin-opt? Oh, maybe it is the plugin-opts below (see my next > comment).It can be preferable to thinking the option was used but was actually ignored.> Did you set these via the cmake command? Maybe these are the options > giving the above error actually (if during cmake). In that case, > edit the CMakeCache.txt and add them there after running cmake.It was cmake but not via -DCMAKE. Just plain CXXFLAGS, etc. to tell the compile driver (gcc) to use gold.> > What's the right way to enable ld.gold explicitly when configuring > > llvm with cmake? > > > If you get rid of the above -plugin-opt from the cmake command (and > maybe add to CMakeCache.txt after running cmake), does it work ok > with -fuse-ld=gold (possibly specify this on the *LINKER_FLAGS > instead as David suggests in his reply)?I haven't tried to build yet, but passing -fuse-ld=gold as suggested with the three cmake variables by Xinliang David Li didn't break cmake.> Another possibility, which is what I did to force usage of ld.bfd, > is to set your PATH to somewhere that ld -> ld.gold before running > the "ninja bin/lldb"A symlink might suffice I suppose.