forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#125872 - fmease:rollup-ei6igof, r=fmease
Rollup of 4 pull requests Successful merges: - rust-lang#124294 (Unroll first iteration of checked_ilog loop) - rust-lang#125773 (Migrate run make cdylib) - rust-lang#125808 (Migrate `run-make/c-link-to-rust-dylib` to `rmake.rs`) - rust-lang#125822 (Refactor `--print=check-cfg` test) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
10 changed files
with
221 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//@ compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
|
||
// Ensure that when val < base, we do not divide or multiply. | ||
|
||
// CHECK-LABEL: @checked_ilog | ||
// CHECK-SAME: (i16 noundef %val, i16 noundef %base) | ||
#[no_mangle] | ||
pub fn checked_ilog(val: u16, base: u16) -> Option<u32> { | ||
// CHECK-NOT: udiv | ||
// CHECK-NOT: mul | ||
// CHECK: %[[IS_LESS:.+]] = icmp ult i16 %val, %base | ||
// CHECK-NEXT: br i1 %[[IS_LESS]], label %[[TRUE:.+]], label %[[FALSE:.+]] | ||
// CHECK: [[TRUE]]: | ||
// CHECK-NOT: udiv | ||
// CHECK-NOT: mul | ||
// CHECK: ret { i32, i32 } | ||
val.checked_ilog(base) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// This test checks that C linking with Rust does not encounter any errors, with dynamic libraries. | ||
// See <https://github.com/rust-lang/rust/issues/10434>. | ||
|
||
//@ ignore-cross-compile | ||
|
||
use std::fs::remove_file; | ||
|
||
use run_make_support::{ | ||
dynamic_lib_extension, is_msvc, read_dir, run, run_fail, rustc, tmp_dir, Cc, | ||
}; | ||
|
||
fn main() { | ||
rustc().input("foo.rs").run(); | ||
|
||
if is_msvc() { | ||
Cc::new().input("bar.c").arg(tmp_dir().join("foo.dll.lib")).out_exe("bar").run(); | ||
} else { | ||
Cc::new() | ||
.input("bar.c") | ||
.arg("-lfoo") | ||
.output(tmp_dir().join("bar")) | ||
.library_search_path(tmp_dir()) | ||
.run(); | ||
} | ||
|
||
run("bar"); | ||
|
||
let expected_extension = dynamic_lib_extension(); | ||
read_dir(tmp_dir(), |path| { | ||
if path.is_file() | ||
&& path.extension().is_some_and(|ext| ext == expected_extension) | ||
&& path | ||
.file_name() | ||
.and_then(|name| name.to_str()) | ||
.is_some_and(|name| name.starts_with("lib")) | ||
{ | ||
remove_file(path).unwrap(); | ||
} | ||
}); | ||
run_fail("bar"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// This test tries to check that basic cdylib libraries can be compiled and linked successfully | ||
// with C code, that the cdylib itself can depend on another rlib, and that the library can be built | ||
// with LTO. | ||
// | ||
// - `bar.rs` is a rlib | ||
// - `foo.rs` is a cdylib that relies on an extern crate `bar` and defines two `extern "C"` | ||
// functions: | ||
// - `foo()` which calls `bar::bar()`. | ||
// - `bar()` which implements basic addition. | ||
|
||
//@ ignore-cross-compile | ||
|
||
use std::fs::remove_file; | ||
|
||
use run_make_support::{cc, dynamic_lib, is_msvc, run, rustc, tmp_dir}; | ||
|
||
fn main() { | ||
rustc().input("bar.rs").run(); | ||
rustc().input("foo.rs").run(); | ||
|
||
if is_msvc() { | ||
cc().input("foo.c").arg(tmp_dir().join("foo.dll.lib")).out_exe("foo").run(); | ||
} else { | ||
cc().input("foo.c") | ||
.arg("-lfoo") | ||
.output(tmp_dir().join("foo")) | ||
.library_search_path(tmp_dir()) | ||
.run(); | ||
} | ||
|
||
run("foo"); | ||
remove_file(dynamic_lib("foo")).unwrap(); | ||
|
||
rustc().input("foo.rs").arg("-Clto").run(); | ||
run("foo"); | ||
} |
Oops, something went wrong.