On demand static/shared libs and binary linkage

Laurent Stacul laurent.stacul@gmail.com
Thu Jun 7 08:01:00 GMT 2018


Hello,

I am quite new on elfutils library. I know their were discussions in
the past about the question I will ask but let me introduce my use
case.

I am working on a project which aims at building some kind of
"standalone" toolchain (binutils, gcc, clang + tools like gdb,
valgrind). This toolchain could be shipped easily on any linux
machines by copying files on the targeted machine.

To ease this, the tools binaries are statically linked to avoid any
interferences with user local LD_LIBRARY_PATH environment variable.

I am planning to add elfutils to this toolchain. The provided binaries
are useful and the delivered libs are a prerequisite for libabigail
(which I plan to also add).

I can see there is no flag to chose between static and shared.

>From my investigations in the code and the build system:

- the delivered libs cannot be 100% static archives. Depending on the
machine the libelf is used, some backend code are dlopen'd. So at
least, the backends code must be delivered as shared lib (in the by
default EBL directory)

- the delivered binaries are by default dynamically linked except if
the gcov or gprof support is enabled.

I was wondering if it would be a good idea (or even possible) to have
two options in the configure script, for instance, --enable-static and
--enable-shared, which would be set to "yes" by default.

In the case --enable-shared=no, no dso is generated (except the
backends) and the binaries are statically linked.
In the case --enable-static=no, only the dso are generated and
binaries are dynamically linked.
The combination --enable-shared=no and --enable-dynamic=no is impossible.

Finally if the gcov or gprof support is required, we force the current
behaviour (ie. --enable-shared=yes and --enable-static=yes).

Can you give me your feed back on such a proposal ? If it is worth
working on this, I can try to provide a patch.

Regarding the project I am working on, I have a workaround which does
not satisfy me:
- build zlib shared lib
- build elfutils with gcov support

Thanks in advance,
Laurent Stacul



More information about the Elfutils-devel mailing list