Re: [PATCH pahole] libbpf: build as PIC and statically link into libdwarves

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 19, 2019 at 5:17 AM Arnaldo Carvalho de Melo
<arnaldo.melo@xxxxxxxxx> wrote:
>
> Em Mon, Feb 18, 2019 at 07:04:17PM -0800, Andrii Nakryiko escreveu:
> > cc Yonghong (mistyped his email)
>
> Applied, but before I split it into two patches, one bumping the minimum
> required cmake version, with an explanation about why that is needed,
> then the rest of the patch, with the explanation you provided.
>
> Please try to make the patches in a granular fashion, with justification
> for each independent part,

Yep, sorry about that, will do next time.

>
> Thanks,
>
> - Arnaldo
>
> > On Mon, Feb 18, 2019 at 7:02 PM Andrii Nakryiko <andriin@xxxxxx> wrote:
> > >
> > > 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@xxxxxx>
> > > ---
> > >  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
> > >
>
> --
>
> - Arnaldo



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux