[libc-commits] [libc] [libc] Implement generic SIMD helper 'simd.h' and implement strlen (PR #152605)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Fri Aug 29 15:47:58 PDT 2025
https://github.com/michaelrj-google commented:
I checked the bazel build, it's currently set to do byte-by-byte so not blocking in theory: https://github.com/llvm/llvm-project/blob/main/utils/bazel/llvm-project-overlay/libc/libc_configure_options.bzl#L42
I did turn that flag on and get the bazel set up to work with your simd header (diff is at the bottom comment) but I ran into a more structural issue. Bazel expects all targets to be able to build on their own. Currently if the `simd` header is built without the appropriate clang intrinsics it errors (even without the static assert). My opinion is that bazel's "every header must build on its own" policy is pretty reasonable, so I'd suggest wrapping the contents of `simd.h` in `#if LIBC_HAS_VECTOR_TYPE` and possibly putting a warning in an `#else` block.
```
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index bfda5385f012..23ef774c1894 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -677,6 +677,18 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_cpp_simd",
+ hdrs = ["src/__support/CPP/simd.h"],
+ deps = [
+ ":__support_cpp_algorithm",
+ ":__support_cpp_bit",
+ ":__support_cpp_type_traits",
+ ":__support_macros_attributes",
+ ":hdr_stdint_proxy",
+ ],
+)
+
libc_support_library(
name = "__support_cpp_span",
hdrs = ["src/__support/CPP/span.h"],
@@ -4938,6 +4950,7 @@ libc_support_library(
"src/string/memory_utils/arm/inline_memset.h",
"src/string/memory_utils/generic/aligned_access.h",
"src/string/memory_utils/generic/byte_per_byte.h",
+ "src/string/memory_utils/generic/inline_strlen.h",
"src/string/memory_utils/inline_bcmp.h",
"src/string/memory_utils/inline_bzero.h",
"src/string/memory_utils/inline_memcmp.h",
@@ -4964,6 +4977,7 @@ libc_support_library(
":__support_cpp_array",
":__support_cpp_bit",
":__support_cpp_cstddef",
+ ":__support_cpp_simd",
":__support_cpp_type_traits",
":__support_macros_attributes",
":__support_macros_optimization",
diff --git a/utils/bazel/llvm-project-overlay/libc/libc_configure_options.bzl b/utils/bazel/llvm-project-overlay/libc/libc_configure_options.bzl
index 179fc83e6729..259d4d292fcf 100644
--- a/utils/bazel/llvm-project-overlay/libc/libc_configure_options.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_configure_options.bzl
@@ -39,7 +39,7 @@ LIBC_CONFIGURE_OPTIONS = [
# "LIBC_COPT_SCANF_DISABLE_FLOAT",
# "LIBC_COPT_SCANF_DISABLE_INDEX_MODE",
"LIBC_COPT_STDIO_USE_SYSTEM_FILE",
- # "LIBC_COPT_STRING_UNSAFE_WIDE_READ",
+ "LIBC_COPT_STRING_UNSAFE_WIDE_READ",
# "LIBC_COPT_STRTOFLOAT_DISABLE_CLINGER_FAST_PATH",
# "LIBC_COPT_STRTOFLOAT_DISABLE_EISEL_LEMIRE",
# "LIBC_COPT_STRTOFLOAT_DISABLE_SIMPLE_DECIMAL_CONVERSION",
```
https://github.com/llvm/llvm-project/pull/152605
More information about the libc-commits
mailing list