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

Support multithreading #388

Closed
bjorn3 opened this issue Feb 28, 2019 · 18 comments · Fixed by #784
Closed

Support multithreading #388

bjorn3 opened this issue Feb 28, 2019 · 18 comments · Fixed by #784
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Feb 28, 2019

Currently atomics are not atomic.

Blocked on https://github.com/CraneStation/cranelift/issues/582

@bjorn3 bjorn3 added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Feb 28, 2019
@bjorn3 bjorn3 changed the title Support threading Support multithreading Feb 28, 2019
@bjorn3
Copy link
Member Author

bjorn3 commented Sep 1, 2019

This would also require TLS support. (not the protocol, but thread-local storage)

Edit: opened bytecodealliance/cranelift#963

@philipc
Copy link
Contributor

philipc commented Sep 1, 2019

I am interested in adding TLS support to the object crate, and this would make a good test for it. Is this something you would be interested in using?

@bjorn3
Copy link
Member Author

bjorn3 commented Sep 1, 2019

Sure @philipc.

@bjorn3
Copy link
Member Author

bjorn3 commented Sep 3, 2019

https://github.com/bjorn3/rustc_codegen_cranelift/tree/wip_tls contains a test for tls support.

@bjorn3
Copy link
Member Author

bjorn3 commented Sep 14, 2019

#![feature(thread_local)]

#[thread_local]
static mut A: u8 = 42;

pub unsafe fn __get_it() -> *mut u8 {
    &mut A
}
$ rustc --crate-type lib tls.rs -Ccodegen-units=1 -Clto=no -O --emit obj,llvm-ir
; ModuleID = 'tls.3a1fbbbh-cgu.0'
source_filename = "tls.3a1fbbbh-cgu.0"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.7.0"

@_ZN3tls1A17h13af140b93a46e97E = internal thread_local global <{ [1 x i8] }> <{ [1 x i8] c"*" }>, section "__DATA,__thread_data", align 1

; tls::__get_it
; Function Attrs: norecurse nounwind readnone uwtable
define i8* @_ZN3tls8__get_it17h59d6925afa6bde3cE() unnamed_addr #0 {
start:
  ret i8* getelementptr inbounds (<{ [1 x i8] }>, <{ [1 x i8] }>* @_ZN3tls1A17h13af140b93a46e97E, i64 0, i32 0, i64 0)
}

attributes #0 = { norecurse nounwind readnone uwtable "no-frame-pointer-elim"="true" "probe-stack"="__rust_probestack" "target-cpu"="core2" }
Generated asm, relocations and sections

MacOS

Mach-o OBJECT x86_64-little-endian @ 0x0:

LoadCommands(4):
   0 LC_SEGMENT_64
   1 LC_VERSION_MIN_MACOSX
   2 LC_SYMTAB
   3 LC_DYSYMTAB

Segments(1):
  Segment   # Sections  
            5           
         Idx   Name               Addr    Size    Offset   Align   Reloff   Nrelocs   Flags       
         0     __text             0x0     0xf     0x270    4       0x2f8    1         0x80000400  
         1     __thread_data      0xf     0x1     0x27f    0       0x0      0         0x11        
         2     __thread_vars      0x10    0x18    0x280    0       0x300    2         0x13        
         3     __compact_unwind   0x28    0x20    0x298    3       0x310    1         0x2000000   
         4     __eh_frame         0x48    0x40    0x2b8    3       0x0      0         0x6800000b  


Relocations(4):
  Segment   Section   Count  
  __TEXT    __text    1      
         Type               Offset   Length   PIC     Extern   SymbolNum   Symbol                          
         X86_64_RELOC_TLV   0x7      2        true    true     0x0         __ZN3tls1A17h13af140b93a46e97E  

  Segment   Section         Count  
  __DATA    __thread_vars   2      
         Type                    Offset   Length   PIC      Extern   SymbolNum   Symbol                                   
         X86_64_RELOC_UNSIGNED   0x10     3        false    true     0x1         __ZN3tls1A17h13af140b93a46e97E$tlv$init  
         X86_64_RELOC_UNSIGNED   0x0      3        false    true     0x3         __tlv_bootstrap                          

  Segment   Section            Count  
  __LD      __compact_unwind   1      
         Type                    Offset   Length   PIC      Extern   SymbolNum   Symbol         
         X86_64_RELOC_UNSIGNED   0x0      3        false    false    0x1         __TEXT.__text  


Symbols(4):
  Offset   Name                                      Section                Global   Undefined  
  0x10     __ZN3tls1A17h13af140b93a46e97E            __DATA.__thread_vars   false    false      
  0xf      __ZN3tls1A17h13af140b93a46e97E$tlv$init   __DATA.__thread_data   false    false      
  0x0      __ZN3tls8__get_it17h59d6925afa6bde3cE     __TEXT.__text          true     false      
  0x0      __tlv_bootstrap                           None                   true     true       

Exports(0):

Imports(0):

Libraries(0):

Name: None
is_64: true
is_lib: false
little_endian: true
entry: 0
Disassembly of section __TEXT,__text:
__ZN3tls8__get_it17h59d6925afa6bde3cE:
       0:	55 	pushq	%rbp
       1:	48 89 e5 	movq	%rsp, %rbp
       4:	48 8b 3d 00 00 00 00 	movq	(%rip), %rdi
		0000000000000007:  X86_64_RELOC_TLV	__ZN3tls1A17h13af140b93a46e97E@TLVP
       b:	ff 17 	callq	*(%rdi)
       d:	5d 	popq	%rbp
       e:	c3 	retq
Disassembly of section __DATA,__thread_data:
__ZN3tls1A17h13af140b93a46e97E$tlv$init:
       f:	2a  <unknown>
Disassembly of section __DATA,__thread_vars:
__ZN3tls1A17h13af140b93a46e97E:
      10:	00 00 	addb	%al, (%rax)
		0000000000000010:  X86_64_RELOC_UNSIGNED	__tlv_bootstrap
      12:	00 00 	addb	%al, (%rax)
      14:	00 00 	addb	%al, (%rax)
      16:	00 00 	addb	%al, (%rax)
      18:	00 00 	addb	%al, (%rax)
      1a:	00 00 	addb	%al, (%rax)
      1c:	00 00 	addb	%al, (%rax)
      1e:	00 00 	addb	%al, (%rax)
      20:	00 00 	addb	%al, (%rax)
		0000000000000020:  X86_64_RELOC_UNSIGNED	__ZN3tls1A17h13af140b93a46e97E$tlv$init
      22:	00 00 	addb	%al, (%rax)
      24:	00 00 	addb	%al, (%rax)
      26:	00 00 	addb	%al, (%rax)

Linux

ELF REL X86_64-little-endian @ 0x0:

e_phoff: 0x0 e_shoff: 0x228 e_flags: 0x0 e_ehsize: 64 e_phentsize: 0 e_phnum: 0 e_shentsize: 64 e_shnum: 10 e_shstrndx: 1

ProgramHeaders(0):
  

SectionHeaders(10):
  Idx   Name                                                      Type   Flags              Offset   Addr   Size    Link         Entsize   Align  
  0                                                           SHT_NULL                      0x0      0x0    0x0                  0x0       0x0    
  1     .strtab                                             SHT_STRTAB                      0x178    0x0    0xad                 0x0       0x1    
  2     .text                                             SHT_PROGBITS   ALLOC EXECINSTR    0x40     0x0    0x0                  0x0       0x4    
  3     .text._ZN3tls8__get_it17h59d6925afa6bde3cE        SHT_PROGBITS   ALLOC EXECINSTR    0x40     0x0    0x16                 0x0       0x10   
  4     .rela.text._ZN3tls8__get_it17h59d6925afa6bde3cE       SHT_RELA                      0x118    0x0    0x48    .symtab(9)   0x18      0x8    
  5     .tdata._ZN3tls1A17h13af140b93a46e97E              SHT_PROGBITS   WRITE ALLOC TLS    0x56     0x0    0x1                  0x0       0x1    
  6     .note.GNU-stack                                   SHT_PROGBITS                      0x57     0x0    0x0                  0x0       0x1    
  7     .eh_frame                                          UNKNOWN_SHT   ALLOC              0x58     0x0    0x30                 0x0       0x8    
  8     .rela.eh_frame                                        SHT_RELA                      0x160    0x0    0x18    .symtab(9)   0x18      0x8    
  9     .symtab                                             SHT_SYMTAB                      0x88     0x0    0x90    .strtab(1)   0x18      0x8    

Syms(6):
               Addr   Bind       Type        Symbol                                 Size    Section                                         Other  
                 0    LOCAL      NOTYPE                                             0x0                                                     0x0    
                 0    LOCAL      FILE        tls.3a1fbbbh-cgu.0                     0x0     ABS                                             0x0    
                 0    LOCAL      TLS         _ZN3tls1A17h13af140b93a46e97E          0x1     .tdata._ZN3tls1A17h13af140b93a46e97E(5)         0x0    
                 0    LOCAL      SECTION                                            0x0     .text._ZN3tls8__get_it17h59d6925afa6bde3cE(3)   0x0    
                 0    GLOBAL     FUNC        _ZN3tls8__get_it17h59d6925afa6bde3cE   0x16    .text._ZN3tls8__get_it17h59d6925afa6bde3cE(3)   0x0    
                 0    GLOBAL     NOTYPE      __tls_get_addr                         0x0                                                     0x0    

Dyn Syms(0):
  

Dynamic Relas(0):

Dynamic Rel(0):

Plt Relocations(0):

Shdr Relocations(4):
  .text._ZN3tls8__get_it17h59d6925afa6bde3cE(3)
               4 X86_64_TLSLD _ZN3tls1A17h13af140b93a46e97E+-4
               9 X86_64_PLT32 __tls_get_addr+-4
              10 X86_64_DTPOFF32 _ZN3tls1A17h13af140b93a46e97E

  .eh_frame(1)
              20 X86_64_PC32 .text._ZN3tls8__get_it17h59d6925afa6bde3cE


Dynamic: None


Libraries(0):

Soname: None
Interpreter: None
is_64: true
is_lib: false
little_endian: true
bias: 0x0
entry: 0
Disassembly of section .text._ZN3tls8__get_it17h59d6925afa6bde3cE:
_ZN3tls8__get_it17h59d6925afa6bde3cE:
       0:	50 	pushq	%rax
       1:	48 8d 3d 00 00 00 00 	leaq	(%rip), %rdi
		0000000000000004:  R_X86_64_TLSLD	_ZN3tls1A17h13af140b93a46e97E-4
       8:	e8 00 00 00 00 	callq	0 <_ZN3tls8__get_it17h59d6925afa6bde3cE+0xd>
		0000000000000009:  R_X86_64_PLT32	__tls_get_addr-4
       d:	48 8d 80 00 00 00 00 	leaq	(%rax), %rax
		0000000000000010:  R_X86_64_DTPOFF32	_ZN3tls1A17h13af140b93a46e97E
      14:	59 	popq	%rcx
      15:	c3 	retq
Disassembly of section .rela.text._ZN3tls8__get_it17h59d6925afa6bde3cE:
.rela.text._ZN3tls8__get_it17h59d6925afa6bde3cE:
       0:	04 00 	addb	$0, %al
       2:	00 00 	addb	%al, (%rax)
       4:	00 00 	addb	%al, (%rax)
       6:	00 00 	addb	%al, (%rax)
       8:	14 00 	adcb	$0, %al
       a:	00 00 	addb	%al, (%rax)
       c:	02 00 	addb	(%rax), %al
       e:	00 00 	addb	%al, (%rax)
      10:	fc 	cld
      11:	ff ff  <unknown>
      13:	ff ff  <unknown>
      15:	ff ff  <unknown>
      17:	ff 09 	decl	(%rcx)
      19:	00 00 	addb	%al, (%rax)
      1b:	00 00 	addb	%al, (%rax)
      1d:	00 00 	addb	%al, (%rax)
      1f:	00 04 00 	addb	%al, (%rax,%rax)
      22:	00 00 	addb	%al, (%rax)
      24:	05 00 00 00 fc 	addl	$4227858432, %eax
      29:	ff ff  <unknown>
      2b:	ff ff  <unknown>
      2d:	ff ff  <unknown>
      2f:	ff 10 	callq	*(%rax)
      31:	00 00 	addb	%al, (%rax)
      33:	00 00 	addb	%al, (%rax)
      35:	00 00 	addb	%al, (%rax)
      37:	00 15 00 00 00 02 	addb	%dl, 33554432(%rip)
      3d:	00 00 	addb	%al, (%rax)
      3f:	00 00 	addb	%al, (%rax)
      41:	00 00 	addb	%al, (%rax)
      43:	00 00 	addb	%al, (%rax)
      45:	00 00 	addb	%al, (%rax)
      47:	00  <unknown>
Disassembly of section .tdata._ZN3tls1A17h13af140b93a46e97E:
_ZN3tls1A17h13af140b93a46e97E:
       0:	2a  <unknown>

@philipc
Copy link
Contributor

philipc commented Sep 19, 2019

@bjorn3 Which tool did you use to dump the object file info?

Generated object for Windows x86-64

tls.o:	file format COFF-x86-64

architecture: x86_64
start address: 0x0000000000000000

RELOCATION RECORDS FOR [.text]:
0000000000000002 IMAGE_REL_AMD64_REL32 _tls_index
0000000000000016 IMAGE_REL_AMD64_SECREL _ZN3tls1A17h13af140b93a46e97E

Sections:
Idx Name          Size      Address          Type
  0 .text         00000000 0000000000000000 TEXT 
  1 .data         00000000 0000000000000000 DATA 
  2 .bss          00000000 0000000000000000 BSS
  3 .text         0000001b 0000000000000000 TEXT 
  4 .tls$         00000001 0000000000000000 DATA 

SYMBOL TABLE:
[ 0](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .text
AUX scnlen 0x0 nreloc 0 nlnno 0 checksum 0x0 assoc 1 comdat 0
[ 2](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .data
AUX scnlen 0x0 nreloc 0 nlnno 0 checksum 0x0 assoc 2 comdat 0
[ 4](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .bss
AUX scnlen 0x0 nreloc 0 nlnno 0 checksum 0x0 assoc 3 comdat 0
[ 6](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .text
AUX scnlen 0x1b nreloc 2 nlnno 0 checksum 0xe244a0f4 assoc 4 comdat 1
[ 8](sec  4)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x00000000 _ZN3tls8__get_it17h59d6925afa6bde3cE
[ 9](sec  5)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .tls$
AUX scnlen 0x1 nreloc 0 nlnno 0 checksum 0xdbbbc9d6 assoc 5 comdat 1
[11](sec  5)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 _ZN3tls1A17h13af140b93a46e97E
[12](sec -1)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 @feat.00
[13](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _tls_index
[14](sec -2)(fl 0x00)(ty   0)(scl  67) (nx 1) 0x00000000 .file
AUX tls.3a1fbbbh-cgu.0
Export Table:
Disassembly of section .text:
0000000000000000 _ZN3tls8__get_it17h59d6925afa6bde3cE:
       0:	8b 05 00 00 00 00 	movl	(%rip), %eax
		0000000000000002:  IMAGE_REL_AMD64_REL32	_tls_index
       6:	65 48 8b 0c 25 58 00 00 00 	movq	%gs:88, %rcx
       f:	48 8b 04 c1 	movq	(%rcx,%rax,8), %rax
      13:	48 8d 80 00 00 00 00 	leaq	(%rax), %rax
		0000000000000016:  IMAGE_REL_AMD64_SECREL	_ZN3tls1A17h13af140b93a46e97E
      1a:	c3 	retq
Disassembly of section .tls$:
0000000000000000 _ZN3tls1A17h13af140b93a46e97E:
       0:	2a  <unknown>

@bjorn3
Copy link
Member Author

bjorn3 commented Sep 19, 2019

Which tool did you use to dump the object file info?

https://github.com/m4b/bingrep

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 26, 2019

I found documentation for ELF TLS: https://akkadia.org/drepper/tls.pdf

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 27, 2019

Opened wip pr bytecodealliance/cranelift#1174 for ELF TLS.

@philipc
Copy link
Contributor

philipc commented Oct 28, 2019

Note that making variable A public changes from LD to GD TLS model.

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 29, 2019

When combining with bytecodealliance/cranelift#1174 and gimli-rs/object#139, the wip_tls_support branch has implemented TLS support.

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 1, 2019

The latest commit to the wip_tls_support branch added std::thread support. Atomics are not yet supported, so you may get panics.

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 2, 2019

@philipc According to https://docs.microsoft.com/en-us/windows/win32/debug/pe-format, TLS needs to load a value from fs, while your disassembly used gs. How is that possible?

@philipc
Copy link
Contributor

philipc commented Nov 3, 2019

It's different for i686 vs x86-64

Generated object for Windows i686

tls.o:     file format pe-i386
tls.o
architecture: i386, flags 0x0000003d:
HAS_RELOC, HAS_LINENO, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x00000000

Characteristics 0x0

Time/Date               Thu Jan 01 10:00:00 1970
Magic                   0000
MajorLinkerVersion      0
MinorLinkerVersion      0
SizeOfCode              00000000
SizeOfInitializedData   00000000
SizeOfUninitializedData 00000000
AddressOfEntryPoint     00000000
BaseOfCode              00000000
BaseOfData              00000000
ImageBase               00000000
SectionAlignment        00000000
FileAlignment           00000000
MajorOSystemVersion     0
MinorOSystemVersion     0
MajorImageVersion       0
MinorImageVersion       0
MajorSubsystemVersion   0
MinorSubsystemVersion   0
Win32Version            00000000
SizeOfImage             00000000
SizeOfHeaders           00000000
CheckSum                00000000
Subsystem               00000000        (unspecified)
DllCharacteristics      00000000
SizeOfStackReserve      00000000
SizeOfStackCommit       00000000
SizeOfHeapReserve       00000000
SizeOfHeapCommit        00000000
LoaderFlags             00000000
NumberOfRvaAndSizes     00000000

The Data Directory
Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
Entry 1 00000000 00000000 Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00000000 00000000 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00000000 00000000 Import Address Table Directory
Entry d 00000000 00000000 Delay Import Directory
Entry e 00000000 00000000 CLR Runtime Header
Entry f 00000000 00000000 Reserved

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000001a  00000000  00000000  000000dc  2**4
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  1 .data         00000000  00000000  00000000  0000010a  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00000000  00000000  00000000  00000000  2**2
                  ALLOC
  3 .tls$         00000001  00000000  00000000  0000010a  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  4 .eh_frame     00000034  00000000  00000000  0000010b  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
SYMBOL TABLE:
[  0](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .text
AUX scnlen 0x1a nreloc 2 nlnno 0 checksum 0x2e733929 assoc 1 comdat 0
[  2](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .data
AUX scnlen 0x0 nreloc 0 nlnno 0 checksum 0x0 assoc 2 comdat 0
[  4](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .bss
AUX scnlen 0x0 nreloc 0 nlnno 0 checksum 0x0 assoc 3 comdat 0
[  6](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .tls$
AUX scnlen 0x1 nreloc 0 nlnno 0 checksum 0xdbbbc9d6 assoc 4 comdat 0
[  8](sec  5)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .eh_frame
AUX scnlen 0x34 nreloc 1 nlnno 0 checksum 0x44dca39 assoc 5 comdat 0
[ 10](sec -1)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000001 @feat.00
[ 11](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x00000000 __ZN3tls8__get_it17h786bec649631d54cE
[ 12](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 __tls_index
[ 13](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 __ZN3tls1A17h13af140b93a46e97E
[ 14](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x00000000 tls.3a1fbbbh-cgu.0
File



Disassembly of section .text:

00000000 <__ZN3tls8__get_it17h786bec649631d54cE>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   a1 00 00 00 00          mov    0x0,%eax
                        4: dir32        __tls_index
   8:   64 8b 0d 2c 00 00 00    mov    %fs:0x2c,%ecx
   f:   8b 04 81                mov    (%ecx,%eax,4),%eax
  12:   8d 80 00 00 00 00       lea    0x0(%eax),%eax
                        14: secrel32    __ZN3tls1A17h13af140b93a46e97E
  18:   5d                      pop    %ebp
  19:   c3                      ret

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 3, 2019

That explains it.

@bjorn3 bjorn3 mentioned this issue Nov 7, 2019
@joshtriplett
Copy link
Member

It's also different for Windows versus Linux. Linux uses gs for TLS on 32-bit and fs on 64-bit. Windows uses fs for TLS on 32-bit and (I think) gs on 64-bit.

So this isn't just architecture specific, it's also platform specific, and we need to match the platform convention.

(Also, very important: on Windows, you're supposed to call a function in a Windows DLL to get TLS, and not access the register itself; Windows reserves the right to change the convention. Linux treats its convention as ABI.)

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 20, 2020

The TLS PR uses a flag to determine the way TLS is implemented. It doesn't use gs or fs on Linux or Windows. Instead it uses the method specifies by the file format. On ELF it uses __tls_get_addr. On Mach-O it calls the function referenced by the X86_64_RELOC_TLV relocation of the TLS value.

@bjorn3 bjorn3 closed this as completed Feb 20, 2020
@bjorn3 bjorn3 reopened this Feb 20, 2020
@philipc
Copy link
Contributor

philipc commented Feb 20, 2020

Also, very important: on Windows, you're supposed to call a function in a Windows DLL to get TLS, and not access the register itself; Windows reserves the right to change the convention. Linux treats its convention as ABI.

@joshtriplett In the Windows disassemblies I gave above it is using fs and gs directly. This is code generated by rustc with the llvm backend. Are you saying that rustc is doing the wrong thing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants