gemini-code-assist[bot] commented on code in PR #19817:
URL: https://github.com/apache/tvm/pull/19817#discussion_r3429792804


##########
cmake/utils/Library.cmake:
##########
@@ -17,6 +17,17 @@
 
 # Helpers for configuring library targets.
 
+# Hide symbols from static archives linked into a shared library. This prevents
+# downstream libraries from accidentally binding to private archive symbols 
such
+# as those from libstdc++_nonshared.a.
+function(tvm_hide_static_linked_lib_symbols target_name)
+  if(CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD|OpenBSD" AND 
CMAKE_CXX_COMPILER_ID
+                                                                         
MATCHES "GNU|Clang"
+  )
+    target_link_options(${target_name} PRIVATE "-Wl,--exclude-libs,ALL")
+  endif()
+endfunction()

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   The new helper function `tvm_hide_static_linked_lib_symbols` unconditionally 
applies `-Wl,--exclude-libs,ALL` on matching platforms and compilers, ignoring 
the user-configurable option `HIDE_PRIVATE_SYMBOLS` (defined in 
`CMakeLists.txt` line 79).
   
   To respect the user's configuration (e.g., when they explicitly want to keep 
private symbols visible for debugging or other purposes), we should check 
`HIDE_PRIVATE_SYMBOLS` before applying the linker option.
   
   Additionally, since this is now handled automatically by 
`tvm_configure_target_library` for all shared and module libraries, you should 
clean up the redundant manual application of `-Wl,--exclude-libs,ALL` to 
`tvm_compiler` and `tvm_runtime` in `CMakeLists.txt` (lines 687-694) to avoid 
adding the flag twice.
   
   ```
   function(tvm_hide_static_linked_lib_symbols target_name)
     if(HIDE_PRIVATE_SYMBOLS AND CMAKE_SYSTEM_NAME MATCHES 
"Linux|Android|FreeBSD|NetBSD|OpenBSD" AND CMAKE_CXX_COMPILER_ID MATCHES 
"GNU|Clang")
       target_link_options(${target_name} PRIVATE "-Wl,--exclude-libs,ALL")
     endif()
   endfunction()
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to