-
Notifications
You must be signed in to change notification settings - Fork 15k
[bazel][libc] Add bazel support for a handful of string functions #158327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jtstogel
wants to merge
1
commit into
llvm:main
Choose a base branch
from
jtstogel:libc-bazel-targets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libc Author: None (jtstogel) ChangesFull diff: https://github.com/llvm/llvm-project/pull/158327.diff 3 Files Affected:
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",
+ ],
+)
|
64e7b2f
to
1b72552
Compare
vonosmas
approved these changes
Sep 12, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.