Skip to content

Commit

Permalink
Auto merge of rust-lang#128863 - matthiaskrgr:rollup-wmp8znk, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#128616 (Don't inline tainted MIR bodies)
 - rust-lang#128804 (run-make: enable msvc for redundant-libs)
 - rust-lang#128823 (run-make: enable msvc for staticlib-dylib-linkage)
 - rust-lang#128824 (Update compiler-builtins version to 0.1.118)

Failed merges:

 - rust-lang#128410 (Migrate `remap-path-prefix-dwarf` `run-make` test to rmake)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Aug 9, 2024
2 parents fac7753 + e880679 commit 97e7252
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.109"
version = "0.1.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f11973008a8cf741fe6d22f339eba21fd0ca81e2760a769ba8243ed6c21edd7e"
dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ resolver = "2"

[dependencies]
core = { path = "./sysroot_src/library/core" }
# TODO: after the sync, revert to using version 0.1.
# compiler_builtins = "0.1"
compiler_builtins = "=0.1.109"
compiler_builtins = "0.1"
alloc = { path = "./sysroot_src/library/alloc" }
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
test = { path = "./sysroot_src/library/test" }
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ impl<'tcx> Inliner<'tcx> {
) -> Result<(), &'static str> {
let tcx = self.tcx;

if let Some(_) = callee_body.tainted_by_errors {
return Err("Body is tainted");
}

let mut threshold = if self.caller_is_inline_forwarder {
self.tcx.sess.opts.unstable_opts.inline_mir_forwarder_threshold.unwrap_or(30)
} else if cross_crate_inlinable {
Expand Down
4 changes: 2 additions & 2 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.117"
version = "0.1.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a91dae36d82fe12621dfb5b596d7db766187747749b22e33ac068e1bfc356f4a"
checksum = "92afe7344b64cccf3662ca26d5d1c0828ab826f04206b97d856e3625e390e4b5"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2021"

[dependencies]
core = { path = "../core" }
compiler_builtins = { version = "0.1.117", features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "0.1.118", features = ['rustc-dep-of-std'] }

[dev-dependencies]
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
compiler_builtins = { version = "0.1.117" }
compiler_builtins = { version = "0.1.118" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
hashbrown = { version = "0.14", default-features = false, features = [
Expand Down
10 changes: 8 additions & 2 deletions tests/run-make/redundant-libs/foo.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
void foo1() {}
void foo2() {}
#ifdef _MSC_VER
#define DllExport __declspec(dllexport)
#else
#define DllExport
#endif

DllExport void foo1() {}
DllExport void foo2() {}
6 changes: 0 additions & 6 deletions tests/run-make/redundant-libs/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@

//@ ignore-cross-compile
// Reason: the compiled binary is executed
//@ ignore-windows-msvc
// Reason: this test links libraries via link.exe, which only accepts the import library
// for the dynamic library, i.e. `foo.dll.lib`. However, build_native_dynamic_lib only
// produces `foo.dll` - the dynamic library itself. To make this test work on MSVC, one
// would need to derive the import library from the dynamic library.
// See https://stackoverflow.com/questions/9360280/

use run_make_support::{
build_native_dynamic_lib, build_native_static_lib, cwd, is_msvc, rfs, run, rustc,
Expand Down
17 changes: 8 additions & 9 deletions tests/run-make/staticlib-dylib-linkage/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@
// Reason: the compiled binary is executed.
//@ ignore-wasm
// Reason: WASM does not support dynamic libraries
//@ ignore-msvc
//FIXME(Oneirical): Getting this to work on MSVC requires passing libcmt.lib to CC,
// which is not trivial to do.
// Tracking issue: https://github.com/rust-lang/rust/issues/128602
// Discussion: https://github.com/rust-lang/rust/pull/128407#discussion_r1702439172

use run_make_support::{cc, regex, run, rustc};
use run_make_support::{cc, is_msvc, regex, run, rustc, static_lib_name};

fn main() {
rustc().arg("-Cprefer-dynamic").input("bar.rs").run();
Expand All @@ -29,9 +24,13 @@ fn main() {
let re = regex::Regex::new(r#"note: native-static-libs:\s*(.+)"#).unwrap();
let libs = re.find(&libs).unwrap().as_str().trim();
// remove the note
let (_, library_search_paths) = libs.split_once("note: native-static-libs: ").unwrap();
let (_, native_link_args) = libs.split_once("note: native-static-libs: ").unwrap();
// divide the command-line arguments in a vec
let library_search_paths = library_search_paths.split(' ').collect::<Vec<&str>>();
cc().input("foo.c").arg("-lfoo").args(library_search_paths).out_exe("foo").run();
let mut native_link_args = native_link_args.split(' ').collect::<Vec<&str>>();
if is_msvc() {
// For MSVC pass the arguments on to the linker.
native_link_args.insert(0, "-link");
}
cc().input("foo.c").input(static_lib_name("foo")).args(native_link_args).out_exe("foo").run();
run("foo");
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes
//@ known-bug: #122909

#![feature(unboxed_closures)]

use std::sync::{Arc, Context, Weak};
use std::sync::Arc;

pub struct WeakOnce<T>();
//~^ ERROR type parameter `T` is never used

impl<T> WeakOnce<T> {
extern "rust-call" fn try_get(&self) -> Option<Arc<T>> {}
//~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument
//~| ERROR mismatched types

pub fn get(&self) -> Arc<T> {
self.try_get()
.unwrap_or_else(|| panic!("Singleton {} not available", std::any::type_name::<T>()))
}
}

fn main() {}
30 changes: 30 additions & 0 deletions tests/ui/polymorphization/inline-tainted-body.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
error[E0392]: type parameter `T` is never used
--> $DIR/inline-tainted-body.rs:7:21
|
LL | pub struct WeakOnce<T>();
| ^ unused type parameter
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error: functions with the "rust-call" ABI must take a single non-self tuple argument
--> $DIR/inline-tainted-body.rs:11:35
|
LL | extern "rust-call" fn try_get(&self) -> Option<Arc<T>> {}
| ^^^^^

error[E0308]: mismatched types
--> $DIR/inline-tainted-body.rs:11:45
|
LL | extern "rust-call" fn try_get(&self) -> Option<Arc<T>> {}
| ------- ^^^^^^^^^^^^^^ expected `Option<Arc<T>>`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected enum `Option<Arc<T>>`
found unit type `()`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0308, E0392.
For more information about an error, try `rustc --explain E0308`.

0 comments on commit 97e7252

Please sign in to comment.