summaryrefslogtreecommitdiff
path: root/Toolchain/Patches/llvm/0004-Driver-Default-to-ftls-model-initial-exec-on-Serenit.patch
blob: 8baa8cf7f358c719ec2e85be03cc9dd33daf37f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Bertalan <dani@danielbertalan.dev>
Date: Thu, 14 Apr 2022 10:12:54 +0200
Subject: [PATCH] [Driver] Default to -ftls-model=initial-exec on SerenityOS

This is a hack to make Clang use the initial-exec TLS model instead of
the default local-exec when building code for Serenity.

This patch should be removed when we implement proper TLS support.
---
 clang/lib/Driver/ToolChains/Clang.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 3704ed8586682677882acb8e1b82bfc14b1d07a5..cc7b598090a8795e5906abc7341f798be7dd638f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6029,7 +6029,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden_static_local_var,
                            options::OPT_fno_visibility_inlines_hidden_static_local_var);
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden);
-  Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
+  if (Triple.isOSSerenity()) {
+    StringRef tls_model =
+        Args.getLastArgValue(options::OPT_ftlsmodel_EQ, "initial-exec");
+    CmdArgs.push_back(Args.MakeArgString("-ftls-model=" + tls_model));
+  } else {
+    Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
+  }
 
   if (Args.hasFlag(options::OPT_fnew_infallible,
                    options::OPT_fno_new_infallible, false))