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

autotools: relax soname pattern for dynamic loading #290

Closed
wants to merge 6 commits into from

Conversation

jpalus
Copy link

@jpalus jpalus commented Jul 10, 2022

SDL makes assumption that each dynamically loaded library must have
SONAME matching pattern .so.+ hence it discards any file
that has two (or more) digits after ".so". in practice however SONAME
might be in the form of ie .so...

as a solution keep requirement for dynamically loaded files to be named
.so.* but consider all the possibilities and prefer the shortest
one.

Fixes: #289
From: libsdl-org/SDL#5901

SDL makes assumption that each dynamically loaded library must have
SONAME matching pattern <libname>.so.<digit>+ hence it discards any file
that has two (or more) digits after ".so". in practice however SONAME
might be in the form of ie <libname>.so.<major>.<minor>.

as a solution keep requirement for dynamically loaded files to be named
<libname>.so.* but consider all the possibilities and prefer the shortest
one.

Fixes: libsdl-org#289
From: libsdl-org/SDL#5901
pld-gitsync pushed a commit to pld-linux/SDL2_image that referenced this pull request Jul 10, 2022
- project moved to github
- patch to fix dynamic loading of libjxl (from
  libsdl-org/SDL_image#290)
@jpalus
Copy link
Author

jpalus commented Jul 10, 2022

Regarding failed macos check I suppose JXL support is expected to be disabled (JXL not listed in dependencies) however autotools somehow managed to find it anyway in -L/usr/local/Cellar/jpeg-xl/0.6.1/lib. -L flags don't seem to be passed down to cmake config files and CMake, contrary to autotools, does not look into /usr/local/Cellar/jpeg-xl/0.6.1/lib.

Can't really tell what is expectation here.

@slouken slouken requested a review from madebr July 11, 2022 15:34
@slouken
Copy link
Collaborator

slouken commented Jul 11, 2022

@madebr, can you look at the CMake macOS build failure?

@madebr
Copy link
Contributor

madebr commented Jul 11, 2022

There is an error in the autotools configure script: https://github.com/libsdl-org/SDL_image/runs/7290582907?check_suite_focus=true#step:16:110

I think the default autotools version on mac can't handle our configure.ac.

Perhaps we need to add AC_REQUIRE?
What minimum version do we require? 2.71?

configure Outdated
@@ -13426,7 +13477,7 @@ find_lib()
host_lib_path="$ac_default_prefix/$base_libdir $ac_default_prefix/$base_bindir /usr/$base_libdir /usr/local/$base_libdir"
fi
for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
lib=`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`
lib=`ls -- $path/$1 2>/dev/null | sed -e 's,.*/,,' | $AWK '{print length() " " $0;}' | sort -n -r | tail -1 | sed 's/^[0-9]\+ //'`
Copy link
Contributor

@madebr madebr Jul 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work on Macos? Because the output of configure complains of an error on the next line.
https://github.com/libsdl-org/SDL_image/runs/7290582907?check_suite_focus=true#step:16:110

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly something to do with awk on macOS, and possibly on other BSDs by extension?

Is this written with gawk in mind? (No, I have no awk skills at all.)

@sezero
Copy link
Contributor

sezero commented Jul 11, 2022

There is an error in the autotools configure script: https://github.com/libsdl-org/SDL_image/runs/7290582907?check_suite_focus=true#step:16:110

I think the default autotools version on mac can't handle our configure.ac.

Perhaps we need to add AC_REQUIRE? What minimum version do we require? 2.71?

We are compatible at least with ac2.63: just tested myself.

lib=[`ls -- $path/$1 2>/dev/null | sed -e 's,.*/,,' | $AWK '{print length() " " $0;}' | sort -n -r | tail -1 | sed -e 's/^[0-9]\+ //'`]
if test "x$lib" != x; then
lib=[`ls -- $path/$1 2>/dev/null | sed -e 's,.*/,,' | $AWK '{print length() " " $0;}' | sort -n -r | tail -1 | sed -e 's/^[0-9]+ //'`]
if test x$lib != x; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't seem reflected in generated configure?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the change to this line as the error was causes by lib containing a space from bad output of the preceding line.

@madebr
Copy link
Contributor

madebr commented Jul 11, 2022

An issue with choosing the shortest one, is that it will prefer development libraries: libjxl.so is shorter then libjxl.so.0.6.
But libjxl.so is only distributed through the libjxl development package where libjxl.so.0.6 is available through "normal" libjxl.

@slouken
Copy link
Collaborator

slouken commented Jul 11, 2022

An issue with choosing the shortest one, is that it will prefer development libraries: libjxl.so is shorter then libjxl.so.0.6. But libjxl.so is only distributed through the libjxl development package where libjxl.so.0.6 is available through "normal" libjxl.

Yeah, this is a problem that we need to fix. I reverted the similar change in SDL for this reason.

@@ -284,8 +284,8 @@ DIST_SUBDIRS = . test
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/SDL2_image.pc.in \
$(srcdir)/SDL2_image.spec.in \
$(srcdir)/sdl2_image-config-version.cmake.in \
$(srcdir)/sdl2_image-config.cmake.in ar-lib compile \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irrelevant to this PR, but this particular removal is correct: We have no ar-lib in SDL_image source tree. If someone's autogen.sh run is really adding it somehow, then it should be git added. @slouken: hint hint..

@jpalus
Copy link
Author

jpalus commented Jul 12, 2022

An issue with choosing the shortest one, is that it will prefer development libraries: libjxl.so is shorter then libjxl.so.0.6. But libjxl.so is only distributed through the libjxl development package where libjxl.so.0.6 is available through "normal" libjxl.

$ rg find_lib'.*\.so' configure.ac 
329:                avif_lib=[`find_lib "libavif[0-9]*.so.*"`]
331:                    avif_lib=[`find_lib "libavif.so.*"`]
381:                    jpg_lib=[`find_lib "libjpeg[0-9]*.so.*"`]
383:                        jpg_lib=[`find_lib "libjpeg.so.*"`]
425:                jxl_lib=[`find_lib "libjxl[0-9]*.so.*"`]
427:                    jxl_lib=[`find_lib "libjxl.so.*"`]
474:                    png_lib=[`find_lib "libpng[0-9]*.so.*"`]
476:                        png_lib=[`find_lib "libpng.so.*"`]
516:                tif_lib=[`find_lib "libtiff[0-9]*.so.*"`]
518:                    tif_lib=[`find_lib "libtiff.so.*"`]
562:                webp_lib=[`find_lib "lib$webplib[0-9]*.so.*"`]
564:                    webp_lib=[`find_lib "lib$webplib.so.*"`]

First argument of find_lib is not a regex but a glob passed to ls hence dot after .so is mandatory in all cases already and there's no way libjxl.so will be considered.

@jpalus
Copy link
Author

jpalus commented Jul 12, 2022

Primary issue with original PR was use of \+ in sed expression which is GNU extension. Replacing it with * would be fine.

@slouken
Copy link
Collaborator

slouken commented Jul 12, 2022

Fixed in 79f9995

@slouken slouken closed this Jul 12, 2022
@jpalus jpalus deleted the relax-soname-pattern branch July 12, 2022 22:53
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.

--enable-jxl-shared does not result in dynamically loaded libjxl
4 participants