Stream: t-compiler/wg-llvm

Topic: Updating LLVM...

Nikita Popov (Jul 06 2019 at 21:16, on Zulip):

I'm trying to update our LLVM version to current master. Ran into this linker error:

/usr/bin/ld: /home/nikic/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-5c2422e2d705ee7d.rlib(std-5c2422e2d705ee7d.std.e5hw7qqp-cgu.2.rcgu.o): TLS transition from R_X86_64_TLSLD to R_X86_64_TPOFF32 against `_ZN3std10sys_common11thread_info11THREAD_INFO7__getit5__KEY17hc720e1025694e38eE' at 0x15 in section `.text._ZN3std10sys_common11thread_info3set17hbe84d5bac17e4e00E' failed

I'm a bit stumped on how I would go about debugging something like this.

Nikita Popov (Jul 07 2019 at 11:45, on Zulip):

I suspect this is due to It looks like __tls_get_addr now uses a GOTPCREL rather than PLT32 relocation and that somehow breaks things.

nagisa (Jul 07 2019 at 11:45, on Zulip):

Try another linker, possibly a linker bug with your particular version of binutil.

nagisa (Jul 07 2019 at 11:55, on Zulip):

At least if I understand the error correctly, then "ELF handling for Thread-Local storage document” specifies a mechanism to transition from TLSLD to TPOFF32

nagisa (Jul 07 2019 at 11:56, on Zulip):

As far as debugging goes, I would also attempt to 1) minimize and 2) look at the assembly to understand what relocations llvm generates

Nikita Popov (Jul 07 2019 at 12:02, on Zulip):

Yeah, I've minimized this (just a thread local linked in from a different crate is enough) and looked at the objdump differences, which turned out to just be GOT vs PLT for the __tls_get_addr symbol.

Nikita Popov (Jul 07 2019 at 12:02, on Zulip):

Tried a different linker -- works with gold.

Nikita Popov (Jul 07 2019 at 12:12, on Zulip):

Wait no, it seems to work with both binutils ld and gold when explicitly specified via -C linker. But fails without. What is our default linker?

Nikita Popov (Jul 07 2019 at 12:20, on Zulip):

Looks like the default linker is cc.

Nikita Popov (Jul 07 2019 at 13:13, on Zulip):

Okay, it doesn't work with -Clinker after all. Turns out I just get an empty executable in that case because crt0 is not linked in. After dropping libc it also happens with an explicit -C linker=/usr/bin/ld.

nagisa (Jul 07 2019 at 18:10, on Zulip):

There’s linker-flavour option which specifies what kind of a linker you’re using.

nagisa (Jul 07 2019 at 18:11, on Zulip):

My go-to alternative is usually clang -fuse-ld=lld

Last update: Jul 03 2020 at 17:45UTC