Skip to content

[BUILD] Hide symbols from linked static libraries#627

Merged
tqchen merged 1 commit into
apache:mainfrom
tqchen:tvm-ffi-hide-libstdc-nonshared-symbols-in-libtvm-ffi-so
Jun 17, 2026
Merged

[BUILD] Hide symbols from linked static libraries#627
tqchen merged 1 commit into
apache:mainfrom
tqchen:tvm-ffi-hide-libstdc-nonshared-symbols-in-libtvm-ffi-so

Conversation

@tqchen

@tqchen tqchen commented Jun 17, 2026

Copy link
Copy Markdown
Member

To avoid downstream mistakenly picking up symbols from static libstdc++_nonshared, always hide symbols from static libraries linked into tvm-ffi shared objects.

This adds a CMake helper for the policy and applies it to tvm_ffi_shared, tvm_ffi_testing, and the optional tvm_ffi_cython target on ELF platforms.

Local validation:

  • Configured and built tvm_ffi_shared and tvm_ffi_testing with TVM_FFI_USE_LIBBACKTRACE=OFF.
  • Verified generated Ninja link flags include -Wl,--exclude-libs,ALL for libtvm_ffi.so and libtvm_ffi_testing.so.

@tqchen tqchen changed the title Hide symbols from linked static libraries [BUILD] Hide symbols from linked static libraries Jun 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a new CMake function, tvm_ffi_hide_static_linked_lib_symbols, to prevent symbols from static archives linked into shared libraries from being exported on ELF targets. This function is applied to the tvm_ffi_shared, tvm_ffi_testing, and tvm_ffi_cython targets. Feedback suggests restricting the compiler option -Wl,--exclude-libs,ALL to specific operating systems (such as Linux, Android, and BSDs) using CMAKE_SYSTEM_NAME to prevent build failures on non-ELF UNIX platforms (like Solaris or AIX) that use native system linkers.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread cmake/Utils/Library.cmake Outdated
To avoid downstream mistakenly picking up symbols from static libstdc++_nonshared, it is helpful to always hide symbols from linked static libraries.
@tqchen tqchen force-pushed the tvm-ffi-hide-libstdc-nonshared-symbols-in-libtvm-ffi-so branch from c13d31f to a4020c4 Compare June 17, 2026 15:31
@tqchen tqchen merged commit e3bcb8d into apache:main Jun 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants