Skip to content

Commit a371038

Browse files
committed
Auto merge of #149426 - antoyo:libgccjit-targets, r=Kobzol
Move the libgccjit.so file in a target directory Since GCC is not multi-target, we need multiple libgccjit.so. Our solution to have a directory per target so that we can have multiple libgccjit.so. r? `@Kobzol`
2 parents 0b96731 + 42059a3 commit a371038

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+125
-101
lines changed

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ use rustc_middle::ty::TyCtxt;
9898
use rustc_middle::util::Providers;
9999
use rustc_session::Session;
100100
use rustc_session::config::{OptLevel, OutputFilenames};
101+
use rustc_session::filesearch::make_target_lib_path;
101102
use rustc_span::Symbol;
102103
use rustc_target::spec::{Arch, RelocModel};
103104
use tempfile::TempDir;
@@ -181,18 +182,12 @@ pub struct GccCodegenBackend {
181182

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

184-
fn libgccjit_path(sysroot_path: &Path) -> PathBuf {
185-
let sysroot_lib_dir = sysroot_path.join("lib");
186-
sysroot_lib_dir.join("libgccjit.so")
187-
}
188-
189-
fn load_libgccjit_if_needed(sysroot_path: &Path) {
185+
fn load_libgccjit_if_needed(libgccjit_target_lib_file: &Path) {
190186
if gccjit::is_loaded() {
191187
// Do not load a libgccjit second time.
192188
return;
193189
}
194190

195-
let libgccjit_target_lib_file = libgccjit_path(sysroot_path);
196191
let path = libgccjit_target_lib_file.to_str().expect("libgccjit path");
197192

198193
let string = CString::new(path).expect("string to libgccjit path");
@@ -216,9 +211,10 @@ impl CodegenBackend for GccCodegenBackend {
216211
// invalid.
217212
// This is the case for instance in Rust for Linux where they specify --sysroot=/dev/null.
218213
for path in sess.opts.sysroot.all_paths() {
219-
let libgccjit_target_lib_file = libgccjit_path(path);
220-
if let Ok(true) = fs::exists(libgccjit_target_lib_file) {
221-
load_libgccjit_if_needed(path);
214+
let libgccjit_target_lib_file =
215+
make_target_lib_path(path, &sess.target.llvm_target).join("libgccjit.so");
216+
if let Ok(true) = fs::exists(&libgccjit_target_lib_file) {
217+
load_libgccjit_if_needed(&libgccjit_target_lib_file);
222218
break;
223219
}
224220
}

src/bootstrap/src/core/build_steps/gcc.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub struct Gcc {
2727
#[derive(Clone)]
2828
pub struct GccOutput {
2929
pub libgccjit: PathBuf,
30+
target: TargetSelection,
3031
}
3132

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

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

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

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

8184
let libgccjit_path = libgccjit_built_path(&metadata.install_dir);
8285
if builder.config.dry_run() {
83-
return GccOutput { libgccjit: libgccjit_path };
86+
return GccOutput { libgccjit: libgccjit_path, target };
8487
}
8588

8689
build_gcc(&metadata, builder, target);
8790

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

90-
GccOutput { libgccjit: libgccjit_path }
93+
GccOutput { libgccjit: libgccjit_path, target }
9194
}
9295
}
9396

tests/mir-opt/inline/inline_instruction_set.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
//@ compile-flags: --target thumbv4t-none-eabi
66
//@ needs-llvm-components: arm
7+
//@ ignore-backends: gcc
78

89
#![crate_type = "lib"]
910
#![feature(rustc_attrs)]

tests/ui/check-cfg/values-target-json.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//@ no-auto-check-cfg
66
//@ needs-llvm-components: x86
77
//@ compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json
8+
//@ ignore-backends: gcc
89

910
#![feature(lang_items, no_core, auto_traits, rustc_attrs)]
1011
#![no_core]

tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ add-minicore
22
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
33
//@ needs-llvm-components: arm
4+
//@ ignore-backends: gcc
45
#![feature(abi_cmse_nonsecure_call, no_core, lang_items)]
56
#![no_core]
67

tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: function pointer types may not have generic parameters
2-
--> $DIR/generics.rs:14:40
2+
--> $DIR/generics.rs:15:40
33
|
44
LL | f1: extern "cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64,
55
| ^^^^^^^^^
66

77
error[E0425]: cannot find type `U` in this scope
8-
--> $DIR/generics.rs:14:50
8+
--> $DIR/generics.rs:15:50
99
|
1010
LL | struct Test<T: Copy> {
1111
| - similarly named type parameter `T` defined here
@@ -23,51 +23,51 @@ LL | struct Test<T: Copy, U> {
2323
| +++
2424

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

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

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

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

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

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

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

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

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

9696
error[E0045]: C-variadic functions with the "cmse-nonsecure-call" calling convention are not supported
97-
--> $DIR/generics.rs:44:20
97+
--> $DIR/generics.rs:45:20
9898
|
9999
LL | type WithVarArgs = extern "cmse-nonsecure-call" fn(u32, ...);
100100
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention

tests/ui/cmse-nonsecure/cmse-nonsecure-call/infer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ add-minicore
22
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
33
//@ needs-llvm-components: arm
4+
//@ ignore-backends: gcc
45
#![feature(abi_cmse_nonsecure_call, no_core, lang_items)]
56
#![no_core]
67

tests/ui/cmse-nonsecure/cmse-nonsecure-call/infer.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error[E0282]: type annotations needed
2-
--> $DIR/infer.rs:16:13
2+
--> $DIR/infer.rs:17:13
33
|
44
LL | let _ = mem::transmute::<fn() -> _, extern "cmse-nonsecure-call" fn() -> _>;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Src` declared on the function `transmute`
66

77
error[E0282]: type annotations needed
8-
--> $DIR/infer.rs:21:13
8+
--> $DIR/infer.rs:22:13
99
|
1010
LL | let _ = mem::transmute::<fn() -> (i32, _), extern "cmse-nonsecure-call" fn() -> (i32, _)>;
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Src` declared on the function `transmute`
1212

1313
error[E0282]: type annotations needed
14-
--> $DIR/infer.rs:26:13
14+
--> $DIR/infer.rs:27:13
1515
|
1616
LL | let _ = mem::transmute::<fn(_: _) -> (), extern "cmse-nonsecure-call" fn(_: _) -> ()>;
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Src` declared on the function `transmute`
1818

1919
error[E0282]: type annotations needed
20-
--> $DIR/infer.rs:32:9
20+
--> $DIR/infer.rs:33:9
2121
|
2222
LL | mem::transmute::<fn(_: (i32, _)) -> (), extern "cmse-nonsecure-call" fn(_: (i32, _)) -> ()>;
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Src` declared on the function `transmute`

tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ add-minicore
22
//@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
33
//@ needs-llvm-components: arm
4+
//@ ignore-backends: gcc
45
#![feature(abi_cmse_nonsecure_call, no_core, lang_items)]
56
#![no_core]
67

tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers
2-
--> $DIR/params-via-stack.rs:16:64
2+
--> $DIR/params-via-stack.rs:17:64
33
|
44
LL | f1: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u32),
55
| ^^^ ^^^ does not fit in the available registers
@@ -9,31 +9,31 @@ LL | f1: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u32)
99
= note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit argument registers
1010

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

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

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

3535
error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers
36-
--> $DIR/params-via-stack.rs:20:41
36+
--> $DIR/params-via-stack.rs:21:41
3737
|
3838
LL | f5: extern "cmse-nonsecure-call" fn([u32; 5]),
3939
| ^^^^^^^^ does not fit in the available registers

0 commit comments

Comments
 (0)