#57 New regression: library naming on Mac
Closed 9 months ago by RJVB. Opened 9 months ago by RJVB.

So the changes around #55 introduced a new regression: my builds on Mac now generate shared libraries with generic Unix naming:

> find dbus-mp9-work/dbus-1.14.6-i386/ -name "libdbus-1.*" 
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.a
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.a.slibtool.deps
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.la
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.lai
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.so
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.so.3
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.so.3.32.2
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.so.def
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.so.def.default
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.so.def.host
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.so.slibtool.deps
dbus-mp9-work/dbus-1.14.6-i386//dbus/.libs/libdbus-1.so.slibtool.rpath
dbus-mp9-work/dbus-1.14.6-i386//dbus/libdbus-1.la

This causes the dbus install (to DESTDIR, aka "destroot") to fail because of missing libdbus-1.dylib*.

pkgconf does destroot, but gives:

> find pkgconf-mp9-work/destroot/ -name "lib*.*"
pkgconf-mp9-work/destroot//opt/local/include/pkgconf/libpkgconf/libpkgconf-api.h
pkgconf-mp9-work/destroot//opt/local/include/pkgconf/libpkgconf/libpkgconf.h
pkgconf-mp9-work/destroot//opt/local/lib/libpkgconf.a
pkgconf-mp9-work/destroot//opt/local/lib/libpkgconf.la
pkgconf-mp9-work/destroot//opt/local/lib/libpkgconf.so
pkgconf-mp9-work/destroot//opt/local/lib/libpkgconf.so.4
pkgconf-mp9-work/destroot//opt/local/lib/libpkgconf.so.4.0.0
pkgconf-mp9-work/destroot//opt/local/lib/pkgconfig/libpkgconf.pc

instead of the platform-correct

> ls -l /opt/local/lib/libpkgconf.*
-rwxr-xr-x 1 bertin admin 56684 Feb 11 14:51 /opt/local/lib/libpkgconf.4.dylib
lrwxr-xr-x 1 bertin admin    18 Feb 11 14:51 /opt/local/lib/libpkgconf.dylib -> libpkgconf.4.dylib

This is a good place to attach the patch required to use the Apple linker at all, i.e. emitting -Wl,-install_name instead of -Wl,-soname and skip -Wl,--no-undefined .

EDIT: sorry, attaching doesn't work in this case?!

diff --git a/src/logic/linkcmd/slbt_linkcmd_dsolib.c b/src/logic/linkcmd/slbt_linkcmd_dsolib.c
index c395118..0e47cb6 100644
--- a/src/logic/linkcmd/slbt_linkcmd_dsolib.c
+++ b/src/logic/linkcmd/slbt_linkcmd_dsolib.c
@@ -103,9 +103,11 @@ int slbt_exec_link_create_library(
                &depsmeta) < 0)
            return SLBT_NESTED_ERROR(dctx);

+#ifndef __APPLE__
    /* --no-undefined */
    if (dctx->cctx->drvflags & SLBT_DRIVER_NO_UNDEFINED)
        *ectx->noundef = "-Wl,--no-undefined";
+#endif

    /* -soname */
    dot   = strrchr(dctx->cctx->output,'.');
@@ -121,7 +123,11 @@ int slbt_exec_link_create_library(
                "-Wl,%s",dctx->cctx->output) < 0)
            return SLBT_BUFFER_ERROR(dctx);

+#ifdef __APPLE__
+       *ectx->soname  = "-Wl,-install_name";
+#else
        *ectx->soname  = "-Wl,-soname";
+#endif
        *ectx->lsoname = soname;

    } else if (relfilename && dctx->cctx->verinfo.verinfo) {
@@ -135,7 +141,11 @@ int slbt_exec_link_create_library(
                    dctx->cctx->settings.osdfussix) < 0)
            return SLBT_BUFFER_ERROR(dctx);

+#ifdef __APPLE__
+       *ectx->soname  = "-Wl,-install_name";
+#else
        *ectx->soname  = "-Wl,-soname";
+#endif
        *ectx->lsoname = soname;

    } else if (relfilename) {
@@ -147,7 +157,11 @@ int slbt_exec_link_create_library(
                    dctx->cctx->settings.dsosuffix) < 0)
            return SLBT_BUFFER_ERROR(dctx);

+#ifdef __APPLE__
+       *ectx->soname  = "-Wl,-install_name";
+#else
        *ectx->soname  = "-Wl,-soname";
+#endif
        *ectx->lsoname = soname;

    } else if (dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION) {
@@ -158,7 +172,11 @@ int slbt_exec_link_create_library(
                    dctx->cctx->settings.dsosuffix) < 0)
            return SLBT_BUFFER_ERROR(dctx);

+#ifdef __APPLE__
+       *ectx->soname  = "-Wl,-install_name";
+#else
        *ectx->soname  = "-Wl,-soname";
+#endif
        *ectx->lsoname = soname;

    } else {
@@ -171,7 +189,11 @@ int slbt_exec_link_create_library(
                    dctx->cctx->settings.osdfussix) < 0)
            return SLBT_BUFFER_ERROR(dctx);

+#ifdef __APPLE__
+       *ectx->soname  = "-Wl,-install_name";
+#else
        *ectx->soname  = "-Wl,-soname";
+#endif
        *ectx->lsoname = soname;
    }

diff --git a/src/logic/linkcmd/slbt_linkcmd_executable.c b/src/logic/linkcmd/slbt_linkcmd_executable.c
index cbb6ffe..9182f19 100644
--- a/src/logic/linkcmd/slbt_linkcmd_executable.c
+++ b/src/logic/linkcmd/slbt_linkcmd_executable.c
@@ -114,9 +114,11 @@ int slbt_exec_link_create_executable(
                &depsmeta) < 0)
            return SLBT_NESTED_ERROR(dctx);

+#ifndef __APPLE__
    /* --no-undefined */
    if (dctx->cctx->drvflags & SLBT_DRIVER_NO_UNDEFINED)
        *ectx->noundef = "-Wl,--no-undefined";
+#endif

    /* executable wrapper: create */
    if (slbt_snprintf(wrapper,sizeof(wrapper),

Looking into this, I see that slbt_host_params.c sets cfgmeta->flavor conditionally in lines 245-257, and then overrides that values to cfghost a few lines down. Only to have another go at it in 262-283 where in my case I end up with the default/fallback branch because dash is an empty string (machine == "/opt/local/bin/clang-mp", which seems to be the path to the compiler minus its version suffix).

Is this because you just moved different bits of code from different functions into the new host_params file?

For now I'm using a simple workaround that makes host_flavor_default a compile-time macro:

diff --git a/src/driver/slbt_host_params.c b/src/driver/slbt_host_params.c
index 5811e0269b519c68b3114c8a1b5827fd09d23885..9892e21fe1f828340b4970b1e0c909d01d82b8af 100644
--- a/src/driver/slbt_host_params.c
+++ b/src/driver/slbt_host_params.c
@@ -49,7 +49,7 @@ static const char*ldrpath_elf[] = {
        exep,exes,impp,imps,                       \
        ldenv,pic}

-SLBT_FLAVOR_SETTINGS(host_flavor_default,       \
+SLBT_FLAVOR_SETTINGS(host_flavor_unix,       \
    "elf","-fPIC",                          \
    "lib",".a","lib",".so",".so","",        \
    "","","","",                            \
@@ -79,6 +79,12 @@ SLBT_FLAVOR_SETTINGS(host_flavor_darwin,        \
    "","","","",                            \
    "DYLD_LIBRARY_PATH");

+#ifdef __APPLE__
+#define host_flavor_default host_flavor_darwin
+#else
+#define host_flavor_default host_flavor_unix
+#endif
+

 static void slbt_get_host_quad(
    char *  hostbuf,

Might not be such a bad idea to keep around as fallback (in completed form that also checks for MingW and Cygwin)?

@midipix On Darwin it expects library names like:

libfoo.0.1.2.dylib
libfoo.0.dylib
libfoo.dylib

While on Linux as I am sure you are aware it requires:

libfoo.so.0.1.2
libfoo.so.0
libfoo.so

Everything is there for the file naming, it's just not being selected by default at the moment.

@RJVB please attach the generated libtool script from that build, and also attach (or paste) the output of rlibtool --info when run in that build directory.

Commit 7718994 might have already taken care of this issue, but let us see first what rlibtool --info says:=)

Metadata Update from @midipix:
- Issue assigned to midipix

9 months ago

Update: I just used the generated libtool script you attached to #59 and rlibtool --info, and this is what I'm getting now:

...

host x86_64-apple-darwin13.4.0 derived from <libtool>
flavor darwin derived from <host>
...

So this actually might have already been resolved. Can you confirm?

Yes, the naming is fine now as surely you saw from the other ticket :)

Metadata Update from @RJVB:
- Issue status updated to: Closed (was: Open)

9 months ago

Login to comment on this ticket.

Metadata