Skip to content

Commit

Permalink
Reorder CMakeLists such that LDC_ENABLE_PLUGINS is available when add…
Browse files Browse the repository at this point in the history
…ing -fvisibility-inlines-hidden
  • Loading branch information
JohanEngelen committed Jul 19, 2023
1 parent fde0bf8 commit 4256475
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"))
endif()
endif()

if(NOT WIN32 AND NOT CYGWIN)
# Unify symbol visibility with LLVM to silence linker warning "direct access in function X to global
# weak symbol Y means the weak symbol cannot be overridden at runtime. This was likely caused by
# different translation units being compiled with different visibility settings."
# See LLVM's cmake/modules/HandleLLVMOptions.cmake.
# For plugins, we shouldn't apply this flag because it hides the inline methods of e.g. Visitor.
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
if (${SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG} AND NOT LDC_ENABLE_PLUGINS)
append("-fvisibility-inlines-hidden" LDC_CXXFLAGS)
endif()
endif()

if(MSVC)
# Remove flags here, for exceptions and RTTI.
# CL.EXE complains to override flags like "/GR /GR-".
Expand Down Expand Up @@ -692,6 +680,18 @@ endif()
message(STATUS "-- Building LDC with plugin support (LDC_ENABLE_PLUGINS): ${LDC_ENABLE_PLUGINS}")
message(STATUS "-- Linking LDC with flags: ${ALTERNATIVE_MALLOC_O};${LDC_LINKERFLAG_LIST}")

if(NOT WIN32 AND NOT CYGWIN)
# Unify symbol visibility with LLVM to silence linker warning "direct access in function X to global
# weak symbol Y means the weak symbol cannot be overridden at runtime. This was likely caused by
# different translation units being compiled with different visibility settings."
# See LLVM's cmake/modules/HandleLLVMOptions.cmake.
# For plugins, we shouldn't apply this flag because it hides the inline methods of e.g. Visitor.
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
if (${SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG} AND NOT LDC_ENABLE_PLUGINS)
append("-fvisibility-inlines-hidden" LDC_CXXFLAGS)
endif()
endif()

build_d_executable(
"${LDC_EXE}"
"${LDC_EXE_FULL}"
Expand Down

0 comments on commit 4256475

Please sign in to comment.