[libcxx-commits] [PATCH] D103379: [libc++][format] Add a CMake Unicode option.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 2 12:01:49 PDT 2021


Mordante updated this revision to Diff 363540.
Mordante added a comment.

Rebase against main.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103379/new/

https://reviews.llvm.org/D103379

Files:
  libcxx/CMakeLists.txt
  libcxx/cmake/caches/Generic-no-unicode.cmake
  libcxx/docs/ReleaseNotes.rst
  libcxx/utils/ci/buildkite-pipeline.yml
  libcxx/utils/ci/run-buildbot
  libcxx/utils/libcxx/test/features.py


Index: libcxx/utils/libcxx/test/features.py
===================================================================
--- libcxx/utils/libcxx/test/features.py
+++ libcxx/utils/libcxx/test/features.py
@@ -106,6 +106,7 @@
   '_LIBCPP_HAS_NO_LOCALIZATION': 'libcpp-has-no-localization',
   '_LIBCPP_HAS_NO_INCOMPLETE_FORMAT': 'libcpp-has-no-incomplete-format',
   '_LIBCPP_HAS_NO_INCOMPLETE_RANGES': 'libcpp-has-no-incomplete-ranges',
+  '_LIBCPP_HAS_NO_UNICODE': 'libcpp-has-no-unicode',
 }
 for macro, feature in macros.items():
   DEFAULT_FEATURES += [
Index: libcxx/utils/ci/run-buildbot
===================================================================
--- libcxx/utils/ci/run-buildbot
+++ libcxx/utils/ci/run-buildbot
@@ -339,6 +339,13 @@
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake"
     check-cxx-cxxabi
 ;;
+generic-no-unicode)
+    export CC=clang
+    export CXX=clang++
+    clean
+    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-unicode.cmake"
+    check-cxx-cxxabi
+;;
 x86_64-apple-system)
     clean
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake"
Index: libcxx/utils/ci/buildkite-pipeline.yml
===================================================================
--- libcxx/utils/ci/buildkite-pipeline.yml
+++ libcxx/utils/ci/buildkite-pipeline.yml
@@ -356,6 +356,17 @@
         - exit_status: -1  # Agent was lost
           limit: 2
 
+  - label: "No Unicode"
+    command: "libcxx/utils/ci/run-buildbot generic-no-unicode"
+    artifact_paths:
+      - "**/test-results.xml"
+    agents:
+      queue: "libcxx-builders"
+    retry:
+      automatic:
+        - exit_status: -1  # Agent was lost
+          limit: 2
+
   - label: "Benchmarks"
     command: "libcxx/utils/ci/run-buildbot benchmarks"
     artifact_paths:
Index: libcxx/docs/ReleaseNotes.rst
===================================================================
--- libcxx/docs/ReleaseNotes.rst
+++ libcxx/docs/ReleaseNotes.rst
@@ -42,6 +42,9 @@
   is incomplete. Some functions are known to be inefficient; both in memory
   usage and performance. The implementation is considered experimental and isn't
   considered ABI stable.
+- There's a new CMake option ``LIBCXX_ENABLE_UNICODE`` to disable Unicode
+  support in the ``<format>`` header. This only affects the estimation of the
+  output width of the format functions.
 
 API Changes
 -----------
Index: libcxx/cmake/caches/Generic-no-unicode.cmake
===================================================================
--- /dev/null
+++ libcxx/cmake/caches/Generic-no-unicode.cmake
@@ -0,0 +1 @@
+set(LIBCXX_ENABLE_UNICODE OFF CACHE BOOL "")
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -116,6 +116,13 @@
    the C locale API (e.g. embedded). When localization is not supported,
    several parts of the library will be disabled: <iostream>, <regex>, <locale>
    will be completely unusable, and other parts may be only partly available." ON)
+option(LIBCXX_ENABLE_UNICODE
+  "Whether to include support for Unicode in the library. Disabling Unicode can
+  be useful when porting to platforms that don't support UTF-8 encoding (e.g.
+  embedded). When Unicode is not supported, the <format> header will use a
+  different width estimation algorithm. Instead of using Unicode based
+  estimations it will assume every input character will result in one output
+  character with a width of one column." ON)
 option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS
   "Whether to turn on vendor availability annotations on declarations that depend
    on definitions in a shared library. By default, we assume that we're not building
@@ -887,6 +894,7 @@
 config_define_if_not(LIBCXX_ENABLE_FILESYSTEM _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
 config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE)
 config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION)
+config_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE)
 config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
 # Incomplete features get their own specific disabling flags. This makes it
 # easier to grep for target specific flags once the feature is complete.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103379.363540.patch
Type: text/x-patch
Size: 4354 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210802/3748fd90/attachment.bin>


More information about the libcxx-commits mailing list