]> git.lizzy.rs Git - rust.git/commitdiff
Add specific target option for returning struct as an integer.
authorBryan Drewery <bryan@shatow.net>
Mon, 26 Feb 2018 18:20:14 +0000 (10:20 -0800)
committerBryan Drewery <bryan@shatow.net>
Mon, 26 Feb 2018 18:21:52 +0000 (10:21 -0800)
src/librustc_back/target/apple_base.rs
src/librustc_back/target/mod.rs
src/librustc_back/target/openbsd_base.rs
src/librustc_back/target/windows_base.rs
src/librustc_back/target/windows_msvc_base.rs
src/librustc_trans/cabi_x86.rs

index 159f93a74c68352276ec630b8a2d9b6b05259c9d..72173b62594e9658cd77fa4802f6d154d4ccd44d 100644 (file)
@@ -46,6 +46,7 @@ pub fn opts() -> TargetOptions {
         pre_link_args: LinkArgs::new(),
         exe_allocation_crate: super::maybe_jemalloc(),
         has_elf_tls: version >= (10, 7),
+        abi_return_struct_as_int: true,
         .. Default::default()
     }
 }
index 2872c59157d6be1cf1b5d73aec7f39d8e0aa584b..e734817098043b6e41af1e33beb6168a59075301 100644 (file)
@@ -343,9 +343,8 @@ pub struct TargetOptions {
     pub staticlib_suffix: String,
     /// OS family to use for conditional compilation. Valid options: "unix", "windows".
     pub target_family: Option<String>,
-    /// Whether the target toolchain is like OpenBSD's.
-    /// Only useful for compiling against OpenBSD, for configuring abi when returning a struct.
-    pub is_like_openbsd: bool,
+    /// Whether the target toolchain's ABI supports returning small structs as an integer.
+    pub abi_return_struct_as_int: bool,
     /// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
     /// in particular running dsymutil and some other stuff like `-dead_strip`. Defaults to false.
     pub is_like_osx: bool,
@@ -501,7 +500,7 @@ fn default() -> TargetOptions {
             staticlib_prefix: "lib".to_string(),
             staticlib_suffix: ".a".to_string(),
             target_family: None,
-            is_like_openbsd: false,
+            abi_return_struct_as_int: false,
             is_like_osx: false,
             is_like_solaris: false,
             is_like_windows: false,
@@ -756,7 +755,7 @@ macro_rules! key {
         key!(staticlib_prefix);
         key!(staticlib_suffix);
         key!(target_family, optional);
-        key!(is_like_openbsd, bool);
+        key!(abi_return_struct_as_int, bool);
         key!(is_like_osx, bool);
         key!(is_like_solaris, bool);
         key!(is_like_windows, bool);
@@ -954,7 +953,7 @@ macro_rules! target_option_val {
         target_option_val!(staticlib_prefix);
         target_option_val!(staticlib_suffix);
         target_option_val!(target_family);
-        target_option_val!(is_like_openbsd);
+        target_option_val!(abi_return_struct_as_int);
         target_option_val!(is_like_osx);
         target_option_val!(is_like_solaris);
         target_option_val!(is_like_windows);
index ab421dec7807ff9fcb3fc244e5da54ad140f41d5..311e260ee3f34a113f0a5e005e679f6d499da36c 100644 (file)
@@ -31,7 +31,7 @@ pub fn opts() -> TargetOptions {
         target_family: Some("unix".to_string()),
         linker_is_gnu: true,
         has_rpath: true,
-        is_like_openbsd: true,
+        abi_return_struct_as_int: true,
         pre_link_args: args,
         position_independent_executables: true,
         eliminate_frame_pointer: false, // FIXME 43575
index cc40b8b0529836440b766579f87f76f5e3ee0530..30038400f6c81ca13785d2aed11334f610e5902f 100644 (file)
@@ -101,6 +101,7 @@ pub fn opts() -> TargetOptions {
             "rsend.o".to_string()
         ],
         custom_unwind_resume: true,
+        abi_return_struct_as_int: true,
 
         .. Default::default()
     }
index 64df6624dd1c23df62a5a696aadb3384d3f7611b..e0bf36ee4077e392346cdc87a585f452862735eb 100644 (file)
@@ -34,6 +34,7 @@ pub fn opts() -> TargetOptions {
         pre_link_args: args,
         crt_static_allows_dylibs: true,
         crt_static_respected: true,
+        abi_return_struct_as_int: true,
 
         .. Default::default()
     }
index 60347ba0945f91beb880d2a520c18b2b5ac07748..b14558448067cc9e67ac6a7a3919bfa12785a43f 100644 (file)
@@ -52,8 +52,7 @@ pub fn compute_abi_info<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
             // http://www.angelcode.com/dev/callconv/callconv.html
             // Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
             let t = &cx.sess().target.target;
-            if t.options.is_like_osx || t.options.is_like_windows
-                || t.options.is_like_openbsd {
+            if t.options.abi_return_struct_as_int {
                 // According to Clang, everyone but MSVC returns single-element
                 // float aggregates directly in a floating-point register.
                 if !t.options.is_like_msvc && is_single_fp_element(cx, fty.ret.layout) {