pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[solved] Re: how to add linker path (or remove "-lgcc"?)




On Sat, Aug 15, 2015 at 07:06:13PM +0200, Matthias Ferdinand wrote:
...
> Background: I am trying to install pkgin-0.9.1 on a Linux host (SuSE
> 10.0) using a non-pkgsrc self-bootstrapped gcc-4.7.4 at
> /opt/gcc-4.7.4/{bin,lib,...}. Linking fails with 
>     /usr/bin/ld: cannot find -lgcc
> ("-lgcc" apparently introduced by /opt/pkgsrc/share/mk/bsd.prog.mk). It
> seems -lgcc is not really required for pkgin, but might be required for
> other packages.

A better way to phrase the question: how not to have the library
path removed by wrappers? gcc invoked the ld command with all the
-L<path> arguments needed, but the wrappers would just throw them away,
and libgcc.a could not be found.

The wrapper scripts remove any directory-related command line options
unless they are explicitly whitelisted (s.
mk/buildlink3/bsd.buildlink3.mk). 

Without the proper hints, the ld wrapper is actively discriminating
against non-pkgsrc / non-system compilers.

Solution: set

    COMPILER_LIB_DIRS=     </gcc/base/dir>/lib
    COMPILER_INCLUDE_DIRS= </gcc/base/dir>/include

in mk.conf.

In my case, </gcc/base/dir> is /opt/gcc-4.7.4

Then these directories are not getting removed anymore from gcc or ld
argument lists.

This is somewhat underdocumented. Here is a proposal to have it at
least mentioned in the pkgsrc guide:


-------------------------------------------------------------------------------
26.2. Adding support for a new compiler

[FIXME: incomplete]

If you want to use a new compiler to produce binaries from your pkgsrc
installation, you need to at least set the CC, CPP and CXX variables in your
mk.conf accordingly.

There are quite a few more variables that might or might not need some
tweaking.  For inspiration, look at the various files in mk/compiler/.

An incomplete list: _COMPILER_ABI_FLAG.32, _COMPILER_ABI_FLAG.64,
_COMPILER_LD_FLAG, _COMPILER_RPATH_FLAG.

If the compiler has libraries and/or include files of its own you should
also set COMPILER_LIB_DIRS and COMPILER_INCLUDE_DIRS. Otherwise any
command line argument using these directories might be dropped by the
pkgsrc wrappers.

[FIXME: using a new compiler for bootstrapping]

[FIXME: adding compiler support in mk/compiler/]


-------------------------------------------------------------------------------


Regards
Matthias


Home | Main Index | Thread Index | Old Index