]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge pull request #997 from SaberUK/master+compiler-detection
authorAttila Molnar <attilamolnar@hush.com>
Thu, 19 Feb 2015 23:49:14 +0000 (00:49 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Thu, 19 Feb 2015 23:49:14 +0000 (00:49 +0100)
Improve compiler detection in configure; update supported compiler tests.

make/configure.pm
make/template/main.mk
make/test/compiler.cpp

index 8653edaac2c14b962be8fd9aa381c3e6163c5710..2cd5beb607495feea5c47a76d5db358b58ab6a7c 100644 (file)
@@ -93,6 +93,13 @@ sub __get_template_settings($$$) {
        return %settings;
 }
 
+sub __test_compiler($) {
+       my $compiler = shift;
+       return 0 unless run_test("`$compiler`", !system "$compiler -v >/dev/null 2>&1");
+       return 0 unless run_test("`$compiler`", test_file($compiler, 'compiler.cpp', '-fno-rtti'), 'compatible');
+       return 1;
+}
+
 sub cmd_clean {
        unlink CONFIGURE_CACHE_FILE;
 }
@@ -177,9 +184,10 @@ sub cmd_update {
        exit 0;
 }
 
-sub run_test($$) {
-       my ($what, $result) = @_;
-       print_format "Checking whether <|GREEN $what|> is available ... ";
+sub run_test($$;$) {
+       my ($what, $result, $adjective) = @_;
+       $adjective ||= 'available';
+       print_format "Checking whether <|GREEN $what|> is $adjective ... ";
        print_format $result ? "<|GREEN yes|>\n" : "<|RED no|>\n";
        return $result;
 }
@@ -244,10 +252,8 @@ sub get_compiler_info($) {
 sub find_compiler {
        my @compilers = qw(c++ g++ clang++ icpc);
        foreach my $compiler (shift || @compilers) {
-               return $compiler if run_test "`$compiler`", test_file $compiler, 'compiler.cpp';
-               if ($^O eq 'darwin') {
-                       return $compiler if run_test "`xcrun $compiler`", test_file "xcrun $compiler", 'compiler.cpp';
-               }
+               return $compiler if __test_compiler $compiler;
+               return "xcrun $compiler" if $^O eq 'darwin' && __test_compiler "xcrun $compiler";
        }
 }
 
index 39e2b1c239d688a824d8e09086cf77178f4ae799..9ac43e3bbc14a72a8deda0774cd61b40ff2f9c21 100644 (file)
@@ -37,7 +37,7 @@ COMPILER = @COMPILER_NAME@
 SYSTEM = @SYSTEM_NAME@
 BUILDPATH ?= $(PWD)/build
 SOCKETENGINE = @SOCKETENGINE@
-CORECXXFLAGS = -fPIC -fvisibility-inlines-hidden -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow
+CORECXXFLAGS = -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow
 LDLIBS = -lstdc++
 CORELDFLAGS = -rdynamic -L. $(LDFLAGS)
 PICLDFLAGS = -fPIC -shared -rdynamic $(LDFLAGS)
@@ -60,10 +60,6 @@ INSTMODE_LIB = 0640
 @ENDIF
 @ENDIF
 
-@IFNEQ $(SYSTEM)-$(COMPILER) darwin-GCC
-  CORECXXFLAGS += -fvisibility=hidden
-@ENDIF
-
 @IFNEQ $(SYSTEM) darwin
   LDLIBS += -pthread
 @ENDIF
index 1c3e1d8752ebeb1aeab44d1a5ef5e9f21875eae4..d78f07830d38d15db375ee23b38396be08140ba0 100644 (file)
 
 #include <iostream>
 #if defined _LIBCPP_VERSION
+# include <type_traits>
 # include <unordered_map>
 #else
+# include <tr1/type_traits>
 # include <tr1/unordered_map>
 #endif
 
+#if defined __APPLE__ && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ == 1
+# error "LLVM-GCC 4.2.1 has broken visibility support."
+#endif
+
 int main() {
        std::cout << "Hello, World!" << std::endl;
        return 0;