[Bug backends/26176] Backend modules of elfutils are always linked to shared library

mark at klomp dot org sourceware-bugzilla@sourceware.org
Sat Jul 4 22:34:37 GMT 2020


https://sourceware.org/bugzilla/show_bug.cgi?id=26176

--- Comment #9 from Mark Wielaard <mark at klomp dot org> ---
(In reply to maarten from comment #6)
> > I was actually going to propose we wouldn't build the static version by
> > default because I didn't think anybody is actually using it.
> > 
> > What is your use case? And would it be a problem if we dropped building the
> > static libraries by default, and you had to explicitly build the package
> > with static libs?
> 
> conan has an option to build libraries statically or shared.
> elfutils needed some patches to make this possible.

The libraries are already build both static and shared (there is both an
libelf.a and libelf.so, libdw.a and libdw.so, etc.).
Your patch makes sure that the static code is build with -fPIC and that the
binaries and tests are linked static. Is that what you intent?

> > > - disable -Werror
> > 
> > What errors/warnings are you seeing?
> 
> ../source_subfolder/libdwfl/dwfl_build_id_find_elf.c: In function
> ‘__libdwfl_open_by_build_id’:
> ../source_subfolder/libdwfl/dwfl_build_id_find_elf.c:60:7: error: variable
> ‘n’ set but not used [-Werror=unused-but-set-variable]
>    60 |   int n = snprintf (&id_name[sizeof "/.build-id/" - 1],
>       |       ^
> cc1: all warnings being treated as errors

You are building with -DNDEBUG and removing asserts.
While asserts in library code are not ideal I would really caution about simply
using -DNDEBUG to get rid of them. I have proposed a patch to turn some of the
asserts in the library and tools into proper checks:
https://sourceware.org/pipermail/elfutils-devel/2020q3/002823.html
So with that you can build with -DNDEBUG if you really must (but I still
recommend not to). But the tests rely on the asserts, trying to compile them
with -DNDEBUG is really not a good idea.

> > > Also, it looks like `libasm.h` and `libdwfl.h` use types defined in
> > > `gelf.h`, but do not include the header.
> > 
> > There was an issue in libasm.h which got fixed in elfutils-0.178-24-g287a1845
> > libdwfl.h includes libdw.h which includes gelf.h so should be usable
> > standalone.
> 
> `libasm.h` from 0.180 is only including system headers <stdbool.h> and
> <stdint.h>.
> You're correct about `libdwfl.h`, that one is including `gelf.h` through
> `libdw.h`.

You are right that it would be better to make all public headers usable
standalone. I proposed a fix for libasm.h and a new testcase:
https://sourceware.org/pipermail/elfutils-devel/2020q3/002822.html

> > Could you attach concrete patches to this bug report?
> 
> I've attached them.
> 
> Using `--disable-werror` + `--enable-static=yes/no` allows us to build
> elfutils as static/shared libraries.

I am really not a fan of adding --disable-werror or building with -DNDEBUG.
If there are real warnings/errors lets just fix them.

I would like to get rid of (automatically) building the static libraries if at
all possible.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Elfutils-devel mailing list