Bug 2263180

Summary: llvm: Implement support for GNU2 TLS descriptors on x86-64
Product: [Fedora] Fedora Reporter: Florian Weimer <fweimer>
Component: llvmAssignee: Tom Stellard <tstellar>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: dmalcolm, jakub, jchecahi, jistone, kkleine, npopov, rjones, scottt.tw, serge.guelton, sergio, siddharth.kde, tbaeder, tstellar, tuliom
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2263181 2263182 (view as bug list) Environment:
Last Closed: 2024-04-16 06:20:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2263739    
Bug Blocks: 2263181, 2263182    

Description Florian Weimer 2024-02-07 12:37:59 UTC
LLVM does not implement GNU2 TLS descriptors on x86-64, related to the R_X86_64_TLSDESC relocation type (and R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL for relaxation).

We want to use TLS descriptors on x86-64. Lack of LLVM support is not a blocker because the new TLS type and the legacy TLS type are fully interoperable (either approach can bind TLS symbols under any TLS model).

There is LLVM support for this feature on AArch64.

Reproducible: Always

Comment 1 Nikita Popov 2024-02-07 13:28:20 UTC
Do you know where to find documentation for these GNU2 TLS descriptors?

Comment 2 Florian Weimer 2024-02-07 13:31:19 UTC
I believe this is the canonical writeup: http://www.fsfla.org/~lxoliva/writeups/TLS/RFC-TLSDESC-x86.txt

Comment 4 Florian Weimer 2024-02-11 14:17:40 UTC
We have encountered a potential GCC or x86-64 psABI ambiguity when we tried to enable this for Fedora 40:

GCC and the GNU2 TLS descriptor call ABI
<https://groups.google.com/g/x86-64-abi/c/NXQve2SPubc>

GNU2 TLS descriptor calls do not follow psABI on x86_64-linux-gnu
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113874>

Comment 5 Nikita Popov 2024-03-04 08:50:24 UTC
It looks like Intel is working on the implementation here: https://github.com/llvm/llvm-project/pull/83136

Comment 6 Sergio Basto 2024-03-22 22:49:05 UTC
building seamonkey on rawhide [2] ATM , is this bug isn't it ? 

configure: error: compiler is incompatible with sanitize options
DEBUG: <truncated - see config.log for full output>
DEBUG: configure:2648: /usr/lib64/ccache/clang -E -std=gnu99  conftest.c >/dev/null 2>conftest.out
DEBUG: configure:2724: /usr/lib64/ccache/clang -std=gnu99 -o conftest -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables  -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wformat -Wno-format-overflow    conftest.c -lXt  1>&5
DEBUG: clang: error: unsupported argument 'gnu2' to option '-mtls-dialect=' for target 'x86_64-redhat-linux-gnu'
DEBUG: configure: failed program was:
DEBUG: #line 2717 "configure"
DEBUG: #include "confdefs.h"
DEBUG:
DEBUG: int main() {
DEBUG: XtMalloc()
DEBUG: ; return 0; }
DEBUG: configure:3957: /usr/lib64/ccache/clang -std=gnu99 -o conftest -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables  -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wformat -Wno-format-overflow -Qunused-arguments    conftest.c  1>&5
DEBUG: clang: error: unsupported argument 'gnu2' to option '-mtls-dialect=' for target 'x86_64-redhat-linux-gnu'
DEBUG: configure: failed program was:
DEBUG: #line 3950 "configure"
DEBUG: #include "confdefs.h"
DEBUG:
DEBUG: int main() {
DEBUG:
DEBUG: ; return 0; }
DEBUG: configure: error: compiler is incompatible with sanitize options
ERROR: old-configure failed

Comment 7 Tom Stellard 2024-03-23 01:05:43 UTC
@sergio That looks like it's trying to using the gcc flags.  If you are compiling with clang you need to define:

%toolchain clang

In your spec file.

Comment 8 Sergio Basto 2024-03-23 02:44:07 UTC
Thank you , I think the best is open a bug report on seamonkey component I'm just rebuild packages with libjxl soname bump

Comment 9 Nikita Popov 2024-04-16 06:20:45 UTC
Closing this as TLSDESC support has been implemented upstream in https://github.com/llvm/llvm-project/pull/83136. I'll keep the clang issue open for now so we have a reminder to do the redhat-rpm-config change after the LLVM 19 update.