sys-libs/netbsd-csu: Package crt{begin,end} from NetBSD, for clang
authorMichał Górny <mgorny@gentoo.org>
Tue, 13 Jun 2017 14:18:25 +0000 (16:18 +0200)
committerMichał Górny <mgorny@gentoo.org>
Wed, 14 Jun 2017 17:04:27 +0000 (19:04 +0200)
sys-libs/netbsd-csu/Manifest [new file with mode: 0644]
sys-libs/netbsd-csu/metadata.xml [new file with mode: 0644]
sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild [new file with mode: 0644]

diff --git a/sys-libs/netbsd-csu/Manifest b/sys-libs/netbsd-csu/Manifest
new file mode 100644 (file)
index 0000000..0849efe
--- /dev/null
@@ -0,0 +1 @@
+DIST netbsd-csu-7.1.tar.xz 993460 SHA256 8e0adb83d9fe0954b4b361eb317e6e56f202ddf3830034739875b4f08a04687b SHA512 834524a3ada2a4c02e7eb17d8be09cf023b91e64627f3b2abc32d4f3302e982dcf0939406dc8d6c0ec7ca5e641d2d1845885bb22a165b3d6a1979c2945e2aaad WHIRLPOOL 7a965d81d6a0d7116c2f4b34019cad0293f2d72a8953827dc4d951452e81bae4af3e96fb6528501353de9b07b5abff8dcd532bb4e65d66de337aa97b97e1142e
diff --git a/sys-libs/netbsd-csu/metadata.xml b/sys-libs/netbsd-csu/metadata.xml
new file mode 100644 (file)
index 0000000..89c4bdb
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+       <maintainer type="project">
+               <email>llvm@gentoo.org</email>
+       </maintainer>
+</pkgmetadata>
diff --git a/sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild b/sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild
new file mode 100644 (file)
index 0000000..9586ae3
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit bsdmk multilib-minimal toolchain-funcs
+
+DESCRIPTION="crtbegin.o/crtend.o from NetBSD CSU for GCC-free toolchain"
+HOMEPAGE="http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/csu/"
+SRC_URI="https://dev.gentoo.org/~mgorny/dist/${P}.tar.xz"
+
+LICENSE="BSD-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE=""
+
+DEPEND="app-arch/xz-utils"
+
+S=${WORKDIR}/${P}/lib/csu
+
+src_prepare() {
+       default
+       multilib_copy_sources
+}
+
+multilib_src_compile() {
+       local inc_arch=${ABI:-${ARCH}}
+
+       # rewrite ARCH to match NetBSD includes
+       case "${inc_arch}" in
+               x86) inc_arch=i386;;
+               # x32 seems to be equivalent to amd64 as far as we're concerned
+               x32) inc_arch=amd64;;
+               arm64) inc_arch=aarch64;;
+       esac
+
+       # we need arch-specific headers for some assembler macros
+       if [[ ! -d ${WORKDIR}/${P}/sys/arch/${inc_arch} ]]; then
+               die "Unexpected ABI/ARCH: ${inc_arch}, please report"
+       fi
+       ln -s "${WORKDIR}/${P}/sys/arch/${inc_arch}/include" common/machine || die
+
+       local opts=(
+               CC="$(tc-getCC)"
+               OBJCOPY="$(tc-getOBJCOPY)"
+
+               MKPIC=yes
+               MKSTRIPIDENT=no
+       )
+       # rewrite MACHINE_ARCH to match names used in CSU
+       case "${inc_arch}" in
+               amd64) opts+=( MACHINE_ARCH=x86_64 );;
+               *) opts+=( MACHINE_ARCH="${inc_arch}" );;
+       esac
+
+       # we only need those files; crt1 and friends are provided by libc
+       opts+=( crtbegin.o crtbeginS.o crtend.o )
+
+       bsdmk_src_compile "${opts[@]}"
+}
+
+multilib_src_install() {
+       dolib crtbegin.o crtbeginS.o crtend.o
+       dosym crtbegin.o "/usr/$(get_libdir)/crtbeginT.o"
+       dosym crtend.o "/usr/$(get_libdir)/crtendS.o"
+}