Skip to content
Draft
Changes from 5 commits
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
16 changes: 16 additions & 0 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,12 @@ macro(build_substrait)

add_library(substrait STATIC ${SUBSTRAIT_SOURCES})
set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this condition? (Can we always set CXX_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN?)

# Match Protobuf's visibility so duplicate inline definitions can't be
# selected with different visibility when linking a side module (GH-50774)
set_target_properties(substrait PROPERTIES CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON)
endif()
target_compile_options(substrait PRIVATE "${SUBSTRAIT_SUPPRESSED_FLAGS}")
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
target_link_libraries(substrait PUBLIC ${ARROW_PROTOBUF_LIBPROTOBUF})
Expand Down Expand Up @@ -3888,6 +3894,12 @@ function(build_orc)

fetchcontent_makeavailable(orc)

if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
# ORC compiles generated Protobuf code into its static library
set_target_properties(orc PROPERTIES CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON)
endif()

# ORC 2.2.1 unconditionally adds /std:c++17 on MSVC via
# add_compile_options, which overrides CMAKE_CXX_STANDARD and causes
# ABI mismatches with protobuf (GlobalEmptyStringConstexpr vs
Expand Down Expand Up @@ -3980,6 +3992,10 @@ function(build_orc)
"-DZLIB_HOME=${ORC_ZLIB_ROOT}"
"-DZLIB_INCLUDE_DIR=$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_INCLUDE_DIRECTORIES>"
"-DZLIB_LIBRARY=$<TARGET_FILE:ZLIB::ZLIB>")
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
list(APPEND ORC_CMAKE_ARGS -DCMAKE_CXX_VISIBILITY_PRESET=hidden
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON)
endif()

# Work around CMake bug
file(MAKE_DIRECTORY ${ORC_INCLUDE_DIR})
Expand Down
Loading