[llvm] [gn build] Allow specifying macOS deployment target (PR #107492)

Daniel Bertalan via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 17:28:38 PDT 2024


https://github.com/BertalanD created https://github.com/llvm/llvm-project/pull/107492

Switching to a newer deployment target can enable features like chained fixups or DWARF 5 debug info. This commit adds a way to configure this with the `mac_deployment_target` GN arg like in Chromium.

For now, the default of 10.10 stays (a 10 years old version), but we should bump that.

>From cd502f386e12ead89870f603a8fe13bf14a4f036 Mon Sep 17 00:00:00 2001
From: Daniel Bertalan <dani at danielbertalan.dev>
Date: Fri, 6 Sep 2024 02:19:00 +0200
Subject: [PATCH] [gn build] Allow specifying macOS deployment target

Switching to a newer deployment target can enable features like chained
fixups or DWARF 5 debug info. This commit adds a way to configure this
with the `mac_deployment_target` GN arg like in Chromium.

For now, the default of 10.10 stays (a 10 years old version), but we
should bump that.
---
 llvm/utils/gn/build/BUILD.gn                   | 6 +++---
 llvm/utils/gn/build/mac_sdk.gni                | 4 ++++
 llvm/utils/gn/build/toolchain/target_flags.gni | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index 68c0cbfd384a65..1ccaefdc21c822 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -72,9 +72,9 @@ config("compiler_defaults") {
     ldflags += [ "-miphoneos-version-min=8.0" ]
   }
   if (current_os == "mac") {
-    asmflags += [ "-mmacos-version-min=10.10" ]
-    cflags += [ "-mmacos-version-min=10.10" ]
-    ldflags += [ "-mmacos-version-min=10.10" ]
+    asmflags += [ "-mmacos-version-min=$mac_deployment_target" ]
+    cflags += [ "-mmacos-version-min=$mac_deployment_target" ]
+    ldflags += [ "-mmacos-version-min=$mac_deployment_target" ]
   }
 
   assert(symbol_level == 0 || symbol_level == 1 || symbol_level == 2,
diff --git a/llvm/utils/gn/build/mac_sdk.gni b/llvm/utils/gn/build/mac_sdk.gni
index af7044ba5c961f..c245f5c0a81ff7 100644
--- a/llvm/utils/gn/build/mac_sdk.gni
+++ b/llvm/utils/gn/build/mac_sdk.gni
@@ -2,6 +2,10 @@ import("//llvm/utils/gn/build/sysroot.gni")
 
 have_ios_sdks = true
 
+declare_args() {
+  mac_deployment_target = "10.10"
+}
+
 if (sysroot == "") {
   declare_args() {
     # Set to true if you don't have Xcode installed, but do have the commandline
diff --git a/llvm/utils/gn/build/toolchain/target_flags.gni b/llvm/utils/gn/build/toolchain/target_flags.gni
index 7a2a842afc1fb5..af8adcd2738668 100644
--- a/llvm/utils/gn/build/toolchain/target_flags.gni
+++ b/llvm/utils/gn/build/toolchain/target_flags.gni
@@ -47,7 +47,7 @@ if (current_os == "android") {
       rebase_path(mac_sdk_path, root_build_dir),
       # TODO(lgrey): We should be getting this from `compiler_defaults`. Why
       # aren't we?
-    "-mmacos-version-min=10.10",
+    "-mmacos-version-min=$mac_deployment_target",
     ]
   }
 } else if (current_os == "baremetal") {



More information about the llvm-commits mailing list