Skip to content

[runtimes] Simplify testing configurations on GCC by using -nostdlib++ #67021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Sep 21, 2023

Since GCC now supports -nostdlib++, we can remove some complexity in the test configurations and do the same as Clang. However, we can't fully remove the GCC test configuration for libc++ because we apparently need to explicitly link against libm for some tests to work.

Since GCC now supports -nostdlib++, we can remove some complexity in
the test configurations and do the same as Clang. However, we can't
fully remove the GCC test configuration for libc++ because we apparently
need to explicitly link against libm for some tests to work.
@ldionne ldionne requested review from a team as code owners September 21, 2023 14:38
@llvmbot llvmbot added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libc++abi libc++abi C++ Runtime Library. Not libc++. labels Sep 21, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 21, 2023

@llvm/pr-subscribers-libcxxabi

@llvm/pr-subscribers-libcxx

Changes

Since GCC now supports -nostdlib++, we can remove some complexity in the test configurations and do the same as Clang. However, we can't fully remove the GCC test configuration for libc++ because we apparently need to explicitly link against libm for some tests to work.


Full diff: https://github.com/llvm/llvm-project/pull/67021.diff

3 Files Affected:

  • (modified) libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in (+2-2)
  • (modified) libcxxabi/CMakeLists.txt (+1-3)
  • (removed) libcxxabi/test/configs/llvm-libc++abi-shared-gcc.cfg.in (-26)
diff --git a/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in b/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in
index df4aaa311dc49ca..a75e90b198896de 100644
--- a/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in
@@ -1,6 +1,6 @@
 # This testing configuration handles running the test suite against LLVM's libc++
 # using a shared library, with GCC. This is done differently from Clang because
-# GCC does not support the -nostdlib++ command-line flag.
+# we need to explicitly link against libm for some tests with GCC.
 
 lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
 
@@ -9,7 +9,7 @@ config.substitutions.append(('%{compile_flags}',
     '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support'
 ))
 config.substitutions.append(('%{link_flags}',
-    '-L %{lib} -Wl,-rpath,%{lib} -nodefaultlibs -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc -latomic'
+    '-nostdlib++ -L %{lib} -Wl,-rpath,%{lib} -lc++ -lm'
 ))
 config.substitutions.append(('%{exec}',
     '%{executor} --execdir %T -- '
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index f380fe6b6b92ec8..6fd4f02c750f5bb 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -144,9 +144,7 @@ endif()
 option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
   "Do not export any symbols from the static library." ${LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT})
 
-if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
-  set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-shared-gcc.cfg.in")
-elseif(MINGW)
+if(MINGW)
   set(LIBCXXABI_DEFAULT_TEST_CONFIG "llvm-libc++abi-mingw.cfg.in")
 elseif(WIN32) # clang-cl
   if (LIBCXXABI_ENABLE_SHARED)
diff --git a/libcxxabi/test/configs/llvm-libc++abi-shared-gcc.cfg.in b/libcxxabi/test/configs/llvm-libc++abi-shared-gcc.cfg.in
deleted file mode 100644
index c61654becdbc757..000000000000000
--- a/libcxxabi/test/configs/llvm-libc++abi-shared-gcc.cfg.in
+++ /dev/null
@@ -1,26 +0,0 @@
-# This testing configuration handles running the test suite against LLVM's libc++abi
-# using a shared library, with GCC. This is done differently from Clang because
-# GCC does not support the -nostdlib++ command-line flag.
-
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
-config.substitutions.append(('%{flags}', ''))
-config.substitutions.append(('%{compile_flags}',
-    '-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
-))
-config.substitutions.append(('%{link_flags}',
-    '-L %{lib} -Wl,-rpath,%{lib} -nodefaultlibs -lc++ -lc++abi -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc -latomic'
-))
-config.substitutions.append(('%{exec}',
-    '%{executor} --execdir %T -- '
-))
-
-import os, site
-site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
-import libcxx.test.params, libcxx.test.config
-libcxx.test.config.configure(
-    libcxx.test.params.DEFAULT_PARAMETERS,
-    libcxx.test.features.DEFAULT_FEATURES,
-    config,
-    lit_config
-)

@ldionne ldionne merged commit d217aeb into llvm:main Sep 21, 2023
@ldionne ldionne deleted the review/simplify-gcc-flags branch September 21, 2023 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++abi libc++abi C++ Runtime Library. Not libc++. libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants