Skip to content

[libc][bazel] Added wchar functions to bazel #146126

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

Merged
merged 2 commits into from
Jun 30, 2025
Merged

Conversation

sribee8
Copy link
Contributor

@sribee8 sribee8 commented Jun 27, 2025

Added wchar functions, apart from ones that use mbstate_t. to the bazel files

@llvmbot llvmbot added libc bazel "Peripheral" support tier build system: utils/bazel labels Jun 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 27, 2025

@llvm/pr-subscribers-libc

Author: None (sribee8)

Changes

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 --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",
+    ],
+)

@sribee8 sribee8 requested a review from michaelrj-google June 27, 2025 18:02
Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sribee8 sribee8 merged commit 4bf0c6b into llvm:main Jun 30, 2025
7 checks passed
@sribee8 sribee8 deleted the wchar-bazel branch June 30, 2025 20:05
rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
Added wchar functions, apart from ones that use mbstate_t. to the bazel
files

---------

Co-authored-by: Sriya Pratipati <[email protected]>
rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
Added wchar functions, apart from ones that use mbstate_t. to the bazel
files

---------

Co-authored-by: Sriya Pratipati <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel libc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants