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

Is there a way around libbsd as a hard dependency? #32

Closed
TimB87 opened this issue Sep 20, 2021 · 10 comments
Closed

Is there a way around libbsd as a hard dependency? #32

TimB87 opened this issue Sep 20, 2021 · 10 comments
Assignees

Comments

@TimB87
Copy link

TimB87 commented Sep 20, 2021

Hi!

Is there any way we could avoid libbsd as a hard dependency?
Having libmd and libbsd around on a source distro makes everything link to it, once a user uninstalls it he has to rebuild crucial parts of the system and might need to do a recovery boot.
As a port maintainer for CRUX, I decided to try and avoid pulling in libbsd as a dependency.

Thanks for the fork and continued work on libsixel!

Best regards,
Tim

Edit: For a quick test, I deleted the part of meson.build entirely - it build fine and img2sixel works as expected. Am I missing anything?

@dankamongmen
Copy link
Collaborator

it is very possible that we can remove it, at least on some platforms. i'll need look at it and try to figure out why it was originally included -- it might be required on only certain platforms.

@TimB87
Copy link
Author

TimB87 commented Sep 24, 2021

Is there any data I can provide to help?
I've just ran the tests successfully

$ meson setup build-tests -Dbuildtype=debug -Dlibcurl=enabled -Dgd=enabled -Dgdk-pixbuf2=enabled -Dtests=enabled
[..]
libsixel was configured as follows

       Install prefix      : /usr/local
       Loader component    : stb-image gd gdk-pixbuf2
       libcurl integration : true
       pkg-config dir      : []
       Bash completion dir : share/bash-completion/completions
       Zsh completion dir  : share/zsh/site-functions
       python bindings     : false
       gcov integration    : false
       build type          : debug
       tests               : true

   
Build targets in project: 3

Option buildtype is: debug [default: release]
Found ninja-1.10.2 at /usr/bin/ninja
$ meson compile -C build-tests 
ninja: Entering directory `build-tests'
[26/26] Linking target converters/img2sixel
$ meson test -C build-tests 
ninja: Entering directory `/home/tim/libsixel/build-tests' 
ninja: no work to do.
1/2 img2sixel tests        OK              22.14s
2/2 sixel2png tests        OK               0.42s


Ok:                 2   
Expected Fail:      0   
Fail:               0   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   

Full log written to /home/tim/libsixel/build-tests/meson-logs/testlog.txt

@eli-schwartz
Copy link

meson has a core option -Db_asneeded=true by default, which causes linking to be performed using -Wl,--as-needed.

Doing a stock build of libsixel results in:

[1/4] cc  -o src/libsixel.so src/libsixel.so.p/allocator.c.o src/libsixel.so.p/chunk.c.o src/libsixel.so.p/decoder.c.o src/libsixel.so.p/dither.c.o src/libsixel.so.p/encoder.c.o src/libsixel.so.p/frame.c.o src/libsixel.so.p/fromgif.c.o src/libsixel.so.p/frompnm.c.o src/libsixel.so.p/fromsixel.c.o src/libsixel.so.p/loader.c.o src/libsixel.so.p/output.c.o src/libsixel.so.p/pixelformat.c.o src/libsixel.so.p/quant.c.o src/libsixel.so.p/scale.c.o src/libsixel.so.p/status.c.o src/libsixel.so.p/stb_image_write.c.o src/libsixel.so.p/tests.c.o src/libsixel.so.p/tosixel.c.o src/libsixel.so.p/tty.c.o src/libsixel.so.p/writer.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,libsixel.so -lbsd -lm -Wl,--end-group

Noting that -lbsd is on the linker command line (and indeed was probed during meson setup builddir/)...

$ readelf -d builddir/src/libsixel.so

Dynamic section at offset 0x81db0 contains 26 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000e (SONAME)             Library soname: [libsixel.so]
 0x000000000000000c (INIT)               0x25000
 0x000000000000000d (FINI)               0x61588
[...]

libbsd.so disappeared from the final binary! It is totally unused.

git grep bsd produces 81 results in examples/opengl/ which has a fully autotooled example build system in there (please consider removing generated files such as configure or config.sub/config.guess! I do understand that you inherited this from the original libsixel project...)

Of the handful of remaining hits, 11 are hyperlinks in README.md, one is a person's email address in a license file, and...

4 are the parts of meson.build under discussion, 1 is the installation of libbsd-dev in github CI.

Any actual uses of libbsd would surely require adding a header #include <bsd/*.h> no matter what else.

Based on a quick grep through commit logs (hindered by yet more checked-in generated files produced by autoreconf -fi) I can't see anywhere in the old build system that libbsd was used either. It does seem to be a mistaken inclusion.

@dankamongmen
Copy link
Collaborator

probably! i'll verify your conclusions and try to excise this this weekend. thanks!

@dankamongmen
Copy link
Collaborator

Any actual uses of libbsd would surely require adding a header #include <bsd/*.h> no matter what else.
Based on a quick grep through commit logs (hindered by yet more checked-in generated files produced by autoreconf -fi) I can't see anywhere in the old build system that libbsd was used either. It does seem to be a mistaken inclusion.

hey eli! i know you from the Arch mailing lists. agreed with the analysis here.

git grep bsd produces 81 results in examples/opengl/ which has a fully autotooled example build system in there (please consider removing generated files such as configure or config.sub/config.guess! I do understand that you inherited this from the original libsixel project...)

yeah. with all due respect to the original author, there were a lot of questionable practices at work.

meson has a core option -Db_asneeded=true by default, which causes linking to be performed using -Wl,--as-needed.

i'm probably going to add this.

@dankamongmen
Copy link
Collaborator

libbsd has been purged from the Meson configuration.

i've removed all autotools-generated files i saw.

@eli-schwartz
Copy link

Great, happy to help!

You don't need to add anything for asneeded though -- it is after all a default. I suppose if you like you could make that core option explicitly set, but it would only make a difference if, for some reason, meson would one day switch the default value.

We have no intention of changing that.

@dankamongmen
Copy link
Collaborator

You don't need to add anything for asneeded though -- it is after all a default. I suppose if you like you could make that core option explicitly set, but it would only make a difference if, for some reason, meson would one day switch the default value.

yep, came to this same conclusion. i've just cut 1.10.2. it drops the libbsd dependency, and is the first release to be signed.

@eli-schwartz
Copy link

Cool, release signing is always nice :) although this doesn't have anything to do with me personally.

Since you mention it... meson dist will create a tarball locally for you, just like autotools make dist, and in fact just like make distcheck since it does a full build + test + DESTDIR install. You can then sign that tarball and upload it, which is probably a stronger security guarantee than wgeting it from github.

Alternatively this is a convenient git alias that uses the same deterministic rules to generate the tarball as github itself performs: https://github.com/eli-schwartz/dotfiles/blob/a4c7b88965c09e55d121bd7a648d72ef8e1633d5/.config/git/config#L40
(The git clone must be a directory called the same name as the remote, which is usually a safe bet.)

@dankamongmen dankamongmen self-assigned this Sep 26, 2021
@TimB87
Copy link
Author

TimB87 commented Sep 26, 2021

Thanks to both of you @eli-schwartz @dankamongmen :)

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

No branches or pull requests

3 participants