[libcxx-commits] [libcxx] df2af99 - [libc++][format] Add a CMake Unicode option.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Sep 4 02:55:19 PDT 2021


Author: Mark de Wever
Date: 2021-09-04T11:55:10+02:00
New Revision: df2af9936ca096d5bfbf3395c661c2d5a354f673

URL: https://github.com/llvm/llvm-project/commit/df2af9936ca096d5bfbf3395c661c2d5a354f673
DIFF: https://github.com/llvm/llvm-project/commit/df2af9936ca096d5bfbf3395c661c2d5a354f673.diff

LOG: [libc++][format] Add a CMake Unicode option.

This option is used to select between the format headers output column
width option. This option should be independent of the locale setting.
It's encouraged to default to Unicode unless the platform doesn't offer
that option.

[format.string.std]/10
```
  For the purposes of width computation, a string is assumed to be in a
  locale-independent, implementation-defined encoding. Implementations
  should use a Unicode encoding on platforms capable of displaying Unicode
```

Reviewed By: #libc, ldionne, vitaut

Differential Revision: https://reviews.llvm.org/D103379

Added: 
    libcxx/cmake/caches/Generic-no-unicode.cmake

Modified: 
    libcxx/CMakeLists.txt
    libcxx/docs/ReleaseNotes.rst
    libcxx/utils/ci/buildkite-pipeline.yml
    libcxx/utils/ci/run-buildbot
    libcxx/utils/libcxx/test/features.py

Removed: 
    


################################################################################
diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index c85caa52318f..492df9a08ca2 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -116,6 +116,10 @@ option(LIBCXX_ENABLE_LOCALIZATION
    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)." 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
@@ -878,6 +882,7 @@ config_define_if(LIBCXX_ENABLE_PARALLEL_ALGORITHMS _LIBCPP_HAS_PARALLEL_ALGORITH
 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.

diff  --git a/libcxx/cmake/caches/Generic-no-unicode.cmake b/libcxx/cmake/caches/Generic-no-unicode.cmake
new file mode 100644
index 000000000000..01160bf21898
--- /dev/null
+++ b/libcxx/cmake/caches/Generic-no-unicode.cmake
@@ -0,0 +1 @@
+set(LIBCXX_ENABLE_UNICODE OFF CACHE BOOL "")

diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index f8b428c3f0c0..65ef26bc82ce 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -42,6 +42,9 @@ New Features
   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
 -----------

diff  --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml
index 0216cb3e91ac..5d0a5975f424 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -382,6 +382,17 @@ steps:
           limit: 2
     timeout_in_minutes: 120
 
+  - 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:

diff  --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 0c5b17e9c52b..ba187b4da2af 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -339,6 +339,13 @@ generic-no-localization)
     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"

diff  --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index a703b0c97539..a37355c53c61 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -101,6 +101,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 += [


        


More information about the libcxx-commits mailing list