mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-20 05:51:18 +02:00
coreos-cargo.eclass: Drop the CoreOS board cross-compilation eclass
With amd64 as the only supported board, the SDK host compiler can be used with EAPI=7 and the upstream cargo.eclass to build our Rust projects using 100% upstream Gentoo configuration. This also drops the std library bootstrapping package along with the eclass, since that was its only use.
This commit is contained in:
parent
dd3d4270c9
commit
416e2c6530
@ -1 +0,0 @@
|
||||
DIST rustc-1.29.1-src.tar.gz 106095241 BLAKE2B c793824bcf9bd60f5e60cc97c297807d9fb998c1fe7478056a68bcc18f8c9166d71c69d6489d1898448b0b470c152206fbe2107e49dbc9a406d4e0a3c92fc97f SHA512 3151c398a79169af7dd0735d5115112cb64858120a637eda018cb4544dd9988f7540120cc0122d2af7348968285650d8605837e9f40337ec95e549d5e8763f04
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
|
||||
<pkgmetadata>
|
||||
</pkgmetadata>
|
@ -1,64 +0,0 @@
|
||||
# Copyright 2017-2018 CoreOS, Inc.
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=6
|
||||
|
||||
inherit coreos-cargo
|
||||
|
||||
DESCRIPTION="Standard libraries for Rust"
|
||||
HOMEPAGE="http://www.rust-lang.org/"
|
||||
LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
|
||||
|
||||
SRC_URI="https://static.rust-lang.org/dist/rustc-${PV}-src.tar.gz"
|
||||
S="${WORKDIR}/rustc-${PV}-src"
|
||||
|
||||
RDEPEND="!dev-lang/rust"
|
||||
|
||||
SLOT="0/${PVR}"
|
||||
KEYWORDS="amd64 arm64"
|
||||
|
||||
src_configure() {
|
||||
# get rid of the top level Cargo.toml or else cargo tries to use this one
|
||||
# too, and we don't want that since we aren't building the whole compiler
|
||||
rm src/Cargo.toml
|
||||
|
||||
# Add the vendored crates to the local registry.
|
||||
ln -fst "${ECARGO_VENDOR}" "${S}"/src/vendor/*
|
||||
}
|
||||
|
||||
src_compile() {
|
||||
# put the target dir somewhere predictable
|
||||
local -x CARGO_TARGET_DIR="${T}/target"
|
||||
# look up required crates in our fake registry
|
||||
local -x CARGO_HOME="${ECARGO_HOME}"
|
||||
# set this required bootstrapping variable
|
||||
local -x CFG_COMPILER_HOST_TRIPLE="${RUST_TARGET}"
|
||||
# fake out the compiler so that it lets us use #!feature attributes
|
||||
# really building the std libs is bootstrapping anyway, so I don't feel bad
|
||||
local -x RUSTC_BOOTSTRAP=1
|
||||
# various required flags for compiling thes std libs
|
||||
local -x RUSTFLAGS="-C prefer-dynamic -L ${CARGO_TARGET_DIR}/${RUST_TARGET}/release/deps -Z force-unstable-if-unmarked"
|
||||
# set the metadata directory for the boostrap build
|
||||
local -x RUSTC_ERROR_METADATA_DST="${T}/target/release/build/tmp/extended-error-metadata"
|
||||
|
||||
# build the std lib, which also builds all the other important libraries
|
||||
# (core, collections, etc). build it for the target we want for this build.
|
||||
# also make sure that the jemalloc libraries are included.
|
||||
local -a features=( $(usex debug debug-jemalloc jemalloc) panic-unwind )
|
||||
cargo build -p std -v --lib $(usex debug '' --release) \
|
||||
--features "${features[*]}" \
|
||||
--manifest-path src/libstd/Cargo.toml \
|
||||
--target "${RUST_TARGET}" || die
|
||||
|
||||
cargo build -p term -v --lib $(usex debug '' --release) \
|
||||
--manifest-path src/libterm/Cargo.toml \
|
||||
--target "${RUST_TARGET}" || die
|
||||
|
||||
# Correct the directory name prior to installing it.
|
||||
mv "${CARGO_TARGET_DIR}/${RUST_TARGET}/release/deps" "${CARGO_TARGET_DIR}/${RUST_TARGET}/release/lib"
|
||||
}
|
||||
|
||||
src_install() {
|
||||
insinto "/usr/$(get_libdir)/rustlib/${RUST_TARGET}"
|
||||
doins -r "${T}/target/${RUST_TARGET}/release/lib"
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
# Copyright 2017-2018 CoreOS, Inc.
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
# @ECLASS: coreos-cargo.eclass
|
||||
# @MAINTAINER:
|
||||
# team-os@coreos.com
|
||||
# @AUTHOR:
|
||||
# David Michael <david.michael@coreos.com>
|
||||
# @BLURB: cargo cross-compilation support for CoreOS/ChromeOS targets
|
||||
|
||||
if [[ -z ${_COREOS_CARGO_ECLASS} ]]; then
|
||||
_COREOS_CARGO_ECLASS=1
|
||||
|
||||
# XXX: Don't require host dependencies to also be in the sysroot.
|
||||
CATEGORY=dev-util PN=cargo inherit cargo
|
||||
inherit toolchain-funcs
|
||||
|
||||
EXPORT_FUNCTIONS src_unpack
|
||||
|
||||
[[ ${CATEGORY}/${PN} != dev-libs/rustlib ]] && DEPEND="|| (
|
||||
dev-libs/rustlib:=
|
||||
dev-util/cargo
|
||||
)"
|
||||
|
||||
# @FUNCTION: coreos-cargo_src_unpack
|
||||
# @DESCRIPTION:
|
||||
# This amends the src_unpack from cargo.eclass to add support for Rust
|
||||
# cross-compiling to the ChromeOS targets. It maps the host triplet to
|
||||
# one built into rustc and uses the board root as its sysroot.
|
||||
coreos-cargo_src_unpack() {
|
||||
debug-print-function ${FUNCNAME} "$@"
|
||||
cargo_src_unpack "$@"
|
||||
|
||||
[[ ${CBUILD:-${CHOST}} != ${CHOST} ]] || return 0
|
||||
|
||||
# Map the SDK host triplet to one that is built into rustc.
|
||||
function rust_builtin_target() case "$1" in
|
||||
aarch64-*-linux-gnu) echo aarch64-unknown-linux-gnu ;;
|
||||
x86_64-*-linux-gnu) echo x86_64-unknown-linux-gnu ;;
|
||||
*) die "Unknown host triplet: $1" ;;
|
||||
esac
|
||||
|
||||
# Set the gcc-rs flags for cross-compiling.
|
||||
export TARGET_CFLAGS="${CFLAGS}"
|
||||
export TARGET_CXXFLAGS="${CXXFLAGS}"
|
||||
|
||||
# Wrap ar for gcc-rs to work around rust-lang/cargo#4456.
|
||||
export TARGET_AR="${T}/rustproof-ar"
|
||||
cat <<- EOF > "${TARGET_AR}" && chmod 0755 "${TARGET_AR}"
|
||||
#!/bin/sh
|
||||
unset LD_LIBRARY_PATH
|
||||
exec $(tc-getAR) "\$@"
|
||||
EOF
|
||||
|
||||
# Wrap gcc for gcc-rs to work around rust-lang/cargo#4456.
|
||||
export TARGET_CC="${T}/rustproof-cc"
|
||||
cat <<- EOF > "${TARGET_CC}" && chmod 0755 "${TARGET_CC}"
|
||||
#!/bin/sh
|
||||
unset LD_LIBRARY_PATH
|
||||
exec $(tc-getCC) "\$@"
|
||||
EOF
|
||||
|
||||
# Wrap g++ for gcc-rs to work around rust-lang/cargo#4456.
|
||||
export TARGET_CXX="${T}/rustproof-cxx"
|
||||
cat <<- EOF > "${TARGET_CXX}" && chmod 0755 "${TARGET_CXX}"
|
||||
#!/bin/sh
|
||||
unset LD_LIBRARY_PATH
|
||||
exec $(tc-getCXX) "\$@"
|
||||
EOF
|
||||
|
||||
# Create a compiler wrapper that uses a sysroot for cross-compiling.
|
||||
export RUSTC_WRAPPER="${T}/wrustc"
|
||||
cat <<- 'EOF' > "${RUSTC_WRAPPER}" && chmod 0755 "${RUSTC_WRAPPER}"
|
||||
#!/bin/bash -e
|
||||
rustc=${1:?Missing rustc command}
|
||||
shift
|
||||
xflags=()
|
||||
[ "x$*" = "x${*#--target}" ] || xflags=( --sysroot="${ROOT:-/}usr" )
|
||||
exec "${rustc}" "${xflags[@]}" "$@"
|
||||
EOF
|
||||
|
||||
# Compile for the built-in target, using the SDK cross-tools.
|
||||
export RUST_TARGET=$(rust_builtin_target "${CHOST}")
|
||||
cat <<- EOF >> "${ECARGO_HOME}/config"
|
||||
|
||||
[build]
|
||||
target = "${RUST_TARGET}"
|
||||
|
||||
[target.${RUST_TARGET}]
|
||||
ar = "${TARGET_AR}"
|
||||
linker = "${TARGET_CC}"
|
||||
EOF
|
||||
}
|
||||
|
||||
fi
|
@ -1,12 +0,0 @@
|
||||
DEFINED_PHASES=compile configure install unpack
|
||||
DESCRIPTION=Standard libraries for Rust
|
||||
EAPI=6
|
||||
HOMEPAGE=http://www.rust-lang.org/
|
||||
IUSE=debug
|
||||
KEYWORDS=amd64 arm64
|
||||
LICENSE=|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA
|
||||
RDEPEND=!dev-lang/rust
|
||||
SLOT=0/1.29.1
|
||||
SRC_URI=https://static.rust-lang.org/dist/rustc-1.29.1-src.tar.gz
|
||||
_eclasses_=cargo c11c4632a7a9d8e0b76e9f4412e76163 coreos-cargo ecc71b7f40f79def52bcee3f1dca6559 multilib b2f01ad412baf81650c23fcf0975fa33 multiprocessing cac3169468f893670dac3e7cb940e045 toolchain-funcs f164325a2cdb5b3ea39311d483988861
|
||||
_md5_=d5ff44d34648d4f7fe52a93db0d8195b
|
Loading…
x
Reference in New Issue
Block a user