summaryrefslogblamecommitdiff
path: root/user/rust/0029-Work-around-libbacktrace-built-with-fstack-protector.patch
blob: 29a31508dac8d1ab355b847286c422fb7691b9d1 (plain) (tree)














































                                                                                       
From 22bb29c2b807180ed0522d9c930e14c327582571 Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Sat, 6 Oct 2018 04:17:14 +0000
Subject: [PATCH 29/29] Work around libbacktrace built with -fstack-protector

On 32-bit x86 and ppc, gcc generates calls to __stack_chk_fail_local,
which must be a hidden function in every DSO. gcc provides the
implementation in libssp_nonshared. libbacktrace is built in hosted
mode, where Adelie's compiler enables -fstack-protector by default.
However, rustc passes -nodefaultlibs, inhibiting gcc from linking
libssp_nonshared.
---
 src/libpanic_unwind/Cargo.toml |  1 +
 src/libpanic_unwind/build.rs   | 10 ++++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 src/libpanic_unwind/build.rs

diff --git a/src/libpanic_unwind/Cargo.toml b/src/libpanic_unwind/Cargo.toml
index 74aaa4d5ae..c1b66aeefe 100644
--- a/src/libpanic_unwind/Cargo.toml
+++ b/src/libpanic_unwind/Cargo.toml
@@ -1,5 +1,6 @@
 [package]
 authors = ["The Rust Project Developers"]
+build = "build.rs"
 name = "panic_unwind"
 version = "0.0.0"
 
diff --git a/src/libpanic_unwind/build.rs b/src/libpanic_unwind/build.rs
new file mode 100644
index 0000000000..0d9a14b64c
--- /dev/null
+++ b/src/libpanic_unwind/build.rs
@@ -0,0 +1,10 @@
+use std::env;
+
+fn main() {
+    let target = env::var("TARGET").unwrap();
+    match target.as_ref() {
+        "i586-foxkit-linux-musl" => println!("cargo:rustc-link-lib=ssp_nonshared"),
+        "powerpc-foxkit-linux-musl" => println!("cargo:rustc-link-lib=ssp_nonshared"),
+        _ => {},
+    };
+}
-- 
2.18.0