Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building on AIX 7.2 with Clang #13397

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
endif(HAS_ALTIVEC)
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")

if(CMAKE_SYSTEM_NAME MATCHES "AIX")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcmodel=large")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large")
endif()

if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64|AARCH64")
CHECK_C_COMPILER_FLAG("-march=armv8-a+crc+crypto" HAS_ARMV8_CRC)
if(HAS_ARMV8_CRC)
Expand Down Expand Up @@ -488,6 +493,8 @@ if(CMAKE_SYSTEM_NAME MATCHES "Cygwin")
add_definitions(-fno-builtin-memcmp -DCYGWIN)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-DOS_MACOSX)
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX")
add_definitions(-DOS_AIX)
elseif(CMAKE_SYSTEM_NAME MATCHES "iOS")
add_definitions(-DOS_MACOSX -DIOS_CROSS_COMPILE)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
Expand Down
10 changes: 10 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ most processors made since roughly 2013.
* Or install via [vcpkg](https://github.com/microsoft/vcpkg)
* run `vcpkg install rocksdb:x64-windows`

* **AIX 7.2**
* Install IBM Open XL C/C++ for AIX and XL C/C++
* Use CMake and run
```
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 \
-DCMAKE_C_COMPILER=ibm-clang \
-DCMAKE_CXX_COMPILER=ibm-clang++_r
cmake --build build --target install
```

* **AIX 6.1**
* Install AIX Toolbox rpms with gcc
* Use these environment variables:
Expand Down
13 changes: 10 additions & 3 deletions env/fs_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#if defined(OS_LINUX) || defined(OS_SOLARIS) || defined(OS_ANDROID)
#if defined(OS_AIX) || defined(OS_LINUX) || defined(OS_SOLARIS) || defined(OS_ANDROID)
#include <sys/statfs.h>
#include <sys/sysmacros.h>
#endif
Expand Down Expand Up @@ -585,8 +585,15 @@ class PosixFileSystem : public FileSystem {
while ((entry = readdir(d)) != nullptr) {
// filter out '.' and '..' directory entries
// which appear only on some platforms
const bool ignore =
entry->d_type == DT_DIR &&
#if defined(OS_AIX)
struct stat entry_stat;
stat(entry->d_name, &entry_stat);
const bool is_dir = S_ISDIR(entry_stat.st_mode);
#else
const bool is_dir = entry->d_type == DT_DIR;
#endif

const bool ignore = is_dir &&
(strcmp(entry->d_name, ".") == 0 ||
strcmp(entry->d_name, "..") == 0
#ifndef ASSERT_STATUS_CHECKED
Expand Down
2 changes: 1 addition & 1 deletion port/port_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include <sys/types.h>
#define PLATFORM_IS_LITTLE_ENDIAN (BYTE_ORDER == LITTLE_ENDIAN)
#include <alloca.h>
#elif defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || \
#elif defined(OS_AIX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || \
defined(OS_DRAGONFLYBSD) || defined(OS_ANDROID)
#include <sys/endian.h>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have sys/endian.h on AIX. You can use sys/machine.h for the ENDIAN macros.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, added now

#include <sys/types.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include <stdint.h>
#include <sys/time.h>
#include <time.h>
#if defined(__powerpc__)
#if !defined(OS_AIX) && defined(__powerpc__)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need defined(__powerpc__)?

Copy link
Author

@mustartt mustartt Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for Linux on power that does have the header

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I misread the code changes. Thought you had:

#if defined(__powerpc__)
#if !defined(OS_AIX) && defined(__powerpc__)

What you have looks good.

#include <sys/platform/ppc.h>
#endif

Expand Down Expand Up @@ -131,6 +131,8 @@ static inline tokutime_t toku_time_now(void) {
uint64_t result;
__asm __volatile__("mrs %[rt], cntvct_el0" : [rt] "=r"(result));
return result;
#elif defined(OS_AIX)
return __builtin_ppc_get_timebase();
#elif defined(__powerpc__)
return __ppc_get_timebase();
Comment on lines +134 to 137
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#elif defined(OS_AIX)
return __builtin_ppc_get_timebase();
#elif defined(__powerpc__)
return __ppc_get_timebase();
#elif defined(__powerpc__)
#if defined(OS_AIX)
return __builtin_ppc_get_timebase();
#else
return __ppc_get_timebase();
#endif

Nit: personal preference to keep the Power targets together.

#elif defined(__s390x__)
Expand Down