Rust: abort on panic
Test: build (test included in build)
Bug: 162266455
Change-Id: I7f53956d3a35f923d0282d511d6360051f945a88
diff --git a/rust/binary_test.go b/rust/binary_test.go
index b44a5bc..86f50d3 100644
--- a/rust/binary_test.go
+++ b/rust/binary_test.go
@@ -130,6 +130,9 @@
if !strings.Contains(flags, "-C relocation-model=static") {
t.Errorf("static binary missing '-C relocation-model=static' in rustcFlags, found: %#v", flags)
}
+ if !strings.Contains(flags, "-C panic=abort") {
+ t.Errorf("static binary missing '-C panic=abort' in rustcFlags, found: %#v", flags)
+ }
if !strings.Contains(linkFlags, "-static") {
t.Errorf("static binary missing '-static' in linkFlags, found: %#v", flags)
}
diff --git a/rust/config/global.go b/rust/config/global.go
index 08ec877..fb62278 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -49,7 +49,9 @@
"-C relocation-model=pic",
}
- deviceGlobalRustFlags = []string{}
+ deviceGlobalRustFlags = []string{
+ "-C panic=abort",
+ }
deviceGlobalLinkFlags = []string{
// Prepend the lld flags from cc_config so we stay in sync with cc
diff --git a/rust/test.go b/rust/test.go
index 408e03a..35e04ff 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -120,6 +120,9 @@
if test.testHarness() {
flags.RustFlags = append(flags.RustFlags, "--test")
}
+ if ctx.Device() {
+ flags.RustFlags = append(flags.RustFlags, "-Z panic_abort_tests")
+ }
return flags
}