[llvm] gn build: Support llvm_enable_zstd. (PR #88457)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 11:28:20 PDT 2024
https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/88457
>From a7b0b608f40fffbdc41dea8de1834f4af4b6fa24 Mon Sep 17 00:00:00 2001
From: Peter Collingbourne <peter at pcc.me.uk>
Date: Thu, 11 Apr 2024 16:25:02 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.6-beta.1
---
llvm/utils/gn/build/libs/zstd/BUILD.gn | 12 ++++++++++++
llvm/utils/gn/build/libs/zstd/enable.gni | 4 ++++
llvm/utils/gn/build/toolchain/BUILD.gn | 3 +++
llvm/utils/gn/secondary/clang/test/BUILD.gn | 8 +++++++-
llvm/utils/gn/secondary/lld/test/BUILD.gn | 8 +++++++-
.../gn/secondary/llvm/include/llvm/Config/BUILD.gn | 8 +++++++-
llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn | 1 +
llvm/utils/gn/secondary/llvm/test/BUILD.gn | 8 +++++++-
8 files changed, 48 insertions(+), 4 deletions(-)
create mode 100644 llvm/utils/gn/build/libs/zstd/BUILD.gn
create mode 100644 llvm/utils/gn/build/libs/zstd/enable.gni
diff --git a/llvm/utils/gn/build/libs/zstd/BUILD.gn b/llvm/utils/gn/build/libs/zstd/BUILD.gn
new file mode 100644
index 0000000000000..a59fca5baacc8
--- /dev/null
+++ b/llvm/utils/gn/build/libs/zstd/BUILD.gn
@@ -0,0 +1,12 @@
+import("//llvm/utils/gn/build/libs/zstd/enable.gni")
+
+config("zstd_config") {
+ visibility = [ ":zstd" ]
+ libs = [ "zstd" ]
+}
+
+group("zstd") {
+ if (llvm_enable_zstd) {
+ public_configs = [ ":zstd_config" ]
+ }
+}
diff --git a/llvm/utils/gn/build/libs/zstd/enable.gni b/llvm/utils/gn/build/libs/zstd/enable.gni
new file mode 100644
index 0000000000000..f5e1bc1beca7f
--- /dev/null
+++ b/llvm/utils/gn/build/libs/zstd/enable.gni
@@ -0,0 +1,4 @@
+declare_args() {
+ # Whether to include code that links against zstd.
+ llvm_enable_zstd = false
+}
diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn
index ebcdcbf6f61e1..2e7fa622a9b52 100644
--- a/llvm/utils/gn/build/toolchain/BUILD.gn
+++ b/llvm/utils/gn/build/toolchain/BUILD.gn
@@ -207,6 +207,9 @@ template("stage2_unix_toolchain") {
ar = "bin/llvm-ar"
deps += [ "//:llvm-ar($host_toolchain)" ]
}
+ if (toolchain_args.current_os != host_os) {
+ toolchain_args.llvm_enable_zstd = false
+ }
}
}
diff --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn b/llvm/utils/gn/secondary/clang/test/BUILD.gn
index bcf7c86ab9d08..1221d1b8ef6b3 100644
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -5,6 +5,7 @@ import("//llvm/lib/Target/targets.gni")
import("//llvm/triples.gni")
import("//llvm/utils/gn/build/libs/pthread/enable.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni")
+import("//llvm/utils/gn/build/libs/zstd/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/utils/llvm-lit/lit_path_function.gni")
import("clang_lit_site_cfg_files.gni")
@@ -62,7 +63,6 @@ write_lit_config("lit_site_cfg") {
"CMAKE_C_COMPILER=cc",
"ENABLE_BACKTRACES=1",
"ENABLE_SHARED=0",
- "LLVM_ENABLE_ZSTD=0",
"LLVM_EXTERNAL_LIT=",
"LLVM_HOST_TRIPLE=$llvm_current_triple",
"LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
@@ -91,6 +91,12 @@ write_lit_config("lit_site_cfg") {
extra_values += [ "LLVM_ENABLE_ZLIB=0" ] # Must be 0.
}
+ if (llvm_enable_zstd) {
+ extra_values += [ "LLVM_ENABLE_ZSTD=1" ]
+ } else {
+ extra_values += [ "LLVM_ENABLE_ZSTD=0" ] # Must be 0.
+ }
+
if (host_cpu == "x64") {
extra_values += [ "HOST_ARCH=x86_64" ]
} else if (host_cpu == "arm64") {
diff --git a/llvm/utils/gn/secondary/lld/test/BUILD.gn b/llvm/utils/gn/secondary/lld/test/BUILD.gn
index 356d93bf052a6..a2313965a41fd 100644
--- a/llvm/utils/gn/secondary/lld/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/lld/test/BUILD.gn
@@ -2,6 +2,7 @@ import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")
import("//llvm/triples.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni")
+import("//llvm/utils/gn/build/libs/zstd/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/utils/llvm-lit/lit_path_function.gni")
import("lld_lit_site_cfg_files.gni")
@@ -51,7 +52,6 @@ write_lit_cfg("lit_site_cfg") {
"LLD_DEFAULT_LD_LLD_IS_MINGW=0",
"LLVM_BUILD_EXAMPLES=0",
- "LLVM_ENABLE_ZSTD=0",
"LLVM_BYE_LINK_INTO_TOOLS=0",
]
@@ -94,6 +94,12 @@ write_lit_cfg("lit_site_cfg") {
extra_values += [ "LLVM_ENABLE_ZLIB=0" ] # Must be 0.
}
+ if (llvm_enable_zstd) {
+ extra_values += [ "LLVM_ENABLE_ZSTD=1" ]
+ } else {
+ extra_values += [ "LLVM_ENABLE_ZSTD=0" ] # Must be 0.
+ }
+
if (current_cpu == "x64" || current_cpu == "arm64" ||
current_cpu == "ppc64") {
extra_values += [ "CMAKE_SIZEOF_VOID_P=8" ]
diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
index 80a91507fcc69..7929c7355a77e 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -14,6 +14,7 @@ import("//llvm/utils/gn/build/libs/terminfo/enable.gni")
import("//llvm/utils/gn/build/libs/xar/enable.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni")
+import("//llvm/utils/gn/build/libs/zstd/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni")
@@ -322,7 +323,6 @@ write_cmake_config("llvm-config") {
"LLVM_DEFAULT_TARGET_TRIPLE=$llvm_target_triple",
"LLVM_ENABLE_DUMP=",
"LLVM_ENABLE_HTTPLIB=",
- "LLVM_ENABLE_ZSTD=",
"LLVM_FORCE_USE_OLD_TOOLCHAIN=",
"LLVM_HAS_ATOMICS=1",
"LLVM_HAVE_TFLITE=",
@@ -393,6 +393,12 @@ write_cmake_config("llvm-config") {
values += [ "LLVM_ENABLE_ZLIB=" ]
}
+ if (llvm_enable_zstd) {
+ values += [ "LLVM_ENABLE_ZSTD=1" ]
+ } else {
+ values += [ "LLVM_ENABLE_ZSTD=" ]
+ }
+
if (llvm_enable_libcurl) {
values += [ "LLVM_ENABLE_CURL=1" ]
} else {
diff --git a/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
index ba0f6d8c0f8cf..eed27dbed965e 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
@@ -8,6 +8,7 @@ static_library("Support") {
"//llvm/utils/gn/build/libs/pthread",
"//llvm/utils/gn/build/libs/terminfo",
"//llvm/utils/gn/build/libs/zlib",
+ "//llvm/utils/gn/build/libs/zstd",
]
# public_deps are used for depending on targets that generate headers
diff --git a/llvm/utils/gn/secondary/llvm/test/BUILD.gn b/llvm/utils/gn/secondary/llvm/test/BUILD.gn
index 3257f4b5ff236..359d4b5f5e138 100644
--- a/llvm/utils/gn/secondary/llvm/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/test/BUILD.gn
@@ -8,6 +8,7 @@ import("//llvm/utils/gn/build/libs/pthread/enable.gni")
import("//llvm/utils/gn/build/libs/xar/enable.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/libs/zlib/enable.gni")
+import("//llvm/utils/gn/build/libs/zstd/enable.gni")
import("//llvm/utils/gn/build/mac_sdk.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/utils/llvm-lit/lit_path_function.gni")
@@ -61,7 +62,6 @@ write_lit_config("lit_site_cfg") {
"LLVM_ENABLE_FFI=0",
"LLVM_ENABLE_HTTPLIB=0",
- "LLVM_ENABLE_ZSTD=0",
"LLVM_HAVE_OPT_VIEWER_MODULES=0",
"LLVM_HOST_TRIPLE=$llvm_current_triple",
"LLVM_INCLUDE_DXIL_TESTS=0",
@@ -208,6 +208,12 @@ write_lit_config("lit_site_cfg") {
extra_values += [ "LLVM_ENABLE_ZLIB=0" ] # Must be 0.
}
+ if (llvm_enable_zstd) {
+ extra_values += [ "LLVM_ENABLE_ZSTD=1" ]
+ } else {
+ extra_values += [ "LLVM_ENABLE_ZSTD=0" ] # Must be 0.
+ }
+
if (llvm_enable_libcurl) {
extra_values += [ "LLVM_ENABLE_CURL=1" ]
} else {
More information about the llvm-commits
mailing list