diff -up a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt 2023-05-18 22:27:12.636576430 +0200 +++ b/CMakeLists.txt 2023-05-18 22:27:22.037665476 +0200 @@ -142,7 +142,7 @@ endif() # (or -nodefaultlibs). llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG) -if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) +if (CXX_SUPPORTS_NOSTDLIBXX_FLAG AND (NOT "${CMAKE_C_COMPILER}" MATCHES ".*gcc")) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") endif() check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG) if (CXX_SUPPORTS_NOSTDINCXX_FLAG)