Send -march to gcc
This commit is contained in:
@@ -19,7 +19,7 @@ use rustc_codegen_ssa::traits::DebugInfoMethods;
|
|||||||
use rustc_session::config::DebugInfo;
|
use rustc_session::config::DebugInfo;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
|
|
||||||
use crate::LockedTargetInfo;
|
use crate::{LockedTargetInfo, gcc_util};
|
||||||
use crate::GccContext;
|
use crate::GccContext;
|
||||||
use crate::builder::Builder;
|
use crate::builder::Builder;
|
||||||
use crate::context::CodegenCx;
|
use crate::context::CodegenCx;
|
||||||
@@ -101,8 +101,6 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock
|
|||||||
// TODO(antoyo): only set on x86 platforms.
|
// TODO(antoyo): only set on x86 platforms.
|
||||||
context.add_command_line_option("-masm=intel");
|
context.add_command_line_option("-masm=intel");
|
||||||
|
|
||||||
// TODO(antoyo): set the correct -march flag.
|
|
||||||
|
|
||||||
if !disabled_features.contains("avx") {
|
if !disabled_features.contains("avx") {
|
||||||
// NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
|
// 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.
|
// SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.
|
||||||
@@ -127,6 +125,11 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock
|
|||||||
context.add_command_line_option("-fno-pie");
|
context.add_command_line_option("-fno-pie");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let target_cpu = gcc_util::target_cpu(tcx.sess);
|
||||||
|
if target_cpu != "generic" {
|
||||||
|
context.add_command_line_option(&format!("-march={}", target_cpu));
|
||||||
|
}
|
||||||
|
|
||||||
if tcx.sess.opts.unstable_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) {
|
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("-ffunction-sections");
|
||||||
context.add_command_line_option("-fdata-sections");
|
context.add_command_line_option("-fdata-sections");
|
||||||
|
|||||||
@@ -198,3 +198,18 @@ pub fn check_tied_features(sess: &Session, features: &FxHashMap<&str, bool>) ->
|
|||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_native(name: &str) -> &str {
|
||||||
|
if name != "native" {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn target_cpu(sess: &Session) -> &str {
|
||||||
|
match sess.opts.cg.target_cpu {
|
||||||
|
Some(ref name) => handle_native(name),
|
||||||
|
None => handle_native(sess.target.cpu.as_ref()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
16
src/lib.rs
16
src/lib.rs
@@ -107,6 +107,7 @@ use rustc_span::fatal_error::FatalError;
|
|||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
|
||||||
use crate::back::lto::ModuleBuffer;
|
use crate::back::lto::ModuleBuffer;
|
||||||
|
use crate::gcc_util::target_cpu;
|
||||||
|
|
||||||
fluent_messages! { "../messages.ftl" }
|
fluent_messages! { "../messages.ftl" }
|
||||||
|
|
||||||
@@ -366,21 +367,6 @@ fn to_gcc_opt_level(optlevel: Option<OptLevel>) -> OptimizationLevel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_native(name: &str) -> &str {
|
|
||||||
if name != "native" {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
unimplemented!();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn target_cpu(sess: &Session) -> &str {
|
|
||||||
match sess.opts.cg.target_cpu {
|
|
||||||
Some(ref name) => handle_native(name),
|
|
||||||
None => handle_native(sess.target.cpu.as_ref()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn target_features(sess: &Session, allow_unstable: bool, target_info: &LockedTargetInfo) -> Vec<Symbol> {
|
pub fn target_features(sess: &Session, allow_unstable: bool, target_info: &LockedTargetInfo) -> Vec<Symbol> {
|
||||||
supported_target_features(sess)
|
supported_target_features(sess)
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
Reference in New Issue
Block a user