bluescarni / piranha

The Piranha computer algebra system.
GNU General Public License v3.0
100 stars 25 forks source link

Is gcc 4.7 necessary? #1

Closed certik closed 10 years ago

certik commented 10 years ago

I have access to a few systems, none of which have gcc 4.7, so I can't compile it... I have access to gcc 4.6. One can relax the checks:

diff --git a/cmake_modules/PiranhaCompilerLinkerSettings.cmake b/cmake_modules/PiranhaCompilerLinkerSettings.cmake
index 96a8c03..012c098 100644
--- a/cmake_modules/PiranhaCompilerLinkerSettings.cmake
+++ b/cmake_modules/PiranhaCompilerLinkerSettings.cmake
@@ -29,7 +29,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
        ENDIF(NOT GCC_VERSION_CHECK)
        MESSAGE(STATUS "GCC version is ok.")
        MESSAGE(STATUS "Enabling c++11 flag.")
-       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
        # Try to see if we have the 128-bit integer type available.
        CHECK_TYPE_SIZE("__int128" PIRANHA_GCC___INT128)
        IF(PIRANHA_GCC___INT128)
diff --git a/cmake_modules/gcc_check_version.cpp b/cmake_modules/gcc_check_version.cpp
index b73bf3f..558beab 100644
--- a/cmake_modules/gcc_check_version.cpp
+++ b/cmake_modules/gcc_check_version.cpp
@@ -1,4 +1,4 @@
-#if __GNUC__  < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
+#if __GNUC__  < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
        #error Unsupported GCC version.
 #endif

diff --git a/src/detail/config_gcc.hpp b/src/detail/config_gcc.hpp
index df31644..10356ab 100644
--- a/src/detail/config_gcc.hpp
+++ b/src/detail/config_gcc.hpp
@@ -21,7 +21,7 @@
 #ifndef PIRANHA_CONFIG_GCC_HPP
 #define PIRANHA_CONFIG_GCC_HPP

-#if __GNUC__  < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
+#if __GNUC__  < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
        #error Minimum GCC version supported is 4.7.0.
 #endif

Then the error with gcc 4.6.3 is:

[  4%] Building CXX object tests/CMakeFiles/aligned_memory.dir/aligned_memory.cpp.o
In file included from /projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/aligned_memory.hpp:33:0,
                 from /projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/aligned_memory.cpp:21:
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/exceptions.hpp:133:42: error: expected ‘;’ at end of member declaration
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/exceptions.hpp:133:44: error: ‘override’ does not name a type
make[2]: *** [tests/CMakeFiles/aligned_memory.dir/aligned_memory.cpp.o] Error 1
make[1]: *** [tests/CMakeFiles/aligned_memory.dir/all] Error 2
make: *** [all] Error 2

By applying the following patch:

diff --git a/src/exceptions.hpp b/src/exceptions.hpp
index bda6f25..4fdf016 100644
--- a/src/exceptions.hpp
+++ b/src/exceptions.hpp
@@ -130,7 +130,7 @@ class base_exception: public std::exception
                /**
                 * @return const pointer to the internal error message.
                 */
-               virtual const char *what() const throw() override
+               virtual const char *what() const throw()
                {
                        return m_what.c_str();
                }

it fails with:

[  7%] Building CXX object tests/CMakeFiles/array_key.dir/array_key.cpp.o
In file included from /projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/math.hpp:47:0,
                 from /projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/array_key.hpp:36,
                 from /projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/array_key.cpp:21:
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:75:59: error: ‘is_destructible’ is not a member of ‘std’
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:75:81: error: template argument 1 is invalid
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:75:89: error: expected ‘(’ before ‘>’ token
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:75:89: error: template argument 2 is invalid
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:75:92: error: expected ‘{’ or ‘:’ before ‘type’
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:75:92: error: expected ‘{’ before ‘type’
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:75:96: error: expected initializer before ‘>’ token
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:78:2: error: extra ‘;’ [-pedantic]
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:90:63: error: ‘is_destructible’ is not a member of ‘std’
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:90:85: error: template argument 1 is invalid
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:90:93: error: expected ‘(’ before ‘>’ token
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:90:93: error: template argument 2 is invalid
/projects/b1cc51a6-c4a2-4281-98b4-a5c2b1dea21b/repos/piranha/tests/../src/type_traits.hpp:90:96: error: expected ‘*’ before ‘type’
...

The std::is_destructible I guess only works in gcc 4.7.

bluescarni commented 10 years ago

Hey Ondřej,

I usually try to track the compiler version available in the latest versions of common distributions. Actually, in the development version of piranha,

https://gitorious.org/piranhapp0x/mainline/commits/511fb057d96a7e28f60fd7b50f9856ccc45b46cd

I have bumped the minimum required GCC version to 4.8 (and clang to 3.3 IIRC).

(As a side note, the main repo of piranha is still on gitorious, might move to github sometimes in the near future)

piranha aims to be a fully-compliant C++11 project and that means that often I have to workaround missing/broken features in compilers and standard libraries. This means that quite a big effort is required to keep compatibility with older compiler versions, and as a one-man project it just makes more sense in term of time budgeting to move on and drop support for older compilers, keep the codebase as clean as possible and just implement features.

I understand that out there there are a lot of real-world scenarios in which having the latest compiler is not an option (in my previous job I was doing commercial development with GCC 4.4 on some Red-Hat long-term support version). In principle I am not against keeping workarounds for older compilers if they are properly tested/maintained and if they do not impact too much the development (e.g., missing unrestricted union support in MSVC is definitely non-fixable), but for this to happen the project would definitely need more manpower.

bluescarni commented 10 years ago

To be a bit more specific wrt your question about GCC 4.6, there is at least one key features that it is missing, alias templates:

http://en.wikipedia.org/wiki/C++11#Alias_templates

I am afraid these are used quite widely now in piranha, so it might be a problem to retro-fit GCC 4.6 compatibility.

certik commented 10 years ago

Ok. I don't have clang either, but I am trying to compile one myself, so that I can finally play with your library: https://github.com/hashdist/hashstack/pull/242, it works, but I need to install the latest header files --- currently it is reusing those from gcc, which is 4.6... I am closing this one, I can see that you need the very latest compilers.