[libcxx-commits] [libcxx] f68e890 - [libcxx] Add LIBCXX_EXTRA_SITE_DEFINES for adding extra defines in __config_site
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Dec 21 14:43:57 PST 2021
Author: Martin Storsjö
Date: 2021-12-22T00:43:29+02:00
New Revision: f68e89044a2ee14babd1af8fc406c9bab080992a
URL: https://github.com/llvm/llvm-project/commit/f68e89044a2ee14babd1af8fc406c9bab080992a
DIFF: https://github.com/llvm/llvm-project/commit/f68e89044a2ee14babd1af8fc406c9bab080992a.diff
LOG: [libcxx] Add LIBCXX_EXTRA_SITE_DEFINES for adding extra defines in __config_site
This is similar to the existing setting LIBCXX_ABI_DEFINES, with
the difference that this also allows setting other defines than
ones that start with "_LIBCPP_ABI_", and allows setting defines
to a specific value.
This allows avoiding using LIBCXX_TEST_COMPILER_FLAGS in two
CI configurations.
Differential Revision: https://reviews.llvm.org/D116109
Added:
Modified:
libcxx/CMakeLists.txt
libcxx/cmake/caches/MinGW.cmake
libcxx/include/__config_site.in
libcxx/utils/ci/run-buildbot
Removed:
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 39744bb21559c..03a6a0781b5af 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -196,6 +196,7 @@ endif()
option(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT "Enable per TU ABI insulation by default. To be used by vendors." OFF)
set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.")
+option(LIBCXX_EXTRA_SITE_DEFINES "Extra defines to add into __config_site")
option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
set(LIBCXX_LIBCPPABI_VERSION "2" CACHE STRING "Version of libc++abi's ABI to re-export from libc++ when re-exporting is enabled.
Note that this is not related to the version of libc++'s ABI itself!")
@@ -909,6 +910,17 @@ if (LIBCXX_ABI_DEFINES)
config_define(${abi_defines} _LIBCPP_ABI_DEFINES)
endif()
+if (LIBCXX_EXTRA_SITE_DEFINES)
+ set(extra_site_defines)
+ foreach (extra_site_define ${LIBCXX_EXTRA_SITE_DEFINES})
+ # Allow defines such as DEFINE=VAL, transformed into "#define DEFINE VAL".
+ string(REPLACE "=" " " extra_site_define "${extra_site_define}")
+ list(APPEND extra_site_defines "#define ${extra_site_define}")
+ endforeach()
+ string(REPLACE ";" "\n" extra_site_defines "${extra_site_defines}")
+ config_define(${extra_site_defines} _LIBCPP_EXTRA_SITE_DEFINES)
+endif()
+
# By default libc++ on Windows expects to use a shared library, which requires
# the headers to use DLL import/export semantics. However when building a
# static library only we modify the headers to disable DLL import/export.
diff --git a/libcxx/cmake/caches/MinGW.cmake b/libcxx/cmake/caches/MinGW.cmake
index 458eb012ad154..b9ac28006eb84 100644
--- a/libcxx/cmake/caches/MinGW.cmake
+++ b/libcxx/cmake/caches/MinGW.cmake
@@ -13,8 +13,6 @@ set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
set(LIBCXX_TARGET_INFO "libcxx.test.target_info.MingwLocalTI" CACHE STRING "")
-# Without these flags, 'long double' (which is 80 bit on x86 mingw, but
+# Without this flag, 'long double' (which is 80 bit on x86 mingw, but
# 64 bit in MSVC) isn't handled correctly in printf.
-set(CMAKE_C_FLAGS "-D__USE_MINGW_ANSI_STDIO=1" CACHE STRING "")
-set(CMAKE_CXX_FLAGS "-D__USE_MINGW_ANSI_STDIO=1" CACHE STRING "")
-set(LIBCXX_TEST_COMPILER_FLAGS "-D__USE_MINGW_ANSI_STDIO=1" CACHE STRING "")
+set(LIBCXX_EXTRA_SITE_DEFINES "__USE_MINGW_ANSI_STDIO=1" CACHE STRING "")
diff --git a/libcxx/include/__config_site.in b/libcxx/include/__config_site.in
index a8b17ad72b73c..59ca229812421 100644
--- a/libcxx/include/__config_site.in
+++ b/libcxx/include/__config_site.in
@@ -35,5 +35,6 @@
#cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_RANGES
@_LIBCPP_ABI_DEFINES@
+ at _LIBCPP_EXTRA_SITE_DEFINES@
#endif // _LIBCPP_CONFIG_SITE
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 5c5b1f9648598..d1bff8e592aa7 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -108,8 +108,7 @@ function generate-cmake-libcxx-win() {
-DCMAKE_C_COMPILER=clang-cl \
-DCMAKE_CXX_COMPILER=clang-cl \
-DLIBCXX_ENABLE_FILESYSTEM=YES \
- -DCMAKE_CXX_FLAGS="-D_LIBCPP_HAS_NO_INT128" \
- -DLIBCXX_TEST_COMPILER_FLAGS="-D_LIBCPP_HAS_NO_INT128" \
+ -DLIBCXX_EXTRA_SITE_DEFINES="_LIBCPP_HAS_NO_INT128" \
"${@}"
}
More information about the libcxx-commits
mailing list