[llvm] [libc][bazel] Remove customization from several libc BUILD rules. (PR #121843)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 6 14:00:49 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Alexey Samsonov (vonosmas)
<details>
<summary>Changes</summary>
Get rid of the following arguments to libc_support_library and libc_function rules:
* `defines` (for raw_mutex.h) - it wasn't used correctly (e.g. didn't provide actual value for spin count), and we can instead fallback to defaults set in the header itself (or rely on library-level configure options).
* `features` - there's no need to disable sanitization for a subset of memory functions -- it generally should be the vendor / user responsibility to control it (e.g. don't include instrumented libc functions in the build, since they would be provided by sanitizer runtimes instead).
* `local_defines` (for printf_parser) - no longer needed, since LIBC_COPT_MOCK_ARG_LIST has been removed in e0be78be427931e94d287002b9c3910f6bc6a22c
This also removes two ad-hoc BUILD rules (strcpy_sanitized and printf_mock_parser) which are no longer needed and can be replaced by strcpy and printf_parser, respectively.
---
Full diff: https://github.com/llvm/llvm-project/pull/121843.diff
2 Files Affected:
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (-55)
- (modified) utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel (+1-1)
``````````diff
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 91c7db9029a660..18019b3757f8ae 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -1395,10 +1395,6 @@ libc_support_library(
hdrs = [
"src/__support/threads/linux/raw_mutex.h",
],
- defines = [
- "LIBC_COPT_TIMEOUT_ENSURE_MONOTONICITY",
- "LIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT",
- ],
target_compatible_with = select({
"@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
@@ -3596,13 +3592,6 @@ libc_function(
############################### string targets ###############################
-no_sanitize_features = [
- "-asan",
- "-msan",
- "-tsan",
- "-ubsan",
-]
-
libc_support_library(
name = "string_memory_utils",
hdrs = [
@@ -3680,7 +3669,6 @@ libc_function(
name = "memcpy",
srcs = ["src/string/memcpy.cpp"],
hdrs = ["src/string/memcpy.h"],
- features = no_sanitize_features,
weak = True,
deps = [
":__support_common",
@@ -3692,7 +3680,6 @@ libc_function(
name = "memset",
srcs = ["src/string/memset.cpp"],
hdrs = ["src/string/memset.h"],
- features = no_sanitize_features,
weak = True,
deps = [
":__support_common",
@@ -3704,7 +3691,6 @@ libc_function(
name = "memmove",
srcs = ["src/string/memmove.cpp"],
hdrs = ["src/string/memmove.h"],
- features = no_sanitize_features,
weak = True,
deps = [
":__support_common",
@@ -3716,7 +3702,6 @@ libc_function(
name = "mempcpy",
srcs = ["src/string/mempcpy.cpp"],
hdrs = ["src/string/mempcpy.h"],
- features = no_sanitize_features,
weak = True,
deps = [
":__support_common",
@@ -3728,7 +3713,6 @@ libc_function(
name = "bcopy",
srcs = ["src/strings/bcopy.cpp"],
hdrs = ["src/strings/bcopy.h"],
- features = no_sanitize_features,
deps = [
":__support_common",
":string_memory_utils",
@@ -3739,7 +3723,6 @@ libc_function(
name = "memcmp",
srcs = ["src/string/memcmp.cpp"],
hdrs = ["src/string/memcmp.h"],
- features = no_sanitize_features,
weak = True,
deps = [
":__support_common",
@@ -3752,7 +3735,6 @@ libc_function(
name = "bcmp",
srcs = ["src/strings/bcmp.cpp"],
hdrs = ["src/strings/bcmp.h"],
- features = no_sanitize_features,
weak = True,
deps = [
":__support_common",
@@ -3764,7 +3746,6 @@ libc_function(
name = "bzero",
srcs = ["src/strings/bzero.cpp"],
hdrs = ["src/strings/bzero.h"],
- features = no_sanitize_features,
weak = True,
deps = [
":__support_common",
@@ -3786,7 +3767,6 @@ libc_function(
name = "strlen",
srcs = ["src/string/strlen.cpp"],
hdrs = ["src/string/strlen.h"],
- features = no_sanitize_features,
deps = [
":__support_common",
":string_utils",
@@ -3797,21 +3777,6 @@ libc_function(
name = "strcpy",
srcs = ["src/string/strcpy.cpp"],
hdrs = ["src/string/strcpy.h"],
- features = no_sanitize_features,
- deps = [
- ":__support_common",
- ":memcpy",
- ":string_memory_utils",
- ":string_utils",
- ],
-)
-
-# A sanitizer instrumented flavor of strcpy to be used with unittests.
-libc_function(
- name = "strcpy_sanitized",
- testonly = 1,
- srcs = ["src/string/strcpy.cpp"],
- hdrs = ["src/string/strcpy.h"],
deps = [
":__support_common",
":memcpy",
@@ -4467,26 +4432,6 @@ libc_support_library(
],
)
-# Only used for testing.
-libc_support_library(
- name = "printf_mock_parser",
- hdrs = ["src/stdio/printf_core/parser.h"],
- local_defines = ["LIBC_COPT_MOCK_ARG_LIST"],
- deps = [
- ":__support_arg_list",
- ":__support_common",
- ":__support_cpp_bit",
- ":__support_cpp_optional",
- ":__support_cpp_string_view",
- ":__support_cpp_type_traits",
- ":__support_ctype_utils",
- ":__support_fputil_fp_bits",
- ":__support_str_to_integer",
- ":printf_config",
- ":printf_core_structs",
- ],
-)
-
libc_support_library(
name = "printf_writer",
srcs = ["src/stdio/printf_core/writer.cpp"],
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel
index a31c67cfcea80c..a36cf2e0cb7d90 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel
@@ -23,7 +23,7 @@ libc_test(
name = "strcpy_test",
srcs = ["strcpy_test.cpp"],
libc_function_deps = [
- "//libc:strcpy_sanitized",
+ "//libc:strcpy",
],
)
``````````
</details>
https://github.com/llvm/llvm-project/pull/121843
More information about the llvm-commits
mailing list