]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Always emit `uwtable` on Android
authorAlex Crichton <alex@alexcrichton.com>
Thu, 19 Apr 2018 22:17:34 +0000 (15:17 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sat, 21 Apr 2018 15:38:44 +0000 (08:38 -0700)
Long ago (#40549) we enabled the `uwtable` attribute on Windows by default
(even with `-C panic=abort`) to allow unwinding binaries for [stack unwinding
information][winstack]. It looks like this same issue is [plaguing][arm1]
Gecko's Android platforms [as well][arm2]. This commit applies the same fix
as #40549 except that this time it's applied for all Android targets.

Generating a `-C panic=abort` binary for `armv7-linux-androideabi` before this
commit generated a number of `cantunwind` functions (detected with `readelf -u`)
but after this commit they all list appropriate unwind information.

Closes #49867

[winstack]: https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
[arm1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1453220
[arm2]: https://bugzilla.mozilla.org/show_bug.cgi?id=1451741

src/librustc_back/target/android_base.rs
src/librustc_back/target/mod.rs
src/librustc_back/target/windows_base.rs
src/librustc_back/target/windows_msvc_base.rs
src/librustc_trans/base.rs
src/test/codegen/nounwind.rs

index 49baa1b96cee3b4bdf61dec87801898f386f7ea1..3660bf7bea917fe7cda7b3c90ba5cc9b794fdce1 100644 (file)
@@ -20,5 +20,6 @@ pub fn opts() -> TargetOptions {
     base.is_like_android = true;
     base.position_independent_executables = true;
     base.has_elf_tls = false;
+    base.requires_uwtable = true;
     base
 }
index 592b27ac641b5204d2af6ec4a16cce4d625e938c..e46266b576e244e5a90bf089d9708735a3f063c5 100644 (file)
@@ -481,6 +481,11 @@ pub struct TargetOptions {
 
     /// Whether a .debug_gdb_scripts section will be added to the output object file
     pub emit_debug_gdb_scripts: bool,
+
+    /// Whether or not to unconditionally `uwtable` attributes on functions,
+    /// typically because the platform needs to unwind for things like stack
+    /// unwinders.
+    pub requires_uwtable: bool,
 }
 
 impl Default for TargetOptions {
@@ -554,6 +559,7 @@ fn default() -> TargetOptions {
             default_hidden_visibility: false,
             embed_bitcode: false,
             emit_debug_gdb_scripts: true,
+            requires_uwtable: false,
         }
     }
 }
@@ -804,6 +810,7 @@ macro_rules! key {
         key!(default_hidden_visibility, bool);
         key!(embed_bitcode, bool);
         key!(emit_debug_gdb_scripts, bool);
+        key!(requires_uwtable, bool);
 
         if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) {
             for name in array.iter().filter_map(|abi| abi.as_string()) {
@@ -1008,6 +1015,7 @@ macro_rules! target_option_val {
         target_option_val!(default_hidden_visibility);
         target_option_val!(embed_bitcode);
         target_option_val!(emit_debug_gdb_scripts);
+        target_option_val!(requires_uwtable);
 
         if default.abi_blacklist != self.options.abi_blacklist {
             d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter()
index 971b21e062f69415d858743eff0d3187cb86f993..4b4fb27caa839baa4d498deab92fe561c2f2b5fd 100644 (file)
@@ -103,6 +103,7 @@ pub fn opts() -> TargetOptions {
         custom_unwind_resume: true,
         abi_return_struct_as_int: true,
         emit_debug_gdb_scripts: false,
+        requires_uwtable: true,
 
         .. Default::default()
     }
index 06e879bec3492310184cce57472dfef0e0b2e535..fee5a0284c80610993a0f7df8946ff222022b140 100644 (file)
@@ -35,6 +35,7 @@ pub fn opts() -> TargetOptions {
         crt_static_respected: true,
         abi_return_struct_as_int: true,
         emit_debug_gdb_scripts: false,
+        requires_uwtable: true,
 
         .. Default::default()
     }
index 1da6f25fd639a0506daac80ef52e1e0d04359e30..a4e1b7f2925dca3f802ff23bc9ada907f3a4f8e6 100644 (file)
@@ -492,7 +492,7 @@ pub fn trans_instance<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, instance: Instance<'tc
     // You can also find more info on why Windows is whitelisted here in:
     //      https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
     if !cx.sess().no_landing_pads() ||
-       cx.sess().target.target.options.is_like_windows {
+       cx.sess().target.target.options.requires_uwtable {
         attributes::emit_uwtable(lldecl, true);
     }
 
index 9fea907d3c884e56f1078e4b197b9dc3df38a8c9..6863b1f2792b919b41cf81b76abaed7faf597f86 100644 (file)
@@ -11,6 +11,7 @@
 // aux-build:nounwind.rs
 // compile-flags: -C no-prepopulate-passes -C panic=abort -C metadata=a
 // ignore-windows
+// ignore-android
 
 #![crate_type = "lib"]