Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_middle::util::Providers;
use rustc_session::Session;
use rustc_session::config::{OptLevel, OutputFilenames};
use rustc_session::filesearch::make_target_lib_path;
use rustc_span::Symbol;
use rustc_target::spec::{Arch, RelocModel};
use tempfile::TempDir;
Expand Down Expand Up @@ -180,14 +181,14 @@ pub struct GccCodegenBackend {

static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false);

fn load_libgccjit_if_needed(sysroot_path: &Path) {
fn load_libgccjit_if_needed(sysroot_path: &Path, target_triple: &str) {
if gccjit::is_loaded() {
// Do not load a libgccjit second time.
return;
}

let sysroot_lib_dir = sysroot_path.join("lib");
let libgccjit_target_lib_file = sysroot_lib_dir.join("libgccjit.so");
let libgccjit_target_lib_file =
make_target_lib_path(sysroot_path, target_triple).join("libgccjit.so");
let path = libgccjit_target_lib_file.to_str().expect("libgccjit path");

let string = CString::new(path).expect("string to libgccjit path");
Expand All @@ -207,7 +208,7 @@ impl CodegenBackend for GccCodegenBackend {
}

fn init(&self, sess: &Session) {
load_libgccjit_if_needed(sess.opts.sysroot.path());
load_libgccjit_if_needed(sess.opts.sysroot.path(), &sess.target.llvm_target);

#[cfg(feature = "master")]
{
Expand Down
11 changes: 7 additions & 4 deletions src/bootstrap/src/core/build_steps/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct Gcc {
#[derive(Clone)]
pub struct GccOutput {
pub libgccjit: PathBuf,
target: TargetSelection,
}

impl GccOutput {
Expand All @@ -46,7 +47,9 @@ impl GccOutput {
format!("Cannot find libgccjit at {}", self.libgccjit.display())
);

let dst = directory.join(target_filename);
let dest_dir = directory.join("rustlib").join(self.target).join("lib");
t!(fs::create_dir_all(&dest_dir));
let dst = dest_dir.join(target_filename);
builder.copy_link(&actual_libgccjit_path, &dst, FileType::NativeLibrary);
}
}
Expand All @@ -70,7 +73,7 @@ impl Step for Gcc {

// If GCC has already been built, we avoid building it again.
let metadata = match get_gcc_build_status(builder, target) {
GccBuildStatus::AlreadyBuilt(path) => return GccOutput { libgccjit: path },
GccBuildStatus::AlreadyBuilt(path) => return GccOutput { libgccjit: path, target },
GccBuildStatus::ShouldBuild(m) => m,
};

Expand All @@ -80,14 +83,14 @@ impl Step for Gcc {

let libgccjit_path = libgccjit_built_path(&metadata.install_dir);
if builder.config.dry_run() {
return GccOutput { libgccjit: libgccjit_path };
return GccOutput { libgccjit: libgccjit_path, target };
}

build_gcc(&metadata, builder, target);

t!(metadata.stamp.write());

GccOutput { libgccjit: libgccjit_path }
GccOutput { libgccjit: libgccjit_path, target }
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/mir-opt/inline/inline_instruction_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
//@ compile-flags: --target thumbv4t-none-eabi
//@ needs-llvm-components: arm
//@ ignore-backends: gcc

#![crate_type = "lib"]
#![feature(rustc_attrs)]
Expand Down
1 change: 1 addition & 0 deletions tests/ui/check-cfg/values-target-json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//@ no-auto-check-cfg
//@ needs-llvm-components: x86
//@ compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json
//@ ignore-backends: gcc

#![feature(lang_items, no_core, auto_traits, rustc_attrs)]
#![no_core]
Expand Down
1 change: 1 addition & 0 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@ add-minicore
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
//@ needs-llvm-components: arm
//@ ignore-backends: gcc
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these new test failures are due to the fact that --target is used and we now put libgccjit.so in a directory named after the target, so rustc_codegen_gcc doesn't find libgccjit.so.
Is this the correct way to ignore these tests?
Or are tests annotated with needs-llvm-compoments not expected to pass with a codegen that is not LLVM?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think //@ ignore-backends: gcc makes sense. These tests would pass just fine with Cranelift if it is one of the targets supported by Cranelift. cg_clif always enables all backends of Cranelift.

#![feature(abi_cmse_nonsecure_call, no_core, lang_items)]
#![no_core]

Expand Down
24 changes: 12 additions & 12 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: function pointer types may not have generic parameters
--> $DIR/generics.rs:14:40
--> $DIR/generics.rs:15:40
|
LL | f1: extern "cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64,
| ^^^^^^^^^

error[E0412]: cannot find type `U` in this scope
--> $DIR/generics.rs:14:50
--> $DIR/generics.rs:15:50
|
LL | struct Test<T: Copy> {
| - similarly named type parameter `T` defined here
Expand All @@ -23,51 +23,51 @@ LL | struct Test<T: Copy, U> {
| +++

error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters
--> $DIR/generics.rs:17:41
--> $DIR/generics.rs:18:41
|
LL | f2: extern "cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> impl Copy,
| ^^^^^^^^^
|
= note: `impl Trait` is only allowed in arguments and return types of functions and methods

error[E0562]: `impl Trait` is not allowed in `fn` pointer return types
--> $DIR/generics.rs:17:70
--> $DIR/generics.rs:18:70
|
LL | f2: extern "cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> impl Copy,
| ^^^^^^^^^
|
= note: `impl Trait` is only allowed in arguments and return types of functions and methods

error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters
--> $DIR/generics.rs:20:42
--> $DIR/generics.rs:21:42
|
LL | f3: extern "cmse-nonsecure-call" fn((impl Copy, u32), u32, u32, u32) -> (impl Copy, u32),
| ^^^^^^^^^
|
= note: `impl Trait` is only allowed in arguments and return types of functions and methods

error[E0562]: `impl Trait` is not allowed in `fn` pointer return types
--> $DIR/generics.rs:20:78
--> $DIR/generics.rs:21:78
|
LL | f3: extern "cmse-nonsecure-call" fn((impl Copy, u32), u32, u32, u32) -> (impl Copy, u32),
| ^^^^^^^^^
|
= note: `impl Trait` is only allowed in arguments and return types of functions and methods

error[E0798]: generics are not allowed in `extern "cmse-nonsecure-call"` signatures
--> $DIR/generics.rs:23:41
--> $DIR/generics.rs:24:41
|
LL | f4: extern "cmse-nonsecure-call" fn(T, u32, u32, u32) -> u64,
| ^

error[E0798]: generics are not allowed in `extern "cmse-nonsecure-call"` signatures
--> $DIR/generics.rs:24:41
--> $DIR/generics.rs:25:41
|
LL | f5: extern "cmse-nonsecure-call" fn(Wrapper<T>, u32, u32, u32) -> u64,
| ^^^^^^^^^^

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/generics.rs:30:71
--> $DIR/generics.rs:31:71
|
LL | type WithTraitObject = extern "cmse-nonsecure-call" fn(&dyn Trait) -> &dyn Trait;
| ^^^^^^^^^^ this type doesn't fit in the available registers
Expand All @@ -76,7 +76,7 @@ LL | type WithTraitObject = extern "cmse-nonsecure-call" fn(&dyn Trait) -> &dyn
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/generics.rs:34:60
--> $DIR/generics.rs:35:60
|
LL | extern "cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn Trait;
| ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers
Expand All @@ -85,7 +85,7 @@ LL | extern "cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn Tra
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/generics.rs:41:60
--> $DIR/generics.rs:42:60
|
LL | extern "cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTransparent;
| ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers
Expand All @@ -94,7 +94,7 @@ LL | extern "cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTranspare
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0045]: C-variadic functions with the "cmse-nonsecure-call" calling convention are not supported
--> $DIR/generics.rs:44:20
--> $DIR/generics.rs:45:20
|
LL | type WithVarArgs = extern "cmse-nonsecure-call" fn(u32, ...);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@ add-minicore
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
//@ needs-llvm-components: arm
//@ ignore-backends: gcc
#![feature(abi_cmse_nonsecure_call, no_core, lang_items)]
#![no_core]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/params-via-stack.rs:16:64
--> $DIR/params-via-stack.rs:17:64
|
LL | f1: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u32),
| ^^^ ^^^ does not fit in the available registers
Expand All @@ -9,31 +9,31 @@ LL | f1: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u32)
= note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit argument registers

error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/params-via-stack.rs:17:61
--> $DIR/params-via-stack.rs:18:61
|
LL | f2: extern "cmse-nonsecure-call" fn(u32, u32, u32, u16, u16),
| ^^^ does not fit in the available registers
|
= note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit argument registers

error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/params-via-stack.rs:18:51
--> $DIR/params-via-stack.rs:19:51
|
LL | f3: extern "cmse-nonsecure-call" fn(u32, u64, u32),
| ^^^ does not fit in the available registers
|
= note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit argument registers

error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/params-via-stack.rs:19:56
--> $DIR/params-via-stack.rs:20:56
|
LL | f4: extern "cmse-nonsecure-call" fn(AlignRelevant, u32),
| ^^^ does not fit in the available registers
|
= note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit argument registers

error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/params-via-stack.rs:20:41
--> $DIR/params-via-stack.rs:21:41
|
LL | f5: extern "cmse-nonsecure-call" fn([u32; 5]),
| ^^^^^^^^ does not fit in the available registers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
//@ needs-llvm-components: arm
//@ add-minicore
//@ ignore-backends: gcc

#![feature(abi_cmse_nonsecure_call, no_core, lang_items)]
#![no_core]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/return-via-stack.rs:36:48
--> $DIR/return-via-stack.rs:37:48
|
LL | u128: extern "cmse-nonsecure-call" fn() -> u128,
| ^^^^ this type doesn't fit in the available registers
Expand All @@ -8,7 +8,7 @@ LL | u128: extern "cmse-nonsecure-call" fn() -> u128,
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/return-via-stack.rs:37:48
--> $DIR/return-via-stack.rs:38:48
|
LL | i128: extern "cmse-nonsecure-call" fn() -> i128,
| ^^^^ this type doesn't fit in the available registers
Expand All @@ -17,7 +17,7 @@ LL | i128: extern "cmse-nonsecure-call" fn() -> i128,
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/return-via-stack.rs:26:46
--> $DIR/return-via-stack.rs:27:46
|
LL | f1: extern "cmse-nonsecure-call" fn() -> ReprCU64,
| ^^^^^^^^ this type doesn't fit in the available registers
Expand All @@ -26,7 +26,7 @@ LL | f1: extern "cmse-nonsecure-call" fn() -> ReprCU64,
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/return-via-stack.rs:27:46
--> $DIR/return-via-stack.rs:28:46
|
LL | f2: extern "cmse-nonsecure-call" fn() -> ReprCBytes,
| ^^^^^^^^^^ this type doesn't fit in the available registers
Expand All @@ -35,7 +35,7 @@ LL | f2: extern "cmse-nonsecure-call" fn() -> ReprCBytes,
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/return-via-stack.rs:28:46
--> $DIR/return-via-stack.rs:29:46
|
LL | f3: extern "cmse-nonsecure-call" fn() -> U64Compound,
| ^^^^^^^^^^^ this type doesn't fit in the available registers
Expand All @@ -44,7 +44,7 @@ LL | f3: extern "cmse-nonsecure-call" fn() -> U64Compound,
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/return-via-stack.rs:29:46
--> $DIR/return-via-stack.rs:30:46
|
LL | f4: extern "cmse-nonsecure-call" fn() -> ReprCAlign16,
| ^^^^^^^^^^^^ this type doesn't fit in the available registers
Expand All @@ -53,7 +53,7 @@ LL | f4: extern "cmse-nonsecure-call" fn() -> ReprCAlign16,
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/return-via-stack.rs:30:46
--> $DIR/return-via-stack.rs:31:46
|
LL | f5: extern "cmse-nonsecure-call" fn() -> [u8; 5],
| ^^^^^^^ this type doesn't fit in the available registers
Expand All @@ -62,7 +62,7 @@ LL | f5: extern "cmse-nonsecure-call" fn() -> [u8; 5],
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/return-via-stack.rs:52:46
--> $DIR/return-via-stack.rs:53:46
|
LL | f1: extern "cmse-nonsecure-call" fn() -> ReprRustUnionU64,
| ^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers
Expand All @@ -71,7 +71,7 @@ LL | f1: extern "cmse-nonsecure-call" fn() -> ReprRustUnionU64,
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size

error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers
--> $DIR/return-via-stack.rs:53:46
--> $DIR/return-via-stack.rs:54:46
|
LL | f2: extern "cmse-nonsecure-call" fn() -> ReprCUnionU64,
| ^^^^^^^^^^^^^ this type doesn't fit in the available registers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
//@ incremental (required to trigger the bug)
//@ needs-llvm-components: arm
//@ ignore-backends: gcc
#![feature(abi_cmse_nonsecure_call, no_core)]
#![no_core]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/undeclared-lifetime.rs:15:43
--> $DIR/undeclared-lifetime.rs:16:43
|
LL | id::<extern "cmse-nonsecure-call" fn(&'a ())>(PhantomData);
| ^^ undeclared lifetime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//@ build-pass
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
//@ needs-llvm-components: arm
//@ ignore-backends: gcc
#![feature(abi_cmse_nonsecure_call, no_core, lang_items, intrinsics)]
#![no_core]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@ add-minicore
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
//@ needs-llvm-components: arm
//@ ignore-backends: gcc
#![feature(abi_cmse_nonsecure_call, lang_items, no_core)]
#![no_core]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0781]: the `"cmse-nonsecure-call"` ABI is only allowed on function pointers
--> $DIR/wrong-abi-location-1.rs:10:1
--> $DIR/wrong-abi-location-1.rs:11:1
|
LL | pub extern "cmse-nonsecure-call" fn test() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@ add-minicore
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
//@ needs-llvm-components: arm
//@ ignore-backends: gcc
#![feature(abi_cmse_nonsecure_call, lang_items, no_core)]
#![no_core]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0781]: the `"cmse-nonsecure-call"` ABI is only allowed on function pointers
--> $DIR/wrong-abi-location-2.rs:10:1
--> $DIR/wrong-abi-location-2.rs:11:1
|
LL | / extern "cmse-nonsecure-call" {
LL | | fn test();
Expand Down
Loading
Loading