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 {
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"; }
}
### 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
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 {