Skip to content

Commit

Permalink
contrib: rav1e: Extend the patch for providing _Unwind_Resume
Browse files Browse the repository at this point in the history
This fixes building with llvm-mingw for i686 (which uses dwarf
for unwinding on i686) after updating to Rust 1.65.0 in
cb4464d.

The problematic patch was needed for fixing build breaks with
mingw toolchains that use SjLj exception handling (which is what
is used in VLC's current CI builds for mingw/i686) - which is
rust-lang/rust#79609.

Rust's stdlib contains references to the _Unwind_Resume symbol
(which is what the symbol is called in dwarf unwinding cases),
but it's not meant to actually be called (since rav1e is built
with "-C panic=abort"). If the mingw toolchain itself uses dwarf
(or SEH) unwinding, then the _Unwind_Resume symbol is provided
from that unwinder. But in the case of SjLj toolchains,
the toolchain only provides a symbol named __Unwind_SjLj_Resume.

The patch provided a dummy _Unwind_Resume symbol as part of the
rav1e build, which fixed the undefined references with SjLj toolchains.

However, since updating to Rust 1.65.0, other object files in
the Rust stdlib seems to pull in more unwinding symbols (there
are undefined references to e.g. _Unwind_GetRegionStart). These
other symbols are named the same both in dwarf, SjLj and SEH
toolchains. In the case of SjLj toolchains, they ended up pulled
in from libunwind/libgcc, but in the case of dwarf or SEH toolchains,
the locally defined _Unwind_Resume caused a conflict with the real
one which ended up included from libunwind/libgcc.

To avoid the issue, provide all referenced symbols as similar stubs;
this makes sure that the build doesn't end up pulling in anything
unwinding related from libunwind/libgcc, either in SjLj or dwarf
toolchains.
  • Loading branch information
mstorsjo authored and jbkempf committed Nov 25, 2022
1 parent 28bcf1d commit 23fb14c
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions contrib/src/rav1e/unwind-resume-stub.patch
Original file line number Diff line number Diff line change
@@ -1,27 +1,55 @@
From 30b9e63817bf60c3cab0bc6cebb073ee2344ac34 Mon Sep 17 00:00:00 2001
From d186b5350e425a82dbd4513b5d629dc892c3c4a5 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <[email protected]>
Date: Fri, 25 Feb 2022 12:30:01 -0500
Subject: [PATCH 1/1] lib: workaround for
Subject: [PATCH] lib: workaround for
https://github.com/rust-lang/rust/issues/79609

This avoids to broken linking on some mingw32 versions. The function
will never be called since we set `-C panic=abort`.
---
src/lib.rs | 4 ++++
1 file changed, 4 insertions(+)
src/lib.rs | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/src/lib.rs b/src/lib.rs
index 63afa2d5..412bb0e0 100644
index 3425588d..1b645340 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -389,3 +389,7 @@ pub mod bench {
@@ -486,3 +486,35 @@ pub mod bench {

#[cfg(fuzzing)]
pub mod fuzzing;
+
+#[no_mangle]
+#[allow(non_snake_case)]
+fn _Unwind_GetDataRelBase() {}
+
+#[no_mangle]
+#[allow(non_snake_case)]
+fn _Unwind_GetIPInfo() {}
+
+#[no_mangle]
+#[allow(non_snake_case)]
+fn _Unwind_GetLanguageSpecificData() {}
+
+#[no_mangle]
+#[allow(non_snake_case)]
+fn _Unwind_GetRegionStart() {}
+
+#[no_mangle]
+#[allow(non_snake_case)]
+fn _Unwind_GetTextRelBase() {}
+
+#[no_mangle]
+#[allow(non_snake_case)]
+fn _Unwind_Resume() {}
+
+#[no_mangle]
+#[allow(non_snake_case)]
+fn _Unwind_SetGR() {}
+
+#[no_mangle]
+#[allow(non_snake_case)]
+fn _Unwind_SetIP() {}
--
2.32.0
2.37.1 (Apple Git-137.1)

0 comments on commit 23fb14c

Please sign in to comment.