Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sframe to libbfd's dependencies list #296

Merged
merged 1 commit into from
Jul 2, 2023

Conversation

LucasChollet
Copy link
Contributor

To bring some context, I tried to build backward-cpp for SerenityOS.

We only rely on binutils' Makefile which doesn't generate a .so for libbfd. When building backward-cpp with this configuration, I faced linker errors with symbols from sframe. It appears that sframe is also a dependency of libbfd.

FWIW, it's in phase with what Arch do to package libbfd.so:
"echo 'INPUT( /usr/lib/libbfd.a -lsframe -liberty -lz -lzstd -ldl )' > "$pkgdir/usr/lib/libbfd.so""

@bombela
Copy link
Owner

bombela commented May 5, 2023

What is sframe? On my ubuntu 22.04 its nowhere to be found. Could it be something specific to x86_32?

Besides, backward-cpp itself doesn't use sframe, so it stands of reason that libbfd should be the one that links to it (statically or dynamically).

@LucasChollet
Copy link
Contributor Author

What is sframe?

I won't try to explain it, I know nothing about it. You might want to read this

On my ubuntu 22.04 its nowhere to be found.

It's in the binutils-dev package, along libbfd

Could it be something specific to x86_32?

Serenity is x86_64 only.

Besides, backward-cpp itself doesn't use sframe, so it stands of reason that libbfd should be the one that links to it (statically or dynamically).

Absolutely agree with that, still you are required to manually add libiberty and zlib as dependencies when using a static libbfd.

@LucasChollet
Copy link
Contributor Author

FYI:

#68 bring support for static linking of libbfd in backward-cpp, it's exactly the same issue. sframe just didn't exist at the time, thus wasn't needed as a dependency.

Besides, backward-cpp itself doesn't use sframe, so it stands of reason that libbfd should be the one that links to it (statically or dynamically).

The GNU project always intended to distribute libbfd as a static package, and most .so that you found are distro's hacks. The Debian project even forbid package construction depending on the shared library.

I guess that it was decided to spare disk space at the time, but anyway, libbfd.a can't be used on its own and require the user to link against its dependencies. I agree that it should be libbfd's concern, but I'm pretty sure that they won't change a 40 years invariant just for us.

@bombela
Copy link
Owner

bombela commented May 23, 2023

I don't mind the change but... will it break something on other systems?

@LucasChollet
Copy link
Contributor Author

LucasChollet commented Jul 1, 2023

will it break something on other systems?

That's a fair point, I've made a change to make sure it's still compatible with old distributions.

As far as I can see:

  • This changes only impacts libbfd users
  • Then there are two possibilities: libbfd is recent enough and depends on sframe or sframe doesn't exist at all.

1. libbfd depends on sframe

This is what we have on Serenity, we build with the latest binutils so we have to add the linker flag, as it is done in that PR.

2. backward-cpp is used with an old libbfd

To test that, I used the same distribution as the author of #68 (OpenSuse Leap 42.2) and make sure it still works there.
screenshot

And sorry for the delay!

@LucasChollet LucasChollet force-pushed the link_sframe branch 2 times, most recently from 90d6cc8 to bd1defa Compare July 1, 2023 16:40
This is required when linking on a system without a dynamic library for
libbfd. Note that `libsframe` is a recent addition to `libbfd`, so we
test for the library existence before adding it to the dependency list.
It allows us to remain compatible with older distributions.
@bombela
Copy link
Owner

bombela commented Jul 1, 2023

So if you have sframe installed and libbfd that doesn't depend on sframe. It will link to sframe anyways?

I wonder if this is one of those case where pkgconfig can help? Though that assumes those libs offer a pkgconfig configuration...

Unless something new comes up, I will merge this PR in the next few days.

@LucasChollet
Copy link
Contributor Author

So if you have sframe installed and libbfd that doesn't depend on sframe. It will link to sframe anyways?

Yes, but I would say that it's a non-issue. If it happens, the linker will be able to get rid of it of the object, so apart from the very small link-time overhead there are no consequences. Nonetheless, that situation shouldn't be accidentally encountered, libsframe is only shipped with binutils (so along libbfd) and there are no versions that provide libsframe without using it.

Though that assumes those libs offer a pkgconfig configuration...

That would be too easy 😄. More seriously, I guess that it would be a mess to provide one, as almost all distribution hacks a libbfd.so in its own way.

Unless something new comes up, I will merge this PR in the next few days.

Sounds good to me, thanks!

@bombela
Copy link
Owner

bombela commented Jul 2, 2023

Ok perfect, thank you for taking the time. I am convinced this is reasonable.

Merci!

@bombela bombela merged commit 65a769f into bombela:master Jul 2, 2023
@LucasChollet LucasChollet deleted the link_sframe branch July 2, 2023 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants