summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2009-10-22 13:07:27 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2009-11-05 18:13:17 +0100
commitfb2214df0930ed07686ecda84309c1722ce95299 (patch)
treea309b0997d900b5568c50f7a06fe12df52c1fe0e
parent2b18f326648a1fd59d720e464363a7a5596ffe0b (diff)
downloadOSELAS.Toolchain-fb2214df0930ed07686ecda84309c1722ce95299.tar.gz
[cross-gcc] fix dynamic linking problem with libstdc++OSELAS.Toolchain-1.99.3.5
We must have the 'libstdc++.so' in both '$SYSROOT/usr/lib' and the compiler's '$TARGET/lib' directory. If missing in '$TARGET/lib' linking a C++ application with 'g++' results in linking the 'libstdc++' statically. If missing in '$SYSROOT/usr/lib' the 'ld' of newer binutils won't find the libstdc++ under certain circumstances, e.g.: Linking a C application with 'gcc' against a shared library implemented in C++. With this patch we move the shared libs to '$SYSROOT/usr/lib' and create links in '$TARGET/lib'. So that everybody shoud be happy. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--rules/cross-gcc.make27
-rwxr-xr-xscripts/ptxd_abs2rel.sh45
2 files changed, 65 insertions, 7 deletions
diff --git a/rules/cross-gcc.make b/rules/cross-gcc.make
index 3450ecf..1dc9fbf 100644
--- a/rules/cross-gcc.make
+++ b/rules/cross-gcc.make
@@ -1,5 +1,4 @@
# -*-makefile-*-
-# $Id$
#
# Copyright (C) 2006 by Robert Schwebel
# 2008, 2009 by Marc Kleine-Budde <mkl@pengutronix.de>
@@ -30,6 +29,8 @@ CROSS_GCC_URL := \
ftp://sourceware.org/pub/gcc/snapshots/$(CROSS_GCC_VERSION)/$(CROSS_GCC).$(CROSS_GCC_SUFFIX) \
ftp://sourceware.org/pub/gcc/releases/$(CROSS_GCC)/$(CROSS_GCC).$(CROSS_GCC_SUFFIX)
+ptx/abs2rel := $(PTXDIST_WORKSPACE)/scripts/ptxd_abs2rel.sh
+
# ----------------------------------------------------------------------------
# Get
# ----------------------------------------------------------------------------
@@ -149,18 +150,30 @@ $(STATEDIR)/cross-gcc.compile:
$(STATEDIR)/cross-gcc.install:
@$(call targetinfo)
- cd $(CROSS_GCC_BUILDDIR) && \
+ @cd $(CROSS_GCC_BUILDDIR) && \
$(CROSS_GCC_PATH) $(MAKE) install
@cd "$(PTXCONF_SYSROOT_CROSS)/$(PTX_TOUPLE_TARGET)/lib"; \
+ rel="$$($(ptx/abs2rel) "$${PWD}" "$(SYSROOT)/usr/lib")" && \
for file in \
- libstdc++*.so* \
- libssp*.so* \
- libgfortran*.so* \
- libg2c*.so* \
+ libg2c.*so* \
+ libgcc_s.*so* \
+ libgfortran.*so* \
+ libgomp.*so* \
+ libmudflap.*so* \
+ libmudflapth.*so* \
+ libssp.*so* \
+ libstdc++.*so* \
; do \
[ \! -e "$${file}" ] && continue; \
- mv -v -f "$${file}" "$(SYSROOT)/usr/lib" || exit 1; \
+ \
+ rel_file="$${rel}/$${file}"; \
+ if [ -L "$${file}" ]; then \
+ cp -vdpR "$${file}" "$${rel_file}"; \
+ else \
+ mv -vf "$${file}" "$${rel_file}" && \
+ ln -vfs "$${rel_file}" "$${file}"; \
+ fi || exit 1; \
done
@find $(PTXCONF_SYSROOT_CROSS) -name "*.la" | while read la_file; do \
diff --git a/scripts/ptxd_abs2rel.sh b/scripts/ptxd_abs2rel.sh
new file mode 100755
index 0000000..d122806
--- /dev/null
+++ b/scripts/ptxd_abs2rel.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Copyright (C) 2009 by Marc Kleine-Budde <mkl@pengutronix.de>
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+ptxd_abs2rel() {
+ local from from_parts to to_parts max orig_IFS
+
+ [ ${#} -eq 2 ] || { echo "supply exactly two paths" >&2; exit 1; }
+
+ from="${1}"
+ to="${2}"
+
+ orig_IFS="${IFS}"
+ IFS="/"
+ from_parts=(${from#/})
+ to_parts=(${to#/})
+
+ if [ ${#from_parts[@]} -gt ${#to_parts[@]} ]; then
+ max=${#from_parts[@]}
+ else
+ max=${#to_parts[@]}
+ fi
+
+ for ((i = 0; i < ${max}; i++)); do
+ from="${from_parts[i]}"
+ to="${to_parts[i]}"
+
+ if [ "${from}" = "${to}" ]; then
+ unset from_parts[$i]
+ unset to_parts[$i]
+ elif [ -n "${from}" ]; then
+ from_parts[$i]=".."
+ fi
+ done
+
+ echo "${from_parts[*]}${from_parts[*]:+/}${to_parts[*]}"
+ IFS="${orig_IFS}"
+}
+
+ptxd_abs2rel "${@}"