Skip to content

Commit

Permalink
fix CMakefile for lua
Browse files Browse the repository at this point in the history
Issue iovisor#1621 reported an issue where bcc-lua has an unresolved
symbol bcc_resolve_symname. This is a side effect of previous
cmake file refactorization which permits better control
over what features can be enabled during build time.
The refactorization caused some symbols in bcc_syms.cc
got lost in the final link which produced bcc-lua.

This patch fixed the issue by add a new static library target
bcc-lua-static and adds bcc_syms.cc to it when the library
is created and hence preserved the symbol.

Also removed unnecessary linking for clang_frontend library.

Signed-off-by: Yonghong Song <[email protected]>
  • Loading branch information
yonghong-song committed Mar 8, 2018
1 parent 66db879 commit 29015d7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/cc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ 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
${bcc_common_sources} ${bcc_table_sources} ${bcc_sym_sources} ${bcc_util_sources})

include(clang_libs)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${clang_lib_exclude_flags}")
Expand All @@ -62,6 +64,7 @@ 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
${clang_libs} ${llvm_libs} ${LIBELF_LIBRARIES})
set(bcc_common_libs_for_s ${bcc_common_libs_for_a})
set(bcc_common_libs_for_lua ${bcc_common_libs_for_a})

if(ENABLE_CPP_API)
add_subdirectory(api)
Expand All @@ -74,13 +77,15 @@ if(ENABLE_USDT)
add_subdirectory(usdt)
list(APPEND bcc_common_libs_for_a usdt-static)
list(APPEND bcc_common_libs_for_s usdt-static)
list(APPEND bcc_common_libs_for_lua usdt-static)
endif()

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})

install(TARGETS bcc-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${bcc_table_headers} DESTINATION include/bcc)
Expand Down
1 change: 0 additions & 1 deletion src/cc/frontends/clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ if(DEFINED BCC_BACKUP_COMPILE)
endif()

add_library(clang_frontend STATIC loader.cc b_frontend_action.cc tp_frontend_action.cc kbuild_helper.cc ../../common.cc)
target_link_libraries(clang_frontend bcc-static)
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-static -Wl,--no-whole-archive)
target_link_libraries(bcc-lua -Wl,--whole-archive bcc-lua-static -Wl,--no-whole-archive)
if (NOT COMPILER_NOPIE_FLAG EQUAL "")
target_link_libraries(bcc-lua ${COMPILER_NOPIE_FLAG})
endif()
Expand Down

0 comments on commit 29015d7

Please sign in to comment.