Skip to content

Commit 586a988

Browse files
authored
Auto merge of #36421 - TimNN:check-abis, r=alexcrichton
check target abi support This PR checks for each extern function / block whether the ABI / calling convention used is supported by the current target. This was achieved by adding an `abi_blacklist` field to the target specifications, listing the calling conventions unsupported for that target.
2 parents a7557e7 + 1422ac9 commit 586a988

25 files changed

+153
-49
lines changed

src/librustc_back/target/aarch64_apple_ios.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub fn target() -> TargetResult {
2626
features: "+neon,+fp-armv8,+cyclone".to_string(),
2727
eliminate_frame_pointer: false,
2828
max_atomic_width: Some(128),
29+
abi_blacklist: super::arm_base::abi_blacklist(),
2930
.. base
3031
},
3132
})

src/librustc_back/target/aarch64_linux_android.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use target::{Target, TargetResult};
11+
use target::{Target, TargetOptions, TargetResult};
1212

1313
pub fn target() -> TargetResult {
1414
let mut base = super::android_base::opts();
@@ -25,6 +25,9 @@ pub fn target() -> TargetResult {
2525
target_os: "android".to_string(),
2626
target_env: "".to_string(),
2727
target_vendor: "unknown".to_string(),
28-
options: base,
28+
options: TargetOptions {
29+
abi_blacklist: super::arm_base::abi_blacklist(),
30+
.. base
31+
},
2932
})
3033
}

src/librustc_back/target/aarch64_unknown_linux_gnu.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use target::{Target, TargetResult};
11+
use target::{Target, TargetOptions, TargetResult};
1212

1313
pub fn target() -> TargetResult {
1414
let mut base = super::linux_base::opts();
@@ -22,6 +22,9 @@ pub fn target() -> TargetResult {
2222
arch: "aarch64".to_string(),
2323
target_os: "linux".to_string(),
2424
target_vendor: "unknown".to_string(),
25-
options: base,
25+
options: TargetOptions {
26+
abi_blacklist: super::arm_base::abi_blacklist(),
27+
.. base
28+
},
2629
})
2730
}

src/librustc_back/target/arm_base.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use syntax::abi::Abi;
12+
13+
// All the calling conventions trigger an assertion(Unsupported calling convention) in llvm on arm
14+
pub fn abi_blacklist() -> Vec<Abi> {
15+
vec![Abi::Stdcall, Abi::Fastcall, Abi::Vectorcall, Abi::Win64, Abi::SysV64]
16+
}

src/librustc_back/target/arm_linux_androideabi.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use target::{Target, TargetResult};
11+
use target::{Target, TargetOptions, TargetResult};
1212

1313
pub fn target() -> TargetResult {
1414
let mut base = super::android_base::opts();
@@ -24,6 +24,9 @@ pub fn target() -> TargetResult {
2424
target_os: "android".to_string(),
2525
target_env: "".to_string(),
2626
target_vendor: "unknown".to_string(),
27-
options: base,
27+
options: TargetOptions {
28+
abi_blacklist: super::arm_base::abi_blacklist(),
29+
.. base
30+
},
2831
})
2932
}

src/librustc_back/target/arm_unknown_linux_gnueabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn target() -> TargetResult {
2525

2626
options: TargetOptions {
2727
features: "+v6".to_string(),
28+
abi_blacklist: super::arm_base::abi_blacklist(),
2829
.. base
2930
},
3031
})

src/librustc_back/target/arm_unknown_linux_gnueabihf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn target() -> TargetResult {
2525

2626
options: TargetOptions {
2727
features: "+v6,+vfp2".to_string(),
28+
abi_blacklist: super::arm_base::abi_blacklist(),
2829
.. base
2930
}
3031
})

src/librustc_back/target/arm_unknown_linux_musleabi.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use target::{Target, TargetResult};
11+
use target::{Target, TargetOptions, TargetResult};
1212

1313
pub fn target() -> TargetResult {
1414
let mut base = super::linux_musl_base::opts();
@@ -29,6 +29,9 @@ pub fn target() -> TargetResult {
2929
target_os: "linux".to_string(),
3030
target_env: "musl".to_string(),
3131
target_vendor: "unknown".to_string(),
32-
options: base,
32+
options: TargetOptions {
33+
abi_blacklist: super::arm_base::abi_blacklist(),
34+
.. base
35+
},
3336
})
3437
}

src/librustc_back/target/arm_unknown_linux_musleabihf.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use target::{Target, TargetResult};
11+
use target::{Target, TargetOptions, TargetResult};
1212

1313
pub fn target() -> TargetResult {
1414
let mut base = super::linux_musl_base::opts();
@@ -29,6 +29,9 @@ pub fn target() -> TargetResult {
2929
target_os: "linux".to_string(),
3030
target_env: "musl".to_string(),
3131
target_vendor: "unknown".to_string(),
32-
options: base,
32+
options: TargetOptions {
33+
abi_blacklist: super::arm_base::abi_blacklist(),
34+
.. base
35+
},
3336
})
3437
}

src/librustc_back/target/armv7_apple_ios.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn target() -> TargetResult {
2525
options: TargetOptions {
2626
features: "+v7,+vfp3,+neon".to_string(),
2727
max_atomic_width: Some(64),
28+
abi_blacklist: super::arm_base::abi_blacklist(),
2829
.. base
2930
}
3031
})

0 commit comments

Comments
 (0)