Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-module TLS imports are broken on MIPS #45654

Closed
alexcrichton opened this issue Oct 31, 2017 · 1 comment · Fixed by #45806
Closed

Cross-module TLS imports are broken on MIPS #45654

alexcrichton opened this issue Oct 31, 2017 · 1 comment · Fixed by #45806
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

Comments

@alexcrichton
Copy link
Member

This is a tracking issue for this debugging story which concludes with:

$ cat foo.ll
@foo = external hidden thread_local global i32

define i32 @bar() {
  %a = load i32, i32* @foo
  ret i32 %a
}
$ llc foo.ll -filetype=obj -o foo.o -mtriple=mipsel-unknown-linux-gnu
$ readelf -Ws foo.o

Symbol table '.symtab' contains 5 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 FILE    LOCAL  DEFAULT  ABS foo.ll
     2: 00000000     0 SECTION LOCAL  DEFAULT    2
     3: 00000000    24 FUNC    GLOBAL DEFAULT    2 bar
     4: 00000000     0 TLS     GLOBAL HIDDEN   UND foo
$ llc foo.ll -filetype=obj -o foo.o -mtriple=mipsel-unknown-linux-gnu -relocation-model=pic
$ readelf -Ws foo.o

Symbol table '.symtab' contains 7 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 FILE    LOCAL  DEFAULT  ABS foo.ll
     2: 00000000     0 SECTION LOCAL  DEFAULT    2
     3: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __tls_get_addr
     4: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _gp_disp
     5: 00000000    56 FUNC    GLOBAL DEFAULT    2 bar
     6: 00000000     0 NOTYPE  GLOBAL HIDDEN   UND foo

Notably the import of foo on MIPS is not flagged as "TLS" under the "Type" column when the import is both hidden visibility and compiled with -relocation-model=pic. This is most likely an LLVM bug but we're starting to implement workarounds for this, and those workarounds will reference this issue.

@alexcrichton alexcrichton added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Oct 31, 2017
alexcrichton added a commit to alexcrichton/rust that referenced this issue Oct 31, 2017
Discovered in rust-lang#45529 it looks like cross-module TLS imports aren't quite working
today, especially with `hidden` visibility which mostly comes up with multiple
codegen units. As a result this completely disables compiling with ThinLTO and
multiple codegen units on MIPS when bootstrapping.

cc rust-lang#45654, the tracking issue for this
bors added a commit that referenced this issue Oct 31, 2017
rustbuild: Don't build with ThinLTO on MIPS

Discovered in #45529 it looks like cross-module TLS imports aren't quite working
today, especially with `hidden` visibility which mostly comes up with multiple
codegen units. As a result this completely disables compiling with ThinLTO and
multiple codegen units on MIPS when bootstrapping.

cc #45654, the tracking issue for this
@alexcrichton
Copy link
Member Author

A fix has landed upstream, I'm now testing to see whether it works.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Nov 6, 2017
Now that the upstream LLVM bug is now fixed this commit cherry-picks the commit
onto our LLVM and then re-enables the ThinLTO paths for MIPS.

Closes rust-lang#45654
bors added a commit that referenced this issue Nov 11, 2017
…erister

rustbuild: Re-enable ThinLTO for MIPS

Now that the upstream LLVM bug is now fixed this commit cherry-picks the commit
onto our LLVM and then re-enables the ThinLTO paths for MIPS.

Closes #45654
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant