[llvm] [libc][bazel] Added wchar functions to bazel (PR #146126)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 27 11:00:23 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: None (sribee8)
<details>
<summary>Changes</summary>
Added wchar functions, apart from ones that use mbstate_t. to the bazel files
---
Full diff: https://github.com/llvm/llvm-project/pull/146126.diff
2 Files Affected:
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+335)
- (added) utils/bazel/llvm-project-overlay/libc/test/src/wchar/BUILD.bazel (+214)
``````````diff
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 9e2828eaf098c..37db3b3b38968 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -259,6 +259,19 @@ libc_support_library(
hdrs = ["hdr/unistd_overlay.h"],
)
+libc_support_library(
+ name = "hdr_wchar_macros",
+ hdrs = ["hdr/wchar_macros.h"],
+ deps = [
+ ":hdr_wchar_overlay",
+ ],
+)
+
+libc_support_library(
+ name = "hdr_wchar_overlay",
+ hdrs = ["hdr/wchar_overlay.h"],
+)
+
############################ Type Proxy Header Files ###########################
libc_support_library(
@@ -285,6 +298,24 @@ libc_support_library(
deps = [":hdr_stdlib_overlay"],
)
+libc_support_library(
+ name = "types_char32_t",
+ hdrs = ["hdr/types/char32_t.h"],
+ deps = [
+ ":hdr_uchar_overlay",
+ ],
+)
+
+libc_support_library(
+ name = "hdr_uchar_overlay",
+ hdrs = ["hdr/uchar_overlay.h"],
+)
+
+libc_support_library(
+ name = "types_char8_t",
+ hdrs = ["hdr/types/char8_t.h"],
+)
+
libc_support_library(
name = "types_clockid_t",
hdrs = ["hdr/types/clockid_t.h"],
@@ -323,6 +354,11 @@ libc_support_library(
deps = [":hdr_stdlib_overlay"],
)
+libc_support_library(
+ name = "types_mbstate_t",
+ hdrs = ["hdr/types/mbstate_t.h"],
+)
+
libc_support_library(
name = "types_mode_t",
hdrs = ["hdr/types/mode_t.h"],
@@ -423,6 +459,22 @@ libc_support_library(
hdrs = ["hdr/types/struct_msghdr.h"],
)
+libc_support_library(
+ name = "types_wchar_t",
+ hdrs = ["hdr/types/wchar_t.h"],
+ deps = [
+ ":hdr_wchar_overlay",
+ ],
+)
+
+libc_support_library(
+ name = "types_wint_t",
+ hdrs = ["hdr/types/wint_t.h"],
+ deps = [
+ ":hdr_wchar_overlay",
+ ],
+)
+
############################### Support libraries ##############################
libc_support_library(
@@ -5676,3 +5728,286 @@ libc_function(
":types_struct_timespec",
],
)
+
+############################## wchar targets ###############################
+
+libc_support_library(
+ name = "__support_wctype_utils",
+ hdrs = ["src/__support/wctype_utils.h"],
+ deps = [
+ ":__support_cpp_optional",
+ ":__support_macros_attributes",
+ ":__support_macros_config",
+ ],
+)
+
+libc_function(
+ name = "btowc",
+ srcs = ["src/wchar/btowc.cpp"],
+ hdrs = ["src/wchar/btowc.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":__support_wctype_utils",
+ ":hdr_wchar_macros",
+ ":types_wint_t",
+ ],
+)
+
+libc_function(
+ name = "wcpcpy",
+ srcs = ["src/wchar/wcpcpy.cpp"],
+ hdrs = ["src/wchar/wcpcpy.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":string_utils",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcpncpy",
+ srcs = ["src/wchar/wcpncpy.cpp"],
+ hdrs = ["src/wchar/wcpncpy.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":__support_macros_null_check",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcscat",
+ srcs = ["src/wchar/wcscat.cpp"],
+ hdrs = ["src/wchar/wcscat.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":string_utils",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcschr",
+ srcs = ["src/wchar/wcschr.cpp"],
+ hdrs = ["src/wchar/wcschr.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcscmp",
+ srcs = ["src/wchar/wcscmp.cpp"],
+ hdrs = ["src/wchar/wcscmp.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcscpy",
+ srcs = ["src/wchar/wcscpy.cpp"],
+ hdrs = ["src/wchar/wcscpy.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":string_utils",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcslen",
+ srcs = ["src/wchar/wcslen.cpp"],
+ hdrs = ["src/wchar/wcslen.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":string_utils",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcsncat",
+ srcs = ["src/wchar/wcsncat.cpp"],
+ hdrs = ["src/wchar/wcsncat.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":string_utils",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcsncmp",
+ srcs = ["src/wchar/wcsncmp.cpp"],
+ hdrs = ["src/wchar/wcsncmp.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcsncpy",
+ srcs = ["src/wchar/wcsncpy.cpp"],
+ hdrs = ["src/wchar/wcsncpy.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcspbrk",
+ srcs = ["src/wchar/wcspbrk.cpp"],
+ hdrs = ["src/wchar/wcspbrk.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcsrchr",
+ srcs = ["src/wchar/wcsrchr.cpp"],
+ hdrs = ["src/wchar/wcsrchr.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":__support_macros_null_check",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcsspn",
+ srcs = ["src/wchar/wcsspn.cpp"],
+ hdrs = ["src/wchar/wcsspn.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wcsstr",
+ srcs = ["src/wchar/wcsstr.cpp"],
+ hdrs = ["src/wchar/wcsstr.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":string_utils",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wctob",
+ srcs = ["src/wchar/wctob.cpp"],
+ hdrs = ["src/wchar/wctob.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":__support_macros_null_check",
+ ":__support_wctype_utils",
+ ":hdr_stdio_macros",
+ ":types_wint_t",
+ ],
+)
+
+libc_function(
+ name = "wmemchr",
+ srcs = ["src/wchar/wmemchr.cpp"],
+ hdrs = ["src/wchar/wmemchr.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wmemcmp",
+ srcs = ["src/wchar/wmemcmp.cpp"],
+ hdrs = ["src/wchar/wmemcmp.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":__support_macros_null_check",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wmemcpy",
+ srcs = ["src/wchar/wmemcpy.cpp"],
+ hdrs = ["src/wchar/wmemcpy.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_config",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wmemmove",
+ srcs = ["src/wchar/wmemmove.cpp"],
+ hdrs = ["src/wchar/wmemmove.h"],
+ deps = [
+ ":__support_common",
+ ":__support_macros_null_check",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wmempcpy",
+ srcs = ["src/wchar/wmempcpy.cpp"],
+ hdrs = ["src/wchar/wmempcpy.h"],
+ deps = [
+ ":__support_common",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
+
+libc_function(
+ name = "wmemset",
+ srcs = ["src/wchar/wmemset.cpp"],
+ hdrs = ["src/wchar/wmemset.h"],
+ deps = [
+ ":__support_common",
+ ":types_size_t",
+ ":types_wchar_t",
+ ],
+)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/wchar/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/wchar/BUILD.bazel
new file mode 100644
index 0000000000000..25243ae7c2b45
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/wchar/BUILD.bazel
@@ -0,0 +1,214 @@
+# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+# Tests for LLVM libc wchar.h functions.
+
+load("//libc/test:libc_test_rules.bzl", "libc_test")
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"])
+
+libc_test(
+ name = "btowc_test",
+ srcs = ["btowc_test.cpp"],
+ deps = [
+ "//libc:btowc",
+ "//libc:hdr_wchar_macros",
+ ],
+)
+
+libc_test(
+ name = "wcpcpy_test",
+ srcs = ["wcpcpy_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcpcpy",
+ ],
+)
+
+libc_test(
+ name = "wcpncpy_test",
+ srcs = ["wcpncpy_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcpncpy",
+ ],
+)
+
+libc_test(
+ name = "wcscat_test",
+ srcs = ["wcscat_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcscat",
+ ],
+)
+
+libc_test(
+ name = "wcschr_test",
+ srcs = ["wcschr_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcschr",
+ ],
+)
+
+libc_test(
+ name = "wcscmp_test",
+ srcs = ["wcscmp_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcscmp",
+ ],
+)
+
+libc_test(
+ name = "wcscpy_test",
+ srcs = ["wcscpy_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcscpy",
+ ],
+)
+
+libc_test(
+ name = "wcslen_test",
+ srcs = ["wcslen_test.cpp"],
+ deps = [
+ "//libc:types_size_t",
+ "//libc:types_wchar_t",
+ "//libc:wcslen",
+ ],
+)
+
+libc_test(
+ name = "wcsncat_test",
+ srcs = ["wcsncat_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcsncat",
+ ],
+)
+
+libc_test(
+ name = "wcsncmp_test",
+ srcs = ["wcsncmp_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcsncmp",
+ ],
+)
+
+libc_test(
+ name = "wcsncpy_test",
+ srcs = ["wcsncpy_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcsncpy",
+ ],
+)
+
+libc_test(
+ name = "wcsrchr_test",
+ srcs = ["wcsrchr_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcsrchr",
+ ],
+)
+
+libc_test(
+ name = "wcspbrk_test",
+ srcs = ["wcspbrk_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcspbrk",
+ ],
+)
+
+libc_test(
+ name = "wcsspn_test",
+ srcs = ["wcsspn_test.cpp"],
+ deps = [
+ "//libc:types_size_t",
+ "//libc:types_wchar_t",
+ "//libc:wcsspn",
+ ],
+)
+
+libc_test(
+ name = "wcsstr_test",
+ srcs = ["wcsstr_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wcsstr",
+ ],
+)
+
+libc_test(
+ name = "wctob_test",
+ srcs = ["wctob_test.cpp"],
+ deps = [
+ "//libc:hdr_stdio_macros",
+ "//libc:wctob",
+ ],
+)
+
+libc_test(
+ name = "wmemchr_test",
+ srcs = ["wmemchr_test.cpp"],
+ deps = [
+ "//libc:types_wchar_t",
+ "//libc:wmemchr",
+ ],
+)
+
+libc_test(
+ name = "wmemcmp_test",
+ srcs = ["wmemcmp_test.cpp"],
+ deps = [
+ "//libc:types_size_t",
+ "//libc:types_wchar_t",
+ "//libc:wmemcmp",
+ ],
+)
+
+libc_test(
+ name = "wmemcpy_test",
+ srcs = ["wmemcpy_test.cpp"],
+ deps = [
+ "//libc:types_size_t",
+ "//libc:types_wchar_t",
+ "//libc:wmemcpy",
+ ],
+)
+
+libc_test(
+ name = "wmemmove_test",
+ srcs = ["wmemmove_test.cpp"],
+ deps = [
+ "//libc:types_size_t",
+ "//libc:types_wchar_t",
+ "//libc:wmemmove",
+ ],
+)
+
+libc_test(
+ name = "wmempcpy_test",
+ srcs = ["wmempcpy_test.cpp"],
+ deps = [
+ "//libc:wmempcpy",
+ ],
+)
+
+libc_test(
+ name = "wmemset_test",
+ srcs = ["wmemset_test.cpp"],
+ deps = [
+ "//libc:types_size_t",
+ "//libc:types_wchar_t",
+ "//libc:wmemset",
+ ],
+)
``````````
</details>
https://github.com/llvm/llvm-project/pull/146126
More information about the llvm-commits
mailing list