Re: [RFC][PATCH] libtraceevent: Fix static library to hide hidden functions

Metin Kaya <[email protected]> Wed, 20 Aug 2025 08:30:48 +0100
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
On 19/08/2025 8:56 PM, Steven Rostedt wrote:
> On Tue, 19 Aug 2025 15:04:32 +0100
> Metin Kaya <[email protected]> wrote:
> 
>> Now this is what I get when I try to build trace-cmd:
>>
>>     BUILD                  trace-cmd
>> /usr/bin/ld: /out/lib64/libtraceevent.a(libtraceevent.o): in function
>> `load_plugin':
>> /libtraceevent/src/event-plugin.c:459:(.text+0x1458c): warning: Using
>> 'dlopen' in statically linked applications requires at runtime the
>> shared libraries from the glibc version used for linking
>> /usr/bin/ld: /trace-cmd/tracecmd/trace-setup-guest.o: in function
>> `trace_setup_guest':
>> trace-setup-guest.c:(.text+0x5c8): warning: Using 'getgrnam' in
>> statically linked applications requires at runtime the shared libraries
>> from the glibc version used for linking
>> /usr/bin/ld: /trace-cmd/tracecmd/trace-record.o: in function
>> `record_trace.isra.0':
>> trace-record.c:(.text+0xe705): warning: Using 'initgroups' in statically
>> linked applications requires at runtime the shared libraries from the
>> glibc version used for linking
>> /usr/bin/ld: /trace-cmd/tracecmd/trace-record.o: in function
>> `do_getaddrinfo':
>> trace-record.c:(.text+0x865): warning: Using 'getaddrinfo' in statically
>> linked applications requires at runtime the shared libraries from the
>> glibc version used for linking
>> /usr/bin/ld: /trace-cmd/tracecmd/trace-record.o: in function
>> `record_trace.isra.0':
>> trace-record.c:(.text+0xe6ee): warning: Using 'getpwnam' in statically
>> linked applications requires at runtime the shared libraries from the
>> glibc version used for linking
> 
> Do you get the above warnings regardless?

Yes.

> 
> 
>> /usr/bin/ld: /trace-cmd/tracecmd/trace-record.o: in function
>> `tracecmd_stat_cpu_instance':
>> trace-record.c:(.text+0x12ec): undefined reference to `trace_seq_printf'
>> /usr/bin/ld: /trace-cmd/tracecmd/trace-record.o: in function `record_stats':
>> trace-record.c:(.text+0x1419): undefined reference to `trace_seq_init'
> 
> 
>> /usr/bin/ld: /trace-cmd/lib/trace-cmd/libtracecmd.a(trace-input.o): in
>> function `update_page_info':
>> trace-input.c:(.text+0x15d7): undefined reference to
>> `kbuffer_load_subbuffer'
>> /usr/bin/ld: trace-input.c:(.text+0x15df): undefined reference to
>> `kbuffer_subbuffer_size'
> 
> Oops, I forgot that trace_seq* and kbuffer_* are also supplied. I made
> everything that didn't start with 'tep_*' "static". I could add kbuffer_*
> and trace_seq_* to that list (the easy way out), or I can parse
> `nm libtraceevent.so` and convert everything that's static in it to static
> in the static library.
> 
> -- Steve