Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not emit .eh_frame section if using -Cpanic=abort #374

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build_sysroot/build_sysroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ fi
# Copy files to sysroot
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
# Copy the source files to the sysroot (Rust for Linux needs this).
source_dir=sysroot/lib/rustlib/src/rust
mkdir -p $source_dir
cp -r sysroot_src/library/ $source_dir
6 changes: 6 additions & 0 deletions build_system/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ fn build_sysroot(
copier,
)?;

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

Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions failing-ui-tests12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ tests/ui/target-feature/missing-plusminus.rs
tests/ui/sse2.rs
tests/ui/codegen/issue-79865-llvm-miscompile.rs
tests/ui/intrinsics/intrinsics-integer.rs
tests/ui/std-backtrace.rs
16 changes: 7 additions & 9 deletions src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::env;
use std::time::Instant;

use gccjit::{
Context,
FunctionType,
GlobalKind,
};
Expand All @@ -18,8 +17,9 @@ use rustc_codegen_ssa::mono_item::MonoItemExt;
use rustc_codegen_ssa::traits::DebugInfoMethods;
use rustc_session::config::DebugInfo;
use rustc_span::Symbol;
use rustc_target::spec::PanicStrategy;

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

context.add_command_line_option("-fexceptions");
context.add_driver_option("-fexceptions");
if tcx.sess.panic_strategy() == PanicStrategy::Unwind {
context.add_command_line_option("-fexceptions");
context.add_driver_option("-fexceptions");
}

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

if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
context.add_command_line_option("-masm=intel");
}

if !disabled_features.contains("avx") && tcx.sess.target.arch == "x86_64" {
// NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
// SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.
Expand Down
14 changes: 10 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,23 @@ impl CodegenBackend for GccCodegenBackend {
}
}

fn new_context<'gcc, 'tcx>(tcx: &TyCtxt<'tcx>) -> Context<'gcc> {
let context = Context::default();
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
context.add_command_line_option("-masm=intel");
}
context.add_command_line_option("-fno-asynchronous-unwind-tables");
context
}

impl ExtraBackendMethods for GccCodegenBackend {
fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, module_name: &str, kind: AllocatorKind, alloc_error_handler_kind: AllocatorKind) -> Self::Module {
let mut mods = GccContext {
context: Context::default(),
context: new_context(&tcx),
should_combine_object_files: false,
temp_dir: None,
};

if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
mods.context.add_command_line_option("-masm=intel");
}
unsafe { allocator::codegen(tcx, &mut mods, module_name, kind, alloc_error_handler_kind); }
mods
}
Expand Down
Loading