summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_gcc/src/base.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /compiler/rustc_codegen_gcc/src/base.rs
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_codegen_gcc/src/base.rs')
-rw-r--r--compiler/rustc_codegen_gcc/src/base.rs45
1 files changed, 41 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_gcc/src/base.rs b/compiler/rustc_codegen_gcc/src/base.rs
index d464bd3d1..dcd560b3d 100644
--- a/compiler/rustc_codegen_gcc/src/base.rs
+++ b/compiler/rustc_codegen_gcc/src/base.rs
@@ -8,6 +8,8 @@ use gccjit::{
};
use rustc_middle::dep_graph;
use rustc_middle::ty::TyCtxt;
+#[cfg(feature="master")]
+use rustc_middle::mir::mono::Visibility;
use rustc_middle::mir::mono::Linkage;
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind};
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
@@ -20,6 +22,15 @@ use crate::GccContext;
use crate::builder::Builder;
use crate::context::CodegenCx;
+#[cfg(feature="master")]
+pub fn visibility_to_gcc(linkage: Visibility) -> gccjit::Visibility {
+ match linkage {
+ Visibility::Default => gccjit::Visibility::Default,
+ Visibility::Hidden => gccjit::Visibility::Hidden,
+ Visibility::Protected => gccjit::Visibility::Protected,
+ }
+}
+
pub fn global_linkage_to_gcc(linkage: Linkage) -> GlobalKind {
match linkage {
Linkage::External => GlobalKind::Imported,
@@ -76,16 +87,34 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, supports_128bit_i
// Instantiate monomorphizations without filling out definitions yet...
//let llvm_module = ModuleLlvm::new(tcx, &cgu_name.as_str());
let context = Context::default();
+
+ context.add_command_line_option("-fexceptions");
+ context.add_driver_option("-fexceptions");
+
// TODO(antoyo): only set on x86 platforms.
context.add_command_line_option("-masm=intel");
// TODO(antoyo): only add the following cli argument if the feature is supported.
context.add_command_line_option("-msse2");
context.add_command_line_option("-mavx2");
- context.add_command_line_option("-msha");
- context.add_command_line_option("-mpclmul");
// FIXME(antoyo): the following causes an illegal instruction on vmovdqu64 in std_example on my CPU.
// Only add if the CPU supports it.
- //context.add_command_line_option("-mavx512f");
+ context.add_command_line_option("-msha");
+ context.add_command_line_option("-mpclmul");
+ context.add_command_line_option("-mfma");
+ context.add_command_line_option("-mfma4");
+ context.add_command_line_option("-m64");
+ context.add_command_line_option("-mbmi");
+ context.add_command_line_option("-mgfni");
+ //context.add_command_line_option("-mavxvnni"); // The CI doesn't support this option.
+ context.add_command_line_option("-mf16c");
+ context.add_command_line_option("-maes");
+ context.add_command_line_option("-mxsavec");
+ context.add_command_line_option("-mbmi2");
+ context.add_command_line_option("-mrtm");
+ context.add_command_line_option("-mvaes");
+ context.add_command_line_option("-mvpclmulqdq");
+ context.add_command_line_option("-mavx");
+
for arg in &tcx.sess.opts.cg.llvm_args {
context.add_command_line_option(arg);
}
@@ -95,12 +124,20 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, supports_128bit_i
context.add_command_line_option("-fno-semantic-interposition");
// NOTE: Rust relies on LLVM not doing TBAA (https://github.com/rust-lang/unsafe-code-guidelines/issues/292).
context.add_command_line_option("-fno-strict-aliasing");
+ // NOTE: Rust relies on LLVM doing wrapping on overflow.
+ context.add_command_line_option("-fwrapv");
if tcx.sess.opts.unstable_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) {
context.add_command_line_option("-ffunction-sections");
context.add_command_line_option("-fdata-sections");
}
+ if env::var("CG_GCCJIT_DUMP_RTL").as_deref() == Ok("1") {
+ context.add_command_line_option("-fdump-rtl-vregs");
+ }
+ if env::var("CG_GCCJIT_DUMP_TREE_ALL").as_deref() == Ok("1") {
+ context.add_command_line_option("-fdump-tree-all");
+ }
if env::var("CG_GCCJIT_DUMP_CODE").as_deref() == Ok("1") {
context.set_dump_code_on_compile(true);
}
@@ -115,7 +152,7 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, supports_128bit_i
context.set_keep_intermediates(true);
}
- // TODO(bjorn3): Remove once unwinding is properly implemented
+ // NOTE: The codegen generates unrechable blocks.
context.set_allow_unreachable_blocks(true);
{