From 66ba89328565ca12e7658fb5c37169f2508f5745 Mon Sep 17 00:00:00 2001 From: Alex Kiernan Date: Fri, 8 Dec 2023 14:03:45 +0000 Subject: rust: Upgrade 1.71.0 -> 1.71.1 https://blog.rust-lang.org/2023/08/03/Rust-1.71.1.html (From OE-Core rev: ad4369d7901c1239e5f07473b1f2517edc4a23ea) Signed-off-by: Alex Kiernan Signed-off-by: Richard Purdie --- meta/recipes-devtools/rust/cargo_1.71.0.bb | 73 ----- meta/recipes-devtools/rust/cargo_1.71.1.bb | 73 +++++ meta/recipes-devtools/rust/libstd-rs_1.71.0.bb | 53 --- meta/recipes-devtools/rust/libstd-rs_1.71.1.bb | 53 +++ .../rust/rust-cross-canadian_1.71.0.bb | 2 - .../rust/rust-cross-canadian_1.71.1.bb | 2 + meta/recipes-devtools/rust/rust-llvm_1.71.0.bb | 94 ------ meta/recipes-devtools/rust/rust-llvm_1.71.1.bb | 94 ++++++ meta/recipes-devtools/rust/rust-source.inc | 2 +- meta/recipes-devtools/rust/rust_1.71.0.bb | 359 --------------------- meta/recipes-devtools/rust/rust_1.71.1.bb | 359 +++++++++++++++++++++ 11 files changed, 582 insertions(+), 582 deletions(-) delete mode 100644 meta/recipes-devtools/rust/cargo_1.71.0.bb create mode 100644 meta/recipes-devtools/rust/cargo_1.71.1.bb delete mode 100644 meta/recipes-devtools/rust/libstd-rs_1.71.0.bb create mode 100644 meta/recipes-devtools/rust/libstd-rs_1.71.1.bb delete mode 100644 meta/recipes-devtools/rust/rust-cross-canadian_1.71.0.bb create mode 100644 meta/recipes-devtools/rust/rust-cross-canadian_1.71.1.bb delete mode 100644 meta/recipes-devtools/rust/rust-llvm_1.71.0.bb create mode 100644 meta/recipes-devtools/rust/rust-llvm_1.71.1.bb delete mode 100644 meta/recipes-devtools/rust/rust_1.71.0.bb create mode 100644 meta/recipes-devtools/rust/rust_1.71.1.bb (limited to 'meta/recipes-devtools/rust') diff --git a/meta/recipes-devtools/rust/cargo_1.71.0.bb b/meta/recipes-devtools/rust/cargo_1.71.0.bb deleted file mode 100644 index 50b7e7c7b4..0000000000 --- a/meta/recipes-devtools/rust/cargo_1.71.0.bb +++ /dev/null @@ -1,73 +0,0 @@ -SUMMARY = "Cargo, a package manager for Rust." -HOMEPAGE = "https://crates.io" -LICENSE = "MIT | Apache-2.0" -SECTION = "devel" - -DEPENDS = "openssl zlib curl ca-certificates libssh2" - -LIC_FILES_CHKSUM = " \ - file://LICENSE-MIT;md5=b377b220f43d747efdec40d69fcaa69d \ - file://LICENSE-APACHE;md5=71b224ca933f0676e26d5c2e2271331c \ - file://LICENSE-THIRD-PARTY;md5=f257ad009884cb88a3a87d6920e7180a \ -" - -require rust-source.inc -require rust-snapshot.inc - -S = "${RUSTSRC}/src/tools/cargo" -CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor" - -inherit cargo pkgconfig - -DEBUG_PREFIX_MAP += "-fdebug-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}" - -do_cargo_setup_snapshot () { - ${WORKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig - # Need to use uninative's loader if enabled/present since the library paths - # are used internally by rust and result in symbol mismatches if we don't - if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then - patchelf-uninative ${WORKDIR}/${CARGO_SNAPSHOT}/bin/cargo --set-interpreter ${UNINATIVE_LOADER} - fi -} - -addtask cargo_setup_snapshot after do_unpack before do_configure -do_cargo_setup_snapshot[dirs] += "${WORKDIR}/${CARGO_SNAPSHOT}" -do_cargo_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER" - - -do_compile:prepend () { - export RUSTC_BOOTSTRAP="1" -} - -do_install () { - install -d "${D}${bindir}" - install -m 755 "${B}/target/${CARGO_TARGET_SUBDIR}/cargo" "${D}${bindir}" -} - -do_install:append:class-nativesdk() { - # To quote the cargo docs, "Cargo also sets the dynamic library path when compiling - # and running binaries with commands like `cargo run` and `cargo test`". Sadly it - # sets to libdir but not base_libdir leading to symbol mismatches depending on the - # host OS. Fully set LD_LIBRARY_PATH to contain both to avoid this. - create_wrapper ${D}/${bindir}/cargo LD_LIBRARY_PATH=${libdir}:${base_libdir} -} - -# Disabled due to incompatibility with libgit2 0.28.x (https://github.com/rust-lang/git2-rs/issues/458, https://bugs.gentoo.org/707746#c1) -# as shipped by Yocto Dunfell. -# According to https://github.com/rust-lang/git2-rs/issues/458#issuecomment-522567539, there are no compatibility guarantees between -# libgit2-sys and arbitrary system libgit2 versions, so better keep this turned off. -#export LIBGIT2_SYS_USE_PKG_CONFIG = "1" - -# Needed for pkg-config to be used -export LIBSSH2_SYS_USE_PKG_CONFIG = "1" - -# When building cargo-native we don't have cargo-native to use and depend on, -# so we must use the locally set up snapshot to bootstrap the build. -BASEDEPENDS:remove:class-native = "cargo-native" -CARGO:class-native = "${WORKDIR}/${CARGO_SNAPSHOT}/bin/cargo" - -DEPENDS:append:class-nativesdk = " nativesdk-rust" -RUSTLIB:append:class-nativesdk = " -L ${STAGING_DIR_HOST}/${SDKPATHNATIVE}/usr/lib/rustlib/${RUST_HOST_SYS}/lib" -RUSTLIB_DEP:class-nativesdk = "" - -BBCLASSEXTEND = "native nativesdk" diff --git a/meta/recipes-devtools/rust/cargo_1.71.1.bb b/meta/recipes-devtools/rust/cargo_1.71.1.bb new file mode 100644 index 0000000000..50b7e7c7b4 --- /dev/null +++ b/meta/recipes-devtools/rust/cargo_1.71.1.bb @@ -0,0 +1,73 @@ +SUMMARY = "Cargo, a package manager for Rust." +HOMEPAGE = "https://crates.io" +LICENSE = "MIT | Apache-2.0" +SECTION = "devel" + +DEPENDS = "openssl zlib curl ca-certificates libssh2" + +LIC_FILES_CHKSUM = " \ + file://LICENSE-MIT;md5=b377b220f43d747efdec40d69fcaa69d \ + file://LICENSE-APACHE;md5=71b224ca933f0676e26d5c2e2271331c \ + file://LICENSE-THIRD-PARTY;md5=f257ad009884cb88a3a87d6920e7180a \ +" + +require rust-source.inc +require rust-snapshot.inc + +S = "${RUSTSRC}/src/tools/cargo" +CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor" + +inherit cargo pkgconfig + +DEBUG_PREFIX_MAP += "-fdebug-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}" + +do_cargo_setup_snapshot () { + ${WORKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig + # Need to use uninative's loader if enabled/present since the library paths + # are used internally by rust and result in symbol mismatches if we don't + if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then + patchelf-uninative ${WORKDIR}/${CARGO_SNAPSHOT}/bin/cargo --set-interpreter ${UNINATIVE_LOADER} + fi +} + +addtask cargo_setup_snapshot after do_unpack before do_configure +do_cargo_setup_snapshot[dirs] += "${WORKDIR}/${CARGO_SNAPSHOT}" +do_cargo_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER" + + +do_compile:prepend () { + export RUSTC_BOOTSTRAP="1" +} + +do_install () { + install -d "${D}${bindir}" + install -m 755 "${B}/target/${CARGO_TARGET_SUBDIR}/cargo" "${D}${bindir}" +} + +do_install:append:class-nativesdk() { + # To quote the cargo docs, "Cargo also sets the dynamic library path when compiling + # and running binaries with commands like `cargo run` and `cargo test`". Sadly it + # sets to libdir but not base_libdir leading to symbol mismatches depending on the + # host OS. Fully set LD_LIBRARY_PATH to contain both to avoid this. + create_wrapper ${D}/${bindir}/cargo LD_LIBRARY_PATH=${libdir}:${base_libdir} +} + +# Disabled due to incompatibility with libgit2 0.28.x (https://github.com/rust-lang/git2-rs/issues/458, https://bugs.gentoo.org/707746#c1) +# as shipped by Yocto Dunfell. +# According to https://github.com/rust-lang/git2-rs/issues/458#issuecomment-522567539, there are no compatibility guarantees between +# libgit2-sys and arbitrary system libgit2 versions, so better keep this turned off. +#export LIBGIT2_SYS_USE_PKG_CONFIG = "1" + +# Needed for pkg-config to be used +export LIBSSH2_SYS_USE_PKG_CONFIG = "1" + +# When building cargo-native we don't have cargo-native to use and depend on, +# so we must use the locally set up snapshot to bootstrap the build. +BASEDEPENDS:remove:class-native = "cargo-native" +CARGO:class-native = "${WORKDIR}/${CARGO_SNAPSHOT}/bin/cargo" + +DEPENDS:append:class-nativesdk = " nativesdk-rust" +RUSTLIB:append:class-nativesdk = " -L ${STAGING_DIR_HOST}/${SDKPATHNATIVE}/usr/lib/rustlib/${RUST_HOST_SYS}/lib" +RUSTLIB_DEP:class-nativesdk = "" + +BBCLASSEXTEND = "native nativesdk" diff --git a/meta/recipes-devtools/rust/libstd-rs_1.71.0.bb b/meta/recipes-devtools/rust/libstd-rs_1.71.0.bb deleted file mode 100644 index d2bf266f9d..0000000000 --- a/meta/recipes-devtools/rust/libstd-rs_1.71.0.bb +++ /dev/null @@ -1,53 +0,0 @@ -SUMMARY = "Rust standard libaries" -HOMEPAGE = "http://www.rust-lang.org" -SECTION = "devel" -LICENSE = "(MIT | Apache-2.0) & Unicode-TOU" -LIC_FILES_CHKSUM = "file://../../COPYRIGHT;md5=c2cccf560306876da3913d79062a54b9" - -require rust-source.inc - -# The dummy crate named `sysroot` represents the standard library target. -# -# See fd4c81f4c19e ("Add a `sysroot` crate to represent the standard library crates") -# https://github.com/rust-lang/rust/pull/108865/ -S = "${RUSTSRC}/library/sysroot" - -RUSTLIB_DEP = "" -inherit cargo - -DEPENDS:append:libc-musl = " libunwind" -# rv32 does not have libunwind ported yet -DEPENDS:remove:riscv32 = "libunwind" -DEPENDS:remove:riscv64 = "libunwind" - -# Embed bitcode in order to allow compiling both with and without LTO -RUSTFLAGS += "-Cembed-bitcode=yes" -# Needed so cargo can find libbacktrace -RUSTFLAGS += "-L ${STAGING_LIBDIR} -C link-arg=-Wl,-soname,libstd.so" - -CARGO_FEATURES ?= "panic-unwind backtrace" -CARGO_BUILD_FLAGS += "--features '${CARGO_FEATURES}'" -CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor" - -do_compile:prepend () { - export CARGO_TARGET_DIR="${B}" - # For Rust 1.13.0 and newer - export RUSTC_BOOTSTRAP="1" -} - -do_install () { - mkdir -p ${D}${rustlibdir} - - # With the incremental build support added in 1.24, the libstd deps directory also includes dependency - # files that get installed. Those are really only needed to incrementally rebuild the libstd library - # itself and don't need to be installed. - rm -f ${B}/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/*.d - cp ${B}/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/* ${D}${rustlibdir} -} - -BBCLASSEXTEND = "nativesdk" - -# Since 1.70.0 upgrade this fails to build with gold: -# http://errors.yoctoproject.org/Errors/Details/708194/ -# ld: error: version script assignment of to symbol __rust_alloc_error_handler_should_panic failed: symbol not defined -LDFLAGS:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd', '', d)}" diff --git a/meta/recipes-devtools/rust/libstd-rs_1.71.1.bb b/meta/recipes-devtools/rust/libstd-rs_1.71.1.bb new file mode 100644 index 0000000000..d2bf266f9d --- /dev/null +++ b/meta/recipes-devtools/rust/libstd-rs_1.71.1.bb @@ -0,0 +1,53 @@ +SUMMARY = "Rust standard libaries" +HOMEPAGE = "http://www.rust-lang.org" +SECTION = "devel" +LICENSE = "(MIT | Apache-2.0) & Unicode-TOU" +LIC_FILES_CHKSUM = "file://../../COPYRIGHT;md5=c2cccf560306876da3913d79062a54b9" + +require rust-source.inc + +# The dummy crate named `sysroot` represents the standard library target. +# +# See fd4c81f4c19e ("Add a `sysroot` crate to represent the standard library crates") +# https://github.com/rust-lang/rust/pull/108865/ +S = "${RUSTSRC}/library/sysroot" + +RUSTLIB_DEP = "" +inherit cargo + +DEPENDS:append:libc-musl = " libunwind" +# rv32 does not have libunwind ported yet +DEPENDS:remove:riscv32 = "libunwind" +DEPENDS:remove:riscv64 = "libunwind" + +# Embed bitcode in order to allow compiling both with and without LTO +RUSTFLAGS += "-Cembed-bitcode=yes" +# Needed so cargo can find libbacktrace +RUSTFLAGS += "-L ${STAGING_LIBDIR} -C link-arg=-Wl,-soname,libstd.so" + +CARGO_FEATURES ?= "panic-unwind backtrace" +CARGO_BUILD_FLAGS += "--features '${CARGO_FEATURES}'" +CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor" + +do_compile:prepend () { + export CARGO_TARGET_DIR="${B}" + # For Rust 1.13.0 and newer + export RUSTC_BOOTSTRAP="1" +} + +do_install () { + mkdir -p ${D}${rustlibdir} + + # With the incremental build support added in 1.24, the libstd deps directory also includes dependency + # files that get installed. Those are really only needed to incrementally rebuild the libstd library + # itself and don't need to be installed. + rm -f ${B}/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/*.d + cp ${B}/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/* ${D}${rustlibdir} +} + +BBCLASSEXTEND = "nativesdk" + +# Since 1.70.0 upgrade this fails to build with gold: +# http://errors.yoctoproject.org/Errors/Details/708194/ +# ld: error: version script assignment of to symbol __rust_alloc_error_handler_should_panic failed: symbol not defined +LDFLAGS:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd', '', d)}" diff --git a/meta/recipes-devtools/rust/rust-cross-canadian_1.71.0.bb b/meta/recipes-devtools/rust/rust-cross-canadian_1.71.0.bb deleted file mode 100644 index 55865238ab..0000000000 --- a/meta/recipes-devtools/rust/rust-cross-canadian_1.71.0.bb +++ /dev/null @@ -1,2 +0,0 @@ -inherit cross-canadian -require rust-cross-canadian.inc \ No newline at end of file diff --git a/meta/recipes-devtools/rust/rust-cross-canadian_1.71.1.bb b/meta/recipes-devtools/rust/rust-cross-canadian_1.71.1.bb new file mode 100644 index 0000000000..55865238ab --- /dev/null +++ b/meta/recipes-devtools/rust/rust-cross-canadian_1.71.1.bb @@ -0,0 +1,2 @@ +inherit cross-canadian +require rust-cross-canadian.inc \ No newline at end of file diff --git a/meta/recipes-devtools/rust/rust-llvm_1.71.0.bb b/meta/recipes-devtools/rust/rust-llvm_1.71.0.bb deleted file mode 100644 index 5bfc1faea8..0000000000 --- a/meta/recipes-devtools/rust/rust-llvm_1.71.0.bb +++ /dev/null @@ -1,94 +0,0 @@ -SUMMARY = "LLVM compiler framework (packaged with rust)" -LICENSE ?= "Apache-2.0-with-LLVM-exception" -HOMEPAGE = "http://www.rust-lang.org" - -# check src/llvm-project/llvm/CMakeLists.txt for llvm version in use -# -LLVM_RELEASE = "16.0.2" - -require rust-source.inc - -SRC_URI += "file://0002-llvm-allow-env-override-of-exe-path.patch;striplevel=2 \ - file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch;striplevel=2 \ - file://0003-llvm-fix-include-benchmarks.patch;striplevel=2" - -S = "${RUSTSRC}/src/llvm-project/llvm" - -LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe" - -inherit cmake - -DEPENDS += "ninja-native rust-llvm-native" - -ARM_INSTRUCTION_SET:armv5 = "arm" -ARM_INSTRUCTION_SET:armv4t = "arm" - -# rustc_llvm with debug info is not recognized as a valid crate that's -# generated by rust-llvm-native. -CFLAGS:remove = "-g" -CXXFLAGS:remove = "-g" - -LLVM_DIR = "llvm${LLVM_RELEASE}" - -RUST_LLVM_TARGETS ?= "ARM;AArch64;Mips;PowerPC;RISCV;X86" - -EXTRA_OECMAKE = " \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_TARGETS_TO_BUILD='${RUST_LLVM_TARGETS}' \ - -DLLVM_BUILD_DOCS=OFF \ - -DLLVM_ENABLE_TERMINFO=OFF \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_ENABLE_LIBXML2=OFF \ - -DLLVM_ENABLE_FFI=OFF \ - -DLLVM_INSTALL_UTILS=ON \ - -DLLVM_BUILD_EXAMPLES=OFF \ - -DLLVM_INCLUDE_EXAMPLES=OFF \ - -DLLVM_BUILD_TESTS=OFF \ - -DLLVM_INCLUDE_TESTS=OFF \ - -DLLVM_TARGET_ARCH=${TARGET_ARCH} \ - -DCMAKE_INSTALL_PREFIX:PATH=${libdir}/llvm-rust \ -" - -# Forcibly disable the detection of these packages as otherwise -# it will look at the host Python install -EXTRA_OECMAKE += "\ - -DPY_PYGMENTS_FOUND=OFF \ - -DPY_PYGMENTS_LEXERS_C_CPP_FOUND=OFF \ - -DPY_YAML_FOUND=OFF \ -" - -EXTRA_OECMAKE:append:class-target = "\ - -DLLVM_BUILD_TOOLS=OFF \ - -DLLVM_TABLEGEN=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-tblgen \ - -DLLVM_CONFIG_PATH=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config \ -" - -EXTRA_OECMAKE:append:class-nativesdk = "\ - -DLLVM_BUILD_TOOLS=OFF \ - -DLLVM_TABLEGEN=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-tblgen \ - -DLLVM_CONFIG_PATH=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config \ -" - -# The debug symbols are huge here (>2GB) so suppress them since they -# provide almost no value. If you really need them then override this -INHIBIT_PACKAGE_DEBUG_SPLIT = "1" - -export YOCTO_ALTERNATE_EXE_PATH = "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" - -do_install:append () { - # we don't need any of this stuff to build Rust - rm -rf "${D}/usr/lib/cmake" -} - -PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liblto" - -# Add the extra locations to avoid the complaints about unpackaged files -FILES:${PN}-bugpointpasses = "${libdir}/llvm-rust/lib/BugpointPasses.so" -FILES:${PN}-llvmhello = "${libdir}/llvm-rust/lib/LLVMHello.so" -FILES:${PN}-liblto = "${libdir}/llvm-rust/lib/libLTO.so.*" -FILES:${PN}-staticdev =+ "${libdir}/llvm-rust/*/*.a" -FILES:${PN} += "${libdir}/libLLVM*.so.* ${libdir}/llvm-rust/lib/*.so.* ${libdir}/llvm-rust/bin" -FILES:${PN}-dev += "${datadir}/llvm ${libdir}/llvm-rust/lib/*.so ${libdir}/llvm-rust/include ${libdir}/llvm-rust/share ${libdir}/llvm-rust/lib/cmake" - -BBCLASSEXTEND = "native nativesdk" diff --git a/meta/recipes-devtools/rust/rust-llvm_1.71.1.bb b/meta/recipes-devtools/rust/rust-llvm_1.71.1.bb new file mode 100644 index 0000000000..5bfc1faea8 --- /dev/null +++ b/meta/recipes-devtools/rust/rust-llvm_1.71.1.bb @@ -0,0 +1,94 @@ +SUMMARY = "LLVM compiler framework (packaged with rust)" +LICENSE ?= "Apache-2.0-with-LLVM-exception" +HOMEPAGE = "http://www.rust-lang.org" + +# check src/llvm-project/llvm/CMakeLists.txt for llvm version in use +# +LLVM_RELEASE = "16.0.2" + +require rust-source.inc + +SRC_URI += "file://0002-llvm-allow-env-override-of-exe-path.patch;striplevel=2 \ + file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch;striplevel=2 \ + file://0003-llvm-fix-include-benchmarks.patch;striplevel=2" + +S = "${RUSTSRC}/src/llvm-project/llvm" + +LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe" + +inherit cmake + +DEPENDS += "ninja-native rust-llvm-native" + +ARM_INSTRUCTION_SET:armv5 = "arm" +ARM_INSTRUCTION_SET:armv4t = "arm" + +# rustc_llvm with debug info is not recognized as a valid crate that's +# generated by rust-llvm-native. +CFLAGS:remove = "-g" +CXXFLAGS:remove = "-g" + +LLVM_DIR = "llvm${LLVM_RELEASE}" + +RUST_LLVM_TARGETS ?= "ARM;AArch64;Mips;PowerPC;RISCV;X86" + +EXTRA_OECMAKE = " \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_TARGETS_TO_BUILD='${RUST_LLVM_TARGETS}' \ + -DLLVM_BUILD_DOCS=OFF \ + -DLLVM_ENABLE_TERMINFO=OFF \ + -DLLVM_ENABLE_ZLIB=OFF \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_ENABLE_LIBXML2=OFF \ + -DLLVM_ENABLE_FFI=OFF \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_BUILD_EXAMPLES=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF \ + -DLLVM_BUILD_TESTS=OFF \ + -DLLVM_INCLUDE_TESTS=OFF \ + -DLLVM_TARGET_ARCH=${TARGET_ARCH} \ + -DCMAKE_INSTALL_PREFIX:PATH=${libdir}/llvm-rust \ +" + +# Forcibly disable the detection of these packages as otherwise +# it will look at the host Python install +EXTRA_OECMAKE += "\ + -DPY_PYGMENTS_FOUND=OFF \ + -DPY_PYGMENTS_LEXERS_C_CPP_FOUND=OFF \ + -DPY_YAML_FOUND=OFF \ +" + +EXTRA_OECMAKE:append:class-target = "\ + -DLLVM_BUILD_TOOLS=OFF \ + -DLLVM_TABLEGEN=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-tblgen \ + -DLLVM_CONFIG_PATH=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config \ +" + +EXTRA_OECMAKE:append:class-nativesdk = "\ + -DLLVM_BUILD_TOOLS=OFF \ + -DLLVM_TABLEGEN=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-tblgen \ + -DLLVM_CONFIG_PATH=${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config \ +" + +# The debug symbols are huge here (>2GB) so suppress them since they +# provide almost no value. If you really need them then override this +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +export YOCTO_ALTERNATE_EXE_PATH = "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" + +do_install:append () { + # we don't need any of this stuff to build Rust + rm -rf "${D}/usr/lib/cmake" +} + +PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liblto" + +# Add the extra locations to avoid the complaints about unpackaged files +FILES:${PN}-bugpointpasses = "${libdir}/llvm-rust/lib/BugpointPasses.so" +FILES:${PN}-llvmhello = "${libdir}/llvm-rust/lib/LLVMHello.so" +FILES:${PN}-liblto = "${libdir}/llvm-rust/lib/libLTO.so.*" +FILES:${PN}-staticdev =+ "${libdir}/llvm-rust/*/*.a" +FILES:${PN} += "${libdir}/libLLVM*.so.* ${libdir}/llvm-rust/lib/*.so.* ${libdir}/llvm-rust/bin" +FILES:${PN}-dev += "${datadir}/llvm ${libdir}/llvm-rust/lib/*.so ${libdir}/llvm-rust/include ${libdir}/llvm-rust/share ${libdir}/llvm-rust/lib/cmake" + +BBCLASSEXTEND = "native nativesdk" diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc index 3a192e42db..0729db6f0b 100644 --- a/meta/recipes-devtools/rust/rust-source.inc +++ b/meta/recipes-devtools/rust/rust-source.inc @@ -7,7 +7,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n file://zlib-off64_t.patch;patchdir=${RUSTSRC} \ file://0001-musl-Define-SOCK_SEQPACKET-in-common-place.patch;patchdir=${RUSTSRC} \ " -SRC_URI[rust.sha256sum] = "5814699031aafdcc2e2f71fc9b389678cd7042350d1583da061463d8e88681c7" +SRC_URI[rust.sha256sum] = "371af0fbe04051e20a74dbea6d4e4e548f10f15309c49cae2688afb882b6c7f1" RUSTSRC = "${WORKDIR}/rustc-${RUST_VERSION}-src" diff --git a/meta/recipes-devtools/rust/rust_1.71.0.bb b/meta/recipes-devtools/rust/rust_1.71.0.bb deleted file mode 100644 index 3d176e54c1..0000000000 --- a/meta/recipes-devtools/rust/rust_1.71.0.bb +++ /dev/null @@ -1,359 +0,0 @@ -SUMMARY = "Rust compiler and runtime libaries" -HOMEPAGE = "http://www.rust-lang.org" -SECTION = "devel" -LICENSE = "(MIT | Apache-2.0) & Unicode-TOU" -LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=c2cccf560306876da3913d79062a54b9" - -inherit rust -inherit cargo_common - -DEPENDS += "file-native python3-native" -DEPENDS:append:class-native = " rust-llvm-native" -DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" - -DEPENDS += "rust-llvm (=${PV})" - -RDEPENDS:${PN}:append:class-target = " gcc g++ binutils" - -# Otherwise we'll depend on what we provide -INHIBIT_DEFAULT_RUST_DEPS:class-native = "1" -# We don't need to depend on gcc-native because yocto assumes it exists -PROVIDES:class-native = "virtual/${TARGET_PREFIX}rust" - -S = "${RUSTSRC}" - -# Use at your own risk, accepted values are stable, beta and nightly -RUST_CHANNEL ?= "stable" -PV .= "${@bb.utils.contains('RUST_CHANNEL', 'stable', '', '-${RUST_CHANNEL}', d)}" - -export FORCE_CRATE_HASH="${BB_TASKHASH}" - -RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" -RUST_ALTERNATE_EXE_PATH_NATIVE = "${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config" - -# We don't want to use bitbakes vendoring because the rust sources do their -# own vendoring. -CARGO_DISABLE_BITBAKE_VENDORING = "1" - -# We can't use RUST_BUILD_SYS here because that may be "musl" if -# TCLIBC="musl". Snapshots are always -unknown-linux-gnu -setup_cargo_environment () { - # The first step is to build bootstrap and some early stage tools, - # these are build for the same target as the snapshot, e.g. - # x86_64-unknown-linux-gnu. - # Later stages are build for the native target (i.e. target.x86_64-linux) - cargo_common_do_configure -} - -inherit rust-target-config - -do_rust_setup_snapshot () { - for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do - "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig - done - - # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo - # and fail without it there. - mkdir -p ${RUSTSRC}/build/${BUILD_SYS} - ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0 - - # Need to use uninative's loader if enabled/present since the library paths - # are used internally by rust and result in symbol mismatches if we don't - if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then - for bin in cargo rustc rustdoc; do - patchelf-uninative ${WORKDIR}/rust-snapshot/bin/$bin --set-interpreter ${UNINATIVE_LOADER} - done - fi -} -addtask rust_setup_snapshot after do_unpack before do_configure -addtask do_test_compile after do_configure do_rust_gen_targets -do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot" -do_rust_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER" - -python do_configure() { - import json - import configparser - - # toml is rather similar to standard ini like format except it likes values - # that look more JSON like. So for our purposes simply escaping all values - # as JSON seem to work fine. - - e = lambda s: json.dumps(s) - - config = configparser.RawConfigParser() - - # [target.ARCH-poky-linux] - host_section = "target.{}".format(d.getVar('RUST_HOST_SYS')) - config.add_section(host_section) - - llvm_config_target = d.expand("${RUST_ALTERNATE_EXE_PATH}") - llvm_config_build = d.expand("${RUST_ALTERNATE_EXE_PATH_NATIVE}") - config.set(host_section, "llvm-config", e(llvm_config_target)) - - config.set(host_section, "cxx", e(d.expand("${RUST_TARGET_CXX}"))) - config.set(host_section, "cc", e(d.expand("${RUST_TARGET_CC}"))) - config.set(host_section, "linker", e(d.expand("${RUST_TARGET_CCLD}"))) - if "musl" in host_section: - config.set(host_section, "musl-root", e(d.expand("${STAGING_DIR_HOST}${exec_prefix}"))) - - # If we don't do this rust-native will compile it's own llvm for BUILD. - # [target.${BUILD_ARCH}-unknown-linux-gnu] - build_section = "target.{}".format(d.getVar('RUST_BUILD_SYS')) - if build_section != host_section: - config.add_section(build_section) - - config.set(build_section, "llvm-config", e(llvm_config_build)) - - config.set(build_section, "cxx", e(d.expand("${RUST_BUILD_CXX}"))) - config.set(build_section, "cc", e(d.expand("${RUST_BUILD_CC}"))) - config.set(build_section, "linker", e(d.expand("${RUST_BUILD_CCLD}"))) - - target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS')) - if target_section != host_section and target_section != build_section: - config.add_section(target_section) - - config.set(target_section, "llvm-config", e(llvm_config_target)) - - config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}"))) - config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}"))) - config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}"))) - - # [llvm] - config.add_section("llvm") - config.set("llvm", "static-libstdcpp", e(False)) - if "llvm" in (d.getVar('TC_CXX_RUNTIME') or ""): - config.set("llvm", "use-libcxx", e(True)) - - # [rust] - config.add_section("rust") - config.set("rust", "rpath", e(True)) - config.set("rust", "remap-debuginfo", e(True)) - config.set("rust", "channel", e(d.expand("${RUST_CHANNEL}"))) - - # Whether or not to optimize the compiler and standard library - config.set("rust", "optimize", e(True)) - - # Emits extraneous output from tests to ensure that failures of the test - # harness are debuggable just from logfiles - config.set("rust", "verbose-tests", e(True)) - - # [build] - config.add_section("build") - config.set("build", "submodules", e(False)) - config.set("build", "docs", e(False)) - - rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc") - config.set("build", "rustc", e(rustc)) - - # Support for the profiler runtime to generate e.g. coverage report, - # PGO etc. - config.set("build", "profiler", e(True)) - - cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo") - config.set("build", "cargo", e(cargo)) - - config.set("build", "vendor", e(True)) - - config.set("build", "target", e([d.getVar("RUST_TARGET_SYS")])) - - config.set("build", "host", e([d.getVar("RUST_HOST_SYS")])) - - # We can't use BUILD_SYS since that is something the rust snapshot knows - # nothing about when trying to build some stage0 tools (like fabricate) - config.set("build", "build", e(d.getVar("RUST_BUILD_SYS"))) - - # [install] - config.add_section("install") - # ./x.py install doesn't have any notion of "destdir" - # but we can prepend ${D} to all the directories instead - config.set("install", "prefix", e(d.getVar("D") + d.getVar("prefix"))) - config.set("install", "bindir", e(d.getVar("D") + d.getVar("bindir"))) - config.set("install", "libdir", e(d.getVar("D") + d.getVar("libdir"))) - config.set("install", "datadir", e(d.getVar("D") + d.getVar("datadir"))) - config.set("install", "mandir", e(d.getVar("D") + d.getVar("mandir"))) - - with open("config.toml", "w") as f: - f.write('changelog-seen = 2\n\n') - config.write(f) - - # set up ${WORKDIR}/cargo_home - bb.build.exec_func("setup_cargo_environment", d) -} - -rust_runx () { - echo "COMPILE ${PN}" "$@" - - # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a - # wide range of targets (not just TARGET). Yocto's settings for them will - # be inappropriate, avoid using. - unset CFLAGS - unset LDFLAGS - unset CXXFLAGS - unset CPPFLAGS - - export RUSTFLAGS="${RUST_DEBUG_REMAP}" - - # Copy the natively built llvm-config into the target so we can run it. Horrible, - # but works! - if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then - mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}` - cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} - chrpath -d ${RUST_ALTERNATE_EXE_PATH} - fi - - oe_cargo_fix_env - - python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose -} -rust_runx[vardepsexclude] += "PARALLEL_MAKE" - -require rust-source.inc -require rust-snapshot.inc - -INSANE_SKIP:${PN}:class-native = "already-stripped" -FILES:${PN} += "${libdir}/rustlib" -FILES:${PN} += "${libdir}/*.so" -FILES:${PN}-dev = "" - -do_compile () { -} - -do_test_compile[dirs] = "${B}" -do_test_compile () { - rust_runx build src/tools/remote-test-server --target "${RUST_TARGET_SYS}" -} - -ALLOW_EMPTY:${PN} = "1" - -PACKAGES =+ "${PN}-rustdoc ${PN}-tools-clippy ${PN}-tools-rustfmt" -FILES:${PN}-rustdoc = "${bindir}/rustdoc" -FILES:${PN}-tools-clippy = "${bindir}/cargo-clippy ${bindir}/clippy-driver" -FILES:${PN}-tools-rustfmt = "${bindir}/rustfmt" -RDEPENDS:${PN}-rustdoc = "${PN}" -RDEPENDS:${PN}-tools-clippy = "${PN}" -RDEPENDS:${PN}-tools-rustfmt = "${PN}" - -SUMMARY:${PN}-tools-clippy = "A collection of lints to catch common mistakes and improve your Rust code" -SUMMARY:${PN}-tools-rustfmt = "A tool for formatting Rust code according to style guidelines" - -do_install () { - rust_do_install -} - -rust_do_install() { - rust_runx install -} - -rust_do_install:class-nativesdk() { - export PSEUDO_UNLOAD=1 - rust_runx install - rust_runx install clippy - rust_runx install rustfmt - unset PSEUDO_UNLOAD - - install -d ${D}${bindir} - for i in cargo-clippy clippy-driver rustfmt; do - cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} - chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i - done - - chown root:root ${D}/ -R - rm ${D}${libdir}/rustlib/uninstall.sh - rm ${D}${libdir}/rustlib/install.log - rm ${D}${libdir}/rustlib/manifest* -} - -EXTRA_TOOLS ?= "cargo-clippy clippy-driver rustfmt" -rust_do_install:class-target() { - export PSEUDO_UNLOAD=1 - rust_runx install - rust_runx install clippy - rust_runx install rustfmt - unset PSEUDO_UNLOAD - - install -d ${D}${bindir} - for i in ${EXTRA_TOOLS}; do - cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} - chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i - done - - install -d ${D}${libdir}/rustlib/${RUST_HOST_SYS} - install -m 0644 ${WORKDIR}/rust-targets/${RUST_HOST_SYS}.json ${D}${libdir}/rustlib/${RUST_HOST_SYS}/target.json - - chown root:root ${D}/ -R - rm ${D}${libdir}/rustlib/uninstall.sh - rm ${D}${libdir}/rustlib/install.log - rm ${D}${libdir}/rustlib/manifest* -} - -addtask do_update_snapshot after do_patch -do_update_snapshot[nostamp] = "1" - -# Run with `bitbake -c update_snapshot rust` to update `rust-snapshot.inc` -# with the checksums for the rust snapshot associated with this rustc-src -# tarball. -python do_update_snapshot() { - import json - import re - import sys - - from collections import defaultdict - - with open(os.path.join(d.getVar("S"), "src", "stage0.json")) as f: - j = json.load(f) - - config_dist_server = j['config']['dist_server'] - compiler_date = j['compiler']['date'] - compiler_version = j['compiler']['version'] - - src_uri = defaultdict(list) - for k, v in j['checksums_sha256'].items(): - m = re.search(f"dist/{compiler_date}/(?P.*)-{compiler_version}-(?P.*)-unknown-linux-gnu\\.tar\\.xz", k) - if m: - component = m.group('component') - arch = m.group('arch') - src_uri[arch].append(f"SRC_URI[{component}-snapshot-{arch}.sha256sum] = \"{v}\"") - - snapshot = """\ -## This is information on the rust-snapshot (binary) used to build our current release. -## snapshot info is taken from rust/src/stage0.json -## Rust is self-hosting and bootstraps itself with a pre-built previous version of itself. -## The exact (previous) version that has been used is specified in the source tarball. -## The version is replicated here. - -SNAPSHOT_VERSION = "%s" - -""" % compiler_version - - for arch, components in src_uri.items(): - snapshot += "\n".join(components) + "\n\n" - - snapshot += """\ -SRC_URI += " \\ - ${RUST_DIST_SERVER}/dist/${RUST_STD_SNAPSHOT}.tar.xz;name=rust-std-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\ - ${RUST_DIST_SERVER}/dist/${RUSTC_SNAPSHOT}.tar.xz;name=rustc-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\ - ${RUST_DIST_SERVER}/dist/${CARGO_SNAPSHOT}.tar.xz;name=cargo-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\ -" - -RUST_DIST_SERVER = "%s" - -RUST_STD_SNAPSHOT = "rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" -RUSTC_SNAPSHOT = "rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" -CARGO_SNAPSHOT = "cargo-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" -""" % config_dist_server - - with open(os.path.join(d.getVar("THISDIR"), "rust-snapshot.inc"), "w") as f: - f.write(snapshot) -} - -RUSTLIB_DEP:class-nativesdk = "" - -# musl builds include libunwind.a -INSANE_SKIP:${PN} = "staticdev" - -BBCLASSEXTEND = "native nativesdk" - -# Since 1.70.0 upgrade this fails to build with gold: -# http://errors.yoctoproject.org/Errors/Details/708196/ -# ld: error: version script assignment of to symbol __rust_alloc_error_handler_should_panic failed: symbol not defined -LDFLAGS:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd', '', d)}" diff --git a/meta/recipes-devtools/rust/rust_1.71.1.bb b/meta/recipes-devtools/rust/rust_1.71.1.bb new file mode 100644 index 0000000000..3d176e54c1 --- /dev/null +++ b/meta/recipes-devtools/rust/rust_1.71.1.bb @@ -0,0 +1,359 @@ +SUMMARY = "Rust compiler and runtime libaries" +HOMEPAGE = "http://www.rust-lang.org" +SECTION = "devel" +LICENSE = "(MIT | Apache-2.0) & Unicode-TOU" +LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=c2cccf560306876da3913d79062a54b9" + +inherit rust +inherit cargo_common + +DEPENDS += "file-native python3-native" +DEPENDS:append:class-native = " rust-llvm-native" +DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" + +DEPENDS += "rust-llvm (=${PV})" + +RDEPENDS:${PN}:append:class-target = " gcc g++ binutils" + +# Otherwise we'll depend on what we provide +INHIBIT_DEFAULT_RUST_DEPS:class-native = "1" +# We don't need to depend on gcc-native because yocto assumes it exists +PROVIDES:class-native = "virtual/${TARGET_PREFIX}rust" + +S = "${RUSTSRC}" + +# Use at your own risk, accepted values are stable, beta and nightly +RUST_CHANNEL ?= "stable" +PV .= "${@bb.utils.contains('RUST_CHANNEL', 'stable', '', '-${RUST_CHANNEL}', d)}" + +export FORCE_CRATE_HASH="${BB_TASKHASH}" + +RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" +RUST_ALTERNATE_EXE_PATH_NATIVE = "${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config" + +# We don't want to use bitbakes vendoring because the rust sources do their +# own vendoring. +CARGO_DISABLE_BITBAKE_VENDORING = "1" + +# We can't use RUST_BUILD_SYS here because that may be "musl" if +# TCLIBC="musl". Snapshots are always -unknown-linux-gnu +setup_cargo_environment () { + # The first step is to build bootstrap and some early stage tools, + # these are build for the same target as the snapshot, e.g. + # x86_64-unknown-linux-gnu. + # Later stages are build for the native target (i.e. target.x86_64-linux) + cargo_common_do_configure +} + +inherit rust-target-config + +do_rust_setup_snapshot () { + for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do + "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig + done + + # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo + # and fail without it there. + mkdir -p ${RUSTSRC}/build/${BUILD_SYS} + ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0 + + # Need to use uninative's loader if enabled/present since the library paths + # are used internally by rust and result in symbol mismatches if we don't + if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then + for bin in cargo rustc rustdoc; do + patchelf-uninative ${WORKDIR}/rust-snapshot/bin/$bin --set-interpreter ${UNINATIVE_LOADER} + done + fi +} +addtask rust_setup_snapshot after do_unpack before do_configure +addtask do_test_compile after do_configure do_rust_gen_targets +do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot" +do_rust_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER" + +python do_configure() { + import json + import configparser + + # toml is rather similar to standard ini like format except it likes values + # that look more JSON like. So for our purposes simply escaping all values + # as JSON seem to work fine. + + e = lambda s: json.dumps(s) + + config = configparser.RawConfigParser() + + # [target.ARCH-poky-linux] + host_section = "target.{}".format(d.getVar('RUST_HOST_SYS')) + config.add_section(host_section) + + llvm_config_target = d.expand("${RUST_ALTERNATE_EXE_PATH}") + llvm_config_build = d.expand("${RUST_ALTERNATE_EXE_PATH_NATIVE}") + config.set(host_section, "llvm-config", e(llvm_config_target)) + + config.set(host_section, "cxx", e(d.expand("${RUST_TARGET_CXX}"))) + config.set(host_section, "cc", e(d.expand("${RUST_TARGET_CC}"))) + config.set(host_section, "linker", e(d.expand("${RUST_TARGET_CCLD}"))) + if "musl" in host_section: + config.set(host_section, "musl-root", e(d.expand("${STAGING_DIR_HOST}${exec_prefix}"))) + + # If we don't do this rust-native will compile it's own llvm for BUILD. + # [target.${BUILD_ARCH}-unknown-linux-gnu] + build_section = "target.{}".format(d.getVar('RUST_BUILD_SYS')) + if build_section != host_section: + config.add_section(build_section) + + config.set(build_section, "llvm-config", e(llvm_config_build)) + + config.set(build_section, "cxx", e(d.expand("${RUST_BUILD_CXX}"))) + config.set(build_section, "cc", e(d.expand("${RUST_BUILD_CC}"))) + config.set(build_section, "linker", e(d.expand("${RUST_BUILD_CCLD}"))) + + target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS')) + if target_section != host_section and target_section != build_section: + config.add_section(target_section) + + config.set(target_section, "llvm-config", e(llvm_config_target)) + + config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}"))) + config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}"))) + config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}"))) + + # [llvm] + config.add_section("llvm") + config.set("llvm", "static-libstdcpp", e(False)) + if "llvm" in (d.getVar('TC_CXX_RUNTIME') or ""): + config.set("llvm", "use-libcxx", e(True)) + + # [rust] + config.add_section("rust") + config.set("rust", "rpath", e(True)) + config.set("rust", "remap-debuginfo", e(True)) + config.set("rust", "channel", e(d.expand("${RUST_CHANNEL}"))) + + # Whether or not to optimize the compiler and standard library + config.set("rust", "optimize", e(True)) + + # Emits extraneous output from tests to ensure that failures of the test + # harness are debuggable just from logfiles + config.set("rust", "verbose-tests", e(True)) + + # [build] + config.add_section("build") + config.set("build", "submodules", e(False)) + config.set("build", "docs", e(False)) + + rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc") + config.set("build", "rustc", e(rustc)) + + # Support for the profiler runtime to generate e.g. coverage report, + # PGO etc. + config.set("build", "profiler", e(True)) + + cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo") + config.set("build", "cargo", e(cargo)) + + config.set("build", "vendor", e(True)) + + config.set("build", "target", e([d.getVar("RUST_TARGET_SYS")])) + + config.set("build", "host", e([d.getVar("RUST_HOST_SYS")])) + + # We can't use BUILD_SYS since that is something the rust snapshot knows + # nothing about when trying to build some stage0 tools (like fabricate) + config.set("build", "build", e(d.getVar("RUST_BUILD_SYS"))) + + # [install] + config.add_section("install") + # ./x.py install doesn't have any notion of "destdir" + # but we can prepend ${D} to all the directories instead + config.set("install", "prefix", e(d.getVar("D") + d.getVar("prefix"))) + config.set("install", "bindir", e(d.getVar("D") + d.getVar("bindir"))) + config.set("install", "libdir", e(d.getVar("D") + d.getVar("libdir"))) + config.set("install", "datadir", e(d.getVar("D") + d.getVar("datadir"))) + config.set("install", "mandir", e(d.getVar("D") + d.getVar("mandir"))) + + with open("config.toml", "w") as f: + f.write('changelog-seen = 2\n\n') + config.write(f) + + # set up ${WORKDIR}/cargo_home + bb.build.exec_func("setup_cargo_environment", d) +} + +rust_runx () { + echo "COMPILE ${PN}" "$@" + + # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a + # wide range of targets (not just TARGET). Yocto's settings for them will + # be inappropriate, avoid using. + unset CFLAGS + unset LDFLAGS + unset CXXFLAGS + unset CPPFLAGS + + export RUSTFLAGS="${RUST_DEBUG_REMAP}" + + # Copy the natively built llvm-config into the target so we can run it. Horrible, + # but works! + if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then + mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}` + cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} + chrpath -d ${RUST_ALTERNATE_EXE_PATH} + fi + + oe_cargo_fix_env + + python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose +} +rust_runx[vardepsexclude] += "PARALLEL_MAKE" + +require rust-source.inc +require rust-snapshot.inc + +INSANE_SKIP:${PN}:class-native = "already-stripped" +FILES:${PN} += "${libdir}/rustlib" +FILES:${PN} += "${libdir}/*.so" +FILES:${PN}-dev = "" + +do_compile () { +} + +do_test_compile[dirs] = "${B}" +do_test_compile () { + rust_runx build src/tools/remote-test-server --target "${RUST_TARGET_SYS}" +} + +ALLOW_EMPTY:${PN} = "1" + +PACKAGES =+ "${PN}-rustdoc ${PN}-tools-clippy ${PN}-tools-rustfmt" +FILES:${PN}-rustdoc = "${bindir}/rustdoc" +FILES:${PN}-tools-clippy = "${bindir}/cargo-clippy ${bindir}/clippy-driver" +FILES:${PN}-tools-rustfmt = "${bindir}/rustfmt" +RDEPENDS:${PN}-rustdoc = "${PN}" +RDEPENDS:${PN}-tools-clippy = "${PN}" +RDEPENDS:${PN}-tools-rustfmt = "${PN}" + +SUMMARY:${PN}-tools-clippy = "A collection of lints to catch common mistakes and improve your Rust code" +SUMMARY:${PN}-tools-rustfmt = "A tool for formatting Rust code according to style guidelines" + +do_install () { + rust_do_install +} + +rust_do_install() { + rust_runx install +} + +rust_do_install:class-nativesdk() { + export PSEUDO_UNLOAD=1 + rust_runx install + rust_runx install clippy + rust_runx install rustfmt + unset PSEUDO_UNLOAD + + install -d ${D}${bindir} + for i in cargo-clippy clippy-driver rustfmt; do + cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} + chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i + done + + chown root:root ${D}/ -R + rm ${D}${libdir}/rustlib/uninstall.sh + rm ${D}${libdir}/rustlib/install.log + rm ${D}${libdir}/rustlib/manifest* +} + +EXTRA_TOOLS ?= "cargo-clippy clippy-driver rustfmt" +rust_do_install:class-target() { + export PSEUDO_UNLOAD=1 + rust_runx install + rust_runx install clippy + rust_runx install rustfmt + unset PSEUDO_UNLOAD + + install -d ${D}${bindir} + for i in ${EXTRA_TOOLS}; do + cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} + chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i + done + + install -d ${D}${libdir}/rustlib/${RUST_HOST_SYS} + install -m 0644 ${WORKDIR}/rust-targets/${RUST_HOST_SYS}.json ${D}${libdir}/rustlib/${RUST_HOST_SYS}/target.json + + chown root:root ${D}/ -R + rm ${D}${libdir}/rustlib/uninstall.sh + rm ${D}${libdir}/rustlib/install.log + rm ${D}${libdir}/rustlib/manifest* +} + +addtask do_update_snapshot after do_patch +do_update_snapshot[nostamp] = "1" + +# Run with `bitbake -c update_snapshot rust` to update `rust-snapshot.inc` +# with the checksums for the rust snapshot associated with this rustc-src +# tarball. +python do_update_snapshot() { + import json + import re + import sys + + from collections import defaultdict + + with open(os.path.join(d.getVar("S"), "src", "stage0.json")) as f: + j = json.load(f) + + config_dist_server = j['config']['dist_server'] + compiler_date = j['compiler']['date'] + compiler_version = j['compiler']['version'] + + src_uri = defaultdict(list) + for k, v in j['checksums_sha256'].items(): + m = re.search(f"dist/{compiler_date}/(?P.*)-{compiler_version}-(?P.*)-unknown-linux-gnu\\.tar\\.xz", k) + if m: + component = m.group('component') + arch = m.group('arch') + src_uri[arch].append(f"SRC_URI[{component}-snapshot-{arch}.sha256sum] = \"{v}\"") + + snapshot = """\ +## This is information on the rust-snapshot (binary) used to build our current release. +## snapshot info is taken from rust/src/stage0.json +## Rust is self-hosting and bootstraps itself with a pre-built previous version of itself. +## The exact (previous) version that has been used is specified in the source tarball. +## The version is replicated here. + +SNAPSHOT_VERSION = "%s" + +""" % compiler_version + + for arch, components in src_uri.items(): + snapshot += "\n".join(components) + "\n\n" + + snapshot += """\ +SRC_URI += " \\ + ${RUST_DIST_SERVER}/dist/${RUST_STD_SNAPSHOT}.tar.xz;name=rust-std-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\ + ${RUST_DIST_SERVER}/dist/${RUSTC_SNAPSHOT}.tar.xz;name=rustc-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\ + ${RUST_DIST_SERVER}/dist/${CARGO_SNAPSHOT}.tar.xz;name=cargo-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\ +" + +RUST_DIST_SERVER = "%s" + +RUST_STD_SNAPSHOT = "rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +RUSTC_SNAPSHOT = "rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +CARGO_SNAPSHOT = "cargo-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +""" % config_dist_server + + with open(os.path.join(d.getVar("THISDIR"), "rust-snapshot.inc"), "w") as f: + f.write(snapshot) +} + +RUSTLIB_DEP:class-nativesdk = "" + +# musl builds include libunwind.a +INSANE_SKIP:${PN} = "staticdev" + +BBCLASSEXTEND = "native nativesdk" + +# Since 1.70.0 upgrade this fails to build with gold: +# http://errors.yoctoproject.org/Errors/Details/708196/ +# ld: error: version script assignment of to symbol __rust_alloc_error_handler_should_panic failed: symbol not defined +LDFLAGS:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd', '', d)}" -- cgit v1.2.3-54-g00ecf