summaryrefslogtreecommitdiff
path: root/sys-libs/netbsd-csu
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-libs/netbsd-csu
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-libs/netbsd-csu')
-rw-r--r--sys-libs/netbsd-csu/Manifest3
-rw-r--r--sys-libs/netbsd-csu/metadata.xml7
-rw-r--r--sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild130
3 files changed, 140 insertions, 0 deletions
diff --git a/sys-libs/netbsd-csu/Manifest b/sys-libs/netbsd-csu/Manifest
new file mode 100644
index 000000000000..e38ac0ac7099
--- /dev/null
+++ b/sys-libs/netbsd-csu/Manifest
@@ -0,0 +1,3 @@
+DIST netbsd-csu-7.1.tar.xz 993460 SHA256 8e0adb83d9fe0954b4b361eb317e6e56f202ddf3830034739875b4f08a04687b SHA512 834524a3ada2a4c02e7eb17d8be09cf023b91e64627f3b2abc32d4f3302e982dcf0939406dc8d6c0ec7ca5e641d2d1845885bb22a165b3d6a1979c2945e2aaad WHIRLPOOL 7a965d81d6a0d7116c2f4b34019cad0293f2d72a8953827dc4d951452e81bae4af3e96fb6528501353de9b07b5abff8dcd532bb4e65d66de337aa97b97e1142e
+EBUILD netbsd-csu-7.1.ebuild 3099 SHA256 674689951286339ccb35461da2c148d31a9553f3c1f8a374c19064ae820312d6 SHA512 6b2e25c5a2c38add7f9b91bf0c03fe4ae4baad4cd645c19d0cfc9004cd85ce16eec2c66bee701487a6b3f48b6985d317f04d87c74d9c7dbd0df48fcce8808f7c WHIRLPOOL 78c8562fb025bd7d5c39c64d8a8037721fa62e7ebadf9ab7dd10e1d7375ca17c28f5e47d5b15a30d8ce133225d04a7ba4caf093962c3eb76d2a402f46dcf5138
+MISC metadata.xml 216 SHA256 e94ba81dd2791908508a3993afdebf723cc617314c53c273b9bcca15a9c48327 SHA512 3485598147c953e72e1785693a489a7e7d73d59620b76054db9c0ce95d8bfa0e8ffec29da7f7a9d73a32e5b77eac07ca3306c56a972dc57fd89d477edaebf3d5 WHIRLPOOL 29145f5721e079e0548c5ef22424c65e6a5b2bfc4428918e923fcfdfc37e9b8749fb63e3c2eb5773c17fab276f7513dd66e326b906f1848911dceba7ae4b419a
diff --git a/sys-libs/netbsd-csu/metadata.xml b/sys-libs/netbsd-csu/metadata.xml
new file mode 100644
index 000000000000..89c4bdb96049
--- /dev/null
+++ b/sys-libs/netbsd-csu/metadata.xml
@@ -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
index 000000000000..bacdd60d24fa
--- /dev/null
+++ b/sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild
@@ -0,0 +1,130 @@
+# 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_test() {
+ local cc=(
+ # -B sets prefix for internal gcc/clang file lookup
+ $(tc-getCC) -B"${BUILD_DIR}"
+ )
+
+ # 1. figure out the correct location for crt* files
+ if tc-is-gcc; then
+ # gcc requires crt*.o in multi-dir
+ local multidir=$("${cc[@]}" -print-multi-directory)
+ if [[ ${multidir} != . ]]; then
+ ln -s . "${multidir}" || die
+ fi
+ elif tc-is-clang; then
+ # clang is entirely happy with crt*.o in -B
+ :
+ else
+ eerror "Unsupported compiler for tests ($(tc-getCC))"
+ return
+ fi
+
+ # 2. verify that the compiler can use our crtbegin/crtend
+ local crtbegin=$("${cc[@]}" -print-file-name=crtbegin.o) || die
+ local crtend=$("${cc[@]}" -print-file-name=crtend.o) || die
+ if [[ ! ${crtbegin} -ef ${BUILD_DIR}/crtbegin.o ]]; then
+ die "Compiler uses wrong crtbegin: ${crtbegin}"
+ fi
+ if [[ ! ${crtend} -ef ${BUILD_DIR}/crtend.o ]]; then
+ die "Compiler uses wrong crtend: ${crtend}"
+ fi
+
+ cat > hello.c <<-EOF || die
+ #include <stdio.h>
+
+ __attribute__((constructor))
+ static void ctor_test()
+ {
+ fputs("ctor:", stdout);
+ }
+
+ __attribute__((destructor))
+ static void dtor_test()
+ {
+ fputs(":dtor", stdout);
+ }
+
+ int main()
+ {
+ fputs("main", stdout);
+ return 0;
+ }
+ EOF
+
+ emake -f /dev/null CC="${cc[*]}" hello
+
+ local out=$(./hello) || die
+ if [[ ${out} != ctor:main:dtor ]]; then
+ eerror "Invalid output from the test case."
+ eerror " Expected: ctor:main:dtor"
+ eerror " Output : ${out}"
+ die "Test failed for ${ABI:-${ARCH}}"
+ fi
+}
+
+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"
+}