[llvm] [bazel][libc] Add bazel support for a handful of string functions (PR #158327)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 12 09:43:36 PDT 2025
https://github.com/jtstogel created https://github.com/llvm/llvm-project/pull/158327
None
>From 64e7b2f3f97d5f8bee0a729c93f5a0874547ee09 Mon Sep 17 00:00:00 2001
From: Jackson Stogel <jtstogel at gmail.com>
Date: Fri, 12 Sep 2025 16:42:53 +0000
Subject: [PATCH] [bazel][libc] Add bazel support for a handful of string
functions
---
.../llvm-project-overlay/libc/BUILD.bazel | 177 ++++++++++++++++++
.../libc/test/src/string/BUILD.bazel | 104 ++++++++++
.../libc/test/src/strings/BUILD.bazel | 34 ++++
3 files changed, 315 insertions(+)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index d9b1bb5635aaf..039ca4e37fdb8 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -5223,6 +5223,27 @@ libc_support_library(
],
)
+libc_function(
+ name = "index",
+ srcs = ["src/strings/index.cpp"],
+ hdrs = ["src/strings/index.h"],
+ deps = [
+ ":__support_common",
+ ":string_utils",
+ ],
+)
+
+libc_function(
+ name = "rindex",
+ srcs = ["src/strings/rindex.cpp"],
+ hdrs = ["src/strings/rindex.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":string_utils",
+ ],
+)
+
libc_function(
name = "memchr",
srcs = ["src/string/memchr.cpp"],
@@ -5245,6 +5266,16 @@ libc_function(
],
)
+libc_function(
+ name = "memccpy",
+ srcs = ["src/string/memccpy.cpp"],
+ hdrs = ["src/string/memccpy.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ],
+)
+
libc_function(
name = "memset",
srcs = ["src/string/memset.cpp"],
@@ -5256,6 +5287,17 @@ libc_function(
],
)
+libc_function(
+ name = "memset_explicit",
+ srcs = ["src/string/memset_explicit.cpp"],
+ hdrs = ["src/string/memset_explicit.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":string_memory_utils",
+ ],
+)
+
libc_function(
name = "memmove",
srcs = ["src/string/memmove.cpp"],
@@ -5267,6 +5309,17 @@ libc_function(
],
)
+libc_function(
+ name = "memmem",
+ srcs = ["src/string/memmem.cpp"],
+ hdrs = ["src/string/memmem.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":string_memory_utils",
+ ],
+)
+
libc_function(
name = "mempcpy",
srcs = ["src/string/mempcpy.cpp"],
@@ -5331,6 +5384,30 @@ libc_function(
],
)
+libc_function(
+ name = "stpcpy",
+ srcs = ["src/string/stpcpy.cpp"],
+ hdrs = ["src/string/stpcpy.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":string_memory_utils",
+ ":string_utils",
+ ],
+)
+
+libc_function(
+ name = "stpncpy",
+ srcs = ["src/string/stpncpy.cpp"],
+ hdrs = ["src/string/stpncpy.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":string_memory_utils",
+ ":string_utils",
+ ],
+)
+
libc_function(
name = "strlen",
srcs = ["src/string/strlen.cpp"],
@@ -5354,6 +5431,17 @@ libc_function(
],
)
+libc_function(
+ name = "strlcpy",
+ srcs = ["src/string/strlcpy.cpp"],
+ hdrs = ["src/string/strlcpy.h"],
+ deps = [
+ ":__support_common",
+ ":llvm_libc_types_size_t",
+ ":string_utils",
+ ],
+)
+
libc_function(
name = "strncpy",
srcs = ["src/string/strncpy.cpp"],
@@ -5375,6 +5463,40 @@ libc_function(
],
)
+libc_function(
+ name = "strncmp",
+ srcs = ["src/string/strncmp.cpp"],
+ hdrs = ["src/string/strncmp.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":string_memory_utils",
+ ":string_utils",
+ ],
+)
+
+libc_function(
+ name = "strcasecmp",
+ srcs = ["src/strings/strcasecmp.cpp"],
+ hdrs = ["src/strings/strcasecmp.h"],
+ deps = [
+ ":__support_common",
+ ":__support_ctype_utils",
+ ":string_memory_utils",
+ ],
+)
+
+libc_function(
+ name = "strncasecmp",
+ srcs = ["src/strings/strncasecmp.cpp"],
+ hdrs = ["src/strings/strncasecmp.h"],
+ deps = [
+ ":__support_common",
+ ":__support_ctype_utils",
+ ":string_memory_utils",
+ ],
+)
+
libc_function(
name = "strchr",
srcs = ["src/string/strchr.cpp"],
@@ -5395,6 +5517,16 @@ libc_function(
],
)
+libc_function(
+ name = "strchrnul",
+ srcs = ["src/string/strchrnul.cpp"],
+ hdrs = ["src/string/strchrnul.h"],
+ deps = [
+ ":__support_common",
+ ":string_utils",
+ ],
+)
+
libc_function(
name = "strsep",
srcs = ["src/string/strsep.cpp"],
@@ -5420,6 +5552,51 @@ libc_function(
],
)
+libc_function(
+ name = "strcasestr",
+ srcs = ["src/string/strcasestr.cpp"],
+ hdrs = ["src/string/strcasestr.h"],
+ deps = [
+ ":__support_common",
+ ":__support_ctype_utils",
+ ":__support_macros_null_check",
+ ":string_memory_utils",
+ ":string_utils",
+ ],
+)
+
+libc_function(
+ name = "strcat",
+ srcs = ["src/string/strcat.cpp"],
+ hdrs = ["src/string/strcat.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":string_utils",
+ ],
+)
+
+libc_function(
+ name = "strlcat",
+ srcs = ["src/string/strlcat.cpp"],
+ hdrs = ["src/string/strlcat.h"],
+ deps = [
+ ":__support_common",
+ ":string_utils",
+ ],
+)
+
+libc_function(
+ name = "strncat",
+ srcs = ["src/string/strncat.cpp"],
+ hdrs = ["src/string/strncat.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":string_utils",
+ ],
+)
+
libc_function(
name = "strnlen",
srcs = ["src/string/strnlen.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 1a95dece8bf20..e78f0a57de3ae 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
@@ -27,6 +27,33 @@ libc_test(
],
)
+libc_test(
+ name = "strlcpy_test",
+ srcs = ["strlcpy_test.cpp"],
+ deps = [
+ "//libc:strlcpy",
+ ],
+)
+
+libc_test(
+ name = "stpcpy_test",
+ srcs = ["stpcpy_test.cpp"],
+ deps = [
+ "//libc:stpcpy",
+ "//libc:string_utils",
+ ],
+)
+
+libc_test(
+ name = "stpncpy_test",
+ srcs = ["stpncpy_test.cpp"],
+ deps = [
+ "//libc:__support_cpp_span",
+ "//libc:hdr_signal_macros",
+ "//libc:stpncpy",
+ ],
+)
+
libc_test(
name = "strcmp_test",
srcs = ["strcmp_test.cpp"],
@@ -35,6 +62,14 @@ libc_test(
],
)
+libc_test(
+ name = "strncmp_test",
+ srcs = ["strncmp_test.cpp"],
+ deps = [
+ "//libc:strncmp",
+ ],
+)
+
libc_test(
name = "memchr_test",
srcs = ["memchr_test.cpp"],
@@ -59,6 +94,14 @@ libc_test(
],
)
+libc_test(
+ name = "strchrnul_test",
+ srcs = ["strchrnul_test.cpp"],
+ deps = [
+ "//libc:strchrnul",
+ ],
+)
+
libc_test(
name = "strpbrk_test",
srcs = ["strpbrk_test.cpp"],
@@ -110,6 +153,39 @@ libc_test(
],
)
+libc_test(
+ name = "strcasestr_test",
+ srcs = ["strcasestr_test.cpp"],
+ deps = [
+ "//libc:strcasestr",
+ ],
+)
+
+libc_test(
+ name = "strcat_test",
+ srcs = ["strcat_test.cpp"],
+ deps = [
+ "//libc:hdr_signal_macros",
+ "//libc:strcat",
+ ],
+)
+
+libc_test(
+ name = "strlcat_test",
+ srcs = ["strlcat_test.cpp"],
+ deps = [
+ "//libc:strlcat",
+ ],
+)
+
+libc_test(
+ name = "strncat_test",
+ srcs = ["strncat_test.cpp"],
+ deps = [
+ "//libc:strncat",
+ ],
+)
+
libc_test(
name = "strcspn_test",
srcs = ["strcspn_test.cpp"],
@@ -178,6 +254,15 @@ libc_test(
],
)
+libc_test(
+ name = "memccpy_test",
+ srcs = ["memccpy_test.cpp"],
+ deps = [
+ "//libc:__support_cpp_span",
+ "//libc:memccpy",
+ ],
+)
+
libc_test(
name = "mempcpy_test",
srcs = ["mempcpy_test.cpp"],
@@ -199,6 +284,16 @@ libc_test(
],
)
+libc_test(
+ name = "memset_explicit_test",
+ srcs = ["memset_explicit_test.cpp"],
+ deps = [
+ "//libc:memset_explicit",
+ "//libc:string_memory_utils",
+ ":memory_check_utils",
+ ],
+)
+
libc_test(
name = "memmove_test",
srcs = ["memmove_test.cpp"],
@@ -222,3 +317,12 @@ libc_test(
"//libc/test/UnitTest:test_logger",
],
)
+
+libc_test(
+ name = "memmem_test",
+ srcs = ["memmem_test.cpp"],
+ deps = [
+ "//libc:string_utils",
+ "//libc:memmem",
+ ],
+)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/strings/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/strings/BUILD.bazel
index 2e6f5644eec71..e576d2177687e 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/strings/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/strings/BUILD.bazel
@@ -39,3 +39,37 @@ libc_test(
"//libc/test/src/string:memory_check_utils",
],
)
+
+libc_test(
+ name = "index_test",
+ srcs = ["index_test.cpp"],
+ deps = [
+ "//libc:index",
+ "//libc/test/src/string:strchr_test_helper",
+ ],
+)
+
+libc_test(
+ name = "rindex_test",
+ srcs = ["rindex_test.cpp"],
+ deps = [
+ "//libc:rindex",
+ "//libc/test/src/string:strchr_test_helper",
+ ],
+)
+
+libc_test(
+ name = "strcasecmp_test",
+ srcs = ["strcasecmp_test.cpp"],
+ deps = [
+ "//libc:strcasecmp",
+ ],
+)
+
+libc_test(
+ name = "strncasecmp_test",
+ srcs = ["strncasecmp_test.cpp"],
+ deps = [
+ "//libc:strncasecmp",
+ ],
+)
More information about the llvm-commits
mailing list