[llvm] [gn] Use exec_script_allowlist in //llvm/utils/gn/.gn (PR #134172)

Dirk Pranke via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 10:58:11 PDT 2025


https://github.com/dpranke updated https://github.com/llvm/llvm-project/pull/134172

>From 19b4d32dd6ebe345bd2e87a8a5767b431e25528a Mon Sep 17 00:00:00 2001
From: Dirk Pranke <dpranke at gmail.com>
Date: Wed, 2 Apr 2025 15:59:24 -0700
Subject: [PATCH 1/4] Update .gn

Use exec_script_allowlist in //llvm/utils/gn/.gn

GN is moving to use exec_script_allowlist instead of exec_script_whitelist everywhere.

See crbug.com/389986807
---
 llvm/utils/gn/.gn | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/gn/.gn b/llvm/utils/gn/.gn
index 4eccc2fc168c0..3abc0f6306585 100644
--- a/llvm/utils/gn/.gn
+++ b/llvm/utils/gn/.gn
@@ -6,7 +6,7 @@ buildconfig = "//llvm/utils/gn/build/BUILDCONFIG.gn"
 
 # Disallow all calls to exec_script. We should be very conservative about
 # whitelisting things here.
-exec_script_whitelist = []
+exec_script_allowlist = []
 
 # Execute action() targets using Python 3.
 script_executable = "python3"

>From fd1e8b6053bc439a96179b5d2b869b36f4202864 Mon Sep 17 00:00:00 2001
From: Dirk Pranke <dpranke at gmail.com>
Date: Mon, 7 Apr 2025 10:27:18 -0700
Subject: [PATCH 2/4] Update BUILD.gn

Remove version check from utils/gn/build/toolchain/BUILD.gn
---
 llvm/utils/gn/build/toolchain/BUILD.gn | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn
index ce2e6df1b69f5..00d9df12f5a97 100644
--- a/llvm/utils/gn/build/toolchain/BUILD.gn
+++ b/llvm/utils/gn/build/toolchain/BUILD.gn
@@ -71,23 +71,6 @@ template("unix_toolchain") {
       default_output_dir = "{{root_out_dir}}/lib"
     }
 
-    if (current_os == "ios" || current_os == "mac") {
-      # gn < 1693 (e214b5d35898) doesn't support |frameworks|, requiring
-      # frameworks to be listed in |libs|, but gn >= 1808 (3028c6a426a4) forbids
-      # frameworks from appearing in |libs|. This assertion provides a helpful
-      # cue to upgrade, and is much more user-friendly than the failure that
-      # occurs when an older gn encounters |frameworks|.
-      #
-      # gn_version doesn’t actually exist in gn < 1709 (52cb644a3fb4), and
-      # defined(gn_version) doesn't actually work as expected
-      # (https://crbug.com/gn/183), so 1709 is the true minimum enforced by
-      # this construct, and if gn_version is not available, this line will still
-      # be blamed, making the resolution somewhat discoverable.
-      assert(gn_version >= 1693,
-             "Your GN is too old! " +
-                 "Update it, perhaps by running llvm/utils/gn/get.py")
-    }
-
     # Make these apply to all tools below.
     lib_switch = "-l"
     lib_dir_switch = "-L"

>From 042b96dc36a75dcb01ced120e56a906f167a9c6b Mon Sep 17 00:00:00 2001
From: Dirk Pranke <dpranke at gmail.com>
Date: Mon, 7 Apr 2025 10:29:25 -0700
Subject: [PATCH 3/4] Add gn_version check in dotfile

Add a gn_version check in the llvm/util/gn/.gn dotfile, to
ensure we have a new enough version of GN.
---
 llvm/utils/gn/.gn | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/llvm/utils/gn/.gn b/llvm/utils/gn/.gn
index 3abc0f6306585..5d66cdf0d8eaa 100644
--- a/llvm/utils/gn/.gn
+++ b/llvm/utils/gn/.gn
@@ -4,6 +4,12 @@
 
 buildconfig = "//llvm/utils/gn/build/BUILDCONFIG.gn"
 
+# `exec_script_allowlist` was added in GN version 2207, so that's the minimum
+# version of GN we require.
+assert(gn_version >= 2207,
+       "Your GN is too old! Update it, perhaps by running llvm/utils/gn/get.py")
+
+
 # Disallow all calls to exec_script. We should be very conservative about
 # whitelisting things here.
 exec_script_allowlist = []

>From cec7d6862247b434df4dfd953b264887e29b9b60 Mon Sep 17 00:00:00 2001
From: Dirk Pranke <dpranke at gmail.com>
Date: Mon, 7 Apr 2025 10:58:02 -0700
Subject: [PATCH 4/4] Update .gn

whoops, missed an "allowing" reference.
---
 llvm/utils/gn/.gn | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/gn/.gn b/llvm/utils/gn/.gn
index 5d66cdf0d8eaa..bcc3df7d56df9 100644
--- a/llvm/utils/gn/.gn
+++ b/llvm/utils/gn/.gn
@@ -11,7 +11,7 @@ assert(gn_version >= 2207,
 
 
 # Disallow all calls to exec_script. We should be very conservative about
-# whitelisting things here.
+# allowing things here.
 exec_script_allowlist = []
 
 # Execute action() targets using Python 3.



More information about the llvm-commits mailing list