Skip to contentSkip to conversation

Fix rust-native build issue when debug is enabled

PATCH In review Pgowda 2 participants 4 messages Sep 29, 2021 – Oct 7, 2021

lore
Share & tools
lore

Pgowda

author
#0 lore raw

PATCH 1/1 Fix rust-native build issue when debug is enabled

When DEBUG_BUILD is set for building rust-native, it generated error as follows:-
=========================================================
Building : rustdoc, rustdoc-json-types
error[E0463]: can't find crate for rustc_llvm which rustc_driver depends on
--> src/librustdoc/lib.rs:37:1

   |
37 | extern crate rustc_driver;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

=========================================================
On analyzing the issue, it was found that rustc_llvm crate was present at required path. However, it was very huge due to the presence of debugging information. Hence, it was somehow not recognized as a valid crate. The following patch removes the debug information from rust-llvm-native which is built prior to rust-native but retains debug information as required in rust-native binaries.

---
 meta/recipes-devtools/rust/rust-llvm.inc | 5 +++++
 1 file changed, 5 insertions(+)
meta/recipes-devtools/rust/rust-llvm.inc +5 -0
index d7f445385b..0f8fb785b7 100644
@@ -15,6 +15,11 @@ 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}"
 
 EXTRA_OECMAKE = " \
Signature · 1 line
2.31.1
#1 lore raw
Quoted 7 lines · Pgowda

When DEBUG_BUILD is set for building rust-native, it generated error as follows:-
=========================================================
Building : rustdoc, rustdoc-json-types
error[E0463]: can't find crate for rustc_llvm which rustc_driver depends on
--> src/librustdoc/lib.rs:37:1

Quoted 8 lines
    |
37 | extern crate rustc_driver;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

=========================================================
On analyzing the issue, it was found that rustc_llvm crate was present at required path. However, it was very huge due to the presence of debugging information. Hence, it was somehow not recognized as a valid crate.

So we need to know more about this. What tool is being used to identify the crate and has there been any changes to fix is since 1.54?

Also, please check this problem still happens with Alex's 1.55 upgrade:

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=akanavin/package-version-updates

Quoted 3 lines

The following patch removes the debug information from rust-llvm-native which is built prior to rust-native but retains debug information as required in rust-native binaries.

This is a functional work-around but I suspect that we'll hold-off for a while before giving in and accepting it in oe-core/master. Some people might find it useful so thanks for posting it as I suggested.

Hopefully we can better understand and fix the root cause.

Thanks Naveen,

../Randy

Quoted 33 lines
---
  meta/recipes-devtools/rust/rust-llvm.inc | 5 +++++
  1 file changed, 5 insertions(+)
meta/recipes-devtools/rust/rust-llvm.inc +5 -1
index d7f445385b..0f8fb785b7 100644
@@ -15,6 +15,11 @@ 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}"
 
  EXTRA_OECMAKE = " \
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#156454): https://lists.openembedded.org/g/openembedded-core/message/156454
Mute This Topic: https://lists.openembedded.org/mt/85948023/3616765
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 2 lines
# Randy MacLeod
# Wind River Linux
#3 lore raw
Quoted 4 lines · pgowda cve

Hi Randy,

Quoted 1 line
Quoted 1 line

check this problem still happens with Alex's 1.55 upgrade:

Quoted 9 lines

I checked the issue with latest version upgrade branch from Alexander:-
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=akanavin/package-version-updates

It builds as expected without any errors for rust-native with DEBUG_BUILD = "1"

Thanks,
pgowda

Oh excellent! We don't really need to identify what the change was that fixed it but I'm curious so please take 10 minutes or so to see if you can find it.

Signature · 2 lines
# Randy MacLeod
# Wind River Linux