Loading ...
Sorry, an error occurred while loading the content.
 

underlinking? ld.gold

Expand Messages
  • Eray Aslan
    I am getting undefined_symbol errors when using gold for linking. 1/ With bfd: $ make tidy $ make -j7 makefiles shared=yes dynamicmaps=no
    Message 1 of 13 , Jul 14, 2014
      I am getting undefined_symbol errors when using gold for linking.

      1/
      With bfd:

      $ make tidy
      $ make -j7 makefiles shared=yes dynamicmaps=no
      shlib_directory=/usr/lib64/postfix/MAIL_VERSION DEBUG=
      CC=x86_64-pc-linux-gnu-gcc 'OPT=-march=native -O2 -pipe -Wno-comment'
      'CCARGS=-DHAS_PCRE -DHAS_LDAP -DUSE_TLS -DNO_NIS -D_FILE_OFFSET_BITS=64
      -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE' 'AUXLIBS=-Wl,-O1
      -Wl,--as-needed -ldl -lpam -lssl -lcrypto' AUXLIBS_CDB=
      'AUXLIBS_LDAP=-lldap -llber' AUXLIBS_LMDB= AUXLIBS_MYSQL=
      'AUXLIBS_PCRE=-L/usr/lib64 -lpcre' AUXLIBS_PGSQL= AUXLIBS_SQLITE=
      [...]
      [... end successful build ...]
      $ ./bin/postconf mail_version
      ./bin/postconf: error while loading shared libraries:
      libpostfix-global.so: cannot open shared object file: No such file or
      directory

      [ would have been nice to run commands in the build tree ]

      $ LD_LIBRARY_PATH="./lib"./bin/postconf mail_version
      mail_version = 2.12-20140713


      2/
      with gold:

      same make statements as above resulting in a successful build again but:

      $ LD_LIBRARY_PATH="./lib" ./bin/postconf mail_version
      ./bin/postconf: symbol lookup error: ./lib/libpostfix-util.so: undefined
      symbol: pcre_malloc

      and sure enough:

      # linked with bfd
      $ ldd bin/postconf
      linux-vdso.so.1 (0x00007fff885fe000)
      libpostfix-global.so => not found
      libpostfix-util.so => not found
      libldap-2.4.so.2 => /usr/lib64/libldap-2.4.so.2 (0x00007f70430c9000)
      libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f7042e60000)
      libc.so.6 => /lib64/libc.so.6 (0x00007f7042abd000)
      liblber-2.4.so.2 => /usr/lib64/liblber-2.4.so.2 (0x00007f70428ae000)
      libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f7042697000)
      libssl.so.1.0.0 => /usr/lib64/libssl.so.1.0.0 (0x00007f704242e000)
      libcrypto.so.1.0.0 => /usr/lib64/libcrypto.so.1.0.0 (0x00007f7042060000)
      libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7041e43000)
      /lib64/ld-linux-x86-64.so.2 (0x00007f7043312000)
      libdl.so.2 => /lib64/libdl.so.2 (0x00007f7041c3f000)
      libz.so.1 => /lib64/libz.so.1 (0x00007f7041a29000)

      # linked with gold
      $ ldd bin/postconf
      linux-vdso.so.1 (0x00007fffe5ffe000)
      libpostfix-global.so => not found
      libpostfix-util.so => not found
      libc.so.6 => /lib64/libc.so.6 (0x00007feb6e377000)
      /lib64/ld-linux-x86-64.so.2 (0x00007feb6e71a000)

      Link order seems good. No idea which behaviour is correct.

      --
      Eray
    • Viktor Dukhovni
      ... This is expected. You need to run: LD_LIBRARY_PATH=$(pwd)/lib ./bin/postconf -d mail_version ... Which you figured out. ... Right, you re building with
      Message 2 of 13 , Jul 14, 2014
        On Mon, Jul 14, 2014 at 07:16:30PM +0000, Eray Aslan wrote:

        > $ ./bin/postconf mail_version
        > ./bin/postconf: error while loading shared libraries:
        > libpostfix-global.so: cannot open shared object file: No such file or
        > directory

        This is expected. You need to run:

        LD_LIBRARY_PATH=$(pwd)/lib ./bin/postconf -d mail_version

        > [ would have been nice to run commands in the build tree ]
        >
        > $ LD_LIBRARY_PATH="./lib"./bin/postconf mail_version
        > mail_version = 2.12-20140713

        Which you figured out.

        > with gold:
        >
        > same make statements as above resulting in a successful build again but:
        >
        > $ LD_LIBRARY_PATH="./lib" ./bin/postconf mail_version
        > ./bin/postconf: symbol lookup error: ./lib/libpostfix-util.so: undefined
        > symbol: pcre_malloc

        Right, you're building with dynamicmaps=no, but SHLIB_SYSLIBS
        variable was not set quite right, see patch below. I also took
        the liberty of adding the RPATH to the shared library and plugin
        build command-lines.

        diff --git a/makedefs b/makedefs
        index 7f83b32..4828d06 100644
        --- a/makedefs
        +++ b/makedefs
        @@ -990,7 +990,7 @@ esac

        case "$shared" in
        yes) SHLIB_SYSLIBS=`${AWK} '
        - BEGIN { wc = split("'"$SYSLIBS"'", words)
        + BEGIN { wc = split("'"$SYSLIBS $AUXLIBS"'", words)
        for (n = 1; n <= wc; n++)
        if (words[n] !~ /\.a$/)
        printf(" %s", words[n])
        diff --git a/src/dns/Makefile.in b/src/dns/Makefile.in
        index b06966c..1f67499 100644
        --- a/src/dns/Makefile.in
        +++ b/src/dns/Makefile.in
        @@ -33,7 +33,7 @@ root_tests:
        $(LIB): $(OBJS)
        $(AR) $(ARFL) $(LIB) $?
        $(RANLIB) $(LIB)
        - $(SHLIB_LD) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)
        + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)

        $(LIB_DIR)/$(LIB): $(LIB)
        cp $(LIB) $(LIB_DIR)
        diff --git a/src/global/Makefile.in b/src/global/Makefile.in
        index 2498f4f..14f35c8 100644
        --- a/src/global/Makefile.in
        +++ b/src/global/Makefile.in
        @@ -138,7 +138,7 @@ test: $(TESTPROG)
        $(LIB): $(OBJS)
        $(AR) $(ARFL) $(LIB) $?
        $(RANLIB) $(LIB)
        - $(SHLIB_LD) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)
        + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)

        $(LIB_DIR)/$(LIB): $(LIB)
        cp $(LIB) $(LIB_DIR)
        @@ -147,27 +147,29 @@ $(LIB_DIR)/$(LIB): $(LIB)
        plugin_map_so_make: $(PLUGIN_MAP_SO)

        $(LIB_PREFIX)ldap$(LIB_SUFFIX): dict_ldap.o
        - $(PLUGIN_LD) -o $@ dict_ldap.o $(AUXLIBS_LDAP)
        + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_ldap.o $(AUXLIBS_LDAP)

        $(LIB_PREFIX)mysql$(LIB_SUFFIX): dict_mysql.o
        - $(PLUGIN_LD) -o $@ dict_mysql.o $(AUXLIBS_MYSQL)
        + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_mysql.o $(AUXLIBS_MYSQL)

        $(LIB_PREFIX)pgsql$(LIB_SUFFIX): dict_pgsql.o
        - $(PLUGIN_LD) -o $@ dict_pgsql.o $(AUXLIBS_PGSQL)
        + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_pgsql.o $(AUXLIBS_PGSQL)

        $(LIB_PREFIX)sqlite$(LIB_SUFFIX): dict_sqlite.o
        - $(PLUGIN_LD) -o $@ dict_sqlite.o $(AUXLIBS_SQLITE)
        + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_sqlite.o $(AUXLIBS_SQLITE)

        $(LIB_PREFIX)cdb$(LIB_SUFFIX): mkmap_cdb.o $(LIB_DIR)/dict_cdb.o
        - $(PLUGIN_LD) -o $@ mkmap_cdb.o $(LIB_DIR)/dict_cdb.o $(AUXLIBS_CDB)
        + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ mkmap_cdb.o \
        + $(LIB_DIR)/dict_cdb.o $(AUXLIBS_CDB)

        $(LIB_PREFIX)lmdb$(LIB_SUFFIX): mkmap_lmdb.o $(LIB_DIR)/dict_lmdb.o \
        $(LIB_DIR)/slmdb.o
        - $(PLUGIN_LD) -o $@ mkmap_lmdb.o $(LIB_DIR)/dict_lmdb.o \
        + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ mkmap_lmdb.o $(LIB_DIR)/dict_lmdb.o \
        $(LIB_DIR)/slmdb.o $(AUXLIBS_LMDB)

        $(LIB_PREFIX)sdbm$(LIB_SUFFIX): mkmap_sdbm.o $(LIB_DIR)/dict_sdbm.o
        - $(PLUGIN_LD) -o $@ mkmap_sdbm.o $(LIB_DIR)/dict_sdbm.o $(AUXLIBS_SDBM)
        + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ mkmap_sdbm.o \
        + $(LIB_DIR)/dict_sdbm.o $(AUXLIBS_SDBM)

        update: $(LIB_DIR)/$(LIB) $(HDRS) $(PLUGIN_MAP_SO_UPDATE)
        -for i in $(HDRS); \
        diff --git a/src/master/Makefile.in b/src/master/Makefile.in
        index 5d3bacc..4c6b607 100644
        --- a/src/master/Makefile.in
        +++ b/src/master/Makefile.in
        @@ -44,7 +44,7 @@ root_tests:
        $(LIB): $(LIB_OBJ)
        $(AR) $(ARFL) $(LIB) $?
        $(RANLIB) $(LIB)
        - $(SHLIB_LD) -o $(LIB) $(LIB_OBJ) $(SHLIB_SYSLIBS)
        + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(LIB_OBJ) $(SHLIB_SYSLIBS)

        $(LIB_DIR)/$(LIB): $(LIB)
        cp $(LIB) $(LIB_DIR)/$(LIB)
        diff --git a/src/tls/Makefile.in b/src/tls/Makefile.in
        index 814ba38..896df5e 100644
        --- a/src/tls/Makefile.in
        +++ b/src/tls/Makefile.in
        @@ -44,7 +44,7 @@ root_tests:
        $(LIB): $(OBJS)
        $(AR) $(ARFL) $(LIB) $?
        $(RANLIB) $(LIB)
        - $(SHLIB_LD) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)
        + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)

        $(LIB_DIR)/$(LIB): $(LIB)
        cp $(LIB) $(LIB_DIR)
        diff --git a/src/util/Makefile.in b/src/util/Makefile.in
        index 5a03a52..29ce751 100644
        --- a/src/util/Makefile.in
        +++ b/src/util/Makefile.in
        @@ -143,7 +143,7 @@ test: $(TESTPROG)
        $(LIB): $(OBJS)
        $(AR) $(ARFL) $(LIB) $?
        $(RANLIB) $(LIB)
        - $(SHLIB_LD) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)
        + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)

        $(LIB_DIR)/$(LIB): $(LIB)
        cp $(LIB) $(LIB_DIR)
        @@ -152,7 +152,7 @@ $(LIB_DIR)/$(LIB): $(LIB)
        plugin_map_so_make: $(PLUGIN_MAP_SO)

        $(LIB_PREFIX)pcre$(LIB_SUFFIX): dict_pcre.o
        - $(PLUGIN_LD) -o $@ dict_pcre.o $(AUXLIBS_PCRE)
        + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_pcre.o $(AUXLIBS_PCRE)

        update: $(LIB_DIR)/$(LIB) $(HDRS) $(PLUGIN_MAP_SO_UPDATE) \
        $(PLUGIN_MAP_OBJ_UPDATE)

        --
        Viktor.
      • Viktor Dukhovni
        ... Actually, AUXLIBS should come before SYSLIBS, so the correct patch is: diff --git a/makedefs b/makedefs index 7f83b32..0ccdba5 100644 ... +++ b/makedefs @@
        Message 3 of 13 , Jul 14, 2014
          On Tue, Jul 15, 2014 at 01:29:22AM +0000, Viktor Dukhovni wrote:

          > Right, you're building with dynamicmaps=no, but SHLIB_SYSLIBS
          > variable was not set quite right, see patch below. I also took
          > the liberty of adding the RPATH to the shared library and plugin
          > build command-lines.

          Actually, AUXLIBS should come before SYSLIBS, so the correct patch is:

          diff --git a/makedefs b/makedefs
          index 7f83b32..0ccdba5 100644
          --- a/makedefs
          +++ b/makedefs
          @@ -990,7 +990,7 @@ esac

          case "$shared" in
          yes) SHLIB_SYSLIBS=`${AWK} '
          - BEGIN { wc = split("'"$SYSLIBS"'", words)
          + BEGIN { wc = split("'"$AUXLIBS $SYSLIBS"'", words)
          for (n = 1; n <= wc; n++)
          if (words[n] !~ /\.a$/)
          printf(" %s", words[n])
          diff --git a/src/dns/Makefile.in b/src/dns/Makefile.in
          index b06966c..1f67499 100644
          --- a/src/dns/Makefile.in
          +++ b/src/dns/Makefile.in
          @@ -33,7 +33,7 @@ root_tests:
          $(LIB): $(OBJS)
          $(AR) $(ARFL) $(LIB) $?
          $(RANLIB) $(LIB)
          - $(SHLIB_LD) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)
          + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)

          $(LIB_DIR)/$(LIB): $(LIB)
          cp $(LIB) $(LIB_DIR)
          diff --git a/src/global/Makefile.in b/src/global/Makefile.in
          index 2498f4f..14f35c8 100644
          --- a/src/global/Makefile.in
          +++ b/src/global/Makefile.in
          @@ -138,7 +138,7 @@ test: $(TESTPROG)
          $(LIB): $(OBJS)
          $(AR) $(ARFL) $(LIB) $?
          $(RANLIB) $(LIB)
          - $(SHLIB_LD) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)
          + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)

          $(LIB_DIR)/$(LIB): $(LIB)
          cp $(LIB) $(LIB_DIR)
          @@ -147,27 +147,29 @@ $(LIB_DIR)/$(LIB): $(LIB)
          plugin_map_so_make: $(PLUGIN_MAP_SO)

          $(LIB_PREFIX)ldap$(LIB_SUFFIX): dict_ldap.o
          - $(PLUGIN_LD) -o $@ dict_ldap.o $(AUXLIBS_LDAP)
          + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_ldap.o $(AUXLIBS_LDAP)

          $(LIB_PREFIX)mysql$(LIB_SUFFIX): dict_mysql.o
          - $(PLUGIN_LD) -o $@ dict_mysql.o $(AUXLIBS_MYSQL)
          + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_mysql.o $(AUXLIBS_MYSQL)

          $(LIB_PREFIX)pgsql$(LIB_SUFFIX): dict_pgsql.o
          - $(PLUGIN_LD) -o $@ dict_pgsql.o $(AUXLIBS_PGSQL)
          + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_pgsql.o $(AUXLIBS_PGSQL)

          $(LIB_PREFIX)sqlite$(LIB_SUFFIX): dict_sqlite.o
          - $(PLUGIN_LD) -o $@ dict_sqlite.o $(AUXLIBS_SQLITE)
          + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_sqlite.o $(AUXLIBS_SQLITE)

          $(LIB_PREFIX)cdb$(LIB_SUFFIX): mkmap_cdb.o $(LIB_DIR)/dict_cdb.o
          - $(PLUGIN_LD) -o $@ mkmap_cdb.o $(LIB_DIR)/dict_cdb.o $(AUXLIBS_CDB)
          + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ mkmap_cdb.o \
          + $(LIB_DIR)/dict_cdb.o $(AUXLIBS_CDB)

          $(LIB_PREFIX)lmdb$(LIB_SUFFIX): mkmap_lmdb.o $(LIB_DIR)/dict_lmdb.o \
          $(LIB_DIR)/slmdb.o
          - $(PLUGIN_LD) -o $@ mkmap_lmdb.o $(LIB_DIR)/dict_lmdb.o \
          + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ mkmap_lmdb.o $(LIB_DIR)/dict_lmdb.o \
          $(LIB_DIR)/slmdb.o $(AUXLIBS_LMDB)

          $(LIB_PREFIX)sdbm$(LIB_SUFFIX): mkmap_sdbm.o $(LIB_DIR)/dict_sdbm.o
          - $(PLUGIN_LD) -o $@ mkmap_sdbm.o $(LIB_DIR)/dict_sdbm.o $(AUXLIBS_SDBM)
          + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ mkmap_sdbm.o \
          + $(LIB_DIR)/dict_sdbm.o $(AUXLIBS_SDBM)

          update: $(LIB_DIR)/$(LIB) $(HDRS) $(PLUGIN_MAP_SO_UPDATE)
          -for i in $(HDRS); \
          diff --git a/src/master/Makefile.in b/src/master/Makefile.in
          index 5d3bacc..4c6b607 100644
          --- a/src/master/Makefile.in
          +++ b/src/master/Makefile.in
          @@ -44,7 +44,7 @@ root_tests:
          $(LIB): $(LIB_OBJ)
          $(AR) $(ARFL) $(LIB) $?
          $(RANLIB) $(LIB)
          - $(SHLIB_LD) -o $(LIB) $(LIB_OBJ) $(SHLIB_SYSLIBS)
          + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(LIB_OBJ) $(SHLIB_SYSLIBS)

          $(LIB_DIR)/$(LIB): $(LIB)
          cp $(LIB) $(LIB_DIR)/$(LIB)
          diff --git a/src/tls/Makefile.in b/src/tls/Makefile.in
          index 814ba38..896df5e 100644
          --- a/src/tls/Makefile.in
          +++ b/src/tls/Makefile.in
          @@ -44,7 +44,7 @@ root_tests:
          $(LIB): $(OBJS)
          $(AR) $(ARFL) $(LIB) $?
          $(RANLIB) $(LIB)
          - $(SHLIB_LD) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)
          + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)

          $(LIB_DIR)/$(LIB): $(LIB)
          cp $(LIB) $(LIB_DIR)
          diff --git a/src/util/Makefile.in b/src/util/Makefile.in
          index 5a03a52..29ce751 100644
          --- a/src/util/Makefile.in
          +++ b/src/util/Makefile.in
          @@ -143,7 +143,7 @@ test: $(TESTPROG)
          $(LIB): $(OBJS)
          $(AR) $(ARFL) $(LIB) $?
          $(RANLIB) $(LIB)
          - $(SHLIB_LD) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)
          + $(SHLIB_LD) $(SHLIB_RPATH) -o $(LIB) $(OBJS) $(SHLIB_SYSLIBS)

          $(LIB_DIR)/$(LIB): $(LIB)
          cp $(LIB) $(LIB_DIR)
          @@ -152,7 +152,7 @@ $(LIB_DIR)/$(LIB): $(LIB)
          plugin_map_so_make: $(PLUGIN_MAP_SO)

          $(LIB_PREFIX)pcre$(LIB_SUFFIX): dict_pcre.o
          - $(PLUGIN_LD) -o $@ dict_pcre.o $(AUXLIBS_PCRE)
          + $(PLUGIN_LD) $(SHLIB_RPATH) -o $@ dict_pcre.o $(AUXLIBS_PCRE)

          update: $(LIB_DIR)/$(LIB) $(HDRS) $(PLUGIN_MAP_SO_UPDATE) \
          $(PLUGIN_MAP_OBJ_UPDATE)
        • Eray Aslan
          ... Thanks. Works for me. Any chance of using ${CC} for the linking stage as well? Perhaps ... +++ makedefs 2014-07-15 06:21:09.252817290 +0000 @@ -200,18
          Message 4 of 13 , Jul 14, 2014
            On Tue, Jul 15, 2014 at 02:31:59AM +0000, Viktor Dukhovni wrote:
            > Actually, AUXLIBS should come before SYSLIBS, so the correct patch is:
            >
            > diff --git a/makedefs b/makedefs

            Thanks. Works for me.

            Any chance of using ${CC} for the linking stage as well? Perhaps
            something along the lines of:

            --- makedefs 2014-07-15 04:40:08.349864932 +0000
            +++ makedefs 2014-07-15 06:21:09.252817290 +0000
            @@ -200,18 +200,18 @@
            FreeBSD.8*) SYSTYPE=FREEBSD8
            : ${SHLIB_SUFFIX=.so}
            : ${SHLIB_CFLAGS=-fPIC}
            - : ${SHLIB_LD='gcc -shared -Wl,-soname,${LIB}'}
            + : ${SHLIB_LD="${CC-gcc} -shared -Wl,-soname,\${LIB}"}
            : ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
            : ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
            - : ${PLUGIN_LD='gcc -shared'}
            + : ${PLUGIN_LD="${CC-gcc} -shared"}
            ;;
            FreeBSD.9*) SYSTYPE=FREEBSD9
            : ${SHLIB_SUFFIX=.so}
            : ${SHLIB_CFLAGS=-fPIC}
            - : ${SHLIB_LD='gcc -shared -Wl,-soname,${LIB}'}
            + : ${SHLIB_LD="${CC-gcc} -shared -Wl,-soname,\${LIB}"}
            : ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
            : ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
            - : ${PLUGIN_LD='gcc -shared'}
            + : ${PLUGIN_LD="${CC-gcc} -shared"}
            ;;
            DragonFly.*) SYSTYPE=DRAGONFLY
            ;;
            @@ -259,10 +259,10 @@
            SYSLIBS="-lresolv -lsocket -lnsl -ldl"
            : ${SHLIB_SUFFIX=.so}
            : ${SHLIB_CFLAGS=-fPIC}
            - : ${SHLIB_LD='gcc -shared -Wl,-h,${LIB}'}
            + : ${SHLIB_LD="${CC-gcc} -shared -Wl,-h,\${LIB}"}
            : ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
            : ${SHLIB_RPATH='-Wl,-R,${SHLIB_DIR}'}
            - : ${PLUGIN_LD='gcc -shared'}
            + : ${PLUGIN_LD="${CC-gcc} -shared"}
            # Stock awk breaks with >10 files.
            test -x /usr/xpg4/bin/awk && AWK=/usr/xpg4/bin/awk
            # Solaris 2.5 added usleep(), POSIX regexp, POSIX getpwnam/uid_r
            @@ -425,10 +425,10 @@
            SYSLIBS="$SYSLIBS -ldl"
            : ${SHLIB_SUFFIX=.so}
            : ${SHLIB_CFLAGS=-fPIC}
            - : ${SHLIB_LD='gcc -shared -Wl,-soname,${LIB}'}
            + : ${SHLIB_LD="${CC-gcc} -shared -Wl,-soname,\${LIB}"}
            : ${SHLIB_RPATH='-Wl,--enable-new-dtags -Wl,-rpath,${SHLIB_DIR}'}
            : ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
            - : ${PLUGIN_LD='gcc -shared'}
            + : ${PLUGIN_LD="${CC-gcc} -shared"}
            ;;
            Linux.3*) SYSTYPE=LINUX3
            case "$CCARGS" in
            @@ -463,10 +463,10 @@
            SYSLIBS="$SYSLIBS -ldl"
            : ${SHLIB_SUFFIX=.so}
            : ${SHLIB_CFLAGS=-fPIC}
            - : ${SHLIB_LD='gcc -shared -Wl,-soname,${LIB}'}
            + : ${SHLIB_LD="${CC-gcc} -shared -Wl,-soname,\${LIB}"}
            : ${SHLIB_RPATH='-Wl,--enable-new-dtags -Wl,-rpath,${SHLIB_DIR}'}
            : ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
            - : ${PLUGIN_LD='gcc -shared'}
            + : ${PLUGIN_LD="${CC-gcc} -shared"}
            ;;
            GNU.0*|GNU/kFreeBSD.[567]*)
            SYSTYPE=GNU0

            --
            Eray
          • Viktor Dukhovni
            ... Glad to hear. The missing AUXLIBS is a simple oversight, so I imagine this will be in the next snapshot. The RPATH additions are less obviously needed,
            Message 5 of 13 , Jul 15, 2014
              On Tue, Jul 15, 2014 at 06:36:44AM +0000, Eray Aslan wrote:

              > On Tue, Jul 15, 2014 at 02:31:59AM +0000, Viktor Dukhovni wrote:
              > > Actually, AUXLIBS should come before SYSLIBS, so the correct patch is:
              > >
              > > diff --git a/makedefs b/makedefs
              >
              > Thanks. Works for me.

              Glad to hear. The missing AUXLIBS is a simple oversight, so I
              imagine this will be in the next snapshot. The RPATH additions
              are less obviously needed, since all Postfix programs link to the
              full set of libraries (libglobal, libutil, ...) they need. So perhaps
              just the makedefs patch is enough.

              > Any chance of using ${CC} for the linking stage as well? Perhaps
              > something along the lines of:
              >
              > - : ${SHLIB_LD='gcc -shared -Wl,-soname,${LIB}'}
              > + : ${SHLIB_LD="${CC-gcc} -shared -Wl,-soname,\${LIB}"}

              We need a compiler that is known to support the requisite options,
              so this is not clear. Since we're only using gcc for linking, if
              it is present, it is a reasonable choice. The reason to use ${CC}
              is if per-chance gss is not even installed. I am not sure what the
              right answer is.

              --
              Viktor.
            • Eray Aslan
              ... I am trying to support those who cross compile postfix. They do have gcc installed but it is not the linker they want. -- Eray
              Message 6 of 13 , Jul 15, 2014
                On Tue, Jul 15, 2014 at 07:15:38AM +0000, Viktor Dukhovni wrote:
                > We need a compiler that is known to support the requisite options,
                > so this is not clear. Since we're only using gcc for linking, if
                > it is present, it is a reasonable choice. The reason to use ${CC}
                > is if per-chance gss is not even installed.

                I am trying to support those who cross compile postfix. They do have
                gcc installed but it is not the linker they want.

                --
                Eray
              • Wietse Venema
                ... Fine. ... What problem does this solve? Wietse
                Message 7 of 13 , Jul 15, 2014
                  Viktor Dukhovni:
                  > On Tue, Jul 15, 2014 at 01:29:22AM +0000, Viktor Dukhovni wrote:
                  >
                  > > Right, you're building with dynamicmaps=no, but SHLIB_SYSLIBS
                  > > variable was not set quite right, see patch below.

                  Fine.

                  > I also took
                  > > the liberty of adding the RPATH to the shared library and plugin
                  > > build command-lines.

                  What problem does this solve?

                  Wietse
                • Viktor Dukhovni
                  ... Perhaps none. Technically most of the libraries and all the plugins depend on libutil which needs a RUNPATH. However, with all the executables already
                  Message 8 of 13 , Jul 15, 2014
                    On Tue, Jul 15, 2014 at 06:46:01AM -0400, Wietse Venema wrote:

                    > > I also took
                    > > > the liberty of adding the RPATH to the shared library and plugin
                    > > > build command-lines.
                    >
                    > What problem does this solve?

                    Perhaps none. Technically most of the libraries and all the plugins
                    depend on libutil which needs a RUNPATH. However, with all the
                    executables already linked to all the libraries, this is likely
                    not needed. If there were commands or daemons that did not need
                    one of the libraries directly, the linker decided to skip the
                    "unnecessary" dependency, then we could hypothetically need to
                    explicitly link plugins with libutil and often libglobal.

                    As it stands, it is not clear this is solving any problems.

                    --
                    Viktor.
                  • Viktor Dukhovni
                    ... Makes sense, you may need to patch this yourself if you can t convince Wietse that ${CC} -shared ... is a good idea for just any old ${CC} . -- Viktor.
                    Message 9 of 13 , Jul 15, 2014
                      On Tue, Jul 15, 2014 at 10:07:30AM +0000, Eray Aslan wrote:

                      > On Tue, Jul 15, 2014 at 07:15:38AM +0000, Viktor Dukhovni wrote:
                      > > We need a compiler that is known to support the requisite options,
                      > > so this is not clear. Since we're only using gcc for linking, if
                      > > it is present, it is a reasonable choice. The reason to use ${CC}
                      > > is if per-chance gss is not even installed.
                      >
                      > I am trying to support those who cross compile postfix. They do have
                      > gcc installed but it is not the linker they want.

                      Makes sense, you may need to patch this yourself if you can't convince
                      Wietse that "${CC} -shared ..." is a good idea for just any old "${CC}".

                      --
                      Viktor.
                    • Wietse Venema
                      ... I think that it is good to make these assuptions explicit in the Postfix implementation. As for the hard-coded gcc dependency for shared-library builds,
                      Message 10 of 13 , Jul 15, 2014
                        Viktor Dukhovni:
                        > On Tue, Jul 15, 2014 at 06:46:01AM -0400, Wietse Venema wrote:
                        >
                        > > > I also took
                        > > > > the liberty of adding the RPATH to the shared library and plugin
                        > > > > build command-lines.
                        > >
                        > > What problem does this solve?
                        >
                        > Perhaps none. Technically most of the libraries and all the plugins
                        > depend on libutil which needs a RUNPATH. However, with all the
                        > executables already linked to all the libraries, this is likely
                        > not needed. If there were commands or daemons that did not need
                        > one of the libraries directly, the linker decided to skip the
                        > "unnecessary" dependency, then we could hypothetically need to
                        > explicitly link plugins with libutil and often libglobal.
                        >
                        > As it stands, it is not clear this is solving any problems.

                        I think that it is good to make these assuptions explicit in the
                        Postfix implementation.

                        As for the hard-coded gcc dependency for shared-library builds,
                        that is an oversight in quality assurance. I guess this part of
                        the patch will require the usual treatment: confirm that it works
                        with a variety of (vendor, vintage, compiler) combinations.

                        Wietse
                      • Wietse Venema
                        ... etc. I tried s/ gcc -shared/ ${CC-gcc} -shared/ on FreeBSD9 and got build errors. Unfortunately, there is no time to fix errors right before the
                        Message 11 of 13 , Jul 15, 2014
                          Eray Aslan:
                          > On Tue, Jul 15, 2014 at 02:31:59AM +0000, Viktor Dukhovni wrote:
                          > > Actually, AUXLIBS should come before SYSLIBS, so the correct patch is:
                          > >
                          > > diff --git a/makedefs b/makedefs
                          >
                          > Thanks. Works for me.
                          >
                          > Any chance of using ${CC} for the linking stage as well? Perhaps
                          > something along the lines of:
                          >
                          > --- makedefs 2014-07-15 04:40:08.349864932 +0000
                          > +++ makedefs 2014-07-15 06:21:09.252817290 +0000
                          > @@ -200,18 +200,18 @@
                          > FreeBSD.8*) SYSTYPE=FREEBSD8
                          > : ${SHLIB_SUFFIX=.so}
                          > : ${SHLIB_CFLAGS=-fPIC}
                          > - : ${SHLIB_LD='gcc -shared -Wl,-soname,${LIB}'}
                          > + : ${SHLIB_LD="${CC-gcc} -shared -Wl,-soname,\${LIB}"}
                          > : ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
                          > : ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
                          > - : ${PLUGIN_LD='gcc -shared'}
                          > + : ${PLUGIN_LD="${CC-gcc} -shared"}

                          etc. I tried s/'gcc -shared/'${CC-gcc} -shared/ on FreeBSD9 and
                          got build errors. Unfortunately, there is no time to fix errors
                          right before the postfix-2.12-20140715 release.

                          Wietse
                        • Eray Aslan
                          ... On a semi-related note, a bump in cross compiling postfix is the postconf command used in the postfix-install script. The script calls postconf to get
                          Message 12 of 13 , Jul 17, 2014
                            On Tue, Jul 15, 2014 at 11:06:42AM +0000, Viktor Dukhovni wrote:
                            > On Tue, Jul 15, 2014 at 10:07:30AM +0000, Eray Aslan wrote:
                            > > I am trying to support those who cross compile postfix. They do have
                            > > gcc installed but it is not the linker they want.
                            >
                            > Makes sense, you may need to patch this yourself if you can't convince
                            > Wietse that "${CC} -shared ..." is a good idea for just any old "${CC}".

                            On a semi-related note, a bump in cross compiling postfix is the
                            postconf command used in the postfix-install script. The script calls
                            postconf to get mail version, config directory, installed defaults and
                            to prepare main.cf for installation. However, in a cross compile
                            environment, the bin/postconf binary is for a different architecture
                            than the build host and therefore does not work.

                            I have seen people patch postfix-install and replace bin/postconf with
                            /usr/bin/postconf - requires postfix to be already installed in the
                            build machine - to work around the issue.

                            Any suggestions on what would be a good/acceptable solution? Or even
                            whether it is worth the trouble?

                            --
                            Eray
                          • Wietse Venema
                            ... This is adopted into postfix-2.12-20140716. ... Both the procedures that *build* Postfix and those that *install* Postfix require programs and shared
                            Message 13 of 13 , Jul 17, 2014
                              Eray Aslan:
                              > On Tue, Jul 15, 2014 at 11:06:42AM +0000, Viktor Dukhovni wrote:
                              > > On Tue, Jul 15, 2014 at 10:07:30AM +0000, Eray Aslan wrote:
                              > > > I am trying to support those who cross compile postfix. They do have
                              > > > gcc installed but it is not the linker they want.
                              > >
                              > > Makes sense, you may need to patch this yourself if you can't convince
                              > > Wietse that "${CC} -shared ..." is a good idea for just any old "${CC}".

                              This is adopted into postfix-2.12-20140716.

                              > On a semi-related note, a bump in cross compiling postfix is the
                              > postconf command used in the postfix-install script. The script calls
                              > postconf to get mail version, config directory, installed defaults and
                              > to prepare main.cf for installation. However, in a cross compile
                              > environment, the bin/postconf binary is for a different architecture
                              > than the build host and therefore does not work.

                              Both the procedures that *build* Postfix and those that *install*
                              Postfix require programs and shared libraries(!) from that same
                              Postfix version. Without this I'd have a chicken and egg problem.

                              You are welcome to try to make those dependencies configurable,
                              from the "built" programs that are used now, to the "native" programs
                              that you want to use instead.

                              However, there is no reasonable way that I can support this. Those
                              "native" programs would have to be the same Postfix version, and
                              they would need to be built with similar-enough compile-time options
                              so that they will be "compatible enough" with the cross-compiled
                              product. The problem is that no-one can specify what "similar enough"
                              or "compatible enough" means. Thus, I cannot promise that something
                              is supported because I can't say what that means.

                              Wietse
                            Your message has been successfully submitted and would be delivered to recipients shortly.