Skip to content

Commit

Permalink
fix lua compilation issue with latest clang/llvm 7.0
Browse files Browse the repository at this point in the history
Commit 46ebd9e ("fix compilation with latest clang/llvm 7.0")
tried to fix a compilation introduced with latest clang change.
It did not fix the lua compilation issue since unfortunately
my bcc environment did not have lua setup properly for that commit.

This commit intends to fix for lua compilation issue as well.
The intermediate static library bcc-lua-static is removed and
now bcc-lua-static is just a list of static libraries used
for final linking to produce bcc-lua. This way, we do not
need the special linker flags like -Wl,--whole-archive and
-Wl,--no-whole-archive. The bcc-static and bcc-shared libraries
did not change since they will be installed and may be used
by the application.

Tested on FC27 based system, with the workaround in issue iovisor#1685,
all tests passed.

Fixes: 46ebd9e ("fix compilation with latest clang/llvm 7.0")
Signed-off-by: Yonghong Song <[email protected]>
  • Loading branch information
yonghong-song committed May 1, 2018
1 parent aa1201a commit eb88b35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/cc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ target_link_libraries(bcc-loader-static elf)
add_library(bcc-static STATIC
${bcc_common_sources} ${bcc_table_sources} ${bcc_util_sources})
set_target_properties(bcc-static PROPERTIES OUTPUT_NAME bcc)
add_library(bcc-lua-static STATIC
set(bcc-lua-static
${bcc_common_sources} ${bcc_table_sources} ${bcc_sym_sources} ${bcc_util_sources})

include(clang_libs)
Expand All @@ -64,9 +64,9 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${llvm_lib_exclude_f
set(bcc_common_libs_for_a b_frontend clang_frontend bpf-static
-Wl,--whole-archive ${clang_libs} ${llvm_libs} -Wl,--no-whole-archive
${LIBELF_LIBRARIES})
set(bcc_common_libs_for_s b_frontend clang_frontend bpf-static
set(bcc_common_libs_for_s ${bcc_common_libs_for_a})
set(bcc_common_libs_for_lua b_frontend clang_frontend bpf-static
${clang_libs} ${llvm_libs} ${LIBELF_LIBRARIES})
set(bcc_common_libs_for_lua ${bcc_common_libs_for_s})

if(ENABLE_CPP_API)
add_subdirectory(api)
Expand All @@ -87,7 +87,7 @@ add_subdirectory(frontends)
# Link against LLVM libraries
target_link_libraries(bcc-shared ${bcc_common_libs_for_s})
target_link_libraries(bcc-static ${bcc_common_libs_for_a} bcc-loader-static)
target_link_libraries(bcc-lua-static ${bcc_common_libs_for_lua})
set(bcc-lua-static ${bcc-lua-static} ${bcc_common_libs_for_lua})

install(TARGETS bcc-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${bcc_table_headers} DESTINATION include/bcc)
Expand Down
2 changes: 1 addition & 1 deletion src/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (LUAJIT_LIBRARIES AND LUAJIT)
add_executable(bcc-lua src/main.c bcc.o)
set_target_properties(bcc-lua PROPERTIES LINKER_LANGUAGE C)
target_link_libraries(bcc-lua ${LUAJIT_LIBRARIES})
target_link_libraries(bcc-lua -Wl,--whole-archive bcc-lua-static -Wl,--no-whole-archive)
target_link_libraries(bcc-lua ${bcc-lua-static})
if (NOT COMPILER_NOPIE_FLAG EQUAL "")
target_link_libraries(bcc-lua ${COMPILER_NOPIE_FLAG})
endif()
Expand Down

0 comments on commit eb88b35

Please sign in to comment.