From 1cb029b33cefe5a5937ca446a00528787f5bafe4 Mon Sep 17 00:00:00 2001 From: Kevin Adler Date: Mon, 2 Nov 2020 11:21:17 -0600 Subject: Use internal getopt for IBM i and AIX --- CMakeLists.txt | 10 ++++++---- src/manifest_parser_perftest.cc | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e02849d..efc4090 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,9 @@ if(WIN32) endif() else() target_sources(libninja PRIVATE src/subprocess-posix.cc) + if(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR CMAKE_SYSTEM_NAME STREQUAL "AIX") + target_sources(libninja PRIVATE src/getopt.c) + endif() endif() #Fixes GetActiveProcessorCount on MinGW @@ -119,11 +122,10 @@ if(MINGW) target_compile_definitions(libninja PRIVATE _WIN32_WINNT=0x0601 __USE_MINGW_ANSI_STDIO=1) endif() -# On IBM i (identified as "OS400" for compatibility reasons), this fixes missing -# PRId64 (and others) at compile time, and links to libutil for getopt_long -if(CMAKE_SYSTEM_NAME STREQUAL "OS400") +# On IBM i (identified as "OS400" for compatibility reasons) and AIX, this fixes missing +# PRId64 (and others) at compile time in C++ sources +if(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR CMAKE_SYSTEM_NAME STREQUAL "AIX") string(APPEND CMAKE_CXX_FLAGS " -D__STDC_FORMAT_MACROS") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -lutil") endif() # Main executable is library plus main() function. diff --git a/src/manifest_parser_perftest.cc b/src/manifest_parser_perftest.cc index 92f5e13..853d8e0 100644 --- a/src/manifest_parser_perftest.cc +++ b/src/manifest_parser_perftest.cc @@ -25,6 +25,9 @@ #ifdef _WIN32 #include "getopt.h" #include +#elif defined(_AIX) +#include "getopt.h" +#include #else #include #include -- cgit v0.12 From b52970e86b7b487da182e3b767b256c5e577d269 Mon Sep 17 00:00:00 2001 From: Kevin Adler Date: Mon, 2 Nov 2020 11:22:10 -0600 Subject: Add libperfstat to AIX CMake build --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index efc4090..7cf6006 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,11 @@ else() if(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR CMAKE_SYSTEM_NAME STREQUAL "AIX") target_sources(libninja PRIVATE src/getopt.c) endif() + + # Needed for perfstat_cpu_total + if(CMAKE_SYSTEM_NAME STREQUAL "AIX") + target_link_libraries(libninja PUBLIC "-lperfstat") + endif() endif() #Fixes GetActiveProcessorCount on MinGW -- cgit v0.12 From 92fc37555fd74b9a3848c956df49a516906af711 Mon Sep 17 00:00:00 2001 From: Kevin Adler Date: Fri, 13 Nov 2020 15:30:51 -0600 Subject: Fix test crashes on AIX Both hash_collision_bench and manifest_parser_perftest crash on AIX with terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc IOT/Abort trap (core dumped) 32-bit AIX applications by default allocates only a single 256M segment for stack and heap for 32-bit applications, which is insufficient for these tests. When building these tests on AIX in 32-bit mode, increase the max number of segments so they will run without crashing. --- CMakeLists.txt | 6 ++++++ configure.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cf6006..7009214 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,6 +203,12 @@ if(BUILD_TESTING) target_link_libraries(${perftest} PRIVATE libninja libninja-re2c) endforeach() + if(CMAKE_SYSTEM_NAME STREQUAL "AIX" AND CMAKE_SIZEOF_VOID_P EQUAL 4) + # These tests require more memory than will fit in the standard AIX shared stack/heap (256M) + target_link_libraries(hash_collision_bench PRIVATE "-Wl,-bmaxdata:0x80000000") + target_link_libraries(manifest_parser_perftest PRIVATE "-Wl,-bmaxdata:0x80000000") + endif() + add_test(NinjaTest ninja_test) endif() diff --git a/configure.py b/configure.py index 48c4821..cded265 100755 --- a/configure.py +++ b/configure.py @@ -596,6 +596,11 @@ all_targets += ninja_test n.comment('Ancillary executables.') +if platform.is_aix() and '-maix64' not in ldflags: + # Both hash_collision_bench and manifest_parser_perftest require more + # memory than will fit in the standard 32-bit AIX shared stack/heap (256M) + libs.append('-Wl,-bmaxdata:0x80000000') + for name in ['build_log_perftest', 'canon_perftest', 'depfile_parser_perftest', -- cgit v0.12