Skip to content

Commit f55fd19

Browse files
Define/guard MLIR_STANDALONE_BUILD LLVM_LIBRARY_OUTPUT_INTDIR var.
It looks like MLIR is using the more modern CMAKE_LIBRARY_OUTPUT_DIRECTORY, but AddLLVM still uses this older LLVM specific alias. In the specific case I was running into, the empty variable was causing `-Wl,-rpath-link,` on the command line, causing the following argument to be swallowed. This was maddening, because the following argument was the .o file containing `main` and I was getting `main` undefined errors when it was clearly there. This is egregious enough that I chose to guard it. Differential Revision: https://reviews.llvm.org/D153373
1 parent 7ab749c commit f55fd19

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,9 @@ function(llvm_setup_rpath name)
23582358
endif()
23592359
if(LLVM_LINKER_IS_GNULD)
23602360
# $ORIGIN is not interpreted at link time by ld.bfd
2361+
if(NOT LLVM_LIBRARY_OUTPUT_INTDIR)
2362+
message(SEND_ERROR "Project does not define LLVM_LIBRARY_OUTPUT_INTDIR and it is required")
2363+
endif()
23612364
set_property(TARGET ${name} APPEND_STRING PROPERTY
23622365
LINK_FLAGS " -Wl,-rpath-link,${LLVM_LIBRARY_OUTPUT_INTDIR} ")
23632366
endif()

mlir/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ if(MLIR_STANDALONE_BUILD)
3535
"${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
3636
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
3737

38+
# Some LLVM CMake utilities use these aliases for the CMake builtin variables.
39+
# We set them for compatibility.
40+
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
41+
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
42+
3843
set(LLVM_LIT_ARGS "-sv" CACHE STRING "Default options for lit")
3944
endif()
4045

0 commit comments

Comments
 (0)