From 84be76133282f8bd66820ca93402a741c0ee632e Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Thu, 7 Jun 2018 19:57:43 +0000 Subject: [PATCH] [CMake] Fix Libc++ Modules build. When building the dylib, the C++ headers are fundamentally non-module. They require special versions of the headers in order to provide C++03 and legacy ABI definitions. This causes ODR issues when modules are enabled during both the build and the usage of the libc++ headers. This patch fixes the build error by disabling modules when building the libc++ sources. llvm-svn: 334220 --- compiler-rt/cmake/Modules/AddCompilerRT.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index 8338eb3406a4..380a4a372d0c 100644 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -537,6 +537,14 @@ macro(add_custom_libcxx name prefix) string(REPLACE "-Wl,-z,defs" "" LIBCXX_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") string(REPLACE "-Wl,-z,defs" "" LIBCXX_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + # The libc++ sources are fundamentally non-modular. They need special + # versions of the headers in order to provide C++03 and legacy ABI definitions. + # NOTE: The public headers can be used with modules in all other contexts + if (LLVM_ENABLE_MODULES) + set(LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS} -Wno-unused-command-line-argument") + set(LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS} -fno-modules") + endif() + ExternalProject_Add(${name} DEPENDS ${name}-clobber ${LIBCXX_DEPS} PREFIX ${prefix}