summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rust/files/revert-link-std-statically-in-rustc_driver-feature.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/rust/files/revert-link-std-statically-in-rustc_driver-feature.patch')
-rw-r--r--meta/recipes-devtools/rust/files/revert-link-std-statically-in-rustc_driver-feature.patch199
1 files changed, 199 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rust/files/revert-link-std-statically-in-rustc_driver-feature.patch b/meta/recipes-devtools/rust/files/revert-link-std-statically-in-rustc_driver-feature.patch
new file mode 100644
index 0000000000..257883ef60
--- /dev/null
+++ b/meta/recipes-devtools/rust/files/revert-link-std-statically-in-rustc_driver-feature.patch
@@ -0,0 +1,199 @@
1rust: oe-selftest issue fix with v1.82
2
3A new feature "Link std statically in rustc_driver" was introduced
4in rust_1.82 [https://github.com/rust-lang/rust/pull/122362],and
5which is causing the below failure in oe-selftest.
6
7Running unittests src/main.rs (build/x86_64-unknown-linux-gnu/stage1-rustc/
8x86_64-poky-linux-gnu/release/deps/rustc_main-92223b15c9f2d827)
9uploaded ".../build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-poky-linux-gnu/
10release/deps/rustc_main-92223b15c9f2d827", waiting for result
11/tmp/work/test4056/rustc_main-92223b15c9f2d827: error while loading shared
12libraries: librustc_driver-fb0866b1cd913c20.so: cannot open shared object file: No
13such file or directory
14
15The rustc_main binary depends on the librustc_driver-*.so file. However,
16this file has not been copied to QEMU. If we manually copy the file into
17QEMU and export the LD_LIBRARY_PATH, the issue does not occur. Issue
18reprorted to upstream and reverted the buggy code as a workaround.
19
20Upstream-Status: Inappropriate [reported at https://github.com/rust-lang/rust/issues/136237]
21
22Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
23diff --git a/compiler/rustc/src/main.rs b/compiler/rustc/src/main.rs
24index e9a7397557..29766fc9d8 100644
25--- a/compiler/rustc/src/main.rs
26+++ b/compiler/rustc/src/main.rs
27@@ -1,6 +1,3 @@
28-// We need this feature as it changes `dylib` linking behavior and allows us to link to `rustc_driver`.
29-#![feature(rustc_private)]
30-
31 // A note about jemalloc: rustc uses jemalloc when built for CI and
32 // distribution. The obvious way to do this is with the `#[global_allocator]`
33 // mechanism. However, for complicated reasons (see
34diff --git a/compiler/rustc_metadata/src/dependency_format.rs b/compiler/rustc_metadata/src/dependency_format.rs
35index 39fa23766b..51d86b4009 100644
36--- a/compiler/rustc_metadata/src/dependency_format.rs
37+++ b/compiler/rustc_metadata/src/dependency_format.rs
38@@ -51,7 +51,7 @@
39 //! Additionally, the algorithm is geared towards finding *any* solution rather
40 //! than finding a number of solutions (there are normally quite a few).
41
42-use rustc_data_structures::fx::{FxHashMap, FxHashSet};
43+use rustc_data_structures::fx::FxHashMap;
44 use rustc_hir::def_id::CrateNum;
45 use rustc_middle::bug;
46 use rustc_middle::middle::dependency_format::{Dependencies, DependencyList, Linkage};
47@@ -162,43 +162,18 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
48 Linkage::Dynamic | Linkage::IncludedFromDylib => {}
49 }
50
51- let all_dylibs = || {
52- tcx.crates(()).iter().filter(|&&cnum| {
53- !tcx.dep_kind(cnum).macros_only() && tcx.used_crate_source(cnum).dylib.is_some()
54- })
55- };
56-
57- let mut upstream_in_dylibs = FxHashSet::default();
58-
59- if tcx.features().rustc_private {
60- // We need this to prevent users of `rustc_driver` from linking dynamically to `std`
61- // which does not work as `std` is also statically linked into `rustc_driver`.
62-
63- // Find all libraries statically linked to upstream dylibs.
64- for &cnum in all_dylibs() {
65- let deps = tcx.dylib_dependency_formats(cnum);
66- for &(depnum, style) in deps.iter() {
67- if let RequireStatic = style {
68- upstream_in_dylibs.insert(depnum);
69- }
70- }
71- }
72- }
73-
74 let mut formats = FxHashMap::default();
75
76 // Sweep all crates for found dylibs. Add all dylibs, as well as their
77 // dependencies, ensuring there are no conflicts. The only valid case for a
78 // dependency to be relied upon twice is for both cases to rely on a dylib.
79- for &cnum in all_dylibs() {
80- if upstream_in_dylibs.contains(&cnum) {
81- info!("skipping dylib: {}", tcx.crate_name(cnum));
82- // If this dylib is also available statically linked to another dylib
83- // we try to use that instead.
84+ for &cnum in tcx.crates(()).iter() {
85+ if tcx.dep_kind(cnum).macros_only() {
86 continue;
87 }
88-
89 let name = tcx.crate_name(cnum);
90+ let src = tcx.used_crate_source(cnum);
91+ if src.dylib.is_some() {
92 info!("adding dylib: {}", name);
93 add_library(tcx, cnum, RequireDynamic, &mut formats, &mut unavailable_as_static);
94 let deps = tcx.dylib_dependency_formats(cnum);
95@@ -207,6 +182,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
96 add_library(tcx, depnum, style, &mut formats, &mut unavailable_as_static);
97 }
98 }
99+ }
100
101 // Collect what we've got so far in the return vector.
102 let last_crate = tcx.crates(()).len();
103diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs
104index d04e2fbeb7..011c289d93 100644
105--- a/src/bootstrap/src/bin/rustc.rs
106+++ b/src/bootstrap/src/bin/rustc.rs
107@@ -89,25 +89,6 @@ fn main() {
108 rustc_real
109 };
110
111- // Get the name of the crate we're compiling, if any.
112- let crate_name = parse_value_from_args(&orig_args, "--crate-name");
113-
114- // When statically linking `std` into `rustc_driver`, remove `-C prefer-dynamic`
115- if env::var("RUSTC_LINK_STD_INTO_RUSTC_DRIVER").unwrap() == "1"
116- && crate_name == Some("rustc_driver")
117- && stage != "0"
118- {
119- if let Some(pos) = args.iter().enumerate().position(|(i, a)| {
120- a == "-C" && args.get(i + 1).map(|a| a == "prefer-dynamic").unwrap_or(false)
121- }) {
122- args.remove(pos);
123- args.remove(pos);
124- }
125- if let Some(pos) = args.iter().position(|a| a == "-Cprefer-dynamic") {
126- args.remove(pos);
127- }
128- }
129-
130 let mut cmd = match env::var_os("RUSTC_WRAPPER_REAL") {
131 Some(wrapper) if !wrapper.is_empty() => {
132 let mut cmd = Command::new(wrapper);
133@@ -118,6 +99,9 @@ fn main() {
134 };
135 cmd.args(&args).env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
136
137+ // Get the name of the crate we're compiling, if any.
138+ let crate_name = parse_value_from_args(&orig_args, "--crate-name");
139+
140 if let Some(crate_name) = crate_name {
141 if let Some(target) = env::var_os("RUSTC_TIME") {
142 if target == "all"
143diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
144index ff0d1f3a72..b2c9602e57 100644
145--- a/src/bootstrap/src/core/builder.rs
146+++ b/src/bootstrap/src/core/builder.rs
147@@ -2153,7 +2153,7 @@ impl<'a> Builder<'a> {
148 // When we build Rust dylibs they're all intended for intermediate
149 // usage, so make sure we pass the -Cprefer-dynamic flag instead of
150 // linking all deps statically into the dylib.
151- if matches!(mode, Mode::Std) {
152+ if matches!(mode, Mode::Std | Mode::Rustc) {
153 rustflags.arg("-Cprefer-dynamic");
154 }
155 if matches!(mode, Mode::Rustc) && !self.link_std_into_rustc_driver(target) {
156diff --git a/src/tools/clippy/src/main.rs b/src/tools/clippy/src/main.rs
157index c9853e53f3..c9af2138a7 100644
158--- a/src/tools/clippy/src/main.rs
159+++ b/src/tools/clippy/src/main.rs
160@@ -1,6 +1,3 @@
161-// We need this feature as it changes `dylib` linking behavior and allows us to link to
162-// `rustc_driver`.
163-#![feature(rustc_private)]
164 // warn on lints, that are included in `rust-lang/rust`s bootstrap
165 #![warn(rust_2018_idioms, unused_lifetimes)]
166
167diff --git a/src/tools/clippy/tests/compile-test.rs b/src/tools/clippy/tests/compile-test.rs
168index 9754254cdd..dd95cc71cd 100644
169--- a/src/tools/clippy/tests/compile-test.rs
170+++ b/src/tools/clippy/tests/compile-test.rs
171@@ -1,4 +1,4 @@
172-#![feature(rustc_private, let_chains)]
173+#![feature(let_chains)]
174 #![warn(rust_2018_idioms, unused_lifetimes)]
175 #![allow(unused_extern_crates)]
176
177diff --git a/src/tools/rustdoc/main.rs b/src/tools/rustdoc/main.rs
178index d4099cafe5..5b499a1fa1 100644
179--- a/src/tools/rustdoc/main.rs
180+++ b/src/tools/rustdoc/main.rs
181@@ -1,6 +1,3 @@
182-// We need this feature as it changes `dylib` linking behavior and allows us to link to `rustc_driver`.
183-#![feature(rustc_private)]
184-
185 fn main() {
186 rustdoc::main()
187 }
188diff --git a/src/tools/rustfmt/src/git-rustfmt/main.rs b/src/tools/rustfmt/src/git-rustfmt/main.rs
189index b8b0432aa9..b5bd71e015 100644
190--- a/src/tools/rustfmt/src/git-rustfmt/main.rs
191+++ b/src/tools/rustfmt/src/git-rustfmt/main.rs
192@@ -1,7 +1,3 @@
193-// We need this feature as it changes `dylib` linking behavior and allows us to link to
194-// `rustc_driver`.
195-#![feature(rustc_private)]
196-
197 use std::env;
198 use std::io::stdout;
199 use std::path::{Path, PathBuf};