mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-21 22:41:09 +02:00
Merge pull request #2779 from dm0-/rust
eclass/coreos-cargo: Restructure how base libs are built
This commit is contained in:
commit
2a15a7dc6b
@ -31,35 +31,8 @@ src_configure() {
|
|||||||
# too, and we don't want that since we aren't building the whole compiler
|
# too, and we don't want that since we aren't building the whole compiler
|
||||||
rm src/Cargo.toml
|
rm src/Cargo.toml
|
||||||
|
|
||||||
# Wrap ar for gcc-rs to work around rust-lang/cargo#4456.
|
# Add the vendored crates to the local registry.
|
||||||
export TARGET_AR="${T}/rustproof-ar"
|
ln -fst "${ECARGO_VENDOR}" "${S}"/src/vendor/*
|
||||||
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
|
|
||||||
|
|
||||||
# Make cargo use the wrappers as well.
|
|
||||||
sed -i \
|
|
||||||
-e "s,^ar *=.*,ar = \"${TARGET_AR}\"," \
|
|
||||||
-e "s,^linker *=.*,linker = \"${TARGET_CC}\"," \
|
|
||||||
"${ECARGO_HOME}/config"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
src_compile() {
|
src_compile() {
|
||||||
@ -71,21 +44,27 @@ src_compile() {
|
|||||||
# really building the std libs is bootstrapping anyway, so I don't feel bad
|
# really building the std libs is bootstrapping anyway, so I don't feel bad
|
||||||
local -x RUSTC_BOOTSTRAP=1
|
local -x RUSTC_BOOTSTRAP=1
|
||||||
# various required flags for compiling thes std libs
|
# various required flags for compiling thes std libs
|
||||||
local -x RUSTFLAGS="-Z force-unstable-if-unmarked"
|
local -x RUSTFLAGS="-C prefer-dynamic -L ${CARGO_TARGET_DIR}/${RUST_TARGET}/release/deps -Z force-unstable-if-unmarked"
|
||||||
# make sure we can find the custom ChromeOS target definitions
|
|
||||||
local -x RUST_TARGET_PATH="/usr/$(get_libdir)/rustlib"
|
|
||||||
|
|
||||||
# build the std lib, which also builds all the other important libraries
|
# 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.
|
# (core, collections, etc). build it for the target we want for this build.
|
||||||
# also make sure that the jemalloc libraries are included.
|
# also make sure that the jemalloc libraries are included.
|
||||||
local -a features=( $(usex debug debug-jemalloc jemalloc) panic-unwind )
|
local -a features=( $(usex debug debug-jemalloc jemalloc) panic-unwind )
|
||||||
cargo build -p std -v $(usex debug '' --release) \
|
cargo build -p std -v --lib $(usex debug '' --release) \
|
||||||
--features "${features[*]}" \
|
--features "${features[*]}" \
|
||||||
--manifest-path src/libstd/Cargo.toml \
|
--manifest-path src/libstd/Cargo.toml \
|
||||||
--target "${RUST_TARGET}"
|
--target "${RUST_TARGET}" || die
|
||||||
|
|
||||||
|
cargo build -p term -v --lib $(usex debug '' --release) \
|
||||||
|
--manifest-path src/libterm/Cargo.toml \
|
||||||
|
--target "${RUST_TARGET}" || die
|
||||||
|
|
||||||
|
cargo build -p proc_macro -v --lib $(usex debug '' --release) \
|
||||||
|
--manifest-path src/libproc_macro/Cargo.toml \
|
||||||
|
--target "${RUST_TARGET}" || die
|
||||||
|
|
||||||
# Correct the directory name prior to installing it.
|
# Correct the directory name prior to installing it.
|
||||||
mv "${T}/target/${RUST_TARGET}/release/deps" "${T}/target/${RUST_TARGET}/release/lib"
|
mv "${CARGO_TARGET_DIR}/${RUST_TARGET}/release/deps" "${CARGO_TARGET_DIR}/${RUST_TARGET}/release/lib"
|
||||||
}
|
}
|
||||||
|
|
||||||
src_install() {
|
src_install() {
|
@ -33,13 +33,6 @@ coreos-cargo_src_unpack() {
|
|||||||
|
|
||||||
[[ ${CBUILD:-${CHOST}} != ${CHOST} ]] || return 0
|
[[ ${CBUILD:-${CHOST}} != ${CHOST} ]] || return 0
|
||||||
|
|
||||||
# Define the cross-compilers for rust-gcc commands.
|
|
||||||
export TARGET_AR="$(tc-getAR)"
|
|
||||||
export TARGET_CC="$(tc-getCC)"
|
|
||||||
export TARGET_CFLAGS="${CFLAGS}"
|
|
||||||
export TARGET_CXX="$(tc-getCXX)"
|
|
||||||
export TARGET_CXXFLAGS="${CXXFLAGS}"
|
|
||||||
|
|
||||||
# Map the SDK host triplet to one that is built into rustc.
|
# Map the SDK host triplet to one that is built into rustc.
|
||||||
function rust_builtin_target() case "$1" in
|
function rust_builtin_target() case "$1" in
|
||||||
aarch64-*-linux-gnu) echo aarch64-unknown-linux-gnu ;;
|
aarch64-*-linux-gnu) echo aarch64-unknown-linux-gnu ;;
|
||||||
@ -47,22 +40,47 @@ coreos-cargo_src_unpack() {
|
|||||||
*) die "Unknown host triplet: $1" ;;
|
*) die "Unknown host triplet: $1" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Allow searching host libraries when targeting incompatible systems.
|
# Set the gcc-rs flags for cross-compiling.
|
||||||
export RUST_TARGET=$(rust_builtin_target "${CHOST}")
|
export TARGET_CFLAGS="${CFLAGS}"
|
||||||
local build_triplet=$(rust_builtin_target "${CBUILD}")
|
export TARGET_CXXFLAGS="${CXXFLAGS}"
|
||||||
[[ ${RUST_TARGET} = ${build_triplet} ]] ||
|
|
||||||
local crossflags="-L /usr/lib64/rustlib/${build_triplet}/lib"
|
|
||||||
|
|
||||||
# Create a compiler wrapper to work around rust-lang/cargo#4456.
|
# Wrap ar for gcc-rs to work around rust-lang/cargo#4456.
|
||||||
if [[ ${CATEGORY}/${PN} != dev-libs/rustlib ]]; then
|
export TARGET_AR="${T}/rustproof-ar"
|
||||||
cat <<- EOF > "${T}/wrustc" && chmod 0755 "${T}/wrustc"
|
cat <<- EOF > "${TARGET_AR}" && chmod 0755 "${TARGET_AR}"
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec rustc --sysroot="${ROOT:-/}usr" ${crossflags-} "\$@"
|
unset LD_LIBRARY_PATH
|
||||||
EOF
|
exec $(tc-getAR) "\$@"
|
||||||
export RUSTC="${T}/wrustc"
|
EOF
|
||||||
fi
|
|
||||||
|
# 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.
|
# Compile for the built-in target, using the SDK cross-tools.
|
||||||
|
export RUST_TARGET=$(rust_builtin_target "${CHOST}")
|
||||||
cat <<- EOF >> "${ECARGO_HOME}/config"
|
cat <<- EOF >> "${ECARGO_HOME}/config"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user