All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH pahole] libbpf: build as PIC and statically link into libdwarves
@ 2019-02-19  3:02 Andrii Nakryiko
  2019-02-19  3:04 ` Andrii Nakryiko
  0 siblings, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2019-02-19  3:02 UTC (permalink / raw)
  To: acme, ast, dwarves, bpf, yst, arnaldo.melo, Kernel-team, jolsa,
	namhyung, wangnan0, andrii.nakryiko
  Cc: Andrii Nakryiko

As libbpf is not yet widely available, it's safer to statically link it
into libdwarves for now. Easiest way to define that in cmake is through
OBJECT library with PIC.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 CMakeLists.txt | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d6929b4..e0fdaf7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
 project(pahole C)
-cmake_minimum_required(VERSION 2.4.8)
+cmake_minimum_required(VERSION 2.8.8)
 cmake_policy(SET CMP0005 NEW)
 
 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
@@ -72,24 +72,19 @@ if (NOT HAVE_REALLOCARRAY_SUPPORT)
 endif()
 
 file(GLOB libbpf_sources "lib/bpf/src/*.c")
-add_library(bpf-static STATIC ${libbpf_sources})
-set_target_properties(bpf-static PROPERTIES OUTPUT_NAME bpf)
-target_include_directories(bpf-static PRIVATE
-			   ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include
-			   ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi)
-add_library(bpf-shared SHARED ${libbpf_sources})
-set_target_properties(bpf-shared PROPERTIES OUTPUT_NAME bpf)
-target_include_directories(bpf-shared PRIVATE
+add_library(bpf OBJECT ${libbpf_sources})
+set_property(TARGET bpf PROPERTY POSITION_INDEPENDENT_CODE 1)
+target_include_directories(bpf PRIVATE
 			   ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include
 			   ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi)
 
 set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer strings
 		     ctf_encoder.c ctf_loader.c libctf.c btf_encoder.c btf_loader.c libbtf.c
 		     dwarf_loader.c dutil.c elf_symtab.c rbtree.c)
-add_library(dwarves SHARED ${dwarves_LIB_SRCS})
+add_library(dwarves SHARED ${dwarves_LIB_SRCS} $<TARGET_OBJECTS:bpf>)
 set_target_properties(dwarves PROPERTIES VERSION 1.0.0 SOVERSION 1)
 set_target_properties(dwarves PROPERTIES INTERFACE_LINK_LIBRARIES "")
-target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES} bpf-shared)
+target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES})
 
 set(dwarves_emit_LIB_SRCS dwarves_emit.c)
 add_library(dwarves_emit SHARED ${dwarves_emit_LIB_SRCS})
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-19 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-19  3:02 [PATCH pahole] libbpf: build as PIC and statically link into libdwarves Andrii Nakryiko
2019-02-19  3:04 ` Andrii Nakryiko
2019-02-19 13:16   ` Arnaldo Carvalho de Melo
2019-02-19 18:22     ` Andrii Nakryiko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.