diff options
author | Yash Shinde <Yash.Shinde@windriver.com> | 2023-07-29 00:00:20 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-07-30 07:54:44 +0100 |
commit | 9b07dbc41f14d48448744bbd8cfe68fd6368c354 (patch) | |
tree | c5c659aa9dc95dc979a9958ab77ea1fe786768f8 /meta/recipes-devtools/rust | |
parent | 80cec38c0cde4eae80c1fdfe4dfaac28bcfc5d91 (diff) | |
download | poky-9b07dbc41f14d48448744bbd8cfe68fd6368c354.tar.gz |
rust: Fix BOOTSTRAP_CARGO failure during Rust Oe-selftest
BOOTSTRAP_CARGO command fails due to codegen flags like `-Cpanic` were
prevented from being reflected in the current target configuration which
leads to Rust build(rust version 1.70) failure in Oe-selftest.
Upstream-Status: Backport [https://github.com/rust-lang/rust/commit/9dffb52738e0b2ccd15af36d4607a709b21e020c]
(From OE-Core rev: a48e3612b5dc0e58a89f88a914365e926101c90b)
Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/rust')
-rw-r--r-- | meta/recipes-devtools/rust/files/bootstrap_fail.patch | 127 | ||||
-rw-r--r-- | meta/recipes-devtools/rust/rust-source.inc | 1 |
2 files changed, 128 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rust/files/bootstrap_fail.patch b/meta/recipes-devtools/rust/files/bootstrap_fail.patch new file mode 100644 index 0000000000..1f44b6eaf6 --- /dev/null +++ b/meta/recipes-devtools/rust/files/bootstrap_fail.patch | |||
@@ -0,0 +1,127 @@ | |||
1 | rust: Fix BOOTSTRAP_CARGO failure during Rust Oe-selftest | ||
2 | |||
3 | BOOTSTRAP_CARGO command fails due to codegen flags like `-Cpanic` were | ||
4 | prevented from being reflected in the current target configuration which | ||
5 | leads to Rust build(rust version 1.70) failure in Oe-selftest. | ||
6 | |||
7 | Upstream-Status: Backport [https://github.com/rust-lang/rust/commit/9dffb52738e0b2ccd15af36d4607a709b21e020c] | ||
8 | |||
9 | Signed-off-by: Yash Shinde <yashinde145@gmail.com> | ||
10 | --- | ||
11 | diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs | ||
12 | --- a/src/tools/compiletest/src/common.rs | ||
13 | +++ b/src/tools/compiletest/src/common.rs | ||
14 | @@ -431,7 +431,6 @@ | ||
15 | .unwrap() | ||
16 | }; | ||
17 | |||
18 | - let mut current = None; | ||
19 | let mut all_targets = HashSet::new(); | ||
20 | let mut all_archs = HashSet::new(); | ||
21 | let mut all_oses = HashSet::new(); | ||
22 | @@ -452,14 +451,11 @@ | ||
23 | } | ||
24 | all_pointer_widths.insert(format!("{}bit", cfg.pointer_width)); | ||
25 | |||
26 | - if target == config.target { | ||
27 | - current = Some(cfg); | ||
28 | - } | ||
29 | all_targets.insert(target.into()); | ||
30 | } | ||
31 | |||
32 | Self { | ||
33 | - current: current.expect("current target not found"), | ||
34 | + current: Self::get_current_target_config(config), | ||
35 | all_targets, | ||
36 | all_archs, | ||
37 | all_oses, | ||
38 | @@ -471,6 +467,89 @@ | ||
39 | } | ||
40 | } | ||
41 | |||
42 | + fn get_current_target_config(config: &Config) -> TargetCfg { | ||
43 | + let mut arch = None; | ||
44 | + let mut os = None; | ||
45 | + let mut env = None; | ||
46 | + let mut abi = None; | ||
47 | + let mut families = Vec::new(); | ||
48 | + let mut pointer_width = None; | ||
49 | + let mut endian = None; | ||
50 | + let mut panic = None; | ||
51 | + | ||
52 | + for config in | ||
53 | + rustc_output(config, &["--print=cfg", "--target", &config.target]).trim().lines() | ||
54 | + { | ||
55 | + let (name, value) = config | ||
56 | + .split_once("=\"") | ||
57 | + .map(|(name, value)| { | ||
58 | + ( | ||
59 | + name, | ||
60 | + Some( | ||
61 | + value | ||
62 | + .strip_suffix("\"") | ||
63 | + .expect("key-value pair should be properly quoted"), | ||
64 | + ), | ||
65 | + ) | ||
66 | + }) | ||
67 | + .unwrap_or_else(|| (config, None)); | ||
68 | + | ||
69 | + match name { | ||
70 | + "target_arch" => { | ||
71 | + arch = Some(value.expect("target_arch should be a key-value pair").to_string()); | ||
72 | + } | ||
73 | + "target_os" => { | ||
74 | + os = Some(value.expect("target_os sould be a key-value pair").to_string()); | ||
75 | + } | ||
76 | + "target_env" => { | ||
77 | + env = Some(value.expect("target_env should be a key-value pair").to_string()); | ||
78 | + } | ||
79 | + "target_abi" => { | ||
80 | + abi = Some(value.expect("target_abi should be a key-value pair").to_string()); | ||
81 | + } | ||
82 | + "target_family" => { | ||
83 | + families | ||
84 | + .push(value.expect("target_family should be a key-value pair").to_string()); | ||
85 | + } | ||
86 | + "target_pointer_width" => { | ||
87 | + pointer_width = Some( | ||
88 | + value | ||
89 | + .expect("target_pointer_width should be a key-value pair") | ||
90 | + .parse::<u32>() | ||
91 | + .expect("target_pointer_width should be a valid u32"), | ||
92 | + ); | ||
93 | + } | ||
94 | + "target_endian" => { | ||
95 | + endian = Some(match value.expect("target_endian should be a key-value pair") { | ||
96 | + "big" => Endian::Big, | ||
97 | + "little" => Endian::Little, | ||
98 | + _ => panic!("target_endian should be either 'big' or 'little'"), | ||
99 | + }); | ||
100 | + } | ||
101 | + "panic" => { | ||
102 | + panic = Some(match value.expect("panic should be a key-value pair") { | ||
103 | + "abort" => PanicStrategy::Abort, | ||
104 | + "unwind" => PanicStrategy::Unwind, | ||
105 | + _ => panic!("panic should be either 'abort' or 'unwind'"), | ||
106 | + }); | ||
107 | + } | ||
108 | + _ => (), | ||
109 | + } | ||
110 | + } | ||
111 | + | ||
112 | + TargetCfg { | ||
113 | + arch: arch.expect("target configuration should specify target_arch"), | ||
114 | + os: os.expect("target configuration should specify target_os"), | ||
115 | + env: env.expect("target configuration should specify target_env"), | ||
116 | + abi: abi.expect("target configuration should specify target_abi"), | ||
117 | + families, | ||
118 | + pointer_width: pointer_width | ||
119 | + .expect("target configuration should specify target_pointer_width"), | ||
120 | + endian: endian.expect("target configuration should specify target_endian"), | ||
121 | + panic: panic.expect("target configuration should specify panic"), | ||
122 | + } | ||
123 | + } | ||
124 | + | ||
125 | // #[cfg(bootstrap)] | ||
126 | // Needed only for one cycle, remove during the bootstrap bump. | ||
127 | fn collect_all_slow(config: &Config) -> HashMap<String, TargetCfg> { | ||
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc index 0009c50172..8b9199e9ab 100644 --- a/meta/recipes-devtools/rust/rust-source.inc +++ b/meta/recipes-devtools/rust/rust-source.inc | |||
@@ -7,6 +7,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n | |||
7 | file://zlib-off64_t.patch;patchdir=${RUSTSRC} \ | 7 | file://zlib-off64_t.patch;patchdir=${RUSTSRC} \ |
8 | file://0001-musl-Define-SOCK_SEQPACKET-in-common-place.patch;patchdir=${RUSTSRC} \ | 8 | file://0001-musl-Define-SOCK_SEQPACKET-in-common-place.patch;patchdir=${RUSTSRC} \ |
9 | file://rust-oe-selftest.patch;patchdir=${RUSTSRC} \ | 9 | file://rust-oe-selftest.patch;patchdir=${RUSTSRC} \ |
10 | file://bootstrap_fail.patch;patchdir=${RUSTSRC} \ | ||
10 | " | 11 | " |
11 | SRC_URI[rust.sha256sum] = "bb8e9c564566b2d3228d95de9063a9254182446a161353f1d843bfbaf5c34639" | 12 | SRC_URI[rust.sha256sum] = "bb8e9c564566b2d3228d95de9063a9254182446a161353f1d843bfbaf5c34639" |
12 | 13 | ||