public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Fabian Groffen (grobian)" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] gentoo-x86 commit in eclass: toolchain-funcs.eclass
Date: Sat, 04 Apr 2009 17:17:56 +0000	[thread overview]
Message-ID: <E1Lq9VE-0007O9-Vd@stork.gentoo.org> (raw)

grobian     09/04/04 17:17:56

  Modified:             toolchain-funcs.eclass
  Log:
  Add support for all Prefix arches, in particular for gen_usr_ld_script, and add AIX specific function, backport from Prefix

Revision  Changes    Path
1.89                 eclass/toolchain-funcs.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/toolchain-funcs.eclass?rev=1.89&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/toolchain-funcs.eclass?rev=1.89&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/toolchain-funcs.eclass?r1=1.88&r2=1.89

Index: toolchain-funcs.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- toolchain-funcs.eclass	28 Mar 2009 11:09:27 -0000	1.88
+++ toolchain-funcs.eclass	4 Apr 2009 17:17:56 -0000	1.89
@@ -1,6 +1,6 @@
 # Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.88 2009/03/28 11:09:27 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.89 2009/04/04 17:17:56 grobian Exp $
 
 # @ECLASS: toolchain-funcs.eclass
 # @MAINTAINER:
@@ -165,6 +165,43 @@
 	[[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
 
 	case ${host} in
+		powerpc-apple-darwin*)
+					echo ppc-macos;;
+		powerpc64-apple-darwin*)
+					echo ppc64-macos;;
+		i?86-apple-darwin*)
+					echo x86-macos;;
+		x86_64-apple-darwin*)
+					echo x64-macos;;
+		sparc-sun-solaris*)
+					echo sparc-solaris;;
+		sparcv9-sun-solaris*)
+					echo sparc64-solaris;;
+		i?86-pc-solaris*)
+					echo x86-solaris;;
+		x86_64-pc-solaris*)
+					echo x64-solaris;;
+		powerpc-ibm-aix*)
+					echo ppc-aix;;
+		mips-sgi-irix*)
+					echo mips-irix;;
+		ia64-hp-hpux*)
+					echo ia64-hpux;;
+		i?86-pc-freebsd*)
+					echo x86-freebsd;;
+		x86_64-pc-freebsd*)
+					echo x64-freebsd;;
+		i?86-pc-netbsd*)
+					echo x86-netbsd;;
+		i?86-pc-interix*)
+					echo x86-interix;;
+		i?86-pc-winnt*)
+					echo x86-winnt;;
+		i*-pc-freebsd*)
+					echo x86-freebsd;;
+		x86_64-pc-freebsd*)
+					echo x64-freebsd;;
+
 		alpha*)		echo alpha;;
 		arm*)		echo arm;;
 		avr*)		ninj avr32 avr;;
@@ -418,11 +455,60 @@
 	[[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
 
 	for lib in "$@" ; do
-		if [[ ${USERLAND} == "Darwin" ]] ; then
-			ewarn "Not creating fake dynamic library for $lib on Darwin;"
-			ewarn "making a symlink instead."
-			dosym "/${libdir}/${lib}" "/usr/${libdir}/${lib}"
-		else
+
+		# Ensure /lib/${lib} exists to avoid dangling scripts/symlinks.
+		# This especially is for AIX where $(get_libname) can return ".a",
+		# so /lib/${lib} might be moved to /usr/lib/${lib} (by accident).
+		[[ -r "${ED}"/${libdir}/${lib} ]] || continue
+
+		case ${CHOST} in
+		*-darwin*)
+			# Mach-O files have an id, which is like a soname, it tells how
+			# another object linking against this lib should reference it.
+			# Since we moved the lib from usr/lib into lib this reference is
+			# wrong.  Hence, we update it here.  We don't configure with
+			# libdir=/lib because that messes up libtool files.
+			# Make sure we don't lose the specific version, so just modify the
+			# existing install_name
+			install_name=$(otool -DX "${ED}"/${libdir}/${lib})
+			[[ -z ${install_name} ]] && die "No install name found for ${ED}/${libdir}/${lib}"
+			install_name_tool \
+				-id "${EPREFIX}"/${libdir}/${install_name##*/} \
+				"${ED}"/${libdir}/${lib}
+			# Now as we don't use GNU binutils and our linker doesn't
+			# understand linker scripts, just create a symlink.
+			pushd "${ED}/usr/${libdir}" > /dev/null
+			ln -snf "../../${libdir}/${lib}" "${lib}"
+			popd > /dev/null
+			;;
+		*-aix*|*-irix*|*-hpux*)
+			# we don't have GNU binutils on these platforms, so we symlink
+			# instead, which seems to work fine.  Keep it relative, otherwise
+			# we break some QA checks in Portage
+			pushd "${ED}/usr/${libdir}" > /dev/null
+			ln -snf "../../${libdir}/${lib}" "${lib}"
+			popd > /dev/null
+			;;
+		*-interix*|*-winnt*)
+			# on interix, the linker scripts would work fine in _most_
+			# situations. if a library links to such a linker script the
+			# absolute path to the correct library is inserted into the binary,
+			# which is wrong, since anybody linking _without_ libtool will miss
+			# some dependencies, since the stupid linker cannot find libraries
+			# hardcoded with absolute paths (as opposed to the loader, which
+			# seems to be able to do this).
+			# this has been seen while building shared-mime-info which needs
+			# libxml2, but links without libtool (and does not add libz to the
+			# command line by itself).
+			pushd "${ED}/usr/${libdir}" > /dev/null
+			ln -snf "../../${libdir}/${lib}" "${lib}"
+			popd > /dev/null
+			;;
+		*-mint*)
+			# do nothing
+			return
+			;;
+		*)	
 			local tlib
 			if ${auto} ; then
 				lib="lib${lib}${suffix}"
@@ -450,7 +536,93 @@
 			${output_format}
 			GROUP ( /${libdir}/${tlib} )
 			END_LDSCRIPT
-			fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}"
+			;;
+		esac
+		fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}"
+	done
+}
+
+# This function is for AIX only.
+#
+# Showing a sample IMO is the best description:
+#
+# First, AIX has its own /usr/lib/libiconv.a containing 'shr.o' and 'shr4.o'.
+# Both of them are shared-objects packed into an archive, thus /usr/lib/libiconv.a
+# is a shared library (!), even it is called lib*.a.
+# This is the default layout on aix for shared libraries.
+# Read the ld(1) manpage for more information.
+#
+# But now, we want to install GNU libiconv (sys-libs/libiconv) both as
+# shared and static library.
+# AIX (since 4.3) can create shared libraries if '-brtl' or '-G' linker flags
+# are used.
+#
+# Now assume we have GNU tar installed while GNU libiconv was not.
+# This tar now has a runtime dependency on "libiconv.a(shr4.o)".
+# With our ld-wrapper (from sys-devel/binutils-config) we add EPREFIX/usr/lib
+# as linker path, thus it is recorded as loader path into the binary.
+#
+# When having libiconv.a (the static GNU libiconv) in prefix, the loader finds
+# that one and claims that it does not contain an 'shr4.o' object file:
+#
+#     Could not load program tar:
+#           Dependent module EPREFIX/usr/lib/libiconv.a(shr4.o) could not be loaded.
+#           Member shr4.o is not found in archive
+#
+# According to gcc's "host/target specific installation notes" for *-ibm-aix* [1],
+# we can extract that 'shr4.o' from /usr/lib/libiconv.a, mark it as
+# non-linkable, and include it in our new static library.
+#
+# [1] http://gcc.gnu.org/install/specific.html#x-ibm-aix
+#
+# usage:
+# keep_aix_runtime_object <target-archive inside EPREFIX> <source-archive(objects)>
+# keep_aix_runtime_object "/usr/lib/libiconv.a "/usr/lib/libiconv.a(shr4.o,...)"
+keep_aix_runtime_objects() {
+	[[ ${CHOST} == *-*-aix* ]] || return 0
+
+	local target=$1
+	shift
+	local sources="$@"
+
+	# strip possible ${ED} prefixes
+	target=${target##/}
+	target=${target#${D##/}}
+	target=${target#${EPREFIX##/}}
+	target=${target##/}
+
+	if ! $(tc-getAR) -t "${ED}${target}" &>/dev/null; then
+		if [[ -e ${ED}${target} ]]; then
+			ewarn "${target} is not an archive."
 		fi
+		return 0
+	fi
+
+	local tmpdir=${TMP}/keep_aix_runtime_object-$$
+	mkdir ${tmpdir} || die
+
+	local origdir=$(pwd)
+	local s
+	for s in ${sources}; do
+		local sourcelib sourceobjs so
+		# format of $s: "/usr/lib/libiconv.a(shr4.o,shr.o)"
+		sourcelib=${s%%(*}
+		sourceobjs=${s#*(}
+		sourceobjs=${sourceobjs%)}
+		sourceobjs=${sourceobjs//,/ }
+		cd ${tmpdir} || die
+		for so in ${sourceobjs}; do
+			ebegin "keeping aix runtime object '${sourcelib}(${so})' in '${EPREFIX}/${target}'"
+			if ! $(tc-getAR) -x "${sourcelib}" ${so}; then
+				eend 1
+			   	continue
+			fi
+			chmod +w ${so} &&
+			$(tc-getSTRIP) -e ${so} &&
+			$(tc-getAR) -q "${ED}${target}" ${so} &&
+			eend 0 ||
+			eend 1
+		done
 	done
+	cd "${origdir}"
 }






             reply	other threads:[~2009-04-04 17:17 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-04 17:17 Fabian Groffen (grobian) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-05-28  7:51 [gentoo-commits] gentoo-x86 commit in eclass: toolchain-funcs.eclass Mike Frysinger (vapier)
2015-04-13  5:38 Mike Frysinger (vapier)
2015-03-31  4:27 Mike Frysinger (vapier)
2015-03-16 21:12 Mike Frysinger (vapier)
2015-03-16 19:26 Mike Frysinger (vapier)
2015-03-10 17:56 Mike Frysinger (vapier)
2015-02-27  6:08 Mike Frysinger (vapier)
2014-11-01  5:19 Mike Frysinger (vapier)
2014-10-15 22:52 Anthony G. Basile (blueness)
2014-10-15 22:30 Anthony G. Basile (blueness)
2014-10-15 22:27 Anthony G. Basile (blueness)
2014-01-17  3:46 Mike Frysinger (vapier)
2014-01-14 20:48 Mike Frysinger (vapier)
2014-01-14  5:33 Mike Frysinger (vapier)
2013-10-12 21:31 Mike Frysinger (vapier)
2013-09-30  1:34 Mike Frysinger (vapier)
2013-05-14 20:40 Mike Frysinger (vapier)
2012-12-29  5:08 Mike Frysinger (vapier)
2012-09-13  5:06 Mike Frysinger (vapier)
2012-07-26 16:43 Mike Frysinger (vapier)
2012-07-25 18:27 Mike Frysinger (vapier)
2012-07-21 16:11 Mike Frysinger (vapier)
2012-06-14  3:38 Mike Frysinger (vapier)
2012-05-10  3:31 Mike Frysinger (vapier)
2011-12-10 19:45 Mike Frysinger (vapier)
2011-10-17 19:11 Mike Frysinger (vapier)
2011-09-12 21:42 Mike Frysinger (vapier)
2011-09-09 19:14 Mike Frysinger (vapier)
2011-09-06 22:54 Mike Frysinger (vapier)
2011-07-12 14:29 Alexis Ballier (aballier)
2010-10-28  4:16 Mike Frysinger (vapier)
2010-09-11 17:12 Mike Frysinger (vapier)
2010-08-20 15:04 Donnie Berkholz (dberkholz)
2010-05-23  2:00 Mike Frysinger (vapier)
2010-04-22 18:28 Raul Porcel (armin76)
2010-03-15 23:51 Mike Frysinger (vapier)
2009-12-01  4:44 Mike Frysinger (vapier)
2009-11-27 21:31 Mike Frysinger (vapier)
2009-09-02 20:08 Fabian Groffen (grobian)
2009-09-02  9:00 Fabian Groffen (grobian)
2009-08-15 15:12 Fabian Groffen (grobian)
2009-08-15 15:11 Fabian Groffen (grobian)
2009-05-24  7:25 Fabian Groffen (grobian)
2009-04-05  7:50 Fabian Groffen (grobian)
2009-03-28 11:09 Mike Frysinger (vapier)
2009-03-01  8:09 Mike Frysinger (vapier)
2009-02-25  0:25 Joshua Kinard (kumba)
2009-01-27 23:35 Mike Frysinger (vapier)
2009-01-08 11:06 Gordon Malm (gengor)
2009-01-08  9:56 Gordon Malm (gengor)
2009-01-08  6:33 Gordon Malm (gengor)
2009-01-08  3:46 Gordon Malm (gengor)
2008-09-16  6:40 Mike Frysinger (vapier)
2008-07-03  5:26 Donnie Berkholz (dberkholz)
2008-06-01  8:56 Alexis Ballier (aballier)
2008-04-16 14:16 Mike Frysinger (vapier)
2008-01-02  1:01 Mike Frysinger (vapier)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1Lq9VE-0007O9-Vd@stork.gentoo.org \
    --to=grobian@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox