[libcxx-commits] [libcxx] 27546a6 - [libcxx] [test] Use -fms-runtime-lib= for picking the CRT to use
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 27 03:53:44 PDT 2023
Author: Martin Storsjö
Date: 2023-09-27T13:52:13+03:00
New Revision: 27546a65d49a21e99038841d47ee7f6ad0e87dd5
URL: https://github.com/llvm/llvm-project/commit/27546a65d49a21e99038841d47ee7f6ad0e87dd5
DIFF: https://github.com/llvm/llvm-project/commit/27546a65d49a21e99038841d47ee7f6ad0e87dd5.diff
LOG: [libcxx] [test] Use -fms-runtime-lib= for picking the CRT to use
This is a more correct way of linking against a specific runtime
library with the GCC-like clang frontend.
This avoids having to pass -D_DEBUG (and passes flags like -D_DLL,
which we should be passing if linking against the dynamic CRT).
When -fms-runtime-lib= is specified, each compiled object file gets
embedded directives instructing the linker about what CRT it should
link against. The -nostdlib we pass to the compiler driver only
inhibits the libs that the compiler driver passes to the linker
command.
Thus, this also avoids having to specify -lmsvcrt, -lmsvcrtd,
-llibcmt or -llibcmtd, and -loldnames.
Based on a patch by Andrew Ng.
The -fms-runtime-lib= option was added in Clang 16, but libcxx
now has dropped support for Clang 15.
Differential Revision: https://reviews.llvm.org/D155562
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 fd194a36a28fc26..0d5fa6959f17881 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -54,22 +54,22 @@ if (MSVC)
set(dbg_include "")
if (NOT CMAKE_MSVC_RUNTIME_LIBRARY OR CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$")
- set(crt_lib "msvcrt")
+ set(fms_runtime_lib "dll")
set(cxx_lib "msvcprt")
else()
- set(crt_lib "libcmt")
+ set(fms_runtime_lib "static")
set(cxx_lib "libcpmt")
endif()
if ((NOT CMAKE_MSVC_RUNTIME_LIBRARY AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
OR (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug"))
- set(dbg_include " -D_DEBUG -include set_windows_crt_report_mode.h")
- set(crt_lib "${crt_lib}d")
+ set(dbg_include " -include set_windows_crt_report_mode.h")
+ set(fms_runtime_lib "${fms_runtime_lib}_dbg")
set(cxx_lib "${cxx_lib}d")
endif()
serialize_lit_param(dbg_include "\"${dbg_include}\"")
- serialize_lit_param(crt_lib "\"${crt_lib}\"")
+ serialize_lit_param(fms_runtime_lib "\"${fms_runtime_lib}\"")
serialize_lit_param(cxx_lib "\"${cxx_lib}\"")
endif()
diff --git a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
index bd8cd8e60eb2614..50d28eb67c77b78 100644
--- a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
@@ -5,10 +5,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
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' + config.dbg_include
+ '-fms-runtime-lib=' + config.fms_runtime_lib + ' -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' % (config.crt_lib, config.cxx_lib)
+ '-nostdlib -L %{lib} -lc++ -l' + 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 921ce05f692f7aa..4c88af3dbb6ebe0 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
@@ -6,10 +6,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
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' + config.dbg_include
+ '-fms-runtime-lib=' + config.fms_runtime_lib + ' -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' % (config.crt_lib, config.cxx_lib)
+ '-nostdlib -L %{lib} -lc++ -l' + 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 bd504df7470a178..4baaad765a92d38 100644
--- a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
@@ -5,10 +5,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
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' + config.dbg_include
+ '-fms-runtime-lib=' + config.fms_runtime_lib + ' -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' % (config.crt_lib, config.cxx_lib)
+ '-nostdlib -L %{lib} -llibc++ -l' + config.cxx_lib
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T -- '
More information about the libcxx-commits
mailing list