All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] dwarves: enable-SHARED-and-STATIC-lib-creation
@ 2021-06-02  5:56 Deepak Kumar Mishra
  2021-06-02  5:56 ` [PATCH 1/2] CMakeLists.txt: enable SHARED and STATIC lib creation Deepak Kumar Mishra
  2021-06-02  5:56 ` [PATCH 2/2] README: add documentation for -DBUILD_SHARED_LIBS Deepak Kumar Mishra
  0 siblings, 2 replies; 7+ messages in thread
From: Deepak Kumar Mishra @ 2021-06-02  5:56 UTC (permalink / raw)
  To: dwarves; +Cc: acme, qais.yousef, Deepak Kumar Mishra

CMakeLists.txt does not allow creation of static library and link applications
accordingly.

Creation of SHARED and STATIC should be allowed using -DBUILD_SHARED_LIBS

README file is also ammended to provide information regarding use of
-DBUILD_SHARED_LIBS while using cmake

Deepak Kumar Mishra (2):
  CMakeLists.txt: enable SHARED and STATIC lib creation
  README: add documentation for -DBUILD_SHARED_LIBS

 CMakeLists.txt | 10 +++++-----
 README         | 13 +++++++++++--
 2 files changed, 16 insertions(+), 7 deletions(-)

--
2.17.1


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

* [PATCH 1/2] CMakeLists.txt: enable SHARED and STATIC lib creation
  2021-06-02  5:56 [PATCH 0/2] dwarves: enable-SHARED-and-STATIC-lib-creation Deepak Kumar Mishra
@ 2021-06-02  5:56 ` Deepak Kumar Mishra
  2021-06-02  5:56 ` [PATCH 2/2] README: add documentation for -DBUILD_SHARED_LIBS Deepak Kumar Mishra
  1 sibling, 0 replies; 7+ messages in thread
From: Deepak Kumar Mishra @ 2021-06-02  5:56 UTC (permalink / raw)
  To: dwarves; +Cc: acme, qais.yousef, Deepak Kumar Mishra

CMakeLists.txt does not allow creation of static library and link applications
accordingly.

Creation of SHARED and STATIC should be allowed using -DBUILD_SHARED_LIBS

Ex:
cmake -D__LIB=lib -DBUILD_SHARED_LIBS=OFF ..
cmake -D__LIB=lib -DBUILD_SHARED_LIBS=ON ..

Signed-off-by: Deepak Kumar Mishra <deepakkumar.mishra@arm.com>
---
 CMakeLists.txt | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5aada20..bc9be63 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -91,7 +91,7 @@ target_include_directories(bpf PRIVATE
 set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer.c strings.c
 		     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} $<TARGET_OBJECTS:bpf>)
+add_library(dwarves ${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_include_directories(dwarves PRIVATE
@@ -99,12 +99,12 @@ target_include_directories(dwarves PRIVATE
 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})
+add_library(dwarves_emit ${dwarves_emit_LIB_SRCS})
 set_target_properties(dwarves_emit PROPERTIES VERSION 1.0.0 SOVERSION 1)
 target_link_libraries(dwarves_emit dwarves)
 
 set(dwarves_reorganize_LIB_SRCS dwarves_reorganize.c)
-add_library(dwarves_reorganize SHARED ${dwarves_reorganize_LIB_SRCS})
+add_library(dwarves_reorganize ${dwarves_reorganize_LIB_SRCS})
 set_target_properties(dwarves_reorganize PROPERTIES VERSION 1.0.0 SOVERSION 1)
 target_link_libraries(dwarves_reorganize dwarves)
 
@@ -151,8 +151,8 @@ target_link_libraries(syscse dwarves)
 install(TARGETS codiff ctracer dtagnames pahole pdwtags
 		pfunct pglobal prefcnt scncopy syscse RUNTIME DESTINATION
 		${CMAKE_INSTALL_PREFIX}/bin)
-install(TARGETS dwarves LIBRARY DESTINATION ${LIB_INSTALL_DIR})
-install(TARGETS dwarves dwarves_emit dwarves_reorganize LIBRARY DESTINATION ${LIB_INSTALL_DIR})
+install(TARGETS dwarves LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
+install(TARGETS dwarves dwarves_emit dwarves_reorganize LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
 install(FILES dwarves.h dwarves_emit.h dwarves_reorganize.h
 	      dutil.h gobuffer.h list.h rbtree.h pahole_strings.h
 	      btf_encoder.h config.h ctf_encoder.h ctf.h
-- 
2.17.1


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

* [PATCH 2/2] README: add documentation for -DBUILD_SHARED_LIBS
  2021-06-02  5:56 [PATCH 0/2] dwarves: enable-SHARED-and-STATIC-lib-creation Deepak Kumar Mishra
  2021-06-02  5:56 ` [PATCH 1/2] CMakeLists.txt: enable SHARED and STATIC lib creation Deepak Kumar Mishra
@ 2021-06-02  5:56 ` Deepak Kumar Mishra
  2021-06-02 13:18   ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 7+ messages in thread
From: Deepak Kumar Mishra @ 2021-06-02  5:56 UTC (permalink / raw)
  To: dwarves; +Cc: acme, qais.yousef, Deepak Kumar Mishra

added a section in README to give details about use of -DBUILD_SHARED_LIBS
cmake option and existing documentation reformatted to accomodate this.

Signed-off-by: Deepak Kumar Mishra <deepakkumar.mishra@arm.com>
---
 README | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/README b/README
index 576cd42..40ca984 100644
--- a/README
+++ b/README
@@ -6,8 +6,17 @@ Build instructions:
 4. cmake -D__LIB=lib ..
 5. make install
 
-Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
-when invoking cmake to specify another install location.
+cmake Options:
+  -DBUILD_SHARED_LIBS
+    By default STATIC libraries are created and applications are linked to it.
+    use -DBUILD_SHARED_LIBS=ON while invoking cmake to create SHARED libraries
+    and link applications to it.
+
+    Ex. cmake -D__LIB=lib -DBUILD_SHARED_LIBS=ON ..
+
+  -DCMAKE_INSTALL_PREFIX
+    Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
+    when invoking cmake to specify another install location.
 
 Known to work scenarios:
 
-- 
2.17.1


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

* Re: [PATCH 2/2] README: add documentation for -DBUILD_SHARED_LIBS
  2021-06-02  5:56 ` [PATCH 2/2] README: add documentation for -DBUILD_SHARED_LIBS Deepak Kumar Mishra
@ 2021-06-02 13:18   ` Arnaldo Carvalho de Melo
  2021-06-03  7:38     ` Deepak Kumar Mishra
  0 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-06-02 13:18 UTC (permalink / raw)
  To: Deepak Kumar Mishra; +Cc: dwarves, qais.yousef

Em Wed, Jun 02, 2021 at 11:26:24AM +0530, Deepak Kumar Mishra escreveu:
> added a section in README to give details about use of -DBUILD_SHARED_LIBS
> cmake option and existing documentation reformatted to accomodate this.

So are you changing the default to build as static? Please keep the
existing default and make building statically the opt-in mode, ok?

- Arnaldo
 
> Signed-off-by: Deepak Kumar Mishra <deepakkumar.mishra@arm.com>
> ---
>  README | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/README b/README
> index 576cd42..40ca984 100644
> --- a/README
> +++ b/README
> @@ -6,8 +6,17 @@ Build instructions:
>  4. cmake -D__LIB=lib ..
>  5. make install
>  
> -Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
> -when invoking cmake to specify another install location.
> +cmake Options:
> +  -DBUILD_SHARED_LIBS
> +    By default STATIC libraries are created and applications are linked to it.
> +    use -DBUILD_SHARED_LIBS=ON while invoking cmake to create SHARED libraries
> +    and link applications to it.
> +
> +    Ex. cmake -D__LIB=lib -DBUILD_SHARED_LIBS=ON ..
> +
> +  -DCMAKE_INSTALL_PREFIX
> +    Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
> +    when invoking cmake to specify another install location.
>  
>  Known to work scenarios:
>  
> -- 
> 2.17.1
> 

-- 

- Arnaldo

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

* Re: [PATCH 2/2] README: add documentation for -DBUILD_SHARED_LIBS
  2021-06-02 13:18   ` Arnaldo Carvalho de Melo
@ 2021-06-03  7:38     ` Deepak Kumar Mishra
  2021-06-03 15:16       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 7+ messages in thread
From: Deepak Kumar Mishra @ 2021-06-03  7:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: dwarves, qais.yousef

Hi Arnaldo,

On 6/2/21 6:48 PM, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jun 02, 2021 at 11:26:24AM +0530, Deepak Kumar Mishra escreveu:
>> added a section in README to give details about use of -DBUILD_SHARED_LIBS
>> cmake option and existing documentation reformatted to accomodate this.
> 
> So are you changing the default to build as static? Please keep the
> existing default and make building statically the opt-in mode, ok?
> 
As per Cmake documentation if -DBUILD_SHARED_LIBS is present and true, 
cmake will cause all libraries to be built shared.
https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html 

If you still suggest, I can override the default behavior to SHARED and 
only when -DBUILD_SHARED_LIBS=OFF is provided, it will make STATIC.

Kindly confirm. 
-Deepak 

> - Arnaldo
>  
>> Signed-off-by: Deepak Kumar Mishra <deepakkumar.mishra@arm.com>
>> ---
>>  README | 13 +++++++++++--
>>  1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/README b/README
>> index 576cd42..40ca984 100644
>> --- a/README
>> +++ b/README
>> @@ -6,8 +6,17 @@ Build instructions:
>>  4. cmake -D__LIB=lib ..
>>  5. make install
>>  
>> -Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
>> -when invoking cmake to specify another install location.
>> +cmake Options:
>> +  -DBUILD_SHARED_LIBS
>> +    By default STATIC libraries are created and applications are linked to it.
>> +    use -DBUILD_SHARED_LIBS=ON while invoking cmake to create SHARED libraries
>> +    and link applications to it.
>> +
>> +    Ex. cmake -D__LIB=lib -DBUILD_SHARED_LIBS=ON ..
>> +
>> +  -DCMAKE_INSTALL_PREFIX
>> +    Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
>> +    when invoking cmake to specify another install location.
>>  
>>  Known to work scenarios:
>>  
>> -- 
>> 2.17.1
>>
> 

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

* Re: [PATCH 2/2] README: add documentation for -DBUILD_SHARED_LIBS
  2021-06-03  7:38     ` Deepak Kumar Mishra
@ 2021-06-03 15:16       ` Arnaldo Carvalho de Melo
  2021-06-07 19:16         ` Deepak Kumar Mishra
  0 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-06-03 15:16 UTC (permalink / raw)
  To: Deepak Kumar Mishra; +Cc: dwarves, qais.yousef

Em Thu, Jun 03, 2021 at 01:08:23PM +0530, Deepak Kumar Mishra escreveu:
> Hi Arnaldo,
> 
> On 6/2/21 6:48 PM, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Jun 02, 2021 at 11:26:24AM +0530, Deepak Kumar Mishra escreveu:
> >> added a section in README to give details about use of -DBUILD_SHARED_LIBS
> >> cmake option and existing documentation reformatted to accomodate this.
> > 
> > So are you changing the default to build as static? Please keep the
> > existing default and make building statically the opt-in mode, ok?
> > 
> As per Cmake documentation if -DBUILD_SHARED_LIBS is present and true, 
> cmake will cause all libraries to be built shared.
> https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html 
> 
> If you still suggest, I can override the default behavior to SHARED and 
> only when -DBUILD_SHARED_LIBS=OFF is provided, it will make STATIC.

Please keep the pre-existing default, i.e. people building pahole all
these years expect the shared library to be produced, if after this
change that isn't the case, some confusion will ensue.

Now if you could provide numbers for, say, 'pahole -J' liked statically,
that would be great and would help understand what decision to make.

- Arnaldo
 
> Kindly confirm. 
> -Deepak 
> 
> > - Arnaldo
> >  
> >> Signed-off-by: Deepak Kumar Mishra <deepakkumar.mishra@arm.com>
> >> ---
> >>  README | 13 +++++++++++--
> >>  1 file changed, 11 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/README b/README
> >> index 576cd42..40ca984 100644
> >> --- a/README
> >> +++ b/README
> >> @@ -6,8 +6,17 @@ Build instructions:
> >>  4. cmake -D__LIB=lib ..
> >>  5. make install
> >>  
> >> -Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
> >> -when invoking cmake to specify another install location.
> >> +cmake Options:
> >> +  -DBUILD_SHARED_LIBS
> >> +    By default STATIC libraries are created and applications are linked to it.
> >> +    use -DBUILD_SHARED_LIBS=ON while invoking cmake to create SHARED libraries
> >> +    and link applications to it.
> >> +
> >> +    Ex. cmake -D__LIB=lib -DBUILD_SHARED_LIBS=ON ..
> >> +
> >> +  -DCMAKE_INSTALL_PREFIX
> >> +    Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
> >> +    when invoking cmake to specify another install location.
> >>  
> >>  Known to work scenarios:
> >>  
> >> -- 
> >> 2.17.1
> >>
> > 

-- 

- Arnaldo

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

* Re: [PATCH 2/2] README: add documentation for -DBUILD_SHARED_LIBS
  2021-06-03 15:16       ` Arnaldo Carvalho de Melo
@ 2021-06-07 19:16         ` Deepak Kumar Mishra
  0 siblings, 0 replies; 7+ messages in thread
From: Deepak Kumar Mishra @ 2021-06-07 19:16 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: dwarves, qais.yousef

Hi Arnaldo,

On 6/3/21 8:46 PM, Arnaldo Carvalho de Melo wrote:
> Em Thu, Jun 03, 2021 at 01:08:23PM +0530, Deepak Kumar Mishra escreveu:
>> Hi Arnaldo,
>>
>> On 6/2/21 6:48 PM, Arnaldo Carvalho de Melo wrote:
>>> Em Wed, Jun 02, 2021 at 11:26:24AM +0530, Deepak Kumar Mishra escreveu:
>>>> added a section in README to give details about use of -DBUILD_SHARED_LIBS
>>>> cmake option and existing documentation reformatted to accomodate this.
>>>
>>> So are you changing the default to build as static? Please keep the
>>> existing default and make building statically the opt-in mode, ok?
>>>
>> As per Cmake documentation if -DBUILD_SHARED_LIBS is present and true, 
>> cmake will cause all libraries to be built shared.
>> https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html 
>>
>> If you still suggest, I can override the default behavior to SHARED and 
>> only when -DBUILD_SHARED_LIBS=OFF is provided, it will make STATIC.
> 
> Please keep the pre-existing default, i.e. people building pahole all
> these years expect the shared library to be produced, if after this
> change that isn't the case, some confusion will ensue.

I got your point. I am sending a v2 of the patch set which will retain the 
previous behavior. (Shared library by default if no cmake options provided) 
-Deepak  
> 
> Now if you could provide numbers for, say, 'pahole -J' liked statically,
> that would be great and would help understand what decision to make.
> 
> - Arnaldo
>  
>> Kindly confirm. 
>> -Deepak 
>>
>>> - Arnaldo
>>>  
>>>> Signed-off-by: Deepak Kumar Mishra <deepakkumar.mishra@arm.com>
>>>> ---
>>>>  README | 13 +++++++++++--
>>>>  1 file changed, 11 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/README b/README
>>>> index 576cd42..40ca984 100644
>>>> --- a/README
>>>> +++ b/README
>>>> @@ -6,8 +6,17 @@ Build instructions:
>>>>  4. cmake -D__LIB=lib ..
>>>>  5. make install
>>>>  
>>>> -Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
>>>> -when invoking cmake to specify another install location.
>>>> +cmake Options:
>>>> +  -DBUILD_SHARED_LIBS
>>>> +    By default STATIC libraries are created and applications are linked to it.
>>>> +    use -DBUILD_SHARED_LIBS=ON while invoking cmake to create SHARED libraries
>>>> +    and link applications to it.
>>>> +
>>>> +    Ex. cmake -D__LIB=lib -DBUILD_SHARED_LIBS=ON ..
>>>> +
>>>> +  -DCMAKE_INSTALL_PREFIX
>>>> +    Default is to install to /usr/local, use -DCMAKE_INSTALL_PREFIX=
>>>> +    when invoking cmake to specify another install location.
>>>>  
>>>>  Known to work scenarios:
>>>>  
>>>> -- 
>>>> 2.17.1
>>>>
>>>
> 

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

end of thread, other threads:[~2021-06-07 19:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02  5:56 [PATCH 0/2] dwarves: enable-SHARED-and-STATIC-lib-creation Deepak Kumar Mishra
2021-06-02  5:56 ` [PATCH 1/2] CMakeLists.txt: enable SHARED and STATIC lib creation Deepak Kumar Mishra
2021-06-02  5:56 ` [PATCH 2/2] README: add documentation for -DBUILD_SHARED_LIBS Deepak Kumar Mishra
2021-06-02 13:18   ` Arnaldo Carvalho de Melo
2021-06-03  7:38     ` Deepak Kumar Mishra
2021-06-03 15:16       ` Arnaldo Carvalho de Melo
2021-06-07 19:16         ` Deepak Kumar Mishra

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.