about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-10-01 09:14:53 +0000
committerbors <bors@rust-lang.org>2017-10-01 09:14:53 +0000
commit0defa208dcb5a0f3c1ca5bc4df7acf52759ece44 (patch)
treea5e7afb6aa8722ffde1533ae1c0ddc288a19e446 /src/test/codegen
parent1c09315f6d7559aaaa23baa92f753ce6f86dff65 (diff)
parenta4e83731e9aa0cd1a412b090626ace6aa54250bb (diff)
downloadrust-0defa208dcb5a0f3c1ca5bc4df7acf52759ece44.tar.gz
rust-0defa208dcb5a0f3c1ca5bc4df7acf52759ece44.zip
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.
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/abi-main-signature-16bit-c-int.rs32
-rw-r--r--src/test/codegen/abi-main-signature-32bit-c-int.rs20
2 files changed, 52 insertions, 0 deletions
diff --git a/src/test/codegen/abi-main-signature-16bit-c-int.rs b/src/test/codegen/abi-main-signature-16bit-c-int.rs
new file mode 100644
index 00000000000..fbe2fd10e7a
--- /dev/null
+++ b/src/test/codegen/abi-main-signature-16bit-c-int.rs
@@ -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**)
diff --git a/src/test/codegen/abi-main-signature-32bit-c-int.rs b/src/test/codegen/abi-main-signature-32bit-c-int.rs
new file mode 100644
index 00000000000..3139749dfcb
--- /dev/null
+++ b/src/test/codegen/abi-main-signature-32bit-c-int.rs
@@ -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**)