Skip to content

Commit c123559

Browse files
committed
Add va_list_kind to target specification
Each architecture may represent a va_list differently. Add the va_list_kind enumeration to the target specification that includes the common ways a va_list is represented.
1 parent aa7ce89 commit c123559

Some content is hidden

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

55 files changed

+182
-56
lines changed

src/librustc_back/lib.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,45 @@ impl ToJson for RelroLevel {
168168
}
169169
}
170170
}
171+
172+
#[derive(Clone, Copy, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
173+
pub enum VaListKind {
174+
CharPtr,
175+
VoidPtr,
176+
AArch64Abi,
177+
PowerPcAbi,
178+
X86_64Abi,
179+
}
180+
181+
impl VaListKind {
182+
pub fn desc(&self) -> &str {
183+
match self {
184+
&VaListKind::CharPtr => "char-ptr",
185+
&VaListKind::VoidPtr => "void-ptr",
186+
&VaListKind::AArch64Abi => "aarch64-abi",
187+
&VaListKind::PowerPcAbi => "powerpc-abi",
188+
&VaListKind::X86_64Abi => "x86_64-abi",
189+
}
190+
}
191+
}
192+
193+
impl FromStr for VaListKind {
194+
type Err = ();
195+
196+
fn from_str(s: &str) -> Result<VaListKind, ()> {
197+
match s {
198+
"char-ptr" => Ok(VaListKind::CharPtr),
199+
"void-ptr" => Ok(VaListKind::VoidPtr),
200+
"aarch64-abi" => Ok(VaListKind::AArch64Abi),
201+
"powerpc-abi" => Ok(VaListKind::PowerPcAbi),
202+
"x86_64-abi" => Ok(VaListKind::X86_64Abi),
203+
_ => Err(()),
204+
}
205+
}
206+
}
207+
208+
impl ToJson for VaListKind {
209+
fn to_json(&self) -> Json {
210+
self.desc().to_json()
211+
}
212+
}

src/librustc_back/target/aarch64_linux_android.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a
1515
// for target ABI requirements.
@@ -20,6 +20,7 @@ pub fn target() -> TargetResult {
2020
// As documented in http://developer.android.com/ndk/guides/cpu-features.html
2121
// the neon (ASIMD) and FP must exist on all android aarch64 targets.
2222
base.features = "+neon,+fp-armv8".to_string();
23+
base.va_list_kind = VaListKind::AArch64Abi;
2324
Ok(Target {
2425
llvm_target: "aarch64-linux-android".to_string(),
2526
target_endian: "little".to_string(),

src/librustc_back/target/aarch64_unknown_cloudabi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetResult};
12+
use target::{Target, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::cloudabi_base::opts();
1616
base.max_atomic_width = Some(128);
1717
base.abi_blacklist = super::arm_base::abi_blacklist();
1818
base.linker = Some("aarch64-unknown-cloudabi-cc".to_string());
19+
base.va_list_kind = VaListKind::AArch64Abi;
1920

2021
Ok(Target {
2122
llvm_target: "aarch64-unknown-cloudabi".to_string(),

src/librustc_back/target/aarch64_unknown_freebsd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::freebsd_base::opts();
1616
base.max_atomic_width = Some(128);
17+
base.va_list_kind = VaListKind::AArch64Abi;
1718

1819
// see #36994
1920
base.exe_allocation_crate = None;

src/librustc_back/target/aarch64_unknown_fuchsia.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::fuchsia_base::opts();
1616
base.max_atomic_width = Some(128);
17+
base.va_list_kind = VaListKind::AArch64Abi;
1718

1819
Ok(Target {
1920
llvm_target: "aarch64-unknown-fuchsia".to_string(),

src/librustc_back/target/aarch64_unknown_linux_gnu.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::linux_base::opts();
1616
base.max_atomic_width = Some(128);
17+
base.va_list_kind = VaListKind::AArch64Abi;
1718

1819
// see #36994
1920
base.exe_allocation_crate = None;

src/librustc_back/target/aarch64_unknown_linux_musl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::linux_musl_base::opts();
1616
base.max_atomic_width = Some(128);
17+
base.va_list_kind = VaListKind::AArch64Abi;
1718

1819
// see #36994
1920
base.exe_allocation_crate = None;

src/librustc_back/target/apple_ios_base.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use LinkerFlavor;
1212
use std::io;
1313
use std::process::Command;
14-
use target::{LinkArgs, TargetOptions};
14+
use target::{LinkArgs, TargetOptions, VaListKind};
1515

1616
use self::Arch::*;
1717

@@ -93,6 +93,13 @@ fn target_cpu(arch: Arch) -> String {
9393

9494
pub fn opts(arch: Arch) -> Result<TargetOptions, String> {
9595
let pre_link_args = build_pre_link_args(arch)?;
96+
let va_list_kind = match arch {
97+
Arch::Armv7 | Arch::Armv7s => VaListKind::VoidPtr,
98+
Arch::Arm64 => VaListKind::AArch64Abi,
99+
Arch::I386 => VaListKind::CharPtr,
100+
Arch::X86_64 => VaListKind::X86_64Abi,
101+
};
102+
96103
Ok(TargetOptions {
97104
cpu: target_cpu(arch),
98105
dynamic_linking: false,
@@ -103,6 +110,7 @@ pub fn opts(arch: Arch) -> Result<TargetOptions, String> {
103110
// ios. jemalloc 5.0 is supposed to fix this.
104111
// see https://github.com/rust-lang/rust/issues/45262
105112
exe_allocation_crate: None,
113+
va_list_kind,
106114
.. super::apple_base::opts()
107115
})
108116
}

src/librustc_back/target/arm_linux_androideabi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::android_base::opts();
@@ -30,6 +30,7 @@ pub fn target() -> TargetResult {
3030
linker_flavor: LinkerFlavor::Gcc,
3131
options: TargetOptions {
3232
abi_blacklist: super::arm_base::abi_blacklist(),
33+
va_list_kind: VaListKind::VoidPtr,
3334
.. base
3435
},
3536
})

src/librustc_back/target/arm_unknown_linux_gnueabi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::linux_base::opts();
@@ -29,6 +29,7 @@ pub fn target() -> TargetResult {
2929
options: TargetOptions {
3030
features: "+strict-align,+v6".to_string(),
3131
abi_blacklist: super::arm_base::abi_blacklist(),
32+
va_list_kind: VaListKind::VoidPtr,
3233
.. base
3334
},
3435
})

src/librustc_back/target/arm_unknown_linux_gnueabihf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::linux_base::opts();
@@ -29,6 +29,7 @@ pub fn target() -> TargetResult {
2929
options: TargetOptions {
3030
features: "+strict-align,+v6,+vfp2".to_string(),
3131
abi_blacklist: super::arm_base::abi_blacklist(),
32+
va_list_kind: VaListKind::VoidPtr,
3233
.. base
3334
}
3435
})

src/librustc_back/target/arm_unknown_linux_musleabi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::linux_musl_base::opts();
@@ -34,6 +34,7 @@ pub fn target() -> TargetResult {
3434
linker_flavor: LinkerFlavor::Gcc,
3535
options: TargetOptions {
3636
abi_blacklist: super::arm_base::abi_blacklist(),
37+
va_list_kind: VaListKind::VoidPtr,
3738
.. base
3839
},
3940
})

src/librustc_back/target/arm_unknown_linux_musleabihf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::linux_musl_base::opts();
@@ -34,6 +34,7 @@ pub fn target() -> TargetResult {
3434
linker_flavor: LinkerFlavor::Gcc,
3535
options: TargetOptions {
3636
abi_blacklist: super::arm_base::abi_blacklist(),
37+
va_list_kind: VaListKind::VoidPtr,
3738
.. base
3839
},
3940
})

src/librustc_back/target/armv4t_unknown_linux_gnueabi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let base = super::linux_base::opts();
@@ -30,6 +30,7 @@ pub fn target() -> TargetResult {
3030
// Atomic operations provided by compiler-builtins
3131
max_atomic_width: Some(32),
3232
abi_blacklist: super::arm_base::abi_blacklist(),
33+
va_list_kind: VaListKind::VoidPtr,
3334
.. base
3435
}
3536
})

src/librustc_back/target/armv5te_unknown_linux_gnueabi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let base = super::linux_base::opts();
@@ -30,6 +30,7 @@ pub fn target() -> TargetResult {
3030
// Atomic operations provided by compiler-builtins
3131
max_atomic_width: Some(32),
3232
abi_blacklist: super::arm_base::abi_blacklist(),
33+
va_list_kind: VaListKind::VoidPtr,
3334
.. base
3435
}
3536
})

src/librustc_back/target/armv7_linux_androideabi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
// See https://developer.android.com/ndk/guides/abis.html#v7a
1515
// for target ABI requirements.
@@ -34,6 +34,7 @@ pub fn target() -> TargetResult {
3434
linker_flavor: LinkerFlavor::Gcc,
3535
options: TargetOptions {
3636
abi_blacklist: super::arm_base::abi_blacklist(),
37+
va_list_kind: VaListKind::VoidPtr,
3738
.. base
3839
},
3940
})

src/librustc_back/target/armv7_unknown_cloudabi_eabihf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetResult};
12+
use target::{Target, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::cloudabi_base::opts();
@@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
1818
base.features = "+v7,+vfp3,+neon".to_string();
1919
base.abi_blacklist = super::arm_base::abi_blacklist();
2020
base.linker = Some("armv7-unknown-cloudabi-eabihf-cc".to_string());
21+
base.va_list_kind = VaListKind::VoidPtr;
2122

2223
Ok(Target {
2324
llvm_target: "armv7-unknown-cloudabi-eabihf".to_string(),

src/librustc_back/target/armv7_unknown_linux_gnueabihf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let base = super::linux_base::opts();
@@ -31,6 +31,7 @@ pub fn target() -> TargetResult {
3131
cpu: "generic".to_string(),
3232
max_atomic_width: Some(64),
3333
abi_blacklist: super::arm_base::abi_blacklist(),
34+
va_list_kind: VaListKind::VoidPtr,
3435
.. base
3536
}
3637
})

src/librustc_back/target/armv7_unknown_linux_musleabihf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetOptions, TargetResult};
12+
use target::{Target, TargetOptions, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let base = super::linux_musl_base::opts();
@@ -35,6 +35,7 @@ pub fn target() -> TargetResult {
3535
cpu: "generic".to_string(),
3636
max_atomic_width: Some(64),
3737
abi_blacklist: super::arm_base::abi_blacklist(),
38+
va_list_kind: VaListKind::VoidPtr,
3839
.. base
3940
}
4041
})

src/librustc_back/target/i686_apple_darwin.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetResult};
12+
use target::{Target, TargetResult, VaListKind};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::apple_base::opts();
1616
base.cpu = "yonah".to_string();
1717
base.max_atomic_width = Some(64);
1818
base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".to_string()]);
1919
base.stack_probes = true;
20+
base.va_list_kind = VaListKind::CharPtr;
2021

2122
Ok(Target {
2223
llvm_target: "i686-apple-darwin".to_string(),
@@ -29,6 +30,6 @@ pub fn target() -> TargetResult {
2930
target_env: "".to_string(),
3031
target_vendor: "apple".to_string(),
3132
linker_flavor: LinkerFlavor::Gcc,
32-
options: base,
33+
options: base
3334
})
3435
}

src/librustc_back/target/i686_linux_android.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use LinkerFlavor;
12-
use target::{Target, TargetResult};
12+
use target::{Target, TargetResult, VaListKind};
1313

1414
// See https://developer.android.com/ndk/guides/abis.html#x86
1515
// for target ABI requirements.
@@ -23,6 +23,7 @@ pub fn target() -> TargetResult {
2323
base.cpu = "pentiumpro".to_string();
2424
base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".to_string();
2525
base.stack_probes = true;
26+
base.va_list_kind = VaListKind::CharPtr;
2627

2728
Ok(Target {
2829
llvm_target: "i686-linux-android".to_string(),

0 commit comments

Comments
 (0)