11
11
)
12
12
load (":platforms.bzl" , "PLATFORM_CPU_ARM64" , "PLATFORM_CPU_X86_64" )
13
13
load ("@bazel_skylib//lib:selects.bzl" , "selects" )
14
- load ("@bazel_skylib//rules:common_settings.bzl" , "string_flag" )
14
+ load ("@bazel_skylib//rules:common_settings.bzl" , "bool_flag" , " string_flag" )
15
15
load ("//:vars.bzl" , "LLVM_VERSION_MAJOR" , "LLVM_VERSION_MINOR" , "LLVM_VERSION_PATCH" )
16
16
17
17
package (
@@ -35,8 +35,6 @@ MEMORY_COPTS = [
35
35
# "LIBC_COPT_MEMCPY_X86_USE_SOFTWARE_PREFETCHING",
36
36
]
37
37
38
- llvm_libc_namespace = "__llvm_libc_{}_{}_{}_git" .format (LLVM_VERSION_MAJOR , LLVM_VERSION_MINOR , LLVM_VERSION_PATCH )
39
-
40
38
# A flag to pick which `mpfr` to use for math tests.
41
39
# Usage: `--@llvm-project//libc:mpfr=<disable|external|system>`.
42
40
# Flag documentation: https://bazel.build/extending/config
@@ -65,14 +63,34 @@ config_setting(
65
63
flag_values = {":mpfr" : "system" },
66
64
)
67
65
66
+ default_libc_namespace = "__llvm_libc_{}_{}_{}_git" .format (LLVM_VERSION_MAJOR , LLVM_VERSION_MINOR , LLVM_VERSION_PATCH )
67
+
68
+ release_libc_namespace = "__llvm_libc"
69
+
70
+ # When set, The ':libc_root' target below will define 'LIBC_NAMESPACE' to
71
+ # 'release_libc_namespace' instead of 'default_libc_namespace'.
72
+ # Usage: `--@llvm-project//libc:release`.
73
+ bool_flag (
74
+ name = "release" ,
75
+ build_setting_default = False ,
76
+ )
77
+
78
+ config_setting (
79
+ name = "use_release_namespace" ,
80
+ flag_values = {":release" : "true" },
81
+ )
82
+
68
83
# This empty root library helps us add an include path to this directory
69
84
# using the 'includes' attribute. The strings listed in the includes attribute
70
85
# are relative paths wrt this library but are inherited by the dependents
71
86
# appropriately. Hence, using this as a root dependency avoids adding include
72
87
# paths of the kind "../../" to other libc targets.
73
88
cc_library (
74
89
name = "libc_root" ,
75
- defines = ["LIBC_NAMESPACE=" + llvm_libc_namespace ],
90
+ defines = select ({
91
+ ":use_release_namespace" : ["LIBC_NAMESPACE=" + release_libc_namespace ],
92
+ "//conditions:default" : ["LIBC_NAMESPACE=" + default_libc_namespace ],
93
+ }),
76
94
includes = ["." ],
77
95
)
78
96
0 commit comments