-
Notifications
You must be signed in to change notification settings - Fork 25
Expose -ftls-model as a multilib flag for AArch64/ARM #241
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
Open
pzhengqc
wants to merge
1
commit into
qualcomm:qualcomm-software
Choose a base branch
from
pzhengqc:multilib-tls-model
base: qualcomm-software
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...ware/patches/llvm-project/0004-multilib-Expose-ftls-model-as-a-multilib-flag-for-AA.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| From 5f1ce69e1cbd688424a4b2efb93972f44a5bc8f5 Mon Sep 17 00:00:00 2001 | ||
| From: Pengxuan Zheng <pzheng@qti.qualcomm.com> | ||
| Date: Thu, 5 Mar 2026 15:58:03 -0800 | ||
| Subject: [PATCH] [multilib] Expose -ftls-model as a multilib flag for | ||
| AArch64/ARM | ||
|
|
||
| This allows multilib selection based on tls model. | ||
| --- | ||
| clang/lib/Driver/ToolChain.cpp | 8 ++++++++ | ||
| clang/test/Driver/print-multi-selection-flags.c | 4 ++++ | ||
| 2 files changed, 12 insertions(+) | ||
|
|
||
| diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp | ||
| index 703a3f8819cb..d9796e820080 100644 | ||
| --- a/clang/lib/Driver/ToolChain.cpp | ||
| +++ b/clang/lib/Driver/ToolChain.cpp | ||
| @@ -229,6 +229,10 @@ static void getAArch64MultilibFlags(const Driver &D, | ||
| break; | ||
| } | ||
| } | ||
| + | ||
| + const Arg *TLSModel = Args.getLastArgNoClaim(options::OPT_ftlsmodel_EQ); | ||
| + if (TLSModel) | ||
| + Result.push_back(TLSModel->getAsString(Args)); | ||
| } | ||
|
|
||
| static void getARMMultilibFlags(const Driver &D, const llvm::Triple &Triple, | ||
| @@ -317,6 +321,10 @@ static void getARMMultilibFlags(const Driver &D, const llvm::Triple &Triple, | ||
| break; | ||
| } | ||
| } | ||
| + | ||
| + const Arg *TLSModel = Args.getLastArgNoClaim(options::OPT_ftlsmodel_EQ); | ||
| + if (TLSModel) | ||
| + Result.push_back(TLSModel->getAsString(Args)); | ||
| } | ||
|
|
||
| static void getRISCVMultilibFlags(const Driver &D, const llvm::Triple &Triple, | ||
| diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c | ||
| index 64efddad878c..4bf03baba2ea 100644 | ||
| --- a/clang/test/Driver/print-multi-selection-flags.c | ||
| +++ b/clang/test/Driver/print-multi-selection-flags.c | ||
| @@ -68,6 +68,10 @@ | ||
| // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s | ||
| // CHECK-BRANCH-PROTECTION: -mbranch-protection=standard | ||
|
|
||
| +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -ftls-model=initial-exec | FileCheck --check-prefix=CHECK-TLS-MODEL %s | ||
| +// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -ftls-model=initial-exec | FileCheck --check-prefix=CHECK-TLS-MODEL %s | ||
| +// CHECK-TLS-MODEL: -ftls-model=initial-exec | ||
| + | ||
| // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s | ||
| // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mstrict-align | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s | ||
| // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s | ||
| -- | ||
| 2.34.1 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure, but I wonder if there needs to be something more than just looking at the command line args? In that I think the TLS model used can vary based on other options like pic, pie, etc. But I don't actually know if that information is available to us here.
(I also don't know if there is a "general" default either or if it varies per-variable.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that the -ftls-model is for user to force certain tls model? I am not sure if LLVM does more than that though. We could try pushing this upstream and get some feedback. Another option is to use multilib custom flags and that should work for the purpose of selecting the variant based on tls model too. Any preferences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this release, let's push a simple patch to default selected aarch64 configs to TLS Init_exec model.
And then you push the clang patch upstream to discuss with community, out of the critical path.