ports/167069: libtool does not respect CC when linking shared library

Tijl Coosemans tijl at coosemans.org
Wed Apr 18 17:20:05 UTC 2012


>Number:         167069
>Category:       ports
>Synopsis:       libtool does not respect CC when linking shared library
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 18 17:20:04 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Tijl Coosemans
>Release:        FreeBSD 10.0-CURRENT i386
>Organization:
>Environment:
>Description:
When a port sets USE_AUTOTOOLS=libtool /usr/local/bin/libtool is used
instead of the port's own libtool script as generated by configure.

The problem is that when linking shared libraries libtool will use the
compiler it was configured for, so in case of USE_AUTOTOOLS=libtool it
will use the compiler used when building devel/libtool instead of the
compiler for the port that is being built.

Here's an excerpt from
http://pointyhat.freebsd.org/errorlogs/amd64-9-full-logs/libctl-3.1_1.log

/bin/sh /usr/local/bin/libtool --tag=CC    --mode=compile gcc46 ...
libtool: compile:  gcc46 -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include ...
libtool: compile:  gcc46 -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include ...
mv -f .deps/cintegrator.Tpo .deps/cintegrator.Plo
/bin/sh /usr/local/bin/libtool --tag=CC    --mode=link gcc46  -O2 -pipe ...
libtool: link: cc -shared  -fPIC -DPIC  .libs/ctl.o .libs/subplex.o ...
libtool: link: (cd ".libs" && rm -f "libctl.so" && ln -s "libctl.so.4" ...
libtool: link: (cd ".libs" && rm -f "libctl.so" && ln -s "libctl.so.4" ...
libtool: link: ar cru .libs/libctl.a  ctl.o subplex.o ctl-f77-glue.o ...
libtool: link: ranlib .libs/libctl.a
libtool: link: ( cd ".libs" && rm -f "libctl.la" && ln -s "../libctl.la" ...

The first libtool command (--mode=compile) works. It compiles a
shared and a static version of a C file using gcc46. The second
command (--mode=libtool) is incorrect. It uses cc instead of gcc46
to create the shared library.

This affects ports that set USE_GCC/FORTRAN and users that set CC/CXX to
use clang or a more recent version of gcc. The resulting library may be
linked with the wrong runtime libraries and features such as link time
optimisation don't work.
>How-To-Repeat:
>Fix:
I haven't got a fix, but I've analysed the problem somewhat.

In compile mode libtool uses the compiler given on the command line,
so this always works. Link mode for an executable does the same. Link
mode for a library however executes $archive_cmds, which is defined as:

archive_cmds="\$CC -shared \$pic_flag \$libobjs \$deplibs ...

and CC is set to the compiler used during configure.

Perhaps libtool can be patched to make this mode work like the other
modes. An alternative would be to make USE_AUTOTOOLS=libtool run
libtoolize instead of patching the port to use /usr/local/bin/libtool.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list