From 3e1e48b786ff2295ca6196253849b48d3a7f91b9 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 12 Apr 2005 21:26:05 +0000 Subject: [PATCH] Even better CPU checks, this time taking into account GCC version. --- lib/autoconf.cfg | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/lib/autoconf.cfg b/lib/autoconf.cfg index e833836f..829b9b93 100644 --- a/lib/autoconf.cfg +++ b/lib/autoconf.cfg @@ -16,6 +16,23 @@ if (Get("OS") eq "Linux") { Fail "Don't know how to run on this operating system."; } +### Compiler ### + +# Default compiler +Test("CC", "Checking for C compiler", sub { return "gcc"; }); + +# GCC version +Test("GCCVER", "Checking for GCC version", sub { + my $gcc = Get("CC"); + my $ver = `$gcc --version | sed '2,\$d; s/^\\(.* \\)\\?\\([0-9]*\\.[0-9]*\\).*/\\2/'`; + chomp $ver; + Fail "Unable to determine GCC version" if $? || $ver eq ""; + return $ver; +}); +my ($gccmaj, $gccmin) = split(/\./, Get("GCCVER")); +my $gccver = 1000*$gccmaj + $gccmin; +$gccver >= 3000 or Fail "GCC older than 3.0 doesn't support C99 well enough."; + ### CPU ### Test("CPU_ARCH", "Checking for CPU architecture", sub { @@ -40,14 +57,14 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub { my $model = $pc{'model'} || 0; if ($vendor eq "AuthenticAMD") { if ($family >= 6) { - if ($model >= 31) { $arch = "athlon64"; } - elsif ($model >= 6) { $arch = "athlon-xp"; } + if ($model >= 31 && $gccver >= 3003) { $arch = "athlon64"; } + elsif ($model >= 6 && $gccver >= 3003) { $arch = "athlon-xp"; } else { $arch = "athlon"; } } } elsif ($vendor eq "GenuineIntel") { - # We don't recognize Prescott and Nocona cores yet - if ($family >= 15) { $arch = "pentium4"; } - elsif ($family >= 6) { + # We don't recognize Prescott and Nocona cores yet (gcc-3.4+) + if ($family >= 15 && $gccver >= 3003) { $arch = "pentium4"; } + elsif ($family >= 6 && $gccver >= 3003) { if ($model >= 7) { $arch = "pentium3"; } elsif ($model >= 3) { $arch = "pentium2"; } } @@ -76,23 +93,11 @@ if (Get("CPU_ARCH") eq "unknown") { Warn "CPU type not recognized, using default ### Compiler and its Options ### -# Default compiler -Test("CC", "Checking for C compiler", sub { return "gcc"; }); - -# GCC version -Test("GCCVER", "Checking for GCC version", sub { - my $gcc = Get("CC"); - my $ver = `$gcc --version | sed '2,\$d; s/^\\(.* \\)\\?\\([0-9]*\\.[0-9]*\\).*/\\2/'`; - chomp $ver; - Fail "Unable to determine GCC version" if $? || $ver eq ""; - return $ver; -}); - # C flags: tell the compiler we're speaking C99 Set("CLANG" => "-std=gnu99"); # C optimizations -Set("COPT" => '-O2 -fstrict-aliasing -march=$(CPU_ARCH)'); +Set("COPT" => '-O2 -fstrict-aliasing'); Append("COPT", '-march=$(CPU_ARCH)') if IsSet("CPU_ARCH"); # C optimizations for highly exposed code @@ -112,11 +117,11 @@ Set("CSHARED" => '-fPIC'); Set("LSHARED" => '-shared -Wl,-soname,lib/$(@F)'); # Extra switches depending on GCC version: -if (Get("GCCVER") eq "3.0") { -} elsif (Get("GCCVER") eq "3.3") { +if ($gccver == 3000) { +} elsif ($gccver == 3003) { Append("CWARNS" => "-Wundef -Wredundant-decls"); Append("COPT" => "-finline-limit=20000 --param max-inline-insns-auto=1000"); -} elsif (Get("GCCVER") eq "3.4") { +} elsif ($gccver == 3004) { Append("CWARNS" => "-Wundef -Wredundant-decls"); Append("COPT" => "-finline-limit=5000 --param large-function-insns=5000 --param inline-unit-growth=200 --param large-function-growth=400"); } else { -- 2.39.5