Skip to content

ppc64le support #10123

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/call-build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
- amd64
- arm64
- arm/v7
- ppc64le
target:
- production
- debug
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ jobs:
arch:
- s390x
- riscv64
- ppc64le
steps:
- name: Checkout Fluent Bit code
uses: actions/checkout@v4
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ if (FLB_SYSTEM_MACOS)
include(cmake/macos-setup.cmake)
endif()

# Tweak build targets for Linux on ppc64le
if (FLB_SYSTEM_LINUX)
include(cmake/ppc64le.cmake)
endif ()

# Build for SystemZ - s390x arch
if (FLB_SYSTEM_LINUX)
include(cmake/s390x.cmake)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ Fluent Bit is fully supported on Windows environments, get started with [these i

Fluent Bit runs on Linux on IBM Z(s390x), but the WASM filter plugin is not. For the LUA filter plugin, it runs when `libluajit` is installed on the system and fluent bit is built with `FLB_LUAJIT` and `FLB_PREFER_SYSTEM_LIB_LUAJIT` on.

#### Running on ppc64le

Fluent Bit runs on Linux on IBM Power(ppc64le), but the WASM filter plugin and the LUA filter plugin do not.

### Plugins: Inputs, Filters and Outputs

[Fluent Bit](http://fluentbit.io) is based in a pluggable architecture where different plugins plays a major role in the data pipeline:
Expand Down
8 changes: 8 additions & 0 deletions cmake/ppc64le.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le")
message(STATUS "Forcing characters to be signed, as on x86_64.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char")
message(STATUS "This platform does not support WAMR building so disabled.")
set(FLB_WASM OFF)
message(STATUS "This platform does not support LuaJIT so disabled.")
set(FLB_LUAJIT OFF)
endif ()
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# docker buildx rm builder
# docker buildx create --name builder --use
# docker buildx inspect --bootstrap
# docker buildx build --platform "linux/amd64,linux/arm64,linux/arm/v7,linux/s390x" -f ./dockerfiles/Dockerfile.multiarch --build-arg FLB_TARBALL=https://github.com/fluent/fluent-bit/archive/v1.8.11.tar.gz ./dockerfiles/
# docker buildx build --platform "linux/amd64,linux/arm64,linux/arm/v7,linux/s390x,linux/ppc64le" -f ./dockerfiles/Dockerfile.multiarch --build-arg FLB_TARBALL=https://github.com/fluent/fluent-bit/archive/v1.8.11.tar.gz ./dockerfiles/

# Set this to the current release version: it gets done so as part of the release.
ARG RELEASE_VERSION=3.2.4
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ docker buildx inspect --bootstrap
```
4. Build Fluent Bit from the **root of the Git repo (not from this directory)**:
```
docker buildx build --platform "linux/amd64,linux/arm64,linux/arm/v7,linux/s390x" --target=production -f dockerfiles/Dockerfile .
docker buildx build --platform "linux/amd64,linux/arm64,linux/arm/v7,linux/s390x,linux/ppc64le" --target=production -f dockerfiles/Dockerfile .
```

## Build and test
Expand Down
4 changes: 3 additions & 1 deletion lib/monkey/deps/flb_libco/libco.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include "arm.c"
#elif defined(__aarch64__)
#include "aarch64.c"
#elif defined(_ARCH_PPC)
#elif defined(__powerpc64__) && defined(_CALL_ELF) && _CALL_ELF == 2
#include "ppc64le.c"
#elif defined(_ARCH_PPC) && !defined(__LITTLE_ENDIAN__)
#include "ppc.c"
#elif defined(_WIN32)
#include "fiber.c"
Expand Down
239 changes: 239 additions & 0 deletions lib/monkey/deps/flb_libco/ppc64le.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
/*
libco.ppc (2016-09-14)
author: blargg
license: public domain
*/

#define LIBCO_C
#include "libco.h"
#include "settings.h"

#include <stdlib.h>
#include <stdint.h>
#include <string.h>

/* state format (offsets in 32-bit words)
+0 pointer to swap code
rest of function descriptor for entry function
+8 PC
+10 SP
special registers
GPRs
FPRs
VRs
stack
*/

enum { state_size = 1024 };
enum { above_stack = 2048 };
enum { stack_align = 256 };

static thread_local cothread_t co_active_handle = 0;

/* determine environment */

#define LIBCO_PPC64 (_ARCH_PPC64 || __PPC64__ || __ppc64__ || __powerpc64__)

text_section
static const uint32_t libco_ppc_code[1024] = {
0xf8240008, /* std r1, 8(4) */
0xf8440010, /* std r2, 16(4) */
0xf9840060, /* std r12, 96(4) */
0xf9a40068, /* std r13, 104(4) */
0xf9c40070, /* std r14, 112(4) */
0xf9e40078, /* std r15, 120(4) */
0xfa040080, /* std r16, 128(4) */
0xfa240088, /* std r17, 136(4) */
0xfa440090, /* std r18, 144(4) */
0xfa640098, /* std r19, 152(4) */
0xfa8400a0, /* std r20, 160(4) */
0xfaa400a8, /* std r21, 168(4) */
0xfac400b0, /* std r22, 176(4) */
0xfae400b8, /* std r23, 184(4) */
0xfb0400c0, /* std r24, 192(4) */
0xfb2400c8, /* std r25, 200(4) */
0xfb4400d0, /* std r26, 208(4) */
0xfb6400d8, /* std r27, 216(4) */
0xfb8400e0, /* std r28, 224(4) */
0xfba400e8, /* std r29, 232(4) */
0xfbc400f0, /* std r30, 240(4) */
0xfbe400f8, /* std r31, 248(4) */
0x7ca802a6, /* mflr r5 */
0xf8a40100, /* std r5, 256(4) */
0x7ca00026, /* mfcr r5 */
0xf8a40108, /* std r5, 264(4) */
0xe8230008, /* ld r1, 8(3) */
0xe8430010, /* ld r2, 16(3) */
0xe9830060, /* ld r12, 96(3) */
0xe9a30068, /* ld r13, 104(3) */
0xe9c30070, /* ld r14, 112(3) */
0xe9e30078, /* ld r15, 120(3) */
0xea030080, /* ld r16, 128(3) */
0xea230088, /* ld r17, 136(3) */
0xea430090, /* ld r18, 144(3) */
0xea630098, /* ld r19, 152(3) */
0xea8300a0, /* ld r20, 160(3) */
0xeaa300a8, /* ld r21, 168(3) */
0xeac300b0, /* ld r22, 176(3) */
0xeae300b8, /* ld r23, 184(3) */
0xeb0300c0, /* ld r24, 192(3) */
0xeb2300c8, /* ld r25, 200(3) */
0xeb4300d0, /* ld r26, 208(3) */
0xeb6300d8, /* ld r27, 216(3) */
0xeb8300e0, /* ld r28, 224(3) */
0xeba300e8, /* ld r29, 232(3) */
0xebc300f0, /* ld r30, 240(3) */
0xebe300f8, /* ld r31, 248(3) */
0xe8a30100, /* ld r5, 256(3) */
0x7ca803a6, /* mtlr r5 */
0xe8a30108, /* ld r5, 264(3) */
0x7caff120, /* mtcr r5 */

#ifndef LIBCO_PPC_NOFP
0xd9c40180, /* stfd r14, 384(4) */
0xd9e40188, /* stfd r15, 392(4) */
0xda040190, /* stfd r16, 400(4) */
0xda240198, /* stfd r17, 408(4) */
0xda4401a0, /* stfd r18, 416(4) */
0xda6401a8, /* stfd r19, 424(4) */
0xda8401b0, /* stfd r20, 432(4) */
0xdaa401b8, /* stfd r21, 440(4) */
0xdac401c0, /* stfd r22, 448(4) */
0xdae401c8, /* stfd r23, 456(4) */
0xdb0401d0, /* stfd r24, 464(4) */
0xdb2401d8, /* stfd r25, 472(4) */
0xdb4401e0, /* stfd r26, 480(4) */
0xdb6401e8, /* stfd r27, 488(4) */
0xdb8401f0, /* stfd r28, 496(4) */
0xdba401f8, /* stfd r29, 504(4) */
0xdbc40200, /* stfd r30, 512(4) */
0xdbe40208, /* stfd r31, 520(4) */
0xc9c30180, /* lfd r14, 384(3) */
0xc9e30188, /* lfd r15, 392(3) */
0xca030190, /* lfd r16, 400(3) */
0xca230198, /* lfd r17, 408(3) */
0xca4301a0, /* lfd r18, 416(3) */
0xca6301a8, /* lfd r19, 424(3) */
0xca8301b0, /* lfd r20, 432(3) */
0xcaa301b8, /* lfd r21, 440(3) */
0xcac301c0, /* lfd r22, 448(3) */
0xcae301c8, /* lfd r23, 456(3) */
0xcb0301d0, /* lfd r24, 464(3) */
0xcb2301d8, /* lfd r25, 472(3) */
0xcb4301e0, /* lfd r26, 480(3) */
0xcb6301e8, /* lfd r27, 488(3) */
0xcb8301f0, /* lfd r28, 496(3) */
0xcba301f8, /* lfd r29, 504(3) */
0xcbc30200, /* lfd r30, 512(3) */
0xcbe30208, /* lfd r31, 520(3) */
#endif

#ifdef __ALTIVEC__
0x38a00210, /* li r5, 528 */
0x7e842bce, /* stvxl v20, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7ea42bce, /* stvxl v21, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7ec42bce, /* stvxl v22, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7ee42bce, /* stvxl v23, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f042bce, /* stvxl v24, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f242bce, /* stvxl v25, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f442bce, /* stvxl v26, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f642bce, /* stvxl v27, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f842bce, /* stvxl v28, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7fa42bce, /* stvxl v29, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7fc42bce, /* stvxl v30, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7fe42bce, /* stvxl v31, r4, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7ca042a6, /* mfvrsave r5 */
0x90a402e0, /* stw r5, 736(4) */
0x38a00210, /* li r5, 528 */
0x7e832ace, /* lvxl v20, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7ea32ace, /* lvxl v21, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7ec32ace, /* lvxl v22, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7ee32ace, /* lvxl v23, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f032ace, /* lvxl v24, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f232ace, /* lvxl v25, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f432ace, /* lvxl v26, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f632ace, /* lvxl v27, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7f832ace, /* lvxl v28, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7fa32ace, /* lvxl v29, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7fc32ace, /* lvxl v30, r3, r5 */
0x38a50010, /* addi r5, r5, 16 */
0x7fe32ace, /* lvxl v31, r3, 5 */
0x38a50010, /* addi r5, r5, 16 */
0x80a302d0, /* lwz r5, 720(3) */
0x7ca043a6, /* mtvrsave r5 */
#endif

0x4e800020 /* blr */
};

/* function call goes directly to code */
#define CO_SWAP_ASM(x, y) ((void (*)(cothread_t, cothread_t))(uintptr_t)libco_ppc_code)(x, y)

cothread_t co_active() {
if(!co_active_handle) co_active_handle = (uint64_t*)malloc(state_size);
return co_active_handle;
}

cothread_t co_create(unsigned int size, void (*entry_)(void),
size_t *out_size) {

uintptr_t entry = (uintptr_t)entry_;
uint64_t* t = 0;
uintptr_t sp;
int shift;

/* be sure main thread was successfully allocated */
if(co_active()) {
size += state_size + above_stack + stack_align;
t = (uint64_t*)malloc(size);
}

if(t) {
/* save current registers into new thread, so that any special ones will have proper values when thread is begun */
CO_SWAP_ASM(t, t);

/* put stack near end of block, and align */
sp = (uintptr_t)t + size - above_stack;
sp -= sp % stack_align;

/* set up sp and entry will be called on next swap */
t[1] = (uint64_t)sp;
t[12] = (uint64_t)entry;
t[32] = (uint64_t)entry;
}
*out_size = size;
return t;
}

void co_delete(cothread_t t) {
free(t);
}

void co_switch(cothread_t t) {
cothread_t old = co_active_handle;
co_active_handle = t;

CO_SWAP_ASM(t, old);
}
Loading