@@ -4,6 +4,7 @@ use itertools::Itertools;
44
55use super :: intrinsic_helpers:: IntrinsicTypeDefinition ;
66use crate :: common:: argument:: ArgumentList ;
7+ use crate :: common:: cli:: ProcessedCli ;
78use crate :: common:: intrinsic:: Intrinsic ;
89use crate :: common:: intrinsic_helpers:: TypeKind ;
910
@@ -314,11 +315,17 @@ pub fn write_build_rs(
314315 w : & mut impl std:: io:: Write ,
315316 i : usize ,
316317 arch_flags : & [ & str ] ,
318+ cli_options : & ProcessedCli ,
317319) -> std:: io:: Result < ( ) > {
318- const COMMON_FLAGS : & [ & str ] = & [
319- "-ffp-contract=off" ,
320+ const COMMON_FLAGS : & [ & str ] = & [ "-ffp-contract=off" , "-Wno-narrowing" ] ;
321+ const CLANG_FLAGS : & [ & str ] = & [ "-ffp-model=strict" ] ;
322+ const GCC_FLAGS : & [ & str ] = & [
320323 "-flax-vector-conversions" ,
321- "-Wno-narrowing" ,
324+ "-fno-fast-math" ,
325+ "-frounding-math" ,
326+ "-fexcess-precision=standard" ,
327+ "-ftrapping-math" ,
328+ "-fsignaling-nans" ,
322329 ] ;
323330
324331 write ! (
@@ -333,7 +340,17 @@ pub fn write_build_rs(
333340 i = i
334341 ) ?;
335342
336- for flag in COMMON_FLAGS . iter ( ) . chain ( arch_flags) {
343+ let compiler_specific_flags = match & * cli_options. cc {
344+ "gcc" => GCC_FLAGS ,
345+ "clang" | "icx" => CLANG_FLAGS ,
346+ cc => unimplemented ! ( "Unknown C compiler {cc}" ) ,
347+ } ;
348+
349+ for flag in COMMON_FLAGS
350+ . iter ( )
351+ . chain ( compiler_specific_flags)
352+ . chain ( arch_flags)
353+ {
337354 writeln ! ( w, "\" {flag}\" ," ) ?;
338355 }
339356
0 commit comments