Skip to content

Commit 551ea4b

Browse files
authored
Merge pull request rust-lang#374 from rust-lang/fix/eh-frame
Do not emit .eh_frame section if using -Cpanic=abort
2 parents f20f6bb + cc2af1f commit 551ea4b

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

build_sysroot/build_sysroot.sh

+4
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ fi
2828
# Copy files to sysroot
2929
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
3030
cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
31+
# Copy the source files to the sysroot (Rust for Linux needs this).
32+
source_dir=sysroot/lib/rustlib/src/rust
33+
mkdir -p $source_dir
34+
cp -r sysroot_src/library/ $source_dir

build_system/src/build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ fn build_sysroot(
194194
copier,
195195
)?;
196196

197+
// Copy the source files to the sysroot (Rust for Linux needs this).
198+
let sysroot_src_path = "sysroot/lib/rustlib/src/rust";
199+
fs::create_dir_all(&sysroot_src_path)
200+
.map_err(|error| format!("Failed to create directory `{}`: {:?}", sysroot_src_path, error))?;
201+
run_command(&[&"cp", &"-r", &"sysroot_src/library/", &sysroot_src_path], None)?;
202+
197203
Ok(())
198204
}
199205

failing-ui-tests12.txt

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ tests/ui/target-feature/missing-plusminus.rs
3838
tests/ui/sse2.rs
3939
tests/ui/codegen/issue-79865-llvm-miscompile.rs
4040
tests/ui/intrinsics/intrinsics-integer.rs
41+
tests/ui/std-backtrace.rs

src/base.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::env;
33
use std::time::Instant;
44

55
use gccjit::{
6-
Context,
76
FunctionType,
87
GlobalKind,
98
};
@@ -18,8 +17,9 @@ use rustc_codegen_ssa::mono_item::MonoItemExt;
1817
use rustc_codegen_ssa::traits::DebugInfoMethods;
1918
use rustc_session::config::DebugInfo;
2019
use rustc_span::Symbol;
20+
use rustc_target::spec::PanicStrategy;
2121

22-
use crate::{LockedTargetInfo, gcc_util};
22+
use crate::{LockedTargetInfo, gcc_util, new_context};
2323
use crate::GccContext;
2424
use crate::builder::Builder;
2525
use crate::context::CodegenCx;
@@ -88,20 +88,18 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock
8888
fn module_codegen(tcx: TyCtxt<'_>, (cgu_name, target_info): (Symbol, LockedTargetInfo)) -> ModuleCodegen<GccContext> {
8989
let cgu = tcx.codegen_unit(cgu_name);
9090
// Instantiate monomorphizations without filling out definitions yet...
91-
let context = Context::default();
91+
let context = new_context(&tcx);
9292

93-
context.add_command_line_option("-fexceptions");
94-
context.add_driver_option("-fexceptions");
93+
if tcx.sess.panic_strategy() == PanicStrategy::Unwind {
94+
context.add_command_line_option("-fexceptions");
95+
context.add_driver_option("-fexceptions");
96+
}
9597

9698
let disabled_features: HashSet<_> = tcx.sess.opts.cg.target_feature.split(',')
9799
.filter(|feature| feature.starts_with('-'))
98100
.map(|string| &string[1..])
99101
.collect();
100102

101-
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
102-
context.add_command_line_option("-masm=intel");
103-
}
104-
105103
if !disabled_features.contains("avx") && tcx.sess.target.arch == "x86_64" {
106104
// NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
107105
// SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.

src/lib.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,23 @@ impl CodegenBackend for GccCodegenBackend {
244244
}
245245
}
246246

247+
fn new_context<'gcc, 'tcx>(tcx: &TyCtxt<'tcx>) -> Context<'gcc> {
248+
let context = Context::default();
249+
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
250+
context.add_command_line_option("-masm=intel");
251+
}
252+
context.add_command_line_option("-fno-asynchronous-unwind-tables");
253+
context
254+
}
255+
247256
impl ExtraBackendMethods for GccCodegenBackend {
248257
fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, module_name: &str, kind: AllocatorKind, alloc_error_handler_kind: AllocatorKind) -> Self::Module {
249258
let mut mods = GccContext {
250-
context: Context::default(),
259+
context: new_context(&tcx),
251260
should_combine_object_files: false,
252261
temp_dir: None,
253262
};
254263

255-
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
256-
mods.context.add_command_line_option("-masm=intel");
257-
}
258264
unsafe { allocator::codegen(tcx, &mut mods, module_name, kind, alloc_error_handler_kind); }
259265
mods
260266
}

0 commit comments

Comments
 (0)