[PATCH] D154397: [Driver] Default to -ftls-model=initial-exec on SerenityOS

Andrew Kaster via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 3 18:51:49 PDT 2023


ADKaster created this revision.
Herald added a project: All.
ADKaster requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Force Clang use the initial-exec TLS model instead of the default
local-exec when building code for Serenity.

This patch should be removed when the SerenityOS program loader
implements proper TLS support.

Depends on D154396 <https://reviews.llvm.org/D154396>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154397

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6170,7 +6170,13 @@
   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))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154397.536923.patch
Type: text/x-patch
Size: 925 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230704/cf4531ba/attachment.bin>


More information about the cfe-commits mailing list