Skip to content

Commit 2495ef5

Browse files
committed
Add patch to link 'signal' into libstd
This changes the behavior for Android targets by linking in signal at compile-time rather than attempting to load the symbol dynamically at runtime. This allows the creation of fully static binaries. See patch commit message for additional details. Bug: 169434439 Test: Toolchain source artifacts contains the applied patch. Change-Id: Ia0cd960237a4a70fd890507f9361b0a61adacfc9
1 parent 69671c7 commit 2495ef5

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
From b3680aa30a319d61e685f82a08c8b205c417c90f Mon Sep 17 00:00:00 2001
2+
From: Ivan Lozano <[email protected]>
3+
Date: Mon, 8 Feb 2021 10:58:34 -0500
4+
Subject: [PATCH] libstd: link 'signal' at compilation for Android.
5+
6+
libstd links 'signal' for Android specifically at runtime since API
7+
levels prior to API 20 did not have 'signal' and used 'bsd_signal'
8+
instead. This prevents static compilation as the function is loaded at
9+
runtime using dlsym.
10+
11+
Because this toolchain is building for platform, we know that our libc
12+
uses 'signal' and not 'bsd_signal'. This means we can safely remove this
13+
behavior and just link 'signal' in normally. This allows us to create
14+
static binaries.
15+
16+
Bug: 169434439
17+
Test: Rust static binary works.
18+
Change-Id: Iabcb41497be08a4fad3d79dfd0ec3dc90f126e63
19+
---
20+
library/std/src/sys/unix/mod.rs | 6 +++---
21+
1 file changed, 3 insertions(+), 3 deletions(-)
22+
23+
diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs
24+
index b28c6d85b7..16defef4cd 100644
25+
--- a/library/std/src/sys/unix/mod.rs
26+
+++ b/library/std/src/sys/unix/mod.rs
27+
@@ -158,9 +158,9 @@ pub fn init() {
28+
unsafe fn reset_sigpipe() {}
29+
}
30+
31+
-#[cfg(target_os = "android")]
32+
-pub use crate::sys::android::signal;
33+
-#[cfg(not(target_os = "android"))]
34+
+//#[cfg(target_os = "android")]
35+
+//pub use crate::sys::android::signal;
36+
+//#[cfg(not(target_os = "android"))]
37+
pub use libc::signal;
38+
39+
pub fn decode_error_kind(errno: i32) -> ErrorKind {
40+
--
41+
2.30.0.478.g8a0d178c01-goog
42+

0 commit comments

Comments
 (0)