diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-03-31 11:39:03 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2021-03-31 12:16:33 +0200 |
| commit | afe74d71e4c2f08696ade0de321a45f7442440d8 (patch) | |
| tree | 9591c83a1c0fe521204488e3d25c00e2d6ab03d6 /src | |
| parent | 5417278438efa00231936bfef3800e75a992f32f (diff) | |
| download | rust-afe74d71e4c2f08696ade0de321a45f7442440d8.tar.gz rust-afe74d71e4c2f08696ade0de321a45f7442440d8.zip | |
Build with `-Cpanic=unwind` by default
This doesn't enable unwinding as cg_clif doesn't support it yet. It does allow for linking to a cg_llvm compiled libstd.so, which uses `-Cpanic=unwind`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/cg_clif.rs | 11 | ||||
| -rw-r--r-- | src/bin/cg_clif_build_sysroot.rs | 6 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs index 983839d48d2..0d73834f165 100644 --- a/src/bin/cg_clif.rs +++ b/src/bin/cg_clif.rs @@ -24,7 +24,16 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks { self.time_passes = config.opts.prints.is_empty() && (config.opts.debugging_opts.time_passes || config.opts.debugging_opts.time); - config.opts.cg.panic = Some(PanicStrategy::Abort); + if config.opts.test { + // Unwinding is not yet supported by cg_clif. `-Cpanic=abort` in combination with + // `-Zpanic-abort-tests` ensures that tests are run in a subprocess. This avoids + // crashing the test driver on panics, thereby allowing it to report the error and + // continue with other tests. + config.opts.cg.panic = Some(PanicStrategy::Abort); + // Avoid `-Cprefer-dynamic` in case of `-Cpanic=abort` as that will cause a dynamically + // linked libstd with `-Cpanic=unwind` to be linked in, which isn't allowed. + config.opts.cg.prefer_dynamic = false; + } config.opts.debugging_opts.panic_abort_tests = true; config.opts.maybe_sysroot = Some(config.opts.maybe_sysroot.clone().unwrap_or_else(|| { std::env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_owned() diff --git a/src/bin/cg_clif_build_sysroot.rs b/src/bin/cg_clif_build_sysroot.rs index e7cd5edbbf6..70e41f9997e 100644 --- a/src/bin/cg_clif_build_sysroot.rs +++ b/src/bin/cg_clif_build_sysroot.rs @@ -44,7 +44,11 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks { return; } - config.opts.cg.panic = Some(PanicStrategy::Abort); + if config.opts.crate_name.as_deref() == Some("panic_abort") { + // panic_abort must always be built with `-Cpanic=abort` + config.opts.cg.panic = Some(PanicStrategy::Abort); + } + config.opts.debugging_opts.panic_abort_tests = true; config.opts.maybe_sysroot = Some(std::env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_owned()); |
