[libcxx-commits] [libcxx] [libcxx] Work around picolibc argv handling in tests. (PR #127662)

Simon Tatham via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 19 01:47:13 PST 2025


================
@@ -274,14 +274,39 @@ def hasAnyLocale(config, locales):
     %{exec} -- this means that the command may be executed on a remote host
     depending on the %{exec} substitution.
     """
+
+    # Some locale names contain spaces, and some embedded use cases
+    # (in particular picolibc under Arm semihosting) can't support
+    # spaces in argv words. Work around this by applying URL-style
+    # %-encoding to the locale names, and undoing it in our test
+    # program.
+    percent_encode = lambda s: "".join(
+        "%{:02x}".format(c) if c in b" %\\\"'" or c >= 128 else chr(c)
+        for c in s.encode()
+    )
+
     program = """
     #include <stddef.h>
     #if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_LOCALIZATION
       int main(int, char**) { return 1; }
     #else
+      #include <stdlib.h>
       #include <locale.h>
       int main(int argc, char** argv) {
         for (int i = 1; i < argc; i++) {
----------------
statham-arm wrote:

Fair enough. I've done that, and updated the PR description to describe the alternative fix (which I _hope_ means that the updated description will be used as the final commit message after squash-and-merge).

https://github.com/llvm/llvm-project/pull/127662


More information about the libcxx-commits mailing list