From 6e613ff399166c59e881331027e65c601feab807 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 28 Nov 2017 11:22:46 -0500 Subject: bootstrap: Add infrastructure to detect threading flags In our loop to detect -std flags, add another layer to detect threading flags. --- bootstrap | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/bootstrap b/bootstrap index d9e243d468..e02c289abc 100755 --- a/bootstrap +++ b/bootstrap @@ -981,6 +981,8 @@ if [ -z "${CC}" -a -z "${CXX}" ]; then cmake_toolchain_detect fi +thread_flags='' + #----------------------------------------------------------------------------- # Test C compiler cmake_c_compiler= @@ -1014,16 +1016,18 @@ int main(int argc, char* argv[]) } ' > "${TMPFILE}.c" for std in 11 99 90; do - try_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" C \"${std}\"`" + std_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" C \"${std}\"`" for compiler in ${cmake_c_compilers}; do - for flag in '' $try_flags; do - echo "Checking whether '${compiler} ${cmake_c_flags} ${flag}' works." >> cmake_bootstrap.log 2>&1 - if cmake_try_run "${compiler}" "${cmake_c_flags} ${flag}" \ - "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then - cmake_c_compiler="${compiler}" - cmake_c_flags="${cmake_c_flags} ${flag}" - break 3 - fi + for std_flag in '' $std_flags; do + for thread_flag in '' $thread_flags; do + echo "Checking whether '${compiler} ${cmake_c_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1 + if cmake_try_run "${compiler}" "${cmake_c_flags} ${std_flag} ${thread_flag}" \ + "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then + cmake_c_compiler="${compiler}" + cmake_c_flags="${cmake_c_flags} ${std_flag} ${thread_flag}" + break 3 + fi + done done done done @@ -1081,16 +1085,18 @@ int main() } ' > "${TMPFILE}.cxx" for std in 17 14 11; do - try_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" CXX \"${std}\"`" + std_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" CXX \"${std}\"`" for compiler in ${cmake_cxx_compilers}; do - for flag in '' $try_flags; do - echo "Checking whether '${compiler} ${cmake_cxx_flags} ${flag}' works." >> cmake_bootstrap.log 2>&1 - if cmake_try_run "${compiler}" "${cmake_cxx_flags} ${flag}" \ - "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then - cmake_cxx_compiler="${compiler}" - cmake_cxx_flags="${cmake_cxx_flags} ${flag} " - break 3 - fi + for std_flag in '' $std_flags; do + for thread_flag in '' $thread_flags; do + echo "Checking whether '${compiler} ${cmake_cxx_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1 + if cmake_try_run "${compiler}" "${cmake_cxx_flags} ${std_flag} ${thread_flag}" \ + "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then + cmake_cxx_compiler="${compiler}" + cmake_cxx_flags="${cmake_cxx_flags} ${std_flag} ${thread_flag} " + break 3 + fi + done done done done -- cgit v1.2.1 From 4ff89fb6084d84aabe2e64aeccad03794af65a8a Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 28 Nov 2017 11:24:26 -0500 Subject: AIX: Add -pthread flag to enable std::thread with GCC --- CMakeLists.txt | 4 ++++ Source/Modules/OverrideC.cmake | 3 +++ Source/Modules/OverrideCXX.cmake | 3 +++ bootstrap | 13 ++++++++++++- 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Source/Modules/OverrideC.cmake create mode 100644 Source/Modules/OverrideCXX.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fafe536e22..ebeca225ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,11 @@ # file Copyright.txt or https://cmake.org/licensing for details. cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake) +set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake) project(CMake) +unset(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) +unset(CMAKE_USER_MAKE_RULES_OVERRIDE_C) # Make sure we can find internal find_package modules only used for # building CMake and not for shipping externally diff --git a/Source/Modules/OverrideC.cmake b/Source/Modules/OverrideC.cmake new file mode 100644 index 0000000000..f8299adb08 --- /dev/null +++ b/Source/Modules/OverrideC.cmake @@ -0,0 +1,3 @@ +if("${CMAKE_SYSTEM_NAME};${CMAKE_C_COMPILER_ID}" STREQUAL "AIX;GNU") + string(APPEND CMAKE_C_FLAGS_INIT " -pthread") +endif() diff --git a/Source/Modules/OverrideCXX.cmake b/Source/Modules/OverrideCXX.cmake new file mode 100644 index 0000000000..13689e2c55 --- /dev/null +++ b/Source/Modules/OverrideCXX.cmake @@ -0,0 +1,3 @@ +if("${CMAKE_SYSTEM_NAME};${CMAKE_CXX_COMPILER_ID}" STREQUAL "AIX;GNU") + string(APPEND CMAKE_CXX_FLAGS_INIT " -pthread") +endif() diff --git a/bootstrap b/bootstrap index e02c289abc..ab087e9361 100755 --- a/bootstrap +++ b/bootstrap @@ -982,6 +982,9 @@ if [ -z "${CC}" -a -z "${CXX}" ]; then fi thread_flags='' +case "${cmake_system}" in + *AIX*) thread_flags='-pthread' ;; +esac #----------------------------------------------------------------------------- # Test C compiler @@ -1003,6 +1006,10 @@ echo ' # error "The CMAKE_C_COMPILER is set to a C++ compiler" #endif +#if defined(_AIX) && defined(__GNUC__) && !defined(_THREAD_SAFE) +#error "On AIX with GNU we need the -pthread flag." +#endif + #if defined(__sun) && __STDC_VERSION__ < 199901L #error "On Solaris we need C99." #endif @@ -1066,6 +1073,10 @@ echo ' #error "Compiler is not in a mode aware of C++11." #endif +#if defined(_AIX) && defined(__GNUC__) && !defined(_THREAD_SAFE) +#error "On AIX with GNU we need the -pthread flag." +#endif + #if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140 #error "SunPro <= 5.13 mode not supported due to bug in move semantics." #endif @@ -1326,7 +1337,7 @@ else uv_c_flags="${uv_c_flags} -DCMAKE_BOOTSTRAP" case "${cmake_system}" in *AIX*) - uv_c_flags="${uv_c_flags} -D_ALL_SOURCE -D_XOPEN_SOURCE=500 -D_LINUX_SOURCE_COMPAT -D_THREAD_SAFE" + uv_c_flags="${uv_c_flags} -D_ALL_SOURCE -D_XOPEN_SOURCE=500 -D_LINUX_SOURCE_COMPAT" libs="${libs} -lperfstat" ;; *Darwin*) -- cgit v1.2.1