Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion llvm/cmake/modules/HandleLLVMStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# if the user has requested it.

include(DetermineGCCCompatible)
include(CheckIncludeFiles)

if(NOT DEFINED LLVM_STDLIB_HANDLED)
set(LLVM_STDLIB_HANDLED ON)
Expand All @@ -19,7 +20,11 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -stdlib=libc++")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is processed in the runtimes cmake sub-command, CMAKE_REQUIRED_FLAGS contains -nostdinc++. You could fix this with:

string(REPLACE "-nostdinc++" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")

Which makes the PR work for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw your updated PR; I think we do need to still inherit CMAKE_REQUIRED_FLAGS, for cases where the path to the c++ lib is being added as a flag etc. We just need to specifically remove -nostdinc++.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, never mind, that's not how CMAKE_REQUIRED_FLAGS works :). It will still be populated with CMAKE_CXX_FLAGS here. I think what you have now is fine.

check_include_files("chrono" CXX_COMPILER_SUPPORTS_STDLIB_CHRONO LANGUAGE CXX)
cmake_pop_check_state()
if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB AND CXX_COMPILER_SUPPORTS_STDLIB_CHRONO)
append("-stdlib=libc++"
CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS)
Expand Down
2 changes: 2 additions & 0 deletions llvm/cmake/modules/LLVMConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ endif()

set(LLVM_ENABLE_RTTI @LLVM_ENABLE_RTTI@)

set(LLVM_ENABLE_LIBCXX @LLVM_ENABLE_LIBCXX@)

set(LLVM_ENABLE_LIBEDIT @HAVE_LIBEDIT@)
if(LLVM_ENABLE_LIBEDIT)
find_package(LibEdit)
Expand Down