[libcxx-commits] [libcxx] 9853e9b - [libcxx] [test] Deduplicate setting parameters for clangcl test configs. NFC.

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 4 05:55:32 PDT 2023


Author: Martin Storsjö
Date: 2023-08-04T15:53:18+03:00
New Revision: 9853e9b85971335ad605b86be45aafee4f7a3573

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

LOG: [libcxx] [test] Deduplicate setting parameters for clangcl test configs. NFC.

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

Added: 
    

Modified: 
    libcxx/test/CMakeLists.txt
    libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
    libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
    libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in

Removed: 
    


################################################################################
diff  --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 54cc485470a510..17c8952acbb127 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -46,6 +46,30 @@ if (NOT DEFINED LIBCXX_TEST_DEPS)
   message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
 endif()
 
+if (MSVC)
+  # Shared code for initializing some parameters used by all
+  # llvm-libc++-*-clangcl.cfg.in test configs.
+  set(dbg_include "")
+
+  if (NOT CMAKE_MSVC_RUNTIME_LIBRARY OR CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$")
+    set(crt_lib "msvcrt")
+    set(cxx_lib "msvcprt")
+  else()
+    set(crt_lib "libcmt")
+    set(cxx_lib "libcpmt")
+  endif()
+
+  if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+    set(dbg_include " -D_DEBUG -include set_windows_crt_report_mode.h")
+    set(crt_lib "${crt_lib}d")
+    set(cxx_lib "${cxx_lib}d")
+  endif()
+
+  serialize_lit_param(dbg_include "\"${dbg_include}\"")
+  serialize_lit_param(crt_lib "\"${crt_lib}\"")
+  serialize_lit_param(cxx_lib "\"${cxx_lib}\"")
+endif()
+
 if (LIBCXX_INCLUDE_TESTS)
   include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
 

diff  --git a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
index 0d46425734ffe8..bd8cd8e60eb261 100644
--- a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
@@ -3,27 +3,12 @@
 
 lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
 
-dbg_include = ''
-runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@'
-
-if runtime_library == '' or runtime_library.endswith('DLL'):
-    crt_lib = 'msvcrt'
-    cxx_lib = 'msvcprt'
-else:
-    crt_lib = 'libcmt'
-    cxx_lib = 'libcpmt'
-
-if '@uppercase_CMAKE_BUILD_TYPE@' == 'DEBUG':
-    dbg_include = ' -D_DEBUG -include set_windows_crt_report_mode.h'
-    crt_lib += 'd'
-    cxx_lib += 'd'
-
 config.substitutions.append(('%{flags}', '--driver-mode=g++'))
 config.substitutions.append(('%{compile_flags}',
-    '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + dbg_include
+    '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include
 ))
 config.substitutions.append(('%{link_flags}',
-    '-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (crt_lib, cxx_lib)
+    '-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib)
 ))
 config.substitutions.append(('%{exec}',
     '%{executor} --execdir %T --prepend_env PATH=%{lib} -- '

diff  --git a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
index de0c4ed1b59522..921ce05f692f7a 100644
--- a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
@@ -4,27 +4,12 @@
 
 lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
 
-dbg_include = ''
-runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@'
-
-if runtime_library == '' or runtime_library.endswith('DLL'):
-    crt_lib = 'msvcrt'
-    cxx_lib = 'msvcprt'
-else:
-    crt_lib = 'libcmt'
-    cxx_lib = 'libcpmt'
-
-if '@uppercase_CMAKE_BUILD_TYPE@' == 'DEBUG':
-    dbg_include = ' -D_DEBUG -include set_windows_crt_report_mode.h'
-    crt_lib += 'd'
-    cxx_lib += 'd'
-
 config.substitutions.append(('%{flags}', '--driver-mode=g++'))
 config.substitutions.append(('%{compile_flags}',
-    '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -D_HAS_EXCEPTIONS=0' + dbg_include
+    '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -D_HAS_EXCEPTIONS=0' + config.dbg_include
 ))
 config.substitutions.append(('%{link_flags}',
-    '-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (crt_lib, cxx_lib)
+    '-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib)
 ))
 config.substitutions.append(('%{exec}',
     '%{executor} --execdir %T --prepend_env PATH=%{lib} -- '

diff  --git a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
index e8b9c035b306d9..bd504df7470a17 100644
--- a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
@@ -3,27 +3,12 @@
 
 lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
 
-dbg_include = ''
-runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@'
-
-if runtime_library == '' or runtime_library.endswith('DLL'):
-    crt_lib = 'msvcrt'
-    cxx_lib = 'msvcprt'
-else:
-    crt_lib = 'libcmt'
-    cxx_lib = 'libcpmt'
-
-if '@uppercase_CMAKE_BUILD_TYPE@' == 'DEBUG':
-    dbg_include = ' -D_DEBUG -include set_windows_crt_report_mode.h'
-    crt_lib += 'd'
-    cxx_lib += 'd'
-
 config.substitutions.append(('%{flags}', '--driver-mode=g++'))
 config.substitutions.append(('%{compile_flags}',
-    '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + dbg_include
+    '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include
 ))
 config.substitutions.append(('%{link_flags}',
-    '-nostdlib -L %%{lib} -llibc++ -l%s -l%s -loldnames' % (crt_lib, cxx_lib)
+    '-nostdlib -L %%{lib} -llibc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib)
 ))
 config.substitutions.append(('%{exec}',
     '%{executor} --execdir %T -- '


        


More information about the libcxx-commits mailing list