Message ID | 20221208112612.3023718-1-sundeep.kokkonda@gmail.com |
---|---|
State | New |
Headers | show |
Series | rust: fix for target compilation failed issue | expand |
The json provided in the commit is x86-specific and will not work on any other target. Rather, you need to copy over and install the target json already available in ${RUST_TARGETS_DIR} and generated according to the target spec. Alex On Thu, 8 Dec 2022 at 12:26, Sundeep KOKKONDA <sundeep.kokkonda@gmail.com> wrote: > > Rust code compilation on qemu failed with with below error. > error: Error loading target specification: Could not find specification for target "x86_64-poky-linux-gnu". Run `rustc --print target-list` for a list of built-in targets. > > This patch fix the issue by adding the missing json file to the image. > > Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@gmail.com> > --- > meta/recipes-devtools/rust/files/target.json | 39 ++++++++++++++++++++ > meta/recipes-devtools/rust/rust.inc | 9 +++++ > meta/recipes-devtools/rust/rust_1.65.0.bb | 2 + > 3 files changed, 50 insertions(+) > create mode 100644 meta/recipes-devtools/rust/files/target.json > > diff --git a/meta/recipes-devtools/rust/files/target.json b/meta/recipes-devtools/rust/files/target.json > new file mode 100644 > index 0000000000..69dbbaa9f9 > --- /dev/null > +++ b/meta/recipes-devtools/rust/files/target.json > @@ -0,0 +1,39 @@ > +{ > + "arch": "x86_64", > + "cpu": "x86-64", > + "crt-static-respected": true, > + "data-layout": > +"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", > + "dynamic-linking": true, > + "env": "gnu", > + "executables": true, > + "has-rpath": true, > + "linker-is-gnu": true, > + "llvm-target": "x86_64-unknown-linux-gnu", > + "max-atomic-width": 64, > + "os": "linux", > + "position-independent-executables": true, > + "pre-link-args": { > + "gcc": [ > + "-m64" > + ] > + }, > + "relro-level": "full", > + "stack-probes": { > + "kind": "inline-or-call", > + "min-llvm-version-for-inline": [ > + 11, > + 0, > + 1 > + ] > + }, > + "supported-sanitizers": [ > + "address", > + "leak", > + "memory", > + "thread" > + ], > + "target-family": "unix", > + "target-pointer-width": "64" > +} > + > diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc > index 956301023a..75473f967b 100644 > --- a/meta/recipes-devtools/rust/rust.inc > +++ b/meta/recipes-devtools/rust/rust.inc > @@ -13,6 +13,10 @@ DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" > > S = "${RUSTSRC}" > > +SRC_URI += "\ > + file://target.json \ > +" > + > export FORCE_CRATE_HASH="${BB_TASKHASH}" > > RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" > @@ -217,3 +221,8 @@ rust_do_install () { > do_install () { > rust_do_install > } > + > +FILE_${PN} += " \ > + ${WORKDIR}/target.json \ > +" > + > diff --git a/meta/recipes-devtools/rust/rust_1.65.0.bb b/meta/recipes-devtools/rust/rust_1.65.0.bb > index dbf74cec8f..afef72e45c 100644 > --- a/meta/recipes-devtools/rust/rust_1.65.0.bb > +++ b/meta/recipes-devtools/rust/rust_1.65.0.bb > @@ -68,6 +68,8 @@ rust_do_install:class-target() { > chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i > done > > + cp ${WORKDIR}/target.json ${D}${libdir}/rustlib/${RUST_TARGET_SYS} > + > chown root:root ${D}/ -R > rm ${D}${libdir}/rustlib/uninstall.sh > rm ${D}${libdir}/rustlib/install.log > -- > 2.25.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#174396): https://lists.openembedded.org/g/openembedded-core/message/174396 > Mute This Topic: https://lists.openembedded.org/mt/95535785/1686489 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
On 2022-12-08 06:26, Sundeep KOKKONDA via lists.openembedded.org wrote: > Rust code compilation on qemu failed with with below error. > error: Error loading target specification: Could not find specification for target "x86_64-poky-linux-gnu". Run `rustc --print target-list` for a list of built-in targets. > > This patch fix the issue by adding the missing json file to the image. > > Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@gmail.com> > --- > meta/recipes-devtools/rust/files/target.json | 39 ++++++++++++++++++++ When I fixed this manually, I just copied this file from: tmp/work/core2-64-poky-linux/rust/1.65.0-r0/rustc-1.65.0-src/src/test/run-make-fulldeps/rustdoc-target-spec-json-path/target.json so I'm puzzled about why you didn't take that file, or better still a non-test source of that file, and perhaps sed out the 'has-elf-tls' line that generates the warning. Also, this looks like it would only work for x86-64 due to: data-layout": +"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", Perhaps the target.json isn't really what's needed since I I don't see such a file in my desktop install that I installed using rustup. Back to the drawing board.... Oh, in the rust git repo: $ grep -B 4 -A 2 target.json RELEASES.md Compiler ----------------------- - [Rustc will now search for custom JSON targets in `/lib/rustlib/<target-triple>/target.json` where `/` is the "sysroot" directory.][83800] You can find your sysroot directory by running `rustc --print sysroot`. so maybe looking at the commit log for that change will get you heading in the right direction. ../Randy > meta/recipes-devtools/rust/rust.inc | 9 +++++ > meta/recipes-devtools/rust/rust_1.65.0.bb | 2 + > 3 files changed, 50 insertions(+) > create mode 100644 meta/recipes-devtools/rust/files/target.json > > diff --git a/meta/recipes-devtools/rust/files/target.json b/meta/recipes-devtools/rust/files/target.json > new file mode 100644 > index 0000000000..69dbbaa9f9 > --- /dev/null > +++ b/meta/recipes-devtools/rust/files/target.json > @@ -0,0 +1,39 @@ > +{ > + "arch": "x86_64", > + "cpu": "x86-64", > + "crt-static-respected": true, > + "data-layout": > +"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", > + "dynamic-linking": true, > + "env": "gnu", > + "executables": true, > + "has-rpath": true, > + "linker-is-gnu": true, > + "llvm-target": "x86_64-unknown-linux-gnu", > + "max-atomic-width": 64, > + "os": "linux", > + "position-independent-executables": true, > + "pre-link-args": { > + "gcc": [ > + "-m64" > + ] > + }, > + "relro-level": "full", > + "stack-probes": { > + "kind": "inline-or-call", > + "min-llvm-version-for-inline": [ > + 11, > + 0, > + 1 > + ] > + }, > + "supported-sanitizers": [ > + "address", > + "leak", > + "memory", > + "thread" > + ], > + "target-family": "unix", > + "target-pointer-width": "64" > +} > + > diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc > index 956301023a..75473f967b 100644 > --- a/meta/recipes-devtools/rust/rust.inc > +++ b/meta/recipes-devtools/rust/rust.inc > @@ -13,6 +13,10 @@ DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" > > S = "${RUSTSRC}" > > +SRC_URI += "\ > + file://target.json \ > +" > + > export FORCE_CRATE_HASH="${BB_TASKHASH}" > > RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" > @@ -217,3 +221,8 @@ rust_do_install () { > do_install () { > rust_do_install > } > + > +FILE_${PN} += " \ > + ${WORKDIR}/target.json \ > +" > + > diff --git a/meta/recipes-devtools/rust/rust_1.65.0.bb b/meta/recipes-devtools/rust/rust_1.65.0.bb > index dbf74cec8f..afef72e45c 100644 > --- a/meta/recipes-devtools/rust/rust_1.65.0.bb > +++ b/meta/recipes-devtools/rust/rust_1.65.0.bb > @@ -68,6 +68,8 @@ rust_do_install:class-target() { > chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i > done > > + cp ${WORKDIR}/target.json ${D}${libdir}/rustlib/${RUST_TARGET_SYS} > + > chown root:root ${D}/ -R > rm ${D}${libdir}/rustlib/uninstall.sh > rm ${D}${libdir}/rustlib/install.log > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#174396): https://lists.openembedded.org/g/openembedded-core/message/174396 > Mute This Topic: https://lists.openembedded.org/mt/95535785/3616765 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [randy.macleod@windriver.com] > -=-=-=-=-=-=-=-=-=-=-=- >
diff --git a/meta/recipes-devtools/rust/files/target.json b/meta/recipes-devtools/rust/files/target.json new file mode 100644 index 0000000000..69dbbaa9f9 --- /dev/null +++ b/meta/recipes-devtools/rust/files/target.json @@ -0,0 +1,39 @@ +{ + "arch": "x86_64", + "cpu": "x86-64", + "crt-static-respected": true, + "data-layout": +"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", + "dynamic-linking": true, + "env": "gnu", + "executables": true, + "has-rpath": true, + "linker-is-gnu": true, + "llvm-target": "x86_64-unknown-linux-gnu", + "max-atomic-width": 64, + "os": "linux", + "position-independent-executables": true, + "pre-link-args": { + "gcc": [ + "-m64" + ] + }, + "relro-level": "full", + "stack-probes": { + "kind": "inline-or-call", + "min-llvm-version-for-inline": [ + 11, + 0, + 1 + ] + }, + "supported-sanitizers": [ + "address", + "leak", + "memory", + "thread" + ], + "target-family": "unix", + "target-pointer-width": "64" +} + diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc index 956301023a..75473f967b 100644 --- a/meta/recipes-devtools/rust/rust.inc +++ b/meta/recipes-devtools/rust/rust.inc @@ -13,6 +13,10 @@ DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" S = "${RUSTSRC}" +SRC_URI += "\ + file://target.json \ +" + export FORCE_CRATE_HASH="${BB_TASKHASH}" RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" @@ -217,3 +221,8 @@ rust_do_install () { do_install () { rust_do_install } + +FILE_${PN} += " \ + ${WORKDIR}/target.json \ +" + diff --git a/meta/recipes-devtools/rust/rust_1.65.0.bb b/meta/recipes-devtools/rust/rust_1.65.0.bb index dbf74cec8f..afef72e45c 100644 --- a/meta/recipes-devtools/rust/rust_1.65.0.bb +++ b/meta/recipes-devtools/rust/rust_1.65.0.bb @@ -68,6 +68,8 @@ rust_do_install:class-target() { chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i done + cp ${WORKDIR}/target.json ${D}${libdir}/rustlib/${RUST_TARGET_SYS} + chown root:root ${D}/ -R rm ${D}${libdir}/rustlib/uninstall.sh rm ${D}${libdir}/rustlib/install.log
Rust code compilation on qemu failed with with below error. error: Error loading target specification: Could not find specification for target "x86_64-poky-linux-gnu". Run `rustc --print target-list` for a list of built-in targets. This patch fix the issue by adding the missing json file to the image. Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@gmail.com> --- meta/recipes-devtools/rust/files/target.json | 39 ++++++++++++++++++++ meta/recipes-devtools/rust/rust.inc | 9 +++++ meta/recipes-devtools/rust/rust_1.65.0.bb | 2 + 3 files changed, 50 insertions(+) create mode 100644 meta/recipes-devtools/rust/files/target.json