[llvm] [libc][bazel] Add a flag to configure LIBC_NAMESPACE (PR #68093)
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 04:27:58 PDT 2023
https://github.com/gchatelet created https://github.com/llvm/llvm-project/pull/68093
None
>From e1e1e6ce88222cff6a3df373516155314a018023 Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Tue, 3 Oct 2023 11:25:44 +0000
Subject: [PATCH] [libc][bazel] Add a flag to configure LIBC_NAMESPACE
---
.../llvm-project-overlay/libc/BUILD.bazel | 26 ++++++++++++++++---
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 258ae5168887fea..6fc4be39b063f07 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -11,7 +11,7 @@ load(
)
load(":platforms.bzl", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_X86_64")
load("@bazel_skylib//lib:selects.bzl", "selects")
-load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("//:vars.bzl", "LLVM_VERSION_MAJOR", "LLVM_VERSION_MINOR", "LLVM_VERSION_PATCH")
package(
@@ -35,8 +35,6 @@ MEMORY_COPTS = [
# "LIBC_COPT_MEMCPY_X86_USE_SOFTWARE_PREFETCHING",
]
-llvm_libc_namespace = "__llvm_libc_{}_{}_{}_git".format(LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, LLVM_VERSION_PATCH)
-
# A flag to pick which `mpfr` to use for math tests.
# Usage: `-- at llvm-project//libc:mpfr=<disable|external|system>`.
# Flag documentation: https://bazel.build/extending/config
@@ -65,6 +63,23 @@ config_setting(
flag_values = {":mpfr": "system"},
)
+default_libc_namespace = "__llvm_libc_{}_{}_{}_git".format(LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, LLVM_VERSION_PATCH)
+
+release_libc_namespace = "__llvm_libc"
+
+# When set, The ':libc_root' target below will define 'LIBC_NAMESPACE' to
+# 'release_libc_namespace' instead of 'default_libc_namespace'.
+# Usage: `-- at llvm-project//libc:release`.
+bool_flag(
+ name = "release",
+ build_setting_default = False,
+)
+
+config_setting(
+ name = "use_release_namespace",
+ flag_values = {":release": "true"},
+)
+
# This empty root library helps us add an include path to this directory
# using the 'includes' attribute. The strings listed in the includes attribute
# are relative paths wrt this library but are inherited by the dependents
@@ -72,7 +87,10 @@ config_setting(
# paths of the kind "../../" to other libc targets.
cc_library(
name = "libc_root",
- defines = ["LIBC_NAMESPACE=" + llvm_libc_namespace],
+ defines = select({
+ ":use_release_namespace": ["LIBC_NAMESPACE=" + release_libc_namespace],
+ "//conditions:default": ["LIBC_NAMESPACE=" + default_libc_namespace],
+ }),
includes = ["."],
)
More information about the llvm-commits
mailing list