1SUMMARY = "Rust standard libaries"
2HOMEPAGE = "http://www.rust-lang.org"
3SECTION = "devel"
4LICENSE = "(MIT | Apache-2.0) & Unicode-TOU"
5LIC_FILES_CHKSUM = "file://../../COPYRIGHT;md5=c2cccf560306876da3913d79062a54b9"
6
7require rust-source.inc
8
9# The dummy crate named `sysroot` represents the standard library target.
10#
11# See fd4c81f4c19e ("Add a `sysroot` crate to represent the standard library crates")
12# https://github.com/rust-lang/rust/pull/108865/
13S = "${RUSTSRC}/library/sysroot"
14
15RUSTLIB_DEP = ""
16inherit cargo
17
18CVE_PRODUCT = "rust"
19
20DEPENDS:append:libc-musl = " libunwind"
21# rv32 does not have libunwind ported yet
22DEPENDS:remove:riscv32 = "libunwind"
23DEPENDS:remove:riscv64 = "libunwind"
24
25# Embed bitcode in order to allow compiling both with and without LTO
26RUSTFLAGS += "-Cembed-bitcode=yes"
27# Needed so cargo can find libbacktrace
28RUSTFLAGS += "-L ${STAGING_LIBDIR} -C link-arg=-Wl,-soname,libstd.so"
29
30CARGO_FEATURES ?= "panic-unwind backtrace"
31CARGO_BUILD_FLAGS += "--features '${CARGO_FEATURES}'"
32CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor"
33
34do_compile:prepend () {
35    export CARGO_TARGET_DIR="${B}"
36    # For Rust 1.13.0 and newer
37    export RUSTC_BOOTSTRAP="1"
38}
39
40do_install () {
41    mkdir -p ${D}${rustlibdir}
42
43    # With the incremental build support added in 1.24, the libstd deps directory also includes dependency
44    # files that get installed. Those are really only needed to incrementally rebuild the libstd library
45    # itself and don't need to be installed.
46    rm -f ${B}/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/*.d
47    cp ${B}/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/* ${D}${rustlibdir}
48}
49
50BBCLASSEXTEND = "nativesdk"
51
52# Since 1.70.0 upgrade this fails to build with gold:
53# http://errors.yoctoproject.org/Errors/Details/708194/
54# ld: error: version script assignment of  to symbol __rust_alloc_error_handler_should_panic failed: symbol not defined
55LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '-fuse-ld=bfd', '', d)}"
56