Ports: Build shared libraries with -Wl,-soname

Without a SONAME gcc will put the whole library path into executables
which link against these libraries:

$ readelf -d Root/usr/local/games/openttd

Dynamic section at offset 0xf0747c contains 32 entries:
 Tag        Type     Name/Value
0x00000001 (NEEDED) [libgcc_s.so]
0x00000001 (NEEDED) [/serenity/Build/i686/Root/usr/local/lib/libpng.so]
0x00000001 (NEEDED) [/serenity/Build/i686/Root/usr/local/lib/libz.so]
0x00000001 (NEEDED) [/serenity/Build/i686/Root/usr/local/lib/liblzma.so]
0x00000001 (NEEDED) [libSDL2-2.0.so.1]
0x00000001 (NEEDED) [libicui18n.so.69]
0x00000001 (NEEDED) [libicuuc.so.69]
0x00000001 (NEEDED) [libicudata.so.69]
0x00000001 (NEEDED) [libpthread.so]
0x00000001 (NEEDED) [libm.so]
0x00000001 (NEEDED) [libc.so]

This causes the executable to fail because the dynamic linker
tries to find the library in the incorrect path.
This commit is contained in:
Gunnar Beutner 2021-04-25 08:42:41 +02:00 committed by Andreas Kling
parent e6953d14d8
commit 5b69e8d2c6
Notes: sideshowbarker 2024-07-18 19:07:07 +09:00
12 changed files with 15 additions and 15 deletions

View file

@ -10,5 +10,5 @@ configopts="--with-sdl-prefix=${SERENITY_INSTALL_ROOT}/usr/local"
install() {
run make install DESTDIR=${SERENITY_INSTALL_ROOT} $installopts
run ${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_gfx.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_gfx.a -Wl,--no-whole-archive
run ${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_gfx.so -Wl,-soname,libSDL2_gfx.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_gfx.a -Wl,--no-whole-archive
}

View file

@ -20,6 +20,6 @@ build() {
install() {
run make -k DESTDIR="${SERENITY_INSTALL_ROOT}" install
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_image.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_image.a -Wl,--no-whole-archive -lpng -ljpeg -ltiff
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_image.so -Wl,-soname,libSDL2_image.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_image.a -Wl,--no-whole-archive -lpng -ljpeg -ltiff
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_image.la
}

View file

@ -21,6 +21,6 @@ build() {
install() {
run make -k DESTDIR="${SERENITY_INSTALL_ROOT}" install
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_mixer.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_mixer.a -Wl,--no-whole-archive -Wl,--no-as-needed -lvorbis -lvorbisfile
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_mixer.so -Wl,-soname,libSDL2_mixer.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_mixer.a -Wl,--no-whole-archive -Wl,--no-as-needed -lvorbis -lvorbisfile
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_mixer.la
}

View file

@ -17,5 +17,5 @@ configure() {
install() {
run make install DESTDIR=${SERENITY_INSTALL_ROOT} $installopts
run ${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_ttf.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_ttf.a -Wl,--no-whole-archive
run ${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_ttf.so -Wl,-soname,libSDL2_ttf.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libSDL2_ttf.a -Wl,--no-whole-archive
}

View file

@ -12,5 +12,5 @@ auth_opts="--keyring ./gnu-keyring.gpg libiconv-${version}.tar.gz.sig"
install() {
run make DESTDIR=${SERENITY_INSTALL_ROOT} $installopts install
run ${SERENITY_ARCH}-pc-serenity-gcc -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libiconv.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libiconv.a -Wl,--no-whole-archive
run ${SERENITY_ARCH}-pc-serenity-gcc -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libiconv.so -Wl,-soname,libiconv.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libiconv.a -Wl,--no-whole-archive
}

View file

@ -8,6 +8,6 @@ workdir="jpeg-$version"
install() {
run make DESTDIR=${SERENITY_INSTALL_ROOT} $installopts install
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libjpeg.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libjpeg.a -Wl,--no-whole-archive
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libjpeg.so -Wl,-soname,libjpeg.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libjpeg.a -Wl,--no-whole-archive
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libjpeg.la
}

View file

@ -7,6 +7,6 @@ auth_type=md5
install() {
run make DESTDIR=${SERENITY_INSTALL_ROOT} $installopts install
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libogg.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libogg.a -Wl,--no-whole-archive
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libogg.so -Wl,-soname,libogg.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libogg.a -Wl,--no-whole-archive
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libogg.la
}

View file

@ -8,7 +8,7 @@ depends="zlib"
install() {
run make DESTDIR=${SERENITY_INSTALL_ROOT} $installopts install
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libpng16.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libpng16.a -Wl,--no-whole-archive -lz
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libpng16.so -Wl,-soname,libpng16.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libpng16.a -Wl,--no-whole-archive -lz
ln -sf libpng16.so ${SERENITY_INSTALL_ROOT}/usr/local/lib/libpng.so
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libpng16.la ${SERENITY_INSTALL_ROOT}/usr/local/lib/libpng.la
}

View file

@ -11,7 +11,7 @@ depends="zstd xz"
install() {
run make DESTDIR=${SERENITY_INSTALL_ROOT} $installopts install
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiff.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiff.a -Wl,--no-whole-archive -lzstd -llzma
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiffxx.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiffxx.a -Wl,--no-whole-archive -lzstd -llzma
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiff.so -Wl,-soname,libtiff.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiff.a -Wl,--no-whole-archive -lzstd -llzma
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiffxx.so -Wl,-soname,libtiffxx.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiffxx.a -Wl,--no-whole-archive -lzstd -llzma
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiff.la ${SERENITY_INSTALL_ROOT}/usr/local/lib/libtiffxx.la
}

View file

@ -8,10 +8,10 @@ depends=libogg
install() {
run make DESTDIR=${SERENITY_INSTALL_ROOT} $installopts install
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbis.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbis.a -Wl,--no-whole-archive -logg
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbis.so -Wl,-soname,libvorbis.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbis.a -Wl,--no-whole-archive -logg
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbis.la
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisenc.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisenc.a -Wl,--no-whole-archive -lvorbis
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisenc.so -Wl,-soname,libvorbisenc.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisenc.a -Wl,--no-whole-archive -lvorbis
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisenc.la
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisfile.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisfile.a -Wl,--no-whole-archive -lvorbis
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisfile.so -Wl,-soname,libvorbisfile.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisfile.a -Wl,--no-whole-archive -lvorbis
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libvorbisfile.la
}

View file

@ -8,6 +8,6 @@ depends="zlib libiconv"
install() {
run make DESTDIR=${SERENITY_INSTALL_ROOT} $installopts install
${CC} -pthread -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/liblzma.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/liblzma.a -Wl,--no-whole-archive -lz -liconv
${CC} -pthread -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/liblzma.so -Wl,-soname,liblzma.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/liblzma.a -Wl,--no-whole-archive -lz -liconv
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/liblzma.la
}

View file

@ -15,6 +15,6 @@ configure() {
install() {
run make DESTDIR=${SERENITY_INSTALL_ROOT} $installopts install
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libz.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libz.a -Wl,--no-whole-archive
${CC} -shared -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libz.so -Wl,-soname,libz.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libz.a -Wl,--no-whole-archive
rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libz.la
}