Auto merge of #44906 - dkl:main-signature, r=nagisa
Fix native main() signature on 64bit Hello, in LLVM-IR produced by rustc on x86_64-linux-gnu, the native main() function had incorrect types for the function result and argc parameter: i64, while it should be i32 (really c_int). See also #20064, #29633. So I've attempted a fix here. I tested it by checking the LLVM IR produced with --target x86_64-unknown-linux-gnu and i686-unknown-linux-gnu. Also I tried running the tests (`./x.py test`), however I'm getting two failures with and without the patch, which I'm guessing is unrelated.
This commit is contained in:
commit
0defa208dc
79 changed files with 153 additions and 6 deletions
|
|
@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "arm64-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "aarch64-linux-android".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "aarch64-unknown-freebsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "freebsd".to_string(),
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "aarch64-unknown-fuchsia".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "fuchsia".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "aarch64-unknown-linux-musl".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
target_env: "musl".to_string(),
|
||||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "arm-linux-androideabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "armv5te-unknown-linux-gnueabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "armv7-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "armv7-none-linux-android".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "armv7-unknown-linux-gnueabihf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "armv7-unknown-linux-gnueabihf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "armv7s-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ pub fn target() -> Result<Target, String> {
|
|||
llvm_target: "asmjs-unknown-emscripten".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
target_os: "emscripten".to_string(),
|
||||
target_env: "".to_string(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i386-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-apple-darwin".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "macos".to_string(),
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-linux-android".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-pc-windows-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-pc-windows-msvc".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-unknown-dragonfly".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "dragonfly".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-unknown-freebsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "freebsd".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-unknown-haiku".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "haiku".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-unknown-linux-musl".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-unknown-netbsdelf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "netbsd".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "i686-unknown-openbsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "openbsd".to_string(),
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "le32-unknown-nacl".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
target_os: "nacl".to_string(),
|
||||
target_env: "newlib".to_string(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "mips64-unknown-linux-gnuabi64".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(),
|
||||
arch: "mips64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "mips64el-unknown-linux-gnuabi64".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(),
|
||||
arch: "mips64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "mips-unknown-linux-gnu".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "mips-unknown-linux-musl".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "mips-unknown-linux-uclibc".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "mipsel-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "mipsel-unknown-linux-musl".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "mipsel-unknown-linux-uclibc".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -239,6 +239,8 @@ pub struct Target {
|
|||
pub target_endian: String,
|
||||
/// String to use as the `target_pointer_width` `cfg` variable.
|
||||
pub target_pointer_width: String,
|
||||
/// Width of c_int type
|
||||
pub target_c_int_width: String,
|
||||
/// OS name to use for conditional compilation.
|
||||
pub target_os: String,
|
||||
/// Environment name to use for conditional compilation.
|
||||
|
|
@ -556,6 +558,7 @@ impl Target {
|
|||
llvm_target: get_req_field("llvm-target")?,
|
||||
target_endian: get_req_field("target-endian")?,
|
||||
target_pointer_width: get_req_field("target-pointer-width")?,
|
||||
target_c_int_width: get_req_field("target-c-int-width")?,
|
||||
data_layout: get_req_field("data-layout")?,
|
||||
arch: get_req_field("arch")?,
|
||||
target_os: get_req_field("os")?,
|
||||
|
|
@ -860,6 +863,7 @@ impl ToJson for Target {
|
|||
target_val!(llvm_target);
|
||||
target_val!(target_endian);
|
||||
target_val!(target_pointer_width);
|
||||
target_val!(target_c_int_width);
|
||||
target_val!(arch);
|
||||
target_val!(target_os, "os");
|
||||
target_val!(target_env, "env");
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "msp430-none-elf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "16".to_string(),
|
||||
target_c_int_width: "16".to_string(),
|
||||
data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".to_string(),
|
||||
arch: "msp430".to_string(),
|
||||
target_os: "none".to_string(),
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "powerpc64-unknown-linux-gnu".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:e-i64:64-n32:64".to_string(),
|
||||
arch: "powerpc64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "powerpc64le-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-n32:64".to_string(),
|
||||
arch: "powerpc64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "powerpc-unknown-linux-gnu".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(),
|
||||
arch: "powerpc".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "s390x-unknown-linux-gnu".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".to_string(),
|
||||
arch: "s390x".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "sparc64-unknown-linux-gnu".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:e-i64:64-n32:64-S128".to_string(),
|
||||
arch: "sparc64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "sparc64-unknown-netbsd".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:e-i64:64-n32:64-S128".to_string(),
|
||||
arch: "sparc64".to_string(),
|
||||
target_os: "netbsd".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "sparcv9-sun-solaris".to_string(),
|
||||
target_endian: "big".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "E-m:e-i64:64-n32:64-S128".to_string(),
|
||||
// Use "sparc64" instead of "sparcv9" here, since the former is already
|
||||
// used widely in the source base. If we ever needed ABI
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "thumbv6m-none-eabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "none".to_string(),
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "thumbv7em-none-eabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "none".to_string(),
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "thumbv7em-none-eabihf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "none".to_string(),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "thumbv7m-none-eabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "none".to_string(),
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ pub fn target() -> Result<Target, String> {
|
|||
llvm_target: "wasm32-unknown-unknown".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
target_os: "emscripten".to_string(),
|
||||
target_env: "".to_string(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ pub fn target() -> Result<Target, String> {
|
|||
llvm_target: "asmjs-unknown-emscripten".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
target_os: "emscripten".to_string(),
|
||||
target_env: "".to_string(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-apple-darwin".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "macos".to_string(),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-linux-android".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-pc-windows-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:w-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-pc-windows-msvc".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:w-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-rumprun-netbsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "netbsd".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-pc-solaris".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "solaris".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-bitrig".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "bitrig".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-dragonfly".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "dragonfly".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-freebsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "freebsd".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-fuchsia".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "fuchsia".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-haiku".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "haiku".to_string(),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-l4re-uclibc".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "l4re".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-linux-musl".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-netbsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "netbsd".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-openbsd".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "openbsd".to_string(),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
|
|||
llvm_target: "x86_64-unknown-redox".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_c_int_width: "32".to_string(),
|
||||
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "redox".to_string(),
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ use value::Value;
|
|||
use rustc::util::nodemap::{NodeSet, FxHashMap, FxHashSet, DefIdSet};
|
||||
use CrateInfo;
|
||||
|
||||
use libc::c_uint;
|
||||
use std::any::Any;
|
||||
use std::cell::RefCell;
|
||||
use std::ffi::{CStr, CString};
|
||||
|
|
@ -692,7 +691,8 @@ fn maybe_create_entry_wrapper(ccx: &CrateContext) {
|
|||
sp: Span,
|
||||
rust_main: ValueRef,
|
||||
use_start_lang_item: bool) {
|
||||
let llfty = Type::func(&[ccx.isize_ty(), Type::i8p(ccx).ptr_to()], &ccx.isize_ty());
|
||||
// Signature of native main(), corresponding to C's `int main(int, char **)`
|
||||
let llfty = Type::func(&[Type::c_int(ccx), Type::i8p(ccx).ptr_to()], &Type::c_int(ccx));
|
||||
|
||||
if declare::get_defined_value(ccx, "main").is_some() {
|
||||
// FIXME: We should be smart and show a better diagnostic here.
|
||||
|
|
@ -711,19 +711,27 @@ fn maybe_create_entry_wrapper(ccx: &CrateContext) {
|
|||
|
||||
debuginfo::gdb::insert_reference_to_gdb_debug_scripts_section_global(ccx, &bld);
|
||||
|
||||
// Params from native main() used as args for rust start function
|
||||
let param_argc = get_param(llfn, 0);
|
||||
let param_argv = get_param(llfn, 1);
|
||||
let arg_argc = bld.intcast(param_argc, ccx.isize_ty(), true);
|
||||
let arg_argv = param_argv;
|
||||
|
||||
let (start_fn, args) = if use_start_lang_item {
|
||||
let start_def_id = ccx.tcx().require_lang_item(StartFnLangItem);
|
||||
let start_instance = Instance::mono(ccx.tcx(), start_def_id);
|
||||
let start_fn = callee::get_fn(ccx, start_instance);
|
||||
(start_fn, vec![bld.pointercast(rust_main, Type::i8p(ccx).ptr_to()), get_param(llfn, 0),
|
||||
get_param(llfn, 1)])
|
||||
(start_fn, vec![bld.pointercast(rust_main, Type::i8p(ccx).ptr_to()),
|
||||
arg_argc, arg_argv])
|
||||
} else {
|
||||
debug!("using user-defined start fn");
|
||||
(rust_main, vec![get_param(llfn, 0 as c_uint), get_param(llfn, 1 as c_uint)])
|
||||
(rust_main, vec![arg_argc, arg_argv])
|
||||
};
|
||||
|
||||
let result = bld.call(start_fn, &args, None);
|
||||
bld.ret(result);
|
||||
|
||||
// Return rust start function's result from native main()
|
||||
bld.ret(bld.intcast(result, Type::c_int(ccx), true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,6 +140,15 @@ impl Type {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn c_int(ccx: &CrateContext) -> Type {
|
||||
match &ccx.tcx().sess.target.target.target_c_int_width[..] {
|
||||
"16" => Type::i16(ccx),
|
||||
"32" => Type::i32(ccx),
|
||||
"64" => Type::i64(ccx),
|
||||
width => bug!("Unsupported target_c_int_width: {}", width),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
|
||||
match t {
|
||||
ast::IntTy::Is => ccx.isize_ty(),
|
||||
|
|
|
|||
32
src/test/codegen/abi-main-signature-16bit-c-int.rs
Normal file
32
src/test/codegen/abi-main-signature-16bit-c-int.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Checks the signature of the implicitly generated native main()
|
||||
// entry point. It must match C's `int main(int, char **)`.
|
||||
|
||||
// This test is for targets with 16bit c_int only.
|
||||
// ignore-aarch64
|
||||
// ignore-arm
|
||||
// ignore-asmjs
|
||||
// ignore-hexagon
|
||||
// ignore-mips
|
||||
// ignore-powerpc
|
||||
// ignore-powerpc64
|
||||
// ignore-s390x
|
||||
// ignore-sparc
|
||||
// ignore-wasm32
|
||||
// ignore-x86
|
||||
// ignore-x86_64
|
||||
// ignore-xcore
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
||||
// CHECK: define i16 @main(i16, i8**)
|
||||
20
src/test/codegen/abi-main-signature-32bit-c-int.rs
Normal file
20
src/test/codegen/abi-main-signature-32bit-c-int.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Checks the signature of the implicitly generated native main()
|
||||
// entry point. It must match C's `int main(int, char **)`.
|
||||
|
||||
// This test is for targets with 32bit c_int only.
|
||||
// ignore-msp430
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
||||
// CHECK: define i32 @main(i32, i8**)
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
"llvm-target": "i686-unknown-linux-gnu",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "32",
|
||||
"target-c-int-width": "32",
|
||||
"arch": "x86",
|
||||
"os": "linux",
|
||||
"morestack": false
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"linker-flavor": "gcc",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "32",
|
||||
"target-c-int-width": "32",
|
||||
"arch": "x86",
|
||||
"os": "foo",
|
||||
"morestack": false
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
"llvm-target": "x86_64-unknown-linux-gnu",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "64",
|
||||
"target-c-int-width": "32",
|
||||
"arch": "x86_64",
|
||||
"os": "linux",
|
||||
"morestack": false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue