Skip to content

Commit

Permalink
build: fix codegen errors when using static linkage
Browse files Browse the repository at this point in the history
Commit 1670a89 upgraded cmake from 3.2 to 3.6, and in the process, broke all
statically linked codegen-dependent Kudu executables. When run, they
produced errors like the following:

  LLVM ERROR: Program used external function '_ZN4kudu9ArenaBaseILb0EE21AllocateBytesFallbackEmm' which could not be resolved!

The release notes revealed the culprit: CMP0065[1]. This policy change
removed -rdynamic from every Kudu executable's link line, which had the side
effect of breaking codegen. I don't know why we need -rdynamic, but I
verified that restoring it manually (and using this patch to restore it) fix
the tests. I went digging for better solutions and saw that maybe we should
call ExecutionEngine::addGlobalMapping() on our created functions[2][3], but
after looking at the hairy mess that is JITWrapper, I decided to punt.

This wasn't caught in precommit tests because gerrit uses distributed
testing, which means release builds are dynamically linked to reduce
executable disk space consumption.

1. https://cmake.org/cmake/help/v3.4/policy/CMP0065.html
2. http://stackoverflow.com/questions/4425797/linking-llvm-jit-code-to-external-c-functions
3. https://llvm.org/bugs/show_bug.cgi?id=20656

Change-Id: Ie803b93cfd9b5bed56ece5f24b769850b7b55b74
Reviewed-on: http://gerrit.cloudera.org:8080/4540
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <[email protected]>
  • Loading branch information
adembo authored and alexeyserbin committed Sep 27, 2016
1 parent 1f40913 commit 9b9188b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ set(BUILD_SUPPORT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build-support)
# Must be declared in the top-level CMakeLists.txt.
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)

# Codegen-dependent executables need to be linked with -rdynamic; otherwise LLVM
# can't find dependent Kudu symbols at runtime.
#
# Setting the ENABLE_EXPORTS target property for each codegen-dependent
# executable is more precise, but that's a rather long target list, so we'll
# just do it once here for all Kudu executables.
set(CMAKE_ENABLE_EXPORTS true)

# Make sure thirdparty stuff is up-to-date.
if ("$ENV{NO_REBUILD_THIRDPARTY}" STREQUAL "")
execute_process(
Expand Down

0 comments on commit 9b9188b

Please sign in to comment.