Skip to content

Commit

Permalink
[CMake] Add compile-time check that libtvm_runtime.so has no undefine…
Browse files Browse the repository at this point in the history
…d symbols.

If libtvm_runtime.so erroneously requires definitions that are only
present in libtvm.so, the -Wl,-z,defs flag forces them to be
compile-time errors rather than runtime, and would be caught by the
CI.
  • Loading branch information
Lunderberg committed Jun 2, 2021
1 parent 0c83fe8 commit 599cc0e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ else(MSVC)
set(CMAKE_CXX_FLAGS "-faligned-new ${CMAKE_CXX_FLAGS}")
endif()

# ld option to warn if symbols are undefined (e.g. libtvm_runtime.so
# using symbols only present in libtvm.so). Not needed for MSVC,
# since this is already the default there.
if(CMAKE_SYSTEM_NAME EQUAL "Darwin")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined,error ${CMAKE_SHARED_LINKER_FLAGS}")
else()
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
endif()

# Detect if we're compiling for Hexagon.
set(TEST_FOR_HEXAGON_CXX
"#ifndef __hexagon__"
Expand Down

0 comments on commit 599cc0e

Please sign in to comment.