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

Re: [patches] Allow ports to define the version of libgcc_s



On Mon, Aug 17, 2009 at 10:44 AM, Maxim Kuvyrkov<maxim@xxxxxxxxxxxxxxxx> wrote:
>> There will always be multiple versions of libgcc_s.so installed, and
>> the one to use for a new glibc is always the most recent version e.g.
>> `ls -a /lib/libgcc_s.so* | tail -1`
>
> This will not work for cases when libgcc_s.so installed in a different
> sysroot.  It is necessary to detect the very libgcc_s.so, which GCC links
> against; this can be done, e.g., by a configure script building an example
> program which calls, say, _Unwind_GetCFA() and then checking how GCC invokes
> the linker.  Maybe there's a simpler way, though... Suggestions?

This should work...

# PREFIX - Location of the installed tools.
# GCCMACH - Canonical GNU name for target.
# GCCMULTIDIR - Sub-directory name of the multilib
# SYSROOT_DIR - Absolute path to the specified sysroot directory.
PREFIX=$(shell $(TARGET_CC) -print-libgcc-file-name | sed -e
's,/bin/../lib/gcc/.*,,g')
GCCMACH=$(shell $(TARGET_CC) -dumpmachine)
GCCMULTIDIR=$(shell $(TARGET_CC) $(TARGET_CFLAGS) -print-multi-directory)
SYSROOT_DIR="${PREFIX}/${GCCMACH}/libc/${GCCMULTIDIR}"

... Build sample application with "-lgcc_s" ...
... Use readelf to extract NEEDED entry e.g. libgcc_s.so.1 ...
... Using readelf search list of all libgcc_s.so* files in
$(SYSROOT_DIR)/lib/ for one whose SONAME matches the NEEDED entry. Use
the first match you find as the shared library file to use...

Cheers,
Carlos.