summaryrefslogtreecommitdiff
path: root/make/configure.pm
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-03-22 17:44:33 +0000
committerPeter Powell <petpow@saberuk.com>2017-04-14 14:59:03 +0100
commit7e1629bdf1454f21fe48a8d3fe5b06be3a5b2552 (patch)
treecc8fa3699b6d3ebf776d2351f6e9087036ffbe4a /make/configure.pm
parent127683c29e6eb33c21f85cf1ccba6fb85fc0cdec (diff)
Switch compiler detection to use a more reliable method.
Its clear that parsing version output is not reliable enough so switch to using a method which is less likely to break.
Diffstat (limited to 'make/configure.pm')
-rw-r--r--make/configure.pm20
1 files changed, 8 insertions, 12 deletions
diff --git a/make/configure.pm b/make/configure.pm
index a10493318..48bd8db38 100644
--- a/make/configure.pm
+++ b/make/configure.pm
@@ -227,19 +227,15 @@ sub write_configure_cache(%) {
sub get_compiler_info($) {
my $binary = shift;
- my $version = `$binary -v 2>&1`;
- if ($version =~ /Apple\sLLVM\sversion\s(\d+\.\d+)/i) {
- # Apple version their LLVM releases slightly differently to the mainline LLVM.
- # See https://trac.macports.org/wiki/XcodeVersionInfo for more information.
- return (NAME => 'AppleClang', VERSION => $1);
- } elsif ($version =~ /clang\sversion\s(\d+\.\d+)/i) {
- return (NAME => 'Clang', VERSION => $1);
- } elsif ($version =~ /gcc\sversion\s(\d+\.\d+)/i) {
- return (NAME => 'GCC', VERSION => $1);
- } elsif ($version =~ /(?:icc|icpc)\sversion\s(\d+\.\d+).\d+\s\(gcc\sversion\s(\d+\.\d+).\d+/i) {
- return (NAME => 'ICC', VERSION => $1);
+ my %info = (NAME => 'Unknown', VERSION => '0.0');
+ return %info if system "$binary -o __compiler_info make/test/compiler_info.cpp ${\CONFIGURE_ERROR_PIPE}";
+ open(my $fh, '-|', './__compiler_info 2>/dev/null');
+ while (my $line = <$fh>) {
+ $info{$1} = $2 if $line =~ /^([A-Z]+)\s(.+)$/;
}
- return (NAME => $binary, VERSION => '0.0');
+ close $fh;
+ unlink './__compiler_info';
+ return %info;
}
sub find_compiler {