Auto merge of #148481 - GuillaumeGomez:subtree-update_cg_gcc_2025-11-04, r=GuillaumeGomez

Sync rustc_codegen_gcc subtree

cc `@antoyo`

r? ghost
This commit is contained in:
bors 2025-11-13 18:00:02 +00:00
commit 2286e5d224
32 changed files with 483 additions and 292 deletions

View file

@ -62,7 +62,7 @@ jobs:
- name: Build
run: |
./y.sh prepare --only-libcore
EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot
./y.sh build --sysroot --release --release-sysroot
./y.sh test --cargo-tests
./y.sh clean all
@ -72,19 +72,14 @@ jobs:
git config --global user.name "User"
./y.sh prepare
- name: Add more failing tests because of undefined symbol errors (FIXME)
run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt
- name: Run tests
run: |
# FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros.
# FIXME(antoyo): this should probably not be needed since we embed the LTO bitcode.
printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml
EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }}
CG_RUSTFLAGS="-Cembed-bitcode=yes" ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }}
- name: Run y.sh cargo build
- name: LTO test
run: |
EMBED_LTO_BITCODE=1 CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml
CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml
call_found=$(objdump -dj .text tests/hello-world/target/release/hello_world | grep -c "call .*mylib.*my_func" ) ||:
if [ $call_found -gt 0 ]; then
echo "ERROR: call my_func found in asm"
@ -92,6 +87,21 @@ jobs:
exit 1
fi
- name: Cross-language LTO test
run: |
pushd tests/cross_lang_lto
gcc -c -flto add.c -masm=intel -fPIC -O3
ar rcs libadd.a add.o
popd
CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml
call_found=$(objdump -dj .text tests/cross_lang_lto/target/release/cross_lang_lto | grep -c "call .*my_add" ) ||:
if [ $call_found -gt 0 ]; then
echo "ERROR: call my_add found in asm"
echo "Test is done with cross-language LTO enabled, hence inlining should occur across object files"
exit 1
fi
# Summary job for the merge queue.
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
success_release:

View file

@ -41,7 +41,7 @@ jobs:
# TODO: remove when we have binutils version 2.43 in the repo.
- name: Install more recent binutils
run: |
echo "deb http://archive.ubuntu.com/ubuntu oracular main universe" | sudo tee /etc/apt/sources.list.d/oracular-copies.list
echo "deb http://archive.ubuntu.com/ubuntu plucky main universe" | sudo tee /etc/apt/sources.list.d/plucky-copies.list
sudo apt-get update
sudo apt-get install binutils

View file

@ -56,18 +56,18 @@ dependencies = [
[[package]]
name = "gccjit"
version = "2.9.0"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a0e310ef75f396cd11b2443b353d55376656ca92c13cba36f92b7aff346ac1a"
checksum = "60362e038e71e4bdc1a5b23fb45e1aba587b5947fe0db58f4871d95608f89eca"
dependencies = [
"gccjit_sys",
]
[[package]]
name = "gccjit_sys"
version = "0.8.2"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95ed7572b30cd32430294dde6fb70822d58e67c6846a548647e8739776a0125b"
checksum = "ddd542c8414e122217551c6af6b7d33acf51a227aee85276f218c087525e01bb"
dependencies = [
"libc",
]

View file

@ -24,7 +24,7 @@ default = ["master"]
[dependencies]
object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
tempfile = "3.20"
gccjit = "2.8"
gccjit = "2.10"
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs" }
# Local copy.

View file

@ -70,11 +70,17 @@ $ ../gcc/configure \
$ make -j4 # You can replace `4` with another number depending on how many cores you have.
```
If you want to run libgccjit tests, you will need to also enable the C++ language in the `configure`:
If you want to run libgccjit tests, you will need to
* Enable the C++ language in the `configure` step:
```bash
--enable-languages=jit,c++
```
* Install [dejagnu](https://www.gnu.org/software/dejagnu/#downloading) to run the tests:
```bash
$ sudo apt install dejagnu
```
Then to run libgccjit tests:
@ -135,16 +141,6 @@ $ CHANNEL="release" $CG_GCCJIT_DIR/y.sh cargo run
If you compiled cg_gccjit in debug mode (aka you didn't pass `--release` to `./y.sh test`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely.
### LTO
To use LTO, you need to set the variable `EMBED_LTO_BITCODE=1` in addition to setting `lto = "fat"` in the `Cargo.toml`.
Failing to set `EMBED_LTO_BITCODE` will give you the following error:
```
error: failed to copy bitcode to object file: No such file or directory (os error 2)
```
### Rustc
If you want to run `rustc` directly, you can do so with:

View file

@ -149,6 +149,9 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
// Copy files to sysroot
let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple));
// To avoid errors like "multiple candidates for `rmeta` dependency `core` found", we clean the
// sysroot directory before copying the sysroot build artifacts.
let _ = fs::remove_dir_all(&sysroot_path);
create_dir(&sysroot_path)?;
let mut copier = |dir_to_copy: &Path| {
// FIXME: should not use shell command!

View file

@ -69,8 +69,13 @@ fn clean_all() -> Result<(), String> {
}
fn clean_ui_tests() -> Result<(), String> {
let path = Path::new(crate::BUILD_DIR).join("rust/build/x86_64-unknown-linux-gnu/test/ui/");
run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?;
let directories = ["run-make", "run-make-cargo", "ui"];
for directory in directories {
let path = Path::new(crate::BUILD_DIR)
.join("rust/build/x86_64-unknown-linux-gnu/test/")
.join(directory);
run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?;
}
Ok(())
}

View file

@ -1,5 +1,7 @@
use std::ffi::OsStr;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Output;
use crate::rustc_info::get_rustc_path;
use crate::utils::{
@ -7,6 +9,41 @@ use crate::utils::{
run_command_with_output, walk_dir,
};
// This is needed on systems where nothing is configured.
// git really needs something here, or it will fail.
// Even using --author is not enough.
const GIT_CMD: [&dyn AsRef<OsStr>; 9] = [
&"git",
&"-c",
&"user.name=None",
&"-c",
&"user.email=none@example.com",
&"-c",
&"core.autocrlf=false",
&"-c",
&"commit.gpgSign=false",
];
fn run_git_command(
command: &dyn AsRef<OsStr>,
input: &[&dyn AsRef<OsStr>],
cwd: Option<&Path>,
) -> Result<Output, String> {
let git_cmd =
&GIT_CMD.into_iter().chain([command]).chain(input.iter().cloned()).collect::<Vec<_>>()[..];
run_command(git_cmd, cwd)
}
fn run_git_command_with_output(
command: &dyn AsRef<OsStr>,
input: &[&dyn AsRef<OsStr>],
cwd: Option<&Path>,
) -> Result<(), String> {
let git_cmd =
&GIT_CMD.into_iter().chain([command]).chain(input.iter().cloned()).collect::<Vec<_>>()[..];
run_command_with_output(git_cmd, cwd)
}
fn prepare_libcore(
sysroot_path: &Path,
libgccjit12_patches: bool,
@ -55,19 +92,12 @@ fn prepare_libcore(
run_command(&[&"cp", &"-r", &rustlib_dir.join("library"), &sysroot_dir], None)?;
println!("[GIT] init (cwd): `{}`", sysroot_dir.display());
run_command(&[&"git", &"init"], Some(&sysroot_dir))?;
run_git_command(&"init", &[], Some(&sysroot_dir))?;
println!("[GIT] add (cwd): `{}`", sysroot_dir.display());
run_command(&[&"git", &"add", &"."], Some(&sysroot_dir))?;
run_git_command(&"add", &[&"."], Some(&sysroot_dir))?;
println!("[GIT] commit (cwd): `{}`", sysroot_dir.display());
// This is needed on systems where nothing is configured.
// git really needs something here, or it will fail.
// Even using --author is not enough.
run_command(&[&"git", &"config", &"user.email", &"none@example.com"], Some(&sysroot_dir))?;
run_command(&[&"git", &"config", &"user.name", &"None"], Some(&sysroot_dir))?;
run_command(&[&"git", &"config", &"core.autocrlf", &"false"], Some(&sysroot_dir))?;
run_command(&[&"git", &"config", &"commit.gpgSign", &"false"], Some(&sysroot_dir))?;
run_command(&[&"git", &"commit", &"-m", &"Initial commit", &"-q"], Some(&sysroot_dir))?;
run_git_command(&"commit", &[&"-m", &"Initial commit", &"-q"], Some(&sysroot_dir))?;
let mut patches = Vec::new();
walk_dir(
@ -105,10 +135,11 @@ fn prepare_libcore(
for file_path in patches {
println!("[GIT] apply `{}`", file_path.display());
let path = Path::new("../../..").join(file_path);
run_command_with_output(&[&"git", &"apply", &path], Some(&sysroot_dir))?;
run_command_with_output(&[&"git", &"add", &"-A"], Some(&sysroot_dir))?;
run_command_with_output(
&[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())],
run_git_command_with_output(&"apply", &[&path], Some(&sysroot_dir))?;
run_git_command_with_output(&"add", &[&"-A"], Some(&sysroot_dir))?;
run_git_command_with_output(
&"commit",
&[&"-m", &format!("Patch {}", path.display())],
Some(&sysroot_dir),
)?;
}
@ -124,10 +155,11 @@ fn prepare_rand() -> Result<(), String> {
let rand_dir = Path::new("build/rand");
println!("[GIT] apply `{file_path}`");
let path = Path::new("../..").join(file_path);
run_command_with_output(&[&"git", &"apply", &path], Some(rand_dir))?;
run_command_with_output(&[&"git", &"add", &"-A"], Some(rand_dir))?;
run_command_with_output(
&[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())],
run_git_command_with_output(&"apply", &[&path], Some(rand_dir))?;
run_git_command_with_output(&"add", &[&"-A"], Some(rand_dir))?;
run_git_command_with_output(
&"commit",
&[&"-m", &format!("Patch {}", path.display())],
Some(rand_dir),
)?;
@ -154,8 +186,8 @@ where
println!("`{}` has already been cloned", clone_result.repo_name);
}
let repo_path = Path::new(crate::BUILD_DIR).join(&clone_result.repo_name);
run_command(&[&"git", &"checkout", &"--", &"."], Some(&repo_path))?;
run_command(&[&"git", &"checkout", &checkout_commit], Some(&repo_path))?;
run_git_command(&"checkout", &[&"--", &"."], Some(&repo_path))?;
run_git_command(&"checkout", &[&checkout_commit], Some(&repo_path))?;
if let Some(extra) = extra {
extra(&repo_path)?;
}

View file

@ -910,6 +910,7 @@ fn test_rustc_inner<F>(
prepare_files_callback: F,
run_error_pattern_test: bool,
test_type: &str,
run_ignored_tests: bool,
) -> Result<(), String>
where
F: Fn(&Path) -> Result<bool, String>,
@ -944,17 +945,7 @@ where
rust_path.join("tests/ui"),
&mut |dir| {
let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or("");
if [
"abi",
"extern",
"unsized-locals",
"proc-macro",
"threads-sendsync",
"borrowck",
"test-attrs",
]
.contains(&dir_name)
{
if ["abi", "extern", "proc-macro", "threads-sendsync"].contains(&dir_name) {
remove_dir_all(dir).map_err(|error| {
format!("Failed to remove folder `{}`: {:?}", dir.display(), error)
})?;
@ -1061,30 +1052,34 @@ where
env.get_mut("RUSTFLAGS").unwrap().clear();
run_command_with_output_and_env(
&[
&"./x.py",
&"test",
&"--run",
&"always",
&"--stage",
&"0",
&"--set",
&"build.compiletest-allow-stage0=true",
&format!("tests/{test_type}"),
&"--compiletest-rustc-args",
&rustc_args,
],
Some(&rust_path),
Some(&env),
)?;
let test_dir = format!("tests/{test_type}");
let mut command: Vec<&dyn AsRef<OsStr>> = vec![
&"./x.py",
&"test",
&"--run",
&"always",
&"--stage",
&"0",
&"--set",
&"build.compiletest-allow-stage0=true",
&test_dir,
&"--compiletest-rustc-args",
&rustc_args,
];
if run_ignored_tests {
command.push(&"--");
command.push(&"--ignored");
}
run_command_with_output_and_env(&command, Some(&rust_path), Some(&env))?;
Ok(())
}
fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?;
test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo")?;
test_rustc_inner(env, args, |_| Ok(false), false, "ui")
test_rustc_inner(env, args, |_| Ok(false), false, "run-make", false)?;
test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo", false)?;
test_rustc_inner(env, args, |_| Ok(false), false, "ui", false)
}
fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
@ -1094,6 +1089,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
retain_files_callback("tests/failing-run-make-tests.txt", "run-make"),
false,
"run-make",
true,
);
let run_make_cargo_result = test_rustc_inner(
@ -1102,6 +1098,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
retain_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"),
false,
"run-make",
true,
);
let ui_result = test_rustc_inner(
@ -1110,6 +1107,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
retain_files_callback("tests/failing-ui-tests.txt", "ui"),
false,
"ui",
true,
);
run_make_result.and(run_make_cargo_result).and(ui_result)
@ -1122,6 +1120,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
remove_files_callback("tests/failing-ui-tests.txt", "ui"),
false,
"ui",
false,
)?;
test_rustc_inner(
env,
@ -1129,6 +1128,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
remove_files_callback("tests/failing-run-make-tests.txt", "run-make"),
false,
"run-make",
false,
)?;
test_rustc_inner(
env,
@ -1136,6 +1136,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
remove_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"),
false,
"run-make-cargo",
false,
)
}
@ -1146,6 +1147,7 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String
remove_files_callback("tests/failing-ice-tests.txt", "ui"),
true,
"ui",
false,
)
}

View file

@ -112,8 +112,7 @@ pub fn run_command_with_output(
cwd: Option<&Path>,
) -> Result<(), String> {
let exit_status = exec_command(input, cwd, None)?;
check_exit_status(input, cwd, exit_status, None, true)?;
Ok(())
check_exit_status(input, cwd, exit_status, None, true)
}
pub fn run_command_with_output_and_env(
@ -122,8 +121,7 @@ pub fn run_command_with_output_and_env(
env: Option<&HashMap<String, String>>,
) -> Result<(), String> {
let exit_status = exec_command(input, cwd, env)?;
check_exit_status(input, cwd, exit_status, None, true)?;
Ok(())
check_exit_status(input, cwd, exit_status, None, true)
}
#[cfg(not(unix))]
@ -133,8 +131,7 @@ pub fn run_command_with_output_and_env_no_err(
env: Option<&HashMap<String, String>>,
) -> Result<(), String> {
let exit_status = exec_command(input, cwd, env)?;
check_exit_status(input, cwd, exit_status, None, false)?;
Ok(())
check_exit_status(input, cwd, exit_status, None, false)
}
pub fn cargo_install(to_install: &str) -> Result<(), String> {

View file

@ -603,7 +603,7 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> fo
impl<T> Box<T> {
pub fn new(val: T) -> Box<T> {
unsafe {
let size = intrinsics::size_of::<T>();
let size = size_of::<T>();
let ptr = libc::malloc(size);
intrinsics::copy(&val as *const T as *const u8, ptr, size);
Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, Global)
@ -657,11 +657,11 @@ pub mod intrinsics {
#[rustc_intrinsic]
pub fn abort() -> !;
#[rustc_intrinsic]
pub fn size_of<T>() -> usize;
pub const fn size_of<T>() -> usize;
#[rustc_intrinsic]
pub unsafe fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
#[rustc_intrinsic]
pub fn align_of<T>() -> usize;
pub const fn align_of<T>() -> usize;
#[rustc_intrinsic]
pub unsafe fn align_of_val<T: ?::Sized>(val: *const T) -> usize;
#[rustc_intrinsic]
@ -671,7 +671,7 @@ pub mod intrinsics {
#[rustc_intrinsic]
pub unsafe fn ctlz_nonzero<T>(x: T) -> u32;
#[rustc_intrinsic]
pub fn needs_drop<T: ?::Sized>() -> bool;
pub const fn needs_drop<T: ?::Sized>() -> bool;
#[rustc_intrinsic]
pub fn bitreverse<T>(x: T) -> T;
#[rustc_intrinsic]
@ -699,6 +699,24 @@ pub mod libc {
}
}
pub const fn size_of<T>() -> usize {
<T as SizedTypeProperties>::SIZE
}
pub const fn align_of<T>() -> usize {
<T as SizedTypeProperties>::ALIGN
}
trait SizedTypeProperties: Sized {
#[lang = "mem_size_const"]
const SIZE: usize = intrinsics::size_of::<Self>();
#[lang = "mem_align_const"]
const ALIGN: usize = intrinsics::align_of::<Self>();
}
impl<T> SizedTypeProperties for T {}
#[lang = "index"]
pub trait Index<Idx: ?Sized> {
type Output: ?Sized;

View file

@ -90,8 +90,8 @@ fn start<T: Termination + 'static>(
) -> isize {
if argc == 3 {
unsafe { puts(*argv); }
unsafe { puts(*((argv as usize + intrinsics::size_of::<*const u8>()) as *const *const u8)); }
unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const u8)); }
unsafe { puts(*((argv as usize + size_of::<*const u8>()) as *const *const u8)); }
unsafe { puts(*((argv as usize + 2 * size_of::<*const u8>()) as *const *const u8)); }
}
main().report();
@ -154,7 +154,7 @@ fn main() {
let slice = &[0, 1] as &[i32];
let slice_ptr = slice as *const [i32] as *const i32;
let align = intrinsics::align_of::<*const i32>();
let align = align_of::<*const i32>();
assert_eq!(slice_ptr as usize % align, 0);
//return;
@ -195,11 +195,9 @@ fn main() {
assert_eq!(intrinsics::size_of_val(a) as u8, 8);
assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4);
assert_eq!(intrinsics::align_of::<u16>() as u8, 2);
assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8);
assert_eq!(align_of::<u16>() as u8, 2);
assert_eq!(intrinsics::align_of_val(&a) as u8, align_of::<&str>() as u8);
/*
* TODO: re-enable in the next sync.
let u8_needs_drop = const { intrinsics::needs_drop::<u8>() };
assert!(!u8_needs_drop);
let slice_needs_drop = const { intrinsics::needs_drop::<[u8]>() };
@ -208,7 +206,6 @@ fn main() {
assert!(noisy_drop);
let noisy_unsized_drop = const { intrinsics::needs_drop::<NoisyDropUnsized>() };
assert!(noisy_unsized_drop);
*/
Unique {
pointer: 0 as *const &str,

View file

@ -1 +1 @@
4e995bd73c4490edfe5080ec6014d63aa9abed5f
28b84db392ac0a572f1a2a2a1317aa5f2bc742cb

View file

@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2025-08-25"
channel = "nightly-2025-11-04"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

View file

@ -90,7 +90,7 @@ impl GccType for Reg {
64 => cx.type_f64(),
_ => bug!("unsupported float: {:?}", self),
},
RegKind::Vector => unimplemented!(), //cx.type_vector(cx.type_i8(), self.size.bytes()),
RegKind::Vector => cx.type_vector(cx.type_i8(), self.size.bytes()),
}
}
}

View file

@ -21,6 +21,7 @@ use std::ffi::{CStr, CString};
use std::fs::{self, File};
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::sync::atomic::Ordering;
use gccjit::{Context, OutputKind};
use object::read::archive::ArchiveFile;
@ -39,7 +40,7 @@ use tempfile::{TempDir, tempdir};
use crate::back::write::save_temp_bitcode;
use crate::errors::LtoBitcodeFromRlib;
use crate::{GccCodegenBackend, GccContext, SyncContext, to_gcc_opt_level};
use crate::{GccCodegenBackend, GccContext, LTO_SUPPORTED, LtoMode, SyncContext, to_gcc_opt_level};
struct LtoData {
// TODO(antoyo): use symbols_below_threshold.
@ -229,7 +230,7 @@ fn fat_lto(
info!("linking {:?}", name);
match bc_decoded {
SerializedModule::Local(ref module_buffer) => {
module.module_llvm.should_combine_object_files = true;
module.module_llvm.lto_mode = LtoMode::Fat;
module
.module_llvm
.context
@ -534,7 +535,7 @@ pub fn optimize_thin_module(
// that LLVM Context and Module.
//let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names);
//let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &dcx)? as *const _;
let mut should_combine_object_files = false;
let mut lto_mode = LtoMode::None;
let context = match thin_module.shared.thin_buffers.get(thin_module.idx) {
Some(thin_buffer) => Arc::clone(&thin_buffer.context),
None => {
@ -545,7 +546,7 @@ pub fn optimize_thin_module(
SerializedModule::Local(ref module_buffer) => {
let path = module_buffer.0.to_str().expect("path");
context.add_driver_option(path);
should_combine_object_files = true;
lto_mode = LtoMode::Thin;
/*module.module_llvm.should_combine_object_files = true;
module
.module_llvm
@ -560,11 +561,13 @@ pub fn optimize_thin_module(
Arc::new(SyncContext::new(context))
}
};
let lto_supported = LTO_SUPPORTED.load(Ordering::SeqCst);
let module = ModuleCodegen::new_regular(
thin_module.name().to_string(),
GccContext {
context,
should_combine_object_files,
lto_mode,
lto_supported,
// TODO(antoyo): use the correct relocation model here.
relocation_model: RelocModel::Pic,
temp_dir: None,

View file

@ -11,7 +11,7 @@ use rustc_target::spec::SplitDebuginfo;
use crate::base::add_pic_option;
use crate::errors::CopyBitcode;
use crate::{GccCodegenBackend, GccContext};
use crate::{GccCodegenBackend, GccContext, LtoMode};
pub(crate) fn codegen(
cgcx: &CodegenContext<GccCodegenBackend>,
@ -25,12 +25,8 @@ pub(crate) fn codegen(
{
let context = &module.module_llvm.context;
let should_combine_object_files = module.module_llvm.should_combine_object_files;
// NOTE: Only generate object files with GIMPLE when this environment variable is set for
// now because this requires a particular setup (same gcc/lto1/lto-wrapper commit as libgccjit).
// TODO(antoyo): remove this environment variable.
let fat_lto = env::var("EMBED_LTO_BITCODE").as_deref() == Ok("1");
let lto_mode = module.module_llvm.lto_mode;
let lto_supported = module.module_llvm.lto_supported;
let bc_out = cgcx.output_filenames.temp_path_for_cgu(
OutputType::Bitcode,
@ -44,80 +40,46 @@ pub(crate) fn codegen(
);
if config.bitcode_needed() {
if fat_lto {
let _timer = cgcx
.prof
.generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name);
// TODO(antoyo)
/*if let Some(bitcode_filename) = bc_out.file_name() {
cgcx.prof.artifact_size(
"llvm_bitcode",
bitcode_filename.to_string_lossy(),
data.len() as u64,
);
}*/
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
let _timer = cgcx
.prof
.generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name);
// TODO(antoyo)
/*if let Some(bitcode_filename) = bc_out.file_name() {
cgcx.prof.artifact_size(
"llvm_bitcode",
bitcode_filename.to_string_lossy(),
data.len() as u64,
);
}*/
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
let _timer = cgcx.prof.generic_activity_with_arg(
"GCC_module_codegen_emit_bitcode",
&*module.name,
);
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
if lto_supported {
context.add_command_line_option("-flto=auto");
context.add_command_line_option("-flto-partition=one");
// TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only.
context.add_command_line_option("-ffat-lto-objects");
context.compile_to_file(
OutputKind::ObjectFile,
bc_out.to_str().expect("path to str"),
);
}
context
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
}
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
let _timer = cgcx.prof.generic_activity_with_arg(
"GCC_module_codegen_embed_bitcode",
&*module.name,
);
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
let _timer = cgcx
.prof
.generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name);
if lto_supported {
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
//embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
context.add_command_line_option("-flto=auto");
context.add_command_line_option("-flto-partition=one");
context.add_command_line_option("-ffat-lto-objects");
// TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument).
context.compile_to_file(
OutputKind::ObjectFile,
bc_out.to_str().expect("path to str"),
);
}
} else {
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
let _timer = cgcx.prof.generic_activity_with_arg(
"GCC_module_codegen_emit_bitcode",
&*module.name,
);
context.compile_to_file(
OutputKind::ObjectFile,
bc_out.to_str().expect("path to str"),
);
}
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
// TODO(antoyo): we might want to emit to emit an error here, saying to set the
// environment variable EMBED_LTO_BITCODE.
let _timer = cgcx.prof.generic_activity_with_arg(
"GCC_module_codegen_embed_bitcode",
&*module.name,
);
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
//embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
// TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument).
context.compile_to_file(
OutputKind::ObjectFile,
bc_out.to_str().expect("path to str"),
);
}
// TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument).
context
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
}
}
@ -166,7 +128,10 @@ pub(crate) fn codegen(
context.set_debug_info(true);
context.dump_to_file(path, true);
}
if should_combine_object_files {
if lto_mode != LtoMode::None {
let fat_lto = lto_mode == LtoMode::Fat;
// We need to check if we're doing LTO since this code is also used for the
// dummy ThinLTO implementation to combine the object files.
if fat_lto {
context.add_command_line_option("-flto=auto");
context.add_command_line_option("-flto-partition=one");

View file

@ -21,7 +21,7 @@ use rustc_target::spec::{Arch, RelocModel};
use crate::builder::Builder;
use crate::context::CodegenCx;
use crate::{GccContext, LockedTargetInfo, SyncContext, gcc_util, new_context};
use crate::{GccContext, LockedTargetInfo, LtoMode, SyncContext, gcc_util, new_context};
#[cfg(feature = "master")]
pub fn visibility_to_gcc(visibility: Visibility) -> gccjit::Visibility {
@ -74,6 +74,7 @@ pub fn compile_codegen_unit(
tcx: TyCtxt<'_>,
cgu_name: Symbol,
target_info: LockedTargetInfo,
lto_supported: bool,
) -> (ModuleCodegen<GccContext>, u64) {
let prof_timer = tcx.prof.generic_activity("codegen_module");
let start_time = Instant::now();
@ -82,7 +83,7 @@ pub fn compile_codegen_unit(
let (module, _) = tcx.dep_graph.with_task(
dep_node,
tcx,
(cgu_name, target_info),
(cgu_name, target_info, lto_supported),
module_codegen,
Some(dep_graph::hash_result),
);
@ -95,7 +96,7 @@ pub fn compile_codegen_unit(
fn module_codegen(
tcx: TyCtxt<'_>,
(cgu_name, target_info): (Symbol, LockedTargetInfo),
(cgu_name, target_info, lto_supported): (Symbol, LockedTargetInfo, bool),
) -> ModuleCodegen<GccContext> {
let cgu = tcx.codegen_unit(cgu_name);
// Instantiate monomorphizations without filling out definitions yet...
@ -247,7 +248,8 @@ pub fn compile_codegen_unit(
GccContext {
context: Arc::new(SyncContext::new(context)),
relocation_model: tcx.sess.relocation_model(),
should_combine_object_files: false,
lto_supported,
lto_mode: LtoMode::None,
temp_dir: None,
},
)

View file

@ -668,32 +668,38 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
}
fn add(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
self.gcc_add(a, b)
self.assign_to_var(self.gcc_add(a, b))
}
fn fadd(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
a + b
self.assign_to_var(a + b)
}
// TODO(antoyo): should we also override the `unchecked_` versions?
fn sub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
self.gcc_sub(a, b)
self.assign_to_var(self.gcc_sub(a, b))
}
fn fsub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
a - b
self.assign_to_var(a - b)
}
fn mul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
self.gcc_mul(a, b)
self.assign_to_var(self.gcc_mul(a, b))
}
fn fmul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
self.cx.context.new_binary_op(self.location, BinaryOp::Mult, a.get_type(), a, b)
self.assign_to_var(self.cx.context.new_binary_op(
self.location,
BinaryOp::Mult,
a.get_type(),
a,
b,
))
}
fn udiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
self.gcc_udiv(a, b)
self.assign_to_var(self.gcc_udiv(a, b))
}
fn exactudiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
@ -702,11 +708,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let a = self.gcc_int_cast(a, a_type);
let b_type = b.get_type().to_unsigned(self);
let b = self.gcc_int_cast(b, b_type);
self.gcc_udiv(a, b)
self.assign_to_var(self.gcc_udiv(a, b))
}
fn sdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
self.gcc_sdiv(a, b)
self.assign_to_var(self.gcc_sdiv(a, b))
}
fn exactsdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
@ -715,19 +721,19 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
// should be the same.
let typ = a.get_type().to_signed(self);
let b = self.gcc_int_cast(b, typ);
self.gcc_sdiv(a, b)
self.assign_to_var(self.gcc_sdiv(a, b))
}
fn fdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
a / b
self.assign_to_var(a / b)
}
fn urem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
self.gcc_urem(a, b)
self.assign_to_var(self.gcc_urem(a, b))
}
fn srem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
self.gcc_srem(a, b)
self.assign_to_var(self.gcc_srem(a, b))
}
fn frem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
@ -865,22 +871,26 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
fn fadd_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
set_rvalue_location(self, lhs + rhs)
let result = set_rvalue_location(self, lhs + rhs);
self.assign_to_var(result)
}
fn fsub_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
set_rvalue_location(self, lhs - rhs)
let result = set_rvalue_location(self, lhs - rhs);
self.assign_to_var(result)
}
fn fmul_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
set_rvalue_location(self, lhs * rhs)
let result = set_rvalue_location(self, lhs * rhs);
self.assign_to_var(result)
}
fn fdiv_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
set_rvalue_location(self, lhs / rhs)
let result = set_rvalue_location(self, lhs / rhs);
self.assign_to_var(result)
}
fn frem_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
@ -892,22 +902,22 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
fn fadd_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
lhs + rhs
self.assign_to_var(lhs + rhs)
}
fn fsub_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
lhs - rhs
self.assign_to_var(lhs - rhs)
}
fn fmul_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
lhs * rhs
self.assign_to_var(lhs * rhs)
}
fn fdiv_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
lhs / rhs
self.assign_to_var(lhs / rhs)
}
fn frem_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
@ -2409,6 +2419,15 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
let res = then_vals | else_vals;
self.bitcast_if_needed(res, result_type)
}
// GCC doesn't like deeply nested expressions.
// By assigning intermediate expressions to a variable, this allow us to avoid deeply nested
// expressions and GCC will use much less RAM.
fn assign_to_var(&self, value: RValue<'gcc>) -> RValue<'gcc> {
let var = self.current_func().new_local(self.location, value.get_type(), "opResult");
self.llbb().add_assignment(self.location, var, value);
var.to_rvalue()
}
}
fn difference_or_zero<'gcc>(

View file

@ -83,12 +83,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
let a_size = a_type.get_size();
let b_size = b_type.get_size();
match a_size.cmp(&b_size) {
std::cmp::Ordering::Less => {
let a = self.context.new_cast(self.location, a, b_type);
a >> b
}
std::cmp::Ordering::Equal => a >> b,
std::cmp::Ordering::Greater => {
_ => {
// NOTE: it is OK to cast even if b has a type bigger than a because b has
// been masked by codegen_ssa before calling Builder::lshr or
// Builder::ashr.
let b = self.context.new_cast(self.location, b, a_type);
a >> b
}
@ -692,12 +691,10 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
let a_size = a_type.get_size();
let b_size = b_type.get_size();
match a_size.cmp(&b_size) {
std::cmp::Ordering::Less => {
let a = self.context.new_cast(self.location, a, b_type);
a << b
}
std::cmp::Ordering::Equal => a << b,
std::cmp::Ordering::Greater => {
_ => {
// NOTE: it is OK to cast even if b has a type bigger than a because b has
// been masked by codegen_ssa before calling Builder::shl.
let b = self.context.new_cast(self.location, b, a_type);
a << b
}

View file

@ -85,12 +85,41 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
fn amdgcn(name: &str, full_name: &str) -> &'static str {
match name {
// amdgcn
"add.max.i32" => "__builtin_amdgcn_add_max_i32",
"add.max.u32" => "__builtin_amdgcn_add_max_u32",
"add.min.i32" => "__builtin_amdgcn_add_min_i32",
"add.min.u32" => "__builtin_amdgcn_add_min_u32",
"alignbyte" => "__builtin_amdgcn_alignbyte",
"ashr.pk.i8.i32" => "__builtin_amdgcn_ashr_pk_i8_i32",
"ashr.pk.u8.i32" => "__builtin_amdgcn_ashr_pk_u8_i32",
"buffer.wbinvl1" => "__builtin_amdgcn_buffer_wbinvl1",
"buffer.wbinvl1.sc" => "__builtin_amdgcn_buffer_wbinvl1_sc",
"buffer.wbinvl1.vol" => "__builtin_amdgcn_buffer_wbinvl1_vol",
"cluster.id.x" => "__builtin_amdgcn_cluster_id_x",
"cluster.id.y" => "__builtin_amdgcn_cluster_id_y",
"cluster.id.z" => "__builtin_amdgcn_cluster_id_z",
"cluster.load.async.to.lds.b128" => {
"__builtin_amdgcn_cluster_load_async_to_lds_b128"
}
"cluster.load.async.to.lds.b32" => {
"__builtin_amdgcn_cluster_load_async_to_lds_b32"
}
"cluster.load.async.to.lds.b64" => {
"__builtin_amdgcn_cluster_load_async_to_lds_b64"
}
"cluster.load.async.to.lds.b8" => {
"__builtin_amdgcn_cluster_load_async_to_lds_b8"
}
"cluster.workgroup.flat.id" => "__builtin_amdgcn_cluster_workgroup_flat_id",
"cluster.workgroup.id.x" => "__builtin_amdgcn_cluster_workgroup_id_x",
"cluster.workgroup.id.y" => "__builtin_amdgcn_cluster_workgroup_id_y",
"cluster.workgroup.id.z" => "__builtin_amdgcn_cluster_workgroup_id_z",
"cluster.workgroup.max.flat.id" => {
"__builtin_amdgcn_cluster_workgroup_max_flat_id"
}
"cluster.workgroup.max.id.x" => "__builtin_amdgcn_cluster_workgroup_max_id_x",
"cluster.workgroup.max.id.y" => "__builtin_amdgcn_cluster_workgroup_max_id_y",
"cluster.workgroup.max.id.z" => "__builtin_amdgcn_cluster_workgroup_max_id_z",
"cubeid" => "__builtin_amdgcn_cubeid",
"cubema" => "__builtin_amdgcn_cubema",
"cubesc" => "__builtin_amdgcn_cubesc",
@ -101,18 +130,36 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"cvt.f32.fp8" => "__builtin_amdgcn_cvt_f32_fp8",
"cvt.f32.fp8.e5m3" => "__builtin_amdgcn_cvt_f32_fp8_e5m3",
"cvt.off.f32.i4" => "__builtin_amdgcn_cvt_off_f32_i4",
"cvt.pk.bf8.f16" => "__builtin_amdgcn_cvt_pk_bf8_f16",
"cvt.pk.bf8.f32" => "__builtin_amdgcn_cvt_pk_bf8_f32",
"cvt.pk.f16.bf8" => "__builtin_amdgcn_cvt_pk_f16_bf8",
"cvt.pk.f16.fp8" => "__builtin_amdgcn_cvt_pk_f16_fp8",
"cvt.pk.f32.bf8" => "__builtin_amdgcn_cvt_pk_f32_bf8",
"cvt.pk.f32.fp8" => "__builtin_amdgcn_cvt_pk_f32_fp8",
"cvt.pk.fp8.f16" => "__builtin_amdgcn_cvt_pk_fp8_f16",
"cvt.pk.fp8.f32" => "__builtin_amdgcn_cvt_pk_fp8_f32",
"cvt.pk.fp8.f32.e5m3" => "__builtin_amdgcn_cvt_pk_fp8_f32_e5m3",
"cvt.pk.i16" => "__builtin_amdgcn_cvt_pk_i16",
"cvt.pk.u16" => "__builtin_amdgcn_cvt_pk_u16",
"cvt.pk.u8.f32" => "__builtin_amdgcn_cvt_pk_u8_f32",
"cvt.pknorm.i16" => "__builtin_amdgcn_cvt_pknorm_i16",
"cvt.pknorm.u16" => "__builtin_amdgcn_cvt_pknorm_u16",
"cvt.pkrtz" => "__builtin_amdgcn_cvt_pkrtz",
"cvt.scale.pk16.bf16.bf6" => "__builtin_amdgcn_cvt_scale_pk16_bf16_bf6",
"cvt.scale.pk16.bf16.fp6" => "__builtin_amdgcn_cvt_scale_pk16_bf16_fp6",
"cvt.scale.pk16.f16.bf6" => "__builtin_amdgcn_cvt_scale_pk16_f16_bf6",
"cvt.scale.pk16.f16.fp6" => "__builtin_amdgcn_cvt_scale_pk16_f16_fp6",
"cvt.scale.pk16.f32.bf6" => "__builtin_amdgcn_cvt_scale_pk16_f32_bf6",
"cvt.scale.pk16.f32.fp6" => "__builtin_amdgcn_cvt_scale_pk16_f32_fp6",
"cvt.scale.pk8.bf16.bf8" => "__builtin_amdgcn_cvt_scale_pk8_bf16_bf8",
"cvt.scale.pk8.bf16.fp4" => "__builtin_amdgcn_cvt_scale_pk8_bf16_fp4",
"cvt.scale.pk8.bf16.fp8" => "__builtin_amdgcn_cvt_scale_pk8_bf16_fp8",
"cvt.scale.pk8.f16.bf8" => "__builtin_amdgcn_cvt_scale_pk8_f16_bf8",
"cvt.scale.pk8.f16.fp4" => "__builtin_amdgcn_cvt_scale_pk8_f16_fp4",
"cvt.scale.pk8.f16.fp8" => "__builtin_amdgcn_cvt_scale_pk8_f16_fp8",
"cvt.scale.pk8.f32.bf8" => "__builtin_amdgcn_cvt_scale_pk8_f32_bf8",
"cvt.scale.pk8.f32.fp4" => "__builtin_amdgcn_cvt_scale_pk8_f32_fp4",
"cvt.scale.pk8.f32.fp8" => "__builtin_amdgcn_cvt_scale_pk8_f32_fp8",
"cvt.scalef32.2xpk16.bf6.f32" => "__builtin_amdgcn_cvt_scalef32_2xpk16_bf6_f32",
"cvt.scalef32.2xpk16.fp6.f32" => "__builtin_amdgcn_cvt_scalef32_2xpk16_fp6_f32",
"cvt.scalef32.f16.bf8" => "__builtin_amdgcn_cvt_scalef32_f16_bf8",
@ -137,6 +184,12 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"cvt.scalef32.pk.fp8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_bf16",
"cvt.scalef32.pk.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_f16",
"cvt.scalef32.pk.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_f32",
"cvt.scalef32.pk16.bf6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk16_bf6_bf16",
"cvt.scalef32.pk16.bf6.f16" => "__builtin_amdgcn_cvt_scalef32_pk16_bf6_f16",
"cvt.scalef32.pk16.bf6.f32" => "__builtin_amdgcn_cvt_scalef32_pk16_bf6_f32",
"cvt.scalef32.pk16.fp6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk16_fp6_bf16",
"cvt.scalef32.pk16.fp6.f16" => "__builtin_amdgcn_cvt_scalef32_pk16_fp6_f16",
"cvt.scalef32.pk16.fp6.f32" => "__builtin_amdgcn_cvt_scalef32_pk16_fp6_f32",
"cvt.scalef32.pk32.bf16.bf6" => "__builtin_amdgcn_cvt_scalef32_pk32_bf16_bf6",
"cvt.scalef32.pk32.bf16.fp6" => "__builtin_amdgcn_cvt_scalef32_pk32_bf16_fp6",
"cvt.scalef32.pk32.bf6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk32_bf6_bf16",
@ -147,6 +200,15 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"cvt.scalef32.pk32.f32.fp6" => "__builtin_amdgcn_cvt_scalef32_pk32_f32_fp6",
"cvt.scalef32.pk32.fp6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk32_fp6_bf16",
"cvt.scalef32.pk32.fp6.f16" => "__builtin_amdgcn_cvt_scalef32_pk32_fp6_f16",
"cvt.scalef32.pk8.bf8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk8_bf8_bf16",
"cvt.scalef32.pk8.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_pk8_bf8_f16",
"cvt.scalef32.pk8.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_pk8_bf8_f32",
"cvt.scalef32.pk8.fp4.bf16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp4_bf16",
"cvt.scalef32.pk8.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp4_f16",
"cvt.scalef32.pk8.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_pk8_fp4_f32",
"cvt.scalef32.pk8.fp8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp8_bf16",
"cvt.scalef32.pk8.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp8_f16",
"cvt.scalef32.pk8.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_pk8_fp8_f32",
"cvt.scalef32.sr.bf8.bf16" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_bf16",
"cvt.scalef32.sr.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_f16",
"cvt.scalef32.sr.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_f32",
@ -156,6 +218,24 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"cvt.scalef32.sr.pk.fp4.bf16" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_bf16",
"cvt.scalef32.sr.pk.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_f16",
"cvt.scalef32.sr.pk.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_f32",
"cvt.scalef32.sr.pk16.bf6.bf16" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk16_bf6_bf16"
}
"cvt.scalef32.sr.pk16.bf6.f16" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk16_bf6_f16"
}
"cvt.scalef32.sr.pk16.bf6.f32" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk16_bf6_f32"
}
"cvt.scalef32.sr.pk16.fp6.bf16" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk16_fp6_bf16"
}
"cvt.scalef32.sr.pk16.fp6.f16" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk16_fp6_f16"
}
"cvt.scalef32.sr.pk16.fp6.f32" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk16_fp6_f32"
}
"cvt.scalef32.sr.pk32.bf6.bf16" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk32_bf6_bf16"
}
@ -174,10 +254,30 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"cvt.scalef32.sr.pk32.fp6.f32" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk32_fp6_f32"
}
"cvt.scalef32.sr.pk8.bf8.bf16" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_bf16"
}
"cvt.scalef32.sr.pk8.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_f16",
"cvt.scalef32.sr.pk8.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_f32",
"cvt.scalef32.sr.pk8.fp4.bf16" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_bf16"
}
"cvt.scalef32.sr.pk8.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_f16",
"cvt.scalef32.sr.pk8.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_f32",
"cvt.scalef32.sr.pk8.fp8.bf16" => {
"__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_bf16"
}
"cvt.scalef32.sr.pk8.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_f16",
"cvt.scalef32.sr.pk8.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_f32",
"cvt.sr.bf16.f32" => "__builtin_amdgcn_cvt_sr_bf16_f32",
"cvt.sr.bf8.f16" => "__builtin_amdgcn_cvt_sr_bf8_f16",
"cvt.sr.bf8.f32" => "__builtin_amdgcn_cvt_sr_bf8_f32",
"cvt.sr.f16.f32" => "__builtin_amdgcn_cvt_sr_f16_f32",
"cvt.sr.fp8.f16" => "__builtin_amdgcn_cvt_sr_fp8_f16",
"cvt.sr.fp8.f32" => "__builtin_amdgcn_cvt_sr_fp8_f32",
"cvt.sr.fp8.f32.e5m3" => "__builtin_amdgcn_cvt_sr_fp8_f32_e5m3",
"cvt.sr.pk.bf16.f32" => "__builtin_amdgcn_cvt_sr_pk_bf16_f32",
"cvt.sr.pk.f16.f32" => "__builtin_amdgcn_cvt_sr_pk_f16_f32",
"dispatch.id" => "__builtin_amdgcn_dispatch_id",
"dot4.f32.bf8.bf8" => "__builtin_amdgcn_dot4_f32_bf8_bf8",
"dot4.f32.bf8.fp8" => "__builtin_amdgcn_dot4_f32_bf8_fp8",
@ -297,8 +397,20 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"mqsad.u32.u8" => "__builtin_amdgcn_mqsad_u32_u8",
"msad.u8" => "__builtin_amdgcn_msad_u8",
"perm" => "__builtin_amdgcn_perm",
"perm.pk16.b4.u4" => "__builtin_amdgcn_perm_pk16_b4_u4",
"perm.pk16.b6.u4" => "__builtin_amdgcn_perm_pk16_b6_u4",
"perm.pk16.b8.u4" => "__builtin_amdgcn_perm_pk16_b8_u4",
"permlane.bcast" => "__builtin_amdgcn_permlane_bcast",
"permlane.down" => "__builtin_amdgcn_permlane_down",
"permlane.idx.gen" => "__builtin_amdgcn_permlane_idx_gen",
"permlane.up" => "__builtin_amdgcn_permlane_up",
"permlane.xor" => "__builtin_amdgcn_permlane_xor",
"permlane16.var" => "__builtin_amdgcn_permlane16_var",
"permlanex16.var" => "__builtin_amdgcn_permlanex16_var",
"pk.add.max.i16" => "__builtin_amdgcn_pk_add_max_i16",
"pk.add.max.u16" => "__builtin_amdgcn_pk_add_max_u16",
"pk.add.min.i16" => "__builtin_amdgcn_pk_add_min_i16",
"pk.add.min.u16" => "__builtin_amdgcn_pk_add_min_u16",
"prng.b32" => "__builtin_amdgcn_prng_b32",
"qsad.pk.u16.u8" => "__builtin_amdgcn_qsad_pk_u16_u8",
"queue.ptr" => "__builtin_amdgcn_queue_ptr",
@ -306,11 +418,15 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"rcp.legacy" => "__builtin_amdgcn_rcp_legacy",
"rsq.legacy" => "__builtin_amdgcn_rsq_legacy",
"s.barrier" => "__builtin_amdgcn_s_barrier",
"s.barrier.init" => "__builtin_amdgcn_s_barrier_init",
"s.barrier.join" => "__builtin_amdgcn_s_barrier_join",
"s.barrier.leave" => "__builtin_amdgcn_s_barrier_leave",
"s.barrier.signal" => "__builtin_amdgcn_s_barrier_signal",
"s.barrier.signal.isfirst" => "__builtin_amdgcn_s_barrier_signal_isfirst",
"s.barrier.signal.var" => "__builtin_amdgcn_s_barrier_signal_var",
"s.barrier.wait" => "__builtin_amdgcn_s_barrier_wait",
"s.buffer.prefetch.data" => "__builtin_amdgcn_s_buffer_prefetch_data",
"s.cluster.barrier" => "__builtin_amdgcn_s_cluster_barrier",
"s.dcache.inv" => "__builtin_amdgcn_s_dcache_inv",
"s.dcache.inv.vol" => "__builtin_amdgcn_s_dcache_inv_vol",
"s.dcache.wb" => "__builtin_amdgcn_s_dcache_wb",
@ -1900,6 +2016,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"V6.vfneg.hf.128B" => "__builtin_HEXAGON_V6_vfneg_hf_128B",
"V6.vfneg.sf" => "__builtin_HEXAGON_V6_vfneg_sf",
"V6.vfneg.sf.128B" => "__builtin_HEXAGON_V6_vfneg_sf_128B",
"V6.vgather.vscattermh" => "__builtin_HEXAGON_V6_vgather_vscattermh",
"V6.vgather.vscattermh.128B" => "__builtin_HEXAGON_V6_vgather_vscattermh_128B",
"V6.vgathermh" => "__builtin_HEXAGON_V6_vgathermh",
"V6.vgathermh.128B" => "__builtin_HEXAGON_V6_vgathermh_128B",
"V6.vgathermhq" => "__builtin_HEXAGON_V6_vgathermhq",
@ -2382,6 +2500,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"V6.vsub.hf.f8.128B" => "__builtin_HEXAGON_V6_vsub_hf_f8_128B",
"V6.vsub.hf.hf" => "__builtin_HEXAGON_V6_vsub_hf_hf",
"V6.vsub.hf.hf.128B" => "__builtin_HEXAGON_V6_vsub_hf_hf_128B",
"V6.vsub.hf.mix" => "__builtin_HEXAGON_V6_vsub_hf_mix",
"V6.vsub.hf.mix.128B" => "__builtin_HEXAGON_V6_vsub_hf_mix_128B",
"V6.vsub.qf16" => "__builtin_HEXAGON_V6_vsub_qf16",
"V6.vsub.qf16.128B" => "__builtin_HEXAGON_V6_vsub_qf16_128B",
"V6.vsub.qf16.mix" => "__builtin_HEXAGON_V6_vsub_qf16_mix",
@ -2396,6 +2516,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"V6.vsub.sf.bf.128B" => "__builtin_HEXAGON_V6_vsub_sf_bf_128B",
"V6.vsub.sf.hf" => "__builtin_HEXAGON_V6_vsub_sf_hf",
"V6.vsub.sf.hf.128B" => "__builtin_HEXAGON_V6_vsub_sf_hf_128B",
"V6.vsub.sf.mix" => "__builtin_HEXAGON_V6_vsub_sf_mix",
"V6.vsub.sf.mix.128B" => "__builtin_HEXAGON_V6_vsub_sf_mix_128B",
"V6.vsub.sf.sf" => "__builtin_HEXAGON_V6_vsub_sf_sf",
"V6.vsub.sf.sf.128B" => "__builtin_HEXAGON_V6_vsub_sf_sf_128B",
"V6.vsubb" => "__builtin_HEXAGON_V6_vsubb",
@ -4883,6 +5005,26 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"f2ull.rp.ftz" => "__nvvm_f2ull_rp_ftz",
"f2ull.rz" => "__nvvm_f2ull_rz",
"f2ull.rz.ftz" => "__nvvm_f2ull_rz_ftz",
"f32x4.to.e2m1x4.rs.relu.satfinite" => {
"__nvvm_f32x4_to_e2m1x4_rs_relu_satfinite"
}
"f32x4.to.e2m1x4.rs.satfinite" => "__nvvm_f32x4_to_e2m1x4_rs_satfinite",
"f32x4.to.e2m3x4.rs.relu.satfinite" => {
"__nvvm_f32x4_to_e2m3x4_rs_relu_satfinite"
}
"f32x4.to.e2m3x4.rs.satfinite" => "__nvvm_f32x4_to_e2m3x4_rs_satfinite",
"f32x4.to.e3m2x4.rs.relu.satfinite" => {
"__nvvm_f32x4_to_e3m2x4_rs_relu_satfinite"
}
"f32x4.to.e3m2x4.rs.satfinite" => "__nvvm_f32x4_to_e3m2x4_rs_satfinite",
"f32x4.to.e4m3x4.rs.relu.satfinite" => {
"__nvvm_f32x4_to_e4m3x4_rs_relu_satfinite"
}
"f32x4.to.e4m3x4.rs.satfinite" => "__nvvm_f32x4_to_e4m3x4_rs_satfinite",
"f32x4.to.e5m2x4.rs.relu.satfinite" => {
"__nvvm_f32x4_to_e5m2x4_rs_relu_satfinite"
}
"f32x4.to.e5m2x4.rs.satfinite" => "__nvvm_f32x4_to_e5m2x4_rs_satfinite",
"fabs.d" => "__nvvm_fabs_d",
"fabs.f" => "__nvvm_fabs_f",
"fabs.ftz.f" => "__nvvm_fabs_ftz_f",
@ -4902,10 +5044,18 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"ff.to.ue8m0x2.rz.satfinite" => "__nvvm_ff_to_ue8m0x2_rz_satfinite",
"ff2bf16x2.rn" => "__nvvm_ff2bf16x2_rn",
"ff2bf16x2.rn.relu" => "__nvvm_ff2bf16x2_rn_relu",
"ff2bf16x2.rs" => "__nvvm_ff2bf16x2_rs",
"ff2bf16x2.rs.relu" => "__nvvm_ff2bf16x2_rs_relu",
"ff2bf16x2.rs.relu.satfinite" => "__nvvm_ff2bf16x2_rs_relu_satfinite",
"ff2bf16x2.rs.satfinite" => "__nvvm_ff2bf16x2_rs_satfinite",
"ff2bf16x2.rz" => "__nvvm_ff2bf16x2_rz",
"ff2bf16x2.rz.relu" => "__nvvm_ff2bf16x2_rz_relu",
"ff2f16x2.rn" => "__nvvm_ff2f16x2_rn",
"ff2f16x2.rn.relu" => "__nvvm_ff2f16x2_rn_relu",
"ff2f16x2.rs" => "__nvvm_ff2f16x2_rs",
"ff2f16x2.rs.relu" => "__nvvm_ff2f16x2_rs_relu",
"ff2f16x2.rs.relu.satfinite" => "__nvvm_ff2f16x2_rs_relu_satfinite",
"ff2f16x2.rs.satfinite" => "__nvvm_ff2f16x2_rs_satfinite",
"ff2f16x2.rz" => "__nvvm_ff2f16x2_rz",
"ff2f16x2.rz.relu" => "__nvvm_ff2f16x2_rz_relu",
"floor.d" => "__nvvm_floor_d",
@ -5129,6 +5279,7 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"read.ptx.sreg.envreg8" => "__nvvm_read_ptx_sreg_envreg8",
"read.ptx.sreg.envreg9" => "__nvvm_read_ptx_sreg_envreg9",
"read.ptx.sreg.globaltimer" => "__nvvm_read_ptx_sreg_globaltimer",
"read.ptx.sreg.globaltimer.lo" => "__nvvm_read_ptx_sreg_globaltimer_lo",
"read.ptx.sreg.gridid" => "__nvvm_read_ptx_sreg_gridid",
// [DUPLICATE]: "read.ptx.sreg.gridid" => "__nvvm_read_ptx_sreg_",
"read.ptx.sreg.laneid" => "__nvvm_read_ptx_sreg_laneid",
@ -5803,6 +5954,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"altivec.vupklsw" => "__builtin_altivec_vupklsw",
"bcdadd" => "__builtin_ppc_bcdadd",
"bcdadd.p" => "__builtin_ppc_bcdadd_p",
"bcdcopysign" => "__builtin_ppc_bcdcopysign",
"bcdsetsign" => "__builtin_ppc_bcdsetsign",
"bcdsub" => "__builtin_ppc_bcdsub",
"bcdsub.p" => "__builtin_ppc_bcdsub_p",
"bpermd" => "__builtin_bpermd",
@ -6160,6 +6313,9 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
"aes64im" => "__builtin_riscv_aes64im",
"aes64ks1i" => "__builtin_riscv_aes64ks1i",
"aes64ks2" => "__builtin_riscv_aes64ks2",
"mips.ehb" => "__builtin_riscv_mips_ehb",
"mips.ihb" => "__builtin_riscv_mips_ihb",
"mips.pause" => "__builtin_riscv_mips_pause",
"sha512sig0" => "__builtin_riscv_sha512sig0",
"sha512sig0h" => "__builtin_riscv_sha512sig0h",
"sha512sig0l" => "__builtin_riscv_sha512sig0l",

View file

@ -308,10 +308,6 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
.or_else(|| get_simple_function_f128(self, name))
.or_else(|| get_simple_function_f128_2args(self, name));
// FIXME(tempdragon): Re-enable `clippy::suspicious_else_formatting` if the following issue is solved:
// https://github.com/rust-lang/rust-clippy/issues/12497
// and leave `else if use_integer_compare` to be placed "as is".
#[allow(clippy::suspicious_else_formatting)]
let value = match name {
_ if simple.is_some() => {
let func = simple.expect("simple intrinsic function");

View file

@ -72,10 +72,7 @@ use std::any::Any;
use std::fmt::Debug;
use std::ops::Deref;
use std::path::PathBuf;
#[cfg(not(feature = "master"))]
use std::sync::atomic::AtomicBool;
#[cfg(not(feature = "master"))]
use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use back::lto::{ThinBuffer, ThinData};
@ -167,8 +164,11 @@ impl LockedTargetInfo {
#[derive(Clone)]
pub struct GccCodegenBackend {
target_info: LockedTargetInfo,
lto_supported: Arc<AtomicBool>,
}
static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false);
impl CodegenBackend for GccCodegenBackend {
fn locale_resource(&self) -> &'static str {
crate::DEFAULT_LOCALE_RESOURCE
@ -193,7 +193,13 @@ impl CodegenBackend for GccCodegenBackend {
}
#[cfg(feature = "master")]
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
{
let lto_supported = gccjit::is_lto_supported();
LTO_SUPPORTED.store(lto_supported, Ordering::SeqCst);
self.lto_supported.store(lto_supported, Ordering::SeqCst);
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
}
#[cfg(not(feature = "master"))]
{
@ -276,10 +282,12 @@ impl ExtraBackendMethods for GccCodegenBackend {
module_name: &str,
methods: &[AllocatorMethod],
) -> Self::Module {
let lto_supported = self.lto_supported.load(Ordering::SeqCst);
let mut mods = GccContext {
context: Arc::new(SyncContext::new(new_context(tcx))),
relocation_model: tcx.sess.relocation_model(),
should_combine_object_files: false,
lto_mode: LtoMode::None,
lto_supported,
temp_dir: None,
};
@ -294,7 +302,12 @@ impl ExtraBackendMethods for GccCodegenBackend {
tcx: TyCtxt<'_>,
cgu_name: Symbol,
) -> (ModuleCodegen<Self::Module>, u64) {
base::compile_codegen_unit(tcx, cgu_name, self.target_info.clone())
base::compile_codegen_unit(
tcx,
cgu_name,
self.target_info.clone(),
self.lto_supported.load(Ordering::SeqCst),
)
}
fn target_machine_factory(
@ -308,12 +321,20 @@ impl ExtraBackendMethods for GccCodegenBackend {
}
}
#[derive(Clone, Copy, PartialEq)]
pub enum LtoMode {
None,
Thin,
Fat,
}
pub struct GccContext {
context: Arc<SyncContext>,
/// This field is needed in order to be able to set the flag -fPIC when necessary when doing
/// LTO.
relocation_model: RelocModel,
should_combine_object_files: bool,
lto_mode: LtoMode,
lto_supported: bool,
// Temporary directory used by LTO. We keep it here so that it's not removed before linking.
temp_dir: Option<TempDir>,
}
@ -425,7 +446,10 @@ pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
supports_128bit_integers: AtomicBool::new(false),
})));
Box::new(GccCodegenBackend { target_info: LockedTargetInfo { info } })
Box::new(GccCodegenBackend {
lto_supported: Arc::new(AtomicBool::new(false)),
target_info: LockedTargetInfo { info },
})
}
fn to_gcc_opt_level(optlevel: Option<OptLevel>) -> OptimizationLevel {

View file

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "cross_lang_lto"
version = "0.1.0"

View file

@ -0,0 +1,6 @@
[package]
name = "cross_lang_lto"
version = "0.1.0"
edition = "2024"
[dependencies]

View file

@ -0,0 +1,5 @@
#include <stdint.h>
uint32_t my_add(uint32_t a, uint32_t b) {
return a + b;
}

View file

@ -0,0 +1,18 @@
/*
* Compile the C code with:
* gcc -c -flto add.c -ffat-lto-objects
* ar rcs libadd.a add.o
*
* Compile the Rust code with:
* CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" y cargo run --release
*/
#[link(name="add")]
unsafe extern "C" {
fn my_add(a: u32, b: u32) -> u32;
}
fn main() {
let res = unsafe { my_add(30, 12) };
println!("{}", res);
}

View file

@ -1,33 +0,0 @@
tests/ui/lint/unsafe_code/forge_unsafe_block.rs
tests/ui/lint/unused-qualification-in-derive-expansion.rs
tests/ui/macros/macro-quote-test.rs
tests/ui/macros/proc_macro.rs
tests/ui/panic-runtime/lto-unwind.rs
tests/ui/resolve/derive-macro-1.rs
tests/ui/resolve/derive-macro-2.rs
tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs
tests/ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs
tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs
tests/ui/rust-2018/suggestions-not-always-applicable.rs
tests/ui/rust-2021/reserved-prefixes-via-macro.rs
tests/ui/underscore-imports/duplicate.rs
tests/ui/async-await/issues/issue-60674.rs
tests/ui/attributes/main-removed-2/main.rs
tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs
tests/ui/crate-loading/cross-compiled-proc-macro.rs
tests/ui/derives/derive-marker-tricky.rs
tests/ui/diagnostic_namespace/existing_proc_macros.rs
tests/ui/fmt/format-args-capture-issue-106408.rs
tests/ui/fmt/indoc-issue-106408.rs
tests/ui/hygiene/issue-77523-def-site-async-await.rs
tests/ui/inherent-impls-overlap-check/no-overlap.rs
tests/ui/enum-discriminant/issue-46519.rs
tests/ui/issues/issue-45731.rs
tests/ui/lint/test-allow-dead-extern-static-no-warning.rs
tests/ui/macros/macro-comma-behavior-rpass.rs
tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs
tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs
tests/ui/macros/stringify.rs
tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs
tests/ui/binding/fn-arg-incomplete-pattern-drop-order.rs
tests/ui/lto/debuginfo-lto-alloc.rs

View file

@ -1,35 +1,11 @@
tests/run-make/a-b-a-linker-guard/
tests/run-make/CURRENT_RUSTC_VERSION/
tests/run-make/cross-lang-lto/
tests/run-make/cross-lang-lto-upstream-rlibs/
tests/run-make/doctests-keep-binaries/
tests/run-make/doctests-runtool/
tests/run-make/emit-shared-files/
tests/run-make/exit-code/
tests/run-make/llvm-ident/
tests/run-make/native-link-modifier-bundle/
tests/run-make/remap-path-prefix-dwarf/
tests/run-make/repr128-dwarf/
tests/run-make/rlib-format-packed-bundled-libs/
tests/run-make/rlib-format-packed-bundled-libs-2/
tests/run-make/rustdoc-determinism/
tests/run-make/rustdoc-error-lines/
tests/run-make/rustdoc-map-file/
tests/run-make/rustdoc-output-path/
tests/run-make/rustdoc-scrape-examples-invalid-expr/
tests/run-make/rustdoc-scrape-examples-multiple/
tests/run-make/rustdoc-scrape-examples-ordering/
tests/run-make/rustdoc-scrape-examples-remap/
tests/run-make/rustdoc-scrape-examples-test/
tests/run-make/rustdoc-scrape-examples-whitespace/
tests/run-make/rustdoc-scrape-examples-macros/
tests/run-make/rustdoc-with-out-dir-option/
tests/run-make/rustdoc-verify-output-files/
tests/run-make/rustdoc-themes/
tests/run-make/rustdoc-with-short-out-dir-option/
tests/run-make/rustdoc-with-output-option/
tests/run-make/arguments-non-c-like-enum/
tests/run-make/c-link-to-rust-staticlib/
tests/run-make/foreign-double-unwind/
tests/run-make/foreign-exceptions/
tests/run-make/glibc-staticlib-args/

View file

@ -1,5 +1,3 @@
tests/ui/allocator/no_std-alloc-error-handler-custom.rs
tests/ui/allocator/no_std-alloc-error-handler-default.rs
tests/ui/asm/may_unwind.rs
tests/ui/asm/x86_64/may_unwind.rs
tests/ui/drop/dynamic-drop-async.rs
@ -17,7 +15,6 @@ tests/ui/panic-runtime/link-to-abort.rs
tests/ui/parser/unclosed-delimiter-in-dep.rs
tests/ui/consts/missing_span_in_backtrace.rs
tests/ui/drop/dynamic-drop.rs
tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs
tests/ui/simd/issue-17170.rs
tests/ui/simd/issue-39720.rs
tests/ui/drop/panic-during-drop-14875.rs
@ -31,11 +28,9 @@ tests/ui/coroutine/resume-after-return.rs
tests/ui/simd/masked-load-store.rs
tests/ui/simd/repr_packed.rs
tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs
tests/ui/consts/try-operator.rs
tests/ui/coroutine/unwind-abort-mix.rs
tests/ui/consts/issue-miri-1910.rs
tests/ui/consts/const_cmp_type_id.rs
tests/ui/consts/issue-73976-monomorphic.rs
tests/ui/consts/issue-94675.rs
tests/ui/traits/const-traits/const-drop-fail.rs
tests/ui/runtime/on-broken-pipe/child-processes.rs
@ -53,7 +48,6 @@ tests/ui/sanitizer/cfi/virtual-auto.rs
tests/ui/sanitizer/cfi/sized-associated-ty.rs
tests/ui/sanitizer/cfi/can-reveal-opaques.rs
tests/ui/sanitizer/kcfi-mangling.rs
tests/ui/statics/const_generics.rs
tests/ui/backtrace/dylib-dep.rs
tests/ui/delegation/fn-header.rs
tests/ui/consts/const-eval/parse_ints.rs
@ -74,13 +68,7 @@ tests/ui/codegen/equal-pointers-unequal/strict-provenance/zero.rs
tests/ui/simd/simd-bitmask-notpow2.rs
tests/ui/codegen/StackColoring-not-blowup-stack-issue-40883.rs
tests/ui/numbers-arithmetic/u128-as-f32.rs
tests/ui/lto/all-crates.rs
tests/ui/uninhabited/uninhabited-transparent-return-abi.rs
tests/ui/coroutine/panic-drops-resume.rs
tests/ui/coroutine/panic-drops.rs
tests/ui/coroutine/panic-safe.rs
tests/ui/process/nofile-limit.rs
tests/ui/simd/intrinsic/generic-arithmetic-pass.rs
tests/ui/linking/no-gc-encapsulation-symbols.rs
tests/ui/panics/unwind-force-no-unwind-tables.rs
tests/ui/attributes/fn-align-dyn.rs
@ -88,3 +76,4 @@ tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs
tests/ui/explicit-tail-calls/recursion-etc.rs
tests/ui/explicit-tail-calls/indexer.rs
tests/ui/explicit-tail-calls/drop-order.rs
tests/ui/c-variadic/valid.rs

@ -1 +1 @@
Subproject commit 4e995bd73c4490edfe5080ec6014d63aa9abed5f
Subproject commit 28b84db392ac0a572f1a2a2a1317aa5f2bc742cb

View file

@ -2,6 +2,7 @@
//@ build-pass
//@ no-prefer-dynamic
//@ needs-crate-type: cdylib
//@ ignore-backends: gcc
use std::alloc::{GlobalAlloc, Layout};