Skip to content

Conversation

@mleleszi
Copy link
Member

@mleleszi mleleszi commented Dec 3, 2025

#170525

Based on our RFC, we are starting the implementation of the wctype header with C.UTF8 support. This implementation will increase the binary size by approximately ~70KB, so this PR introduces a flag so that this is configurable, allowing the user to choose between a simple ASCII implementation or the full Unicode one.

@mleleszi mleleszi marked this pull request as ready for review December 3, 2025 18:42
@llvmbot llvmbot added the libc label Dec 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 3, 2025

@llvm/pr-subscribers-libc

Author: Marcell Leleszi (mleleszi)

Changes

#170525

Based on our RFC, we are starting the implementation of the wctype header with C.UTF8 support. This implementation will increase the binary size by approximately ~70KB, so this PR introduces a flag so that this is configurable, allowing the user to choose between a simple ASCII implementation or the full Unicode one.


Full diff: https://github.com/llvm/llvm-project/pull/170531.diff

1 Files Affected:

  • (modified) libc/config/config.json (+6)
diff --git a/libc/config/config.json b/libc/config/config.json
index cfbe9a43948ea..a7844e4fe2dd1 100644
--- a/libc/config/config.json
+++ b/libc/config/config.json
@@ -130,5 +130,11 @@
       "value": true,
       "doc": "Add nullptr checks in the library's implementations to some functions for which passing nullptr is undefined behavior."
     }
+  },
+  "wctype": {
+    "LIBC_CONF_WCTYPE_MODE": {
+      "value": "LIBC_WCTYPE_MODE_ASCII",
+      "doc": "The implementation used for wctype, acceptable values are LIBC_WCTYPE_MODE_ASCII and LIBC_WCTYPE_MODE_UTF8."
+    }
   }
 }

Copy link
Contributor

@bassiounix bassiounix left a comment

Choose a reason for hiding this comment

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

We need to add some description to let people know how to utilize this option with its possible values.
Please add some description in the docs like:

@michaelrj-google
Copy link
Contributor

The config flag looks good, if you run the cmake it should automatically update the documentation.

@bassiounix
Copy link
Contributor

The config flag looks good, if you run the cmake it should automatically update the documentation.

I had no idea it's automatically generated. I thought we write the docs ourselves.

@michaelrj-google
Copy link
Contributor

The configuration documentation and the lists of implemented functions are both automatically generated: https://github.com/llvm/llvm-project/blob/main/libc/utils/docgen/docgen.py

@mleleszi
Copy link
Member Author

mleleszi commented Dec 4, 2025

Done, regenerated docs

Copy link
Contributor

@bassiounix bassiounix left a comment

Choose a reason for hiding this comment

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

LGTM

@mleleszi mleleszi merged commit d8b43ed into llvm:main Dec 4, 2025
27 checks passed
@mleleszi mleleszi deleted the libc-wctype-mode-cmake-flag branch December 4, 2025 14:38
kcloudy0717 pushed a commit to kcloudy0717/llvm-project that referenced this pull request Dec 4, 2025
…sed (llvm#170531)

llvm#170525 

Based on our
[RFC](https://discourse.llvm.org/t/rfc-libc-wctype-header-implementation/88941/10),
we are starting the implementation of the wctype header with C.UTF8
support. This implementation will increase the binary size by
approximately ~70KB, so this PR introduces a flag so that this is
configurable, allowing the user to choose between a simple ASCII
implementation or the full Unicode one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants