Skip to content
Closed
Changes from all 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
4 changes: 4 additions & 0 deletions .github/actions/build-wheel-for-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,13 @@ runs:
CIBW_ENVIRONMENT_MACOS: >-
CMAKE_PREFIX_PATH="/opt/llvm"
CMAKE_ARGS="-DUSE_LLVM='/opt/llvm/bin/llvm-config --link-static' -DZLIB_USE_STATIC_LIBS=ON -DCMAKE_PREFIX_PATH=/opt/llvm ${{ inputs.cmake_defines }}"
# Statically link libstdc++/libgcc on Linux: the C++20 gcc-toolset (>=12) emits
# libstdc++ symbols newer than the manylinux_2_28 runtime baseline (e.g.
# _M_replace_cold @ GLIBCXX_3.4.30), so the wheel would otherwise fail to load.
CIBW_ENVIRONMENT_LINUX: >-
CMAKE_PREFIX_PATH="/opt/llvm"
LIBRARY_PATH="/opt/llvm/lib"
LDFLAGS="-static-libstdc++ -static-libgcc"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

While adding LDFLAGS="-static-libstdc++ -static-libgcc" here statically links the C++ runtime for libtvm.so and libtvm_runtime.so built during the main wheel build, the CUDA runtime sidecar libtvm_runtime_cuda.so (specified in TVM_PACKAGE_EXTRA_LIBS) is built separately via ci/scripts/package/manylinux_build_libtvm_runtime_cuda.sh. If libtvm_runtime_cuda.so is built in a container with a newer GCC/toolset, it will still dynamically link against the newer libstdc++ and fail to load on older host environments with the same undefined symbol error. To address this, also statically link libstdc++ and libgcc when building libtvm_runtime_cuda.so by passing -DCMAKE_SHARED_LINKER_FLAGS="-static-libstdc++ -static-libgcc" to the cmake command in ci/scripts/package/manylinux_build_libtvm_runtime_cuda.sh.

CMAKE_ARGS="-DUSE_LLVM='/opt/llvm/bin/llvm-config --link-static' -DZLIB_USE_STATIC_LIBS=ON -DCMAKE_PREFIX_PATH=/opt/llvm ${{ inputs.cmake_defines }} -DTVM_PACKAGE_EXTRA_LIBS=/project/build-wheel-cuda/lib/libtvm_runtime_cuda.so"
CIBW_ENVIRONMENT_WINDOWS: >-
CMAKE_PREFIX_PATH="C:/opt/llvm/Library"
Expand Down
Loading