public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
@ 2021-11-15  5:25 sam at gentoo dot org
  2021-11-15  5:29 ` [Bug libc/28595] " sam at gentoo dot org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: sam at gentoo dot org @ 2021-11-15  5:25 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

            Bug ID: 28595
           Summary: glibc-2.34 build fails with linker error (TLS
                    transition from R_386_TLS_GOTIE to R_386_TLS_LE_32
                    against `__libc_tsd_CTYPE_B' at 0xf4 in section
                    `.text' failed)
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: sam at gentoo dot org
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

This is a forward of a downstream report in Gentoo:
https://bugs.gentoo.org/823780, although I've hit it myself.

Building glibc-2.34 fails with the following error:
```
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld:
/var/tmp/portage/sys-libs/glibc-2.34-r1/work/build-x86-x86_64-pc-linux-gnu-nptl/libc.a(inet_addr.o):
TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against
`__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld:
final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [../Rules:269:
/var/tmp/portage/sys-libs/glibc-2.34-r1/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/ldconfig]
Error 1
```

In the bug, someone observed that it may be AVX512 related which matches my
experience (I can only make the build fail on a Tiger Lake system).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libc/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
@ 2021-11-15  5:29 ` sam at gentoo dot org
  2021-11-15  5:30 ` sam at gentoo dot org
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sam at gentoo dot org @ 2021-11-15  5:29 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #1 from Sam James <sam at gentoo dot org> ---
Created attachment 13787
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13787&action=edit
build.log (from user downstream)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libc/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
  2021-11-15  5:29 ` [Bug libc/28595] " sam at gentoo dot org
@ 2021-11-15  5:30 ` sam at gentoo dot org
  2021-11-15  5:35 ` [Bug build/28595] " sam at gentoo dot org
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sam at gentoo dot org @ 2021-11-15  5:30 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

Sam James <sam at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #13787|0                           |1
        is obsolete|                            |

--- Comment #2 from Sam James <sam at gentoo dot org> ---
Created attachment 13788
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13788&action=edit
build.log (from user downstream)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
  2021-11-15  5:29 ` [Bug libc/28595] " sam at gentoo dot org
  2021-11-15  5:30 ` sam at gentoo dot org
@ 2021-11-15  5:35 ` sam at gentoo dot org
  2021-11-15  5:36 ` sam at gentoo dot org
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sam at gentoo dot org @ 2021-11-15  5:35 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

Sam James <sam at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libc                        |build
                 CC|                            |carlos at redhat dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (2 preceding siblings ...)
  2021-11-15  5:35 ` [Bug build/28595] " sam at gentoo dot org
@ 2021-11-15  5:36 ` sam at gentoo dot org
  2021-11-15  9:09 ` schwab@linux-m68k.org
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sam at gentoo dot org @ 2021-11-15  5:36 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #3 from Sam James <sam at gentoo dot org> ---
I can only reproduce this with GCC 11, and not GCC 10.

Both latest binutils from git and binutils-2.37 (from near the tip of the
stable branch - a few days ago) fails.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (3 preceding siblings ...)
  2021-11-15  5:36 ` sam at gentoo dot org
@ 2021-11-15  9:09 ` schwab@linux-m68k.org
  2021-11-15 13:38 ` jason at zx2c4 dot com
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2021-11-15  9:09 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> ---
What does -march=native resolve to?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (4 preceding siblings ...)
  2021-11-15  9:09 ` schwab@linux-m68k.org
@ 2021-11-15 13:38 ` jason at zx2c4 dot com
  2021-11-15 13:53 ` jason at zx2c4 dot com
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-15 13:38 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

Jason A. Donenfeld <jason at zx2c4 dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at zx2c4 dot com

--- Comment #5 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
Pulling from the downstream bug report:

> -march=tigerlake - ERROR
> -march=cooperlake - ERROR
> -march=cascadelake - ERROR
> -march=cannonlake - ERROR
> -march=skylake-avx512 - ERROR
> -march=skylake - OK

And from my own failure, I noticed that this is hit during the -m32 build. I
don't know whether that's a relevant detail, but it is a detail:

x86_64-pc-linux-gnu-gcc -m32 -march=native -pipe -O2 -Wl,-O1 -Wl,--as-needed
-nostdlib -nostartfiles -static -o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/ldconfig
  -Wl,-O1 -Wl,--as-needed 
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/csu/crt1.o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/csu/crti.o
`x86_64-pc-linux-gnu-gcc -m32 -march=native -pipe -O2 -Wl,-O1 -Wl,--as-needed 
--print-file-name=crtbeginT.o`
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/ldconfig.o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/cache.o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/readlib.o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/xmalloc.o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/xstrdup.o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/chroot_canon.o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/static-stubs.o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/stringtable.o
 -Wl,-z,now -Wl,--start-group
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/libc.a
-lgcc  -Wl,--end-group `x86_64-pc-linux-gnu-gcc -m32 -march=native -pipe -O2
-Wl,-O1 -Wl,--as-needed  --print-file-name=crtend.o`
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/csu/crtn.o
make[4]: Leaving directory
'/var/tmp/portage/sys-libs/glibc-2.34-r2/work/glibc-2.34/nptl'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld:
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/libc.a(inet_addr.o):
TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against
`__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld:
final link failed: bad value
collect2: error: ld returned 1 exit status

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (5 preceding siblings ...)
  2021-11-15 13:38 ` jason at zx2c4 dot com
@ 2021-11-15 13:53 ` jason at zx2c4 dot com
  2021-11-15 13:59 ` jason at zx2c4 dot com
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-15 13:53 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

Jason A. Donenfeld <jason at zx2c4 dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at redhat dot com

--- Comment #6 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
The two related-ish recent changes both seem C++ related and not
avx512-related. Hm.

https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=4e62aca0e0520e4ed2532f2d8153581190621c1a
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ee8f9ff00d79998274c967ad0c23692be9dd3ada

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (6 preceding siblings ...)
  2021-11-15 13:53 ` jason at zx2c4 dot com
@ 2021-11-15 13:59 ` jason at zx2c4 dot com
  2021-11-15 14:02 ` jakub at redhat dot com
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-15 13:59 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #7 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
Wow, gcc is wild. It looks like it's converting that ctypes indexing into a
kmovd, into the mask register (even in 32-bit mode, woah):

movsx   eax, dl
kmovd   k0, ds:(__libc_tsd_CTYPE_B_tpoff - _GLOBAL_OFFSET_TABLE_)[ebx]
kmovd   edx, k0
kmovd   k0, dword ptr gs:[edx]
kmovd   edx, k0
test    byte ptr [edx+eax*2+1], 20h
jz      short loc_80000B0

Presumably when this happens, gcc isn't emitting the right type of relocation.
It assumes it's a local-exec instead of an init-exec, or something like that?
Notably, that symbol is declared with `__attribute__ ((tls_model
("initial-exec")))`.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (7 preceding siblings ...)
  2021-11-15 13:59 ` jason at zx2c4 dot com
@ 2021-11-15 14:02 ` jakub at redhat dot com
  2021-11-15 14:14 ` jason at zx2c4 dot com
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jakub at redhat dot com @ 2021-11-15 14:02 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #8 from Jakub Jelinek <jakub at redhat dot com> ---
If you suspect a gcc bug, you should file it into gcc.gnu.org bugzilla with
preprocessed source on which you encounter it and full command line option.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (8 preceding siblings ...)
  2021-11-15 14:02 ` jakub at redhat dot com
@ 2021-11-15 14:14 ` jason at zx2c4 dot com
  2021-11-15 14:24 ` jason at zx2c4 dot com
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-15 14:14 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #9 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
I'm really not quite sure, actually. Does it seem like a potential gcc bug to
you?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (9 preceding siblings ...)
  2021-11-15 14:14 ` jason at zx2c4 dot com
@ 2021-11-15 14:24 ` jason at zx2c4 dot com
  2021-11-15 14:28 ` jason at zx2c4 dot com
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-15 14:24 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #10 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
Gcc seems to emit the same sort of reference. On -march=skylake that same
snippet is:

mov     eax, ecx
mov     ecx, ds:(__libc_tsd_CTYPE_B_tpoff - _GLOBAL_OFFSET_TABLE_)[ebx]
mov     ecx, gs:[ecx]
test    byte ptr [ecx+eax*2+1], 20h
jz      short loc_80000B0

So I wonder if we're exposing a binutils bug here rather than a glibc or gcc
one?

Still not super certain what's up, though.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (10 preceding siblings ...)
  2021-11-15 14:24 ` jason at zx2c4 dot com
@ 2021-11-15 14:28 ` jason at zx2c4 dot com
  2021-11-15 19:29 ` fweimer at redhat dot com
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-15 14:28 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #11 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
And in both cases, the gcc-generated .o yields a `000000f0 R_386_TLS_GOTIE  
__libc_tsd_CTYPE_B`. Is ld supposed to be changing this into a R_386_TLS_LE_32,
but it doesn't recognize it somehow when it's used from kmov?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (11 preceding siblings ...)
  2021-11-15 14:28 ` jason at zx2c4 dot com
@ 2021-11-15 19:29 ` fweimer at redhat dot com
  2021-11-16 11:56 ` jason at zx2c4 dot com
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: fweimer at redhat dot com @ 2021-11-15 19:29 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com

--- Comment #12 from Florian Weimer <fweimer at redhat dot com> ---
(In reply to Jason A. Donenfeld from comment #7)
> Wow, gcc is wild. It looks like it's converting that ctypes indexing into a
> kmovd, into the mask register (even in 32-bit mode, woah):
> 
> movsx   eax, dl
> kmovd   k0, ds:(__libc_tsd_CTYPE_B_tpoff - _GLOBAL_OFFSET_TABLE_)[ebx]
> kmovd   edx, k0
> kmovd   k0, dword ptr gs:[edx]
> kmovd   edx, k0
> test    byte ptr [edx+eax*2+1], 20h
> jz      short loc_80000B0

Could you please attach the assembler output from --save-temps to this bug (the
.s file), and also the preprocessed sources (the .i file)? Thanks.

This is either a GCC bug or an assembler bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (12 preceding siblings ...)
  2021-11-15 19:29 ` fweimer at redhat dot com
@ 2021-11-16 11:56 ` jason at zx2c4 dot com
  2021-11-16 11:57 ` jason at zx2c4 dot com
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-16 11:56 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #13 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
The GCC-bug side of things seems to be a bad optimization caused by weird
register allocator performance. That's being tracked here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103252

The .o that gcc creates for both the avx512 case and the non-avx512 case both
have the same relocation type:

000000f0 R_386_TLS_GOTIE   __libc_tsd_CTYPE_B

That makes me suspect that the problem isn't with gcc but is with something in
binutils -- the assembler or the linker or something called later on.

Either way, I'll attach the preprocessed source and assembly as requested.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (13 preceding siblings ...)
  2021-11-16 11:56 ` jason at zx2c4 dot com
@ 2021-11-16 11:57 ` jason at zx2c4 dot com
  2021-11-16 12:00 ` jason at zx2c4 dot com
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-16 11:57 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #14 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
Created attachment 13789
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13789&action=edit
preprocessed source

thinkpad /var/tmp/portage/sys-libs/glibc-2.34-r2/work/glibc-2.34/resolv #
x86_64-pc-linux-gnu-gcc -m32 -march=native -pipe -O2 -Wl,-O1 -Wl,--as-needed
inet_addr.c -c -std=gnu11 -fgnu89-inline  -march=native -pipe -O2 -Wall
-Wwrite-strings -Wundef -fmerge-all-constants -frounding-math
-fstack-protector-strong -fno-common -Wstrict-prototypes -Wold-style-definition
-fmath-errno    -Wa,-mtune=i686   -ftls-model=initial-exec   -U_FORTIFY_SOURCE 
 -I../include
-I/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv

-I/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl
 -I../sysdeps/unix/sysv/linux/i386/i686  -I../sysdeps/i386/i686/nptl 
-I../sysdeps/unix/sysv/linux/i386  -I../sysdeps/unix/sysv/linux/x86/include
-I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -I../sysdeps/i386/nptl
 -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux 
-I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu 
-I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/i386 
-I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/i386/i686/fpu/multiarch 
-I../sysdeps/i386/i686/fpu  -I../sysdeps/i386/i686/multiarch 
-I../sysdeps/i386/i686  -I../sysdeps/i386/fpu  -I../sysdeps/x86/fpu 
-I../sysdeps/i386  -I../sysdeps/x86/include -I../sysdeps/x86 
-I../sysdeps/wordsize-32  -I../sysdeps/ieee754/float128 
-I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96 
-I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754 
-I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include -isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include-fixed -isystem /usr/include
-D_LIBC_REENTRANT -include
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/libc-modules.h
-DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC    
-DTOP_NAMESPACE=glibc -o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv/inet_addr.o
-MD -MP -MF
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv/inet_addr.o.dt
-MT
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv/inet_addr.o
-E

My -march=native should expand to:

-march=tigerlake -mmmx -mpopcnt -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2
-mavx -mavx2 -mno-sse4a -mno-fma4 -mno-xop -mfma -mavx512f -mbmi -mbmi2 -maes
-mpclmul -mavx512vl -mavx512bw -mavx512dq -mavx512cd -mno-avx512er
-mno-avx512pf -mavx512vbmi -mavx512ifma -mno-avx5124vnniw -mno-avx5124fmaps
-mavx512vpopcntdq -mavx512vbmi2 -mgfni -mvpclmulqdq -mavx512vnni -mavx512bitalg
-mno-avx512bf16 -mavx512vp2intersect -mno-3dnow -madx -mabm -mno-cldemote
-mclflushopt -mclwb -mno-clzero -mcx16 -mno-enqcmd -mf16c -mfsgsbase -mfxsr
-mno-hle -msahf -mno-lwp -mlzcnt -mmovbe -mmovdir64b -mmovdiri -mno-mwaitx
-mno-pconfig -mpku -mno-prefetchwt1 -mprfchw -mno-ptwrite -mrdpid -mrdrnd
-mrdseed -mno-rtm -mno-serialize -mno-sgx -msha -mshstk -mno-tbm -mno-tsxldtrk
-mvaes -mno-waitpkg -mno-wbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves
-mno-amx-tile -mno-amx-int8 -mno-amx-bf16 -mno-uintr -mno-hreset -mno-kl
-mno-widekl -mno-avxvnni --param "l1-cache-size=48" --param
"l1-cache-line-size=64" --param "l2-cache-size=24576" -mtune=tigerlake

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (14 preceding siblings ...)
  2021-11-16 11:57 ` jason at zx2c4 dot com
@ 2021-11-16 12:00 ` jason at zx2c4 dot com
  2021-11-16 12:12 ` jason at zx2c4 dot com
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-16 12:00 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #15 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
Created attachment 13790
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13790&action=edit
assembler intermediate file

The relevant diff from a symbol point of view is just:

-       movl    __libc_tsd_CTYPE_B@gotntpoff(%ebx), %ecx
+       kmovd   __libc_tsd_CTYPE_B@gotntpoff(%ebx), %k0

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (15 preceding siblings ...)
  2021-11-16 12:00 ` jason at zx2c4 dot com
@ 2021-11-16 12:12 ` jason at zx2c4 dot com
  2021-11-16 12:24 ` jason at zx2c4 dot com
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-16 12:12 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

Jason A. Donenfeld <jason at zx2c4 dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nickc at redhat dot com

--- Comment #16 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
Adding Nick to the CC, as this is looking more like a binutils issue.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (16 preceding siblings ...)
  2021-11-16 12:12 ` jason at zx2c4 dot com
@ 2021-11-16 12:24 ` jason at zx2c4 dot com
  2021-11-16 12:34 ` jakub at redhat dot com
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-16 12:24 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #17 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
I might be way off here, but...

    case R_386_TLS_GOTIE:
    case R_386_TLS_IE_32:
      /* Check transition from {IE_32,GOTIE} access model:
                subl foo@{tpoff,gontoff}(%reg1), %reg2
                movl foo@{tpoff,gontoff}(%reg1), %reg2
                addl foo@{tpoff,gontoff}(%reg1), %reg2
       */

      if (offset < 2 || (offset + 4) > sec->size)
        return false;

      val = bfd_get_8 (abfd, contents + offset - 1);
      if ((val & 0xc0) != 0x80 || (val & 7) == 4)
        return false;

      type = bfd_get_8 (abfd, contents + offset - 2);
      return type == 0x8b || type == 0x2b || type == 0x03;

It seems like it's looking at subl, movl (0x8b), and addl, but bfd does not
support the TLS_GOTIE relocation for kmovd.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (17 preceding siblings ...)
  2021-11-16 12:24 ` jason at zx2c4 dot com
@ 2021-11-16 12:34 ` jakub at redhat dot com
  2021-11-16 12:35 ` jakub at redhat dot com
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jakub at redhat dot com @ 2021-11-16 12:34 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #18 from Jakub Jelinek <jakub at redhat dot com> ---
This boils down to:
1.c:
extern __thread int mytls __attribute__((tls_model ("initial-exec")));

__attribute__((noipa)) void
foo (void)
{
  asm ("");
}

int
main ()
{
  foo ();
#ifdef KMOVD
  asm volatile ("kmovd mytls@gotntpoff(%%ebx), %%k0" : : : "k0");
#else
  volatile int a = mytls;
#endif
  return 0;
}
2.c:
__thread int mytls __attribute__((tls_model ("initial-exec")));
$ gcc -O2 -m32 -fPIC /tmp/1.c /tmp/2.c -o /tmp/1 -UKMOVD -mavx512f
$ gcc -O2 -m32 -fPIC /tmp/1.c /tmp/2.c -o /tmp/1 -DKMOVD -mavx512f
/usr/bin/ld: /tmp/ccQrvWxU.o: TLS transition from R_386_TLS_GOTIE to
R_386_TLS_LE_32 against `mytls' at 0x1c in section `.text.startup' failed
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

https://akkadia.org/drepper/tls.pdf

I don't remember anymore whether it is ok if some of the TLS relocations appear
also in instructions not exactly mentioned in the above mentioned pdf and if
instead of giving the linker errors like the above the linker should just not
optimize a particular TLS model, i.e. still use IE model here when it can't
optimize it into LE model (then it would be a linker bug), or whether
the compiler needs to ensure that those @gotntpoff etc. appear solely in the
instructions mentioned in the pdf (here in movl).  In that case it would be a
gcc bug, e.g. for the @gotntpoff
MEMs it would need to disallow them by default and only accept them as a
special case in a simple *movsi_internal.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (18 preceding siblings ...)
  2021-11-16 12:34 ` jakub at redhat dot com
@ 2021-11-16 12:35 ` jakub at redhat dot com
  2021-11-16 12:38 ` jakub at redhat dot com
  2021-11-16 13:02 ` jason at zx2c4 dot com
  21 siblings, 0 replies; 23+ messages in thread
From: jakub at redhat dot com @ 2021-11-16 12:35 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

Jakub Jelinek <jakub at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rth at gcc dot gnu.org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (19 preceding siblings ...)
  2021-11-16 12:35 ` jakub at redhat dot com
@ 2021-11-16 12:38 ` jakub at redhat dot com
  2021-11-16 13:02 ` jason at zx2c4 dot com
  21 siblings, 0 replies; 23+ messages in thread
From: jakub at redhat dot com @ 2021-11-16 12:38 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

Jakub Jelinek <jakub at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl.tools at gmail dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug build/28595] glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed)
  2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
                   ` (20 preceding siblings ...)
  2021-11-16 12:38 ` jakub at redhat dot com
@ 2021-11-16 13:02 ` jason at zx2c4 dot com
  21 siblings, 0 replies; 23+ messages in thread
From: jason at zx2c4 dot com @ 2021-11-16 13:02 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28595

--- Comment #19 from Jason A. Donenfeld <jason at zx2c4 dot com> ---
Indeed it looks like with a bit of mucking around in there I can have it accept
kmovd instructions and change the relative address around, sort of.

Maybe Ulrich's got an opinion on what he'd prefer here.

Also, I don't have access to do so, but I suppose we ought to reclassify this
as a binutils bug for now, since we're on the same bugzilla as that, and then
later if necessary we can open a bug on gcc's tracker. Whether it's bfd or gcc,
it's certainly not glibc.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-11-16 13:02 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15  5:25 [Bug libc/28595] New: glibc-2.34 build fails with linker error (TLS transition from R_386_TLS_GOTIE to R_386_TLS_LE_32 against `__libc_tsd_CTYPE_B' at 0xf4 in section `.text' failed) sam at gentoo dot org
2021-11-15  5:29 ` [Bug libc/28595] " sam at gentoo dot org
2021-11-15  5:30 ` sam at gentoo dot org
2021-11-15  5:35 ` [Bug build/28595] " sam at gentoo dot org
2021-11-15  5:36 ` sam at gentoo dot org
2021-11-15  9:09 ` schwab@linux-m68k.org
2021-11-15 13:38 ` jason at zx2c4 dot com
2021-11-15 13:53 ` jason at zx2c4 dot com
2021-11-15 13:59 ` jason at zx2c4 dot com
2021-11-15 14:02 ` jakub at redhat dot com
2021-11-15 14:14 ` jason at zx2c4 dot com
2021-11-15 14:24 ` jason at zx2c4 dot com
2021-11-15 14:28 ` jason at zx2c4 dot com
2021-11-15 19:29 ` fweimer at redhat dot com
2021-11-16 11:56 ` jason at zx2c4 dot com
2021-11-16 11:57 ` jason at zx2c4 dot com
2021-11-16 12:00 ` jason at zx2c4 dot com
2021-11-16 12:12 ` jason at zx2c4 dot com
2021-11-16 12:24 ` jason at zx2c4 dot com
2021-11-16 12:34 ` jakub at redhat dot com
2021-11-16 12:35 ` jakub at redhat dot com
2021-11-16 12:38 ` jakub at redhat dot com
2021-11-16 13:02 ` jason at zx2c4 dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).