Skip to content

Commit 6c5a70d

Browse files
authored
Merge pull request #244 from rust-lang/feature/unwinding
Implement unwinding
2 parents 7c1d21c + 8e77fbf commit 6c5a70d

File tree

20 files changed

+388
-97
lines changed

20 files changed

+388
-97
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
libgccjit_version:
22-
- { gcc: "libgccjit.so", extra: "", artifacts_branch: "master" }
23-
- { gcc: "libgccjit_without_int128.so", extra: "", artifacts_branch: "master-without-128bit-integers" }
24-
- { gcc: "libgccjit12.so", extra: "--no-default-features", artifacts_branch: "gcc12" }
22+
- { gcc: "libgccjit.so", extra: "", env_extra: "", artifacts_branch: "master" }
23+
- { gcc: "libgccjit_without_int128.so", extra: "", env_extra: "", artifacts_branch: "master-without-128bit-integers" }
24+
- { gcc: "libgccjit12.so", extra: "--no-default-features", env_extra: "TEST_FLAGS='-Cpanic=abort -Zpanic-abort-tests'", artifacts_branch: "gcc12" }
2525
commands: [
2626
"--mini-tests",
2727
"--std-tests",
@@ -120,8 +120,8 @@ jobs:
120120
- name: Build
121121
run: |
122122
./prepare_build.sh
123-
./build.sh ${{ matrix.libgccjit_version.extra }}
124-
cargo test ${{ matrix.libgccjit_version.extra }}
123+
${{ matrix.libgccjit_version.env_extra }} ./build.sh ${{ matrix.libgccjit_version.extra }}
124+
${{ matrix.libgccjit_version.env_extra }} cargo test ${{ matrix.libgccjit_version.extra }}
125125
./clean_all.sh
126126
127127
- name: Prepare dependencies
@@ -143,7 +143,7 @@ jobs:
143143

144144
- name: Run tests
145145
run: |
146-
./test.sh --release --clean --build-sysroot ${{ matrix.commands }} ${{ matrix.libgccjit_version.extra }}
146+
${{ matrix.libgccjit_version.env_extra }} ./test.sh --release --clean --build-sysroot ${{ matrix.commands }} ${{ matrix.libgccjit_version.extra }}
147147
148148
duplicates:
149149
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,26 @@ To print a debug representation of a tree:
162162
debug_tree(expr);
163163
```
164164

165+
(defined in print-tree.h)
166+
167+
To print a debug reprensentation of a gimple struct:
168+
169+
```c
170+
debug_gimple_stmt(gimple_struct)
171+
```
172+
165173
To get the `rustc` command to run in `gdb`, add the `--verbose` flag to `cargo build`.
166174
175+
To have the correct file paths in `gdb` instead of `/usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_personality.cc`, TODO
176+
177+
Maybe by calling the following at the beginning of gdb:
178+
179+
```
180+
set substitute-path /usr/src/debug/gcc /path/to/gcc-repo/gcc
181+
```
182+
183+
TODO: but that's not what I remember I was doing.
184+
167185
### How to use a custom-build rustc
168186
169187
* Build the stage2 compiler (`rustup toolchain link debug-current build/x86_64-unknown-linux-gnu/stage2`).

build_sysroot/build_sysroot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true
1616
rm -r sysroot/ 2>/dev/null || true
1717

1818
# Build libs
19-
export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked -Cpanic=abort"
19+
export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
2020
if [[ "$1" == "--release" ]]; then
2121
sysroot_channel='release'
2222
RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release

config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
3838
fi
3939
fi
4040

41-
export RUSTFLAGS="$CG_RUSTFLAGS $linker -Cpanic=abort -Csymbol-mangling-version=v0 -Cdebuginfo=2 -Clto=off -Zpanic-abort-tests -Zcodegen-backend=$(pwd)/target/${CHANNEL:-debug}/librustc_codegen_gcc.$dylib_ext --sysroot $(pwd)/build_sysroot/sysroot"
41+
export RUSTFLAGS="$CG_RUSTFLAGS $linker -Csymbol-mangling-version=v0 -Cdebuginfo=2 -Clto=off -Zcodegen-backend=$(pwd)/target/${CHANNEL:-debug}/librustc_codegen_gcc.$dylib_ext --sysroot $(pwd)/build_sysroot/sysroot $TEST_FLAGS"
4242

4343
# FIXME(antoyo): remove once the atomic shim is gone
4444
if [[ `uname` == 'Darwin' ]]; then

example/alloc_example.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(start, box_syntax, core_intrinsics, alloc_error_handler)]
1+
#![feature(start, box_syntax, core_intrinsics, alloc_error_handler, lang_items)]
22
#![no_std]
33

44
extern crate alloc;
@@ -26,6 +26,16 @@ fn alloc_error_handler(_: alloc::alloc::Layout) -> ! {
2626
core::intrinsics::abort();
2727
}
2828

29+
#[lang = "eh_personality"]
30+
fn eh_personality() -> ! {
31+
loop {}
32+
}
33+
34+
#[no_mangle]
35+
unsafe extern "C" fn _Unwind_Resume() {
36+
core::intrinsics::unreachable();
37+
}
38+
2939
#[start]
3040
fn main(_argc: isize, _argv: *const *const u8) -> isize {
3141
let world: Box<&str> = box "Hello World!\0";

failing-ui-tests.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,29 @@ src/test/ui/sse2.rs
4141
src/test/ui/statics/issue-91050-1.rs
4242
src/test/ui/statics/issue-91050-2.rs
4343
src/test/ui/target-feature/missing-plusminus.rs
44+
src/test/ui/asm/x86_64/may_unwind.rs
45+
src/test/ui/backtrace.rs
46+
src/test/ui/catch-unwind-bang.rs
47+
src/test/ui/cfg/cfg-panic-abort.rs
48+
src/test/ui/drop/dynamic-drop-async.rs
49+
src/test/ui/drop/repeat-drop.rs
50+
src/test/ui/fmt/format-args-capture.rs
51+
src/test/ui/generator/panic-drops-resume.rs
52+
src/test/ui/generator/panic-drops.rs
53+
src/test/ui/generator/panic-safe.rs
54+
src/test/ui/intrinsics/panic-uninitialized-zeroed.rs
55+
src/test/ui/issues/issue-14875.rs
56+
src/test/ui/issues/issue-29948.rs
57+
src/test/ui/issues/issue-43853.rs
58+
src/test/ui/iterators/iter-sum-overflow-debug.rs
59+
src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs
60+
src/test/ui/mir/mir_calls_to_shims.rs
61+
src/test/ui/mir/mir_drop_order.rs
62+
src/test/ui/mir/mir_let_chains_drop_order.rs
63+
src/test/ui/oom_unwind.rs
64+
src/test/ui/panic-runtime/abort-link-to-unwinding-crates.rs
65+
src/test/ui/panic-runtime/abort.rs
66+
src/test/ui/panic-runtime/link-to-abort.rs
67+
src/test/ui/rfc-2091-track-caller/std-panic-locations.rs
68+
src/test/ui/rfcs/rfc1857-drop-order.rs
69+
src/test/ui/unwind-no-uwtable.rs

failing-ui-tests12.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ src/test/ui/simd/intrinsic/inlining-issue67557.rs
2222
src/test/ui/simd/monomorphize-shuffle-index.rs
2323
src/test/ui/simd/shuffle.rs
2424
src/test/ui/simd/simd-bitmask.rs
25+
src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs
26+
src/test/ui/drop/dynamic-drop.rs
27+
src/test/ui/generator/resume-after-return.rs
28+
src/test/ui/iterators/iter-step-overflow-debug.rs
29+
src/test/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs
30+
src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs
31+
src/test/ui/panic-while-printing.rs
32+
src/test/ui/privacy/reachable-unnameable-items.rs
33+
src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs

src/asm.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
352352
inputs.push(AsmInOperand {
353353
constraint: "X".into(),
354354
rust_idx,
355-
val: self.cx.rvalue_as_function(get_fn(self.cx, instance))
356-
.get_address(None),
355+
val: get_fn(self.cx, instance).get_address(None),
357356
});
358357
}
359358

@@ -739,7 +738,7 @@ impl<'gcc, 'tcx> AsmMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
739738
}
740739

741740
GlobalAsmOperandRef::SymFn { instance } => {
742-
let function = self.rvalue_as_function(get_fn(self, instance));
741+
let function = get_fn(self, instance);
743742
self.add_used_function(function);
744743
// TODO(@Amanieu): Additional mangling is needed on
745744
// some targets to add a leading underscore (Mach-O)

src/base.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_
8787
// Instantiate monomorphizations without filling out definitions yet...
8888
//let llvm_module = ModuleLlvm::new(tcx, &cgu_name.as_str());
8989
let context = Context::default();
90+
91+
context.add_command_line_option("-fexceptions");
92+
context.add_driver_option("-fexceptions");
93+
9094
// TODO(antoyo): only set on x86 platforms.
9195
context.add_command_line_option("-masm=intel");
9296
// TODO(antoyo): only add the following cli argument if the feature is supported.
@@ -146,7 +150,7 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_
146150
context.set_keep_intermediates(true);
147151
}
148152

149-
// TODO(bjorn3): Remove once unwinding is properly implemented
153+
// NOTE: The codegen generates unrechable blocks.
150154
context.set_allow_unreachable_blocks(true);
151155

152156
{

0 commit comments

Comments
 (0)