diff --git a/sdk_container/src/third_party/coreos-overlay/dev-libs/rustlib/rustlib-1.19.0.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-libs/rustlib/rustlib-1.19.0-r1.ebuild similarity index 58% rename from sdk_container/src/third_party/coreos-overlay/dev-libs/rustlib/rustlib-1.19.0.ebuild rename to sdk_container/src/third_party/coreos-overlay/dev-libs/rustlib/rustlib-1.19.0-r1.ebuild index 00ee2483c9..224d783035 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-libs/rustlib/rustlib-1.19.0.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/dev-libs/rustlib/rustlib-1.19.0-r1.ebuild @@ -31,35 +31,8 @@ src_configure() { # too, and we don't want that since we aren't building the whole compiler rm src/Cargo.toml - # 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 - - # Make cargo use the wrappers as well. - sed -i \ - -e "s,^ar *=.*,ar = \"${TARGET_AR}\"," \ - -e "s,^linker *=.*,linker = \"${TARGET_CC}\"," \ - "${ECARGO_HOME}/config" + # Add the vendored crates to the local registry. + ln -fst "${ECARGO_VENDOR}" "${S}"/src/vendor/* } src_compile() { @@ -71,21 +44,27 @@ src_compile() { # 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="-Z force-unstable-if-unmarked" - # make sure we can find the custom ChromeOS target definitions - local -x RUST_TARGET_PATH="/usr/$(get_libdir)/rustlib" + local -x RUSTFLAGS="-C prefer-dynamic -L ${CARGO_TARGET_DIR}/${RUST_TARGET}/release/deps -Z force-unstable-if-unmarked" # 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 $(usex debug '' --release) \ + cargo build -p std -v --lib $(usex debug '' --release) \ --features "${features[*]}" \ --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. - 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() { diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/coreos-cargo.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-cargo.eclass index 5ebe69be1d..dc8fe32a54 100644 --- a/sdk_container/src/third_party/coreos-overlay/eclass/coreos-cargo.eclass +++ b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-cargo.eclass @@ -33,13 +33,6 @@ coreos-cargo_src_unpack() { [[ ${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. function rust_builtin_target() case "$1" in aarch64-*-linux-gnu) echo aarch64-unknown-linux-gnu ;; @@ -47,22 +40,47 @@ coreos-cargo_src_unpack() { *) die "Unknown host triplet: $1" ;; esac - # Allow searching host libraries when targeting incompatible systems. - export RUST_TARGET=$(rust_builtin_target "${CHOST}") - local build_triplet=$(rust_builtin_target "${CBUILD}") - [[ ${RUST_TARGET} = ${build_triplet} ]] || - local crossflags="-L /usr/lib64/rustlib/${build_triplet}/lib" + # Set the gcc-rs flags for cross-compiling. + export TARGET_CFLAGS="${CFLAGS}" + export TARGET_CXXFLAGS="${CXXFLAGS}" - # Create a compiler wrapper to work around rust-lang/cargo#4456. - if [[ ${CATEGORY}/${PN} != dev-libs/rustlib ]]; then - cat <<- EOF > "${T}/wrustc" && chmod 0755 "${T}/wrustc" - #!/bin/sh - exec rustc --sysroot="${ROOT:-/}usr" ${crossflags-} "\$@" - EOF - export RUSTC="${T}/wrustc" - fi + # 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]