ClickHouse는 현재 s390x를 실험적으로 지원합니다.
s390x용 ClickHouse 빌드
s390x는 다른 플랫폼과 마찬가지로 OpenSSL을 정적 라이브러리로 빌드합니다. OpenSSL을 동적 라이브러리로 빌드하려면 CMake에 -DENABLE_OPENSSL_DYNAMIC=1을 전달해야 합니다.
이 지침은 호스트 머신이 Linux x86_64/ARM이고 빌드 지침에 따라 네이티브 빌드에 필요한 모든 도구를 갖추고 있다고 가정합니다. 또한 호스트가 Ubuntu 22.04라고 가정하지만, 아래 지침은 Ubuntu 20.04에서도 작동합니다.
네이티브 빌드에 사용하는 도구를 설치하는 것 외에도, 다음 추가 패키지를 설치해야 합니다:
apt-get mold
rustup target add s390x-unknown-linux-gnus390x용으로 빌드하려면 다음을 실행하십시오:
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/linux/toolchain-s390x.cmake ..
ninja실행
에뮬레이션하려면 s390x용 QEMU user static binary가 필요합니다. Ubuntu에서는 다음과 같이 설치할 수 있습니다.
apt-get install binfmt-support binutils-s390x-linux-gnu qemu-user-static빌드가 완료되면 예를 들어 다음과 같이 바이너리를 실행할 수 있습니다:
qemu-s390x-static -L /usr/s390x-linux-gnu ./programs/clickhouse local --query "Select 2"
2디버깅
LLDB를 설치합니다:
apt-get install lldb-21s390x 실행형을 디버그하려면 QEMU를 디버그 모드로 실행하여 clickhouse를 실행하세요:
qemu-s390x-static -g 31338 -L /usr/s390x-linux-gnu ./clickhouse다른 셸에서 LLDB를 실행해 attach한 후, <ClickHouse Parent Directory>와 <build directory>를 환경에 맞는 값으로 바꾸십시오.
lldb-15
(lldb) target create ./clickhouse
Current executable set to '/<ClickHouse Parent Directory>/ClickHouse/<build directory>/programs/clickhouse' (s390x).
(lldb) settings set target.source-map <build directory> /<ClickHouse Parent Directory>/ClickHouse
(lldb) gdb-remote 31338
Process 1 stopped
* thread #1, stop reason = signal SIGTRAP
frame #0: 0x0000004020e74cd0
-> 0x4020e74cd0: lgr %r2, %r15
0x4020e74cd4: aghi %r15, -160
0x4020e74cd8: xc 0(8,%r15), 0(%r15)
0x4020e74cde: brasl %r14, 275429939040
(lldb) b main
Breakpoint 1: 9 locations.
(lldb) c
Process 1 resuming
Process 1 stopped
* thread #1, stop reason = breakpoint 1.1
frame #0: 0x0000004005cd9fc0 clickhouse`main(argc_=1, argv_=0x0000004020e594a8) at main.cpp:450:17
447 #if !defined(FUZZING_MODE)
448 int main(int argc_, char ** argv_)
449 {
-> 450 inside_main = true;
451 SCOPE_EXIT({ inside_main = false; });
452
453 /// PHDR cache is required for query profiler to work reliablyVisual Studio Code 통합
- 비주얼 디버깅을 위해 CodeLLDB 확장 기능이 필요합니다.
- CMake Variants를 사용하는 경우, Command Variable 확장 기능이 동적 실행 구성에 도움이 될 수 있습니다.
- 백엔드가 LLVM 설치를 가리키도록 설정해야 합니다. 예:
"lldb.library": "/usr/lib/x86_64-linux-gnu/liblldb-21.so" - 시작하기 전에 clickhouse 실행형을 디버그 모드로 실행해야 합니다. (이를 자동화하는
preLaunchTask를 만들 수도 있습니다)
구성 예시
cmake-variants.yaml
buildType:
default: relwithdebinfo
choices:
debug:
short: Debug
long: Emit debug information
buildType: Debug
release:
short: Release
long: Optimize generated code
buildType: Release
relwithdebinfo:
short: RelWithDebInfo
long: Release with Debug Info
buildType: RelWithDebInfo
tsan:
short: MinSizeRel
long: Minimum Size Release
buildType: MinSizeRel
toolchain:
default: default
description: Select toolchain
choices:
default:
short: x86_64
long: x86_64
s390x:
short: s390x
long: s390x
settings:
CMAKE_TOOLCHAIN_FILE: cmake/linux/toolchain-s390x.cmakelaunch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "custom",
"name": "(lldb) Launch s390x with qemu",
"targetCreateCommands": ["target create ${command:cmake.launchTargetPath}"],
"processCreateCommands": ["gdb-remote 2159"],
"preLaunchTask": "Run ClickHouse"
}
]
}settings.json
이렇게 하면 서로 다른 빌드가 build 폴더 아래의 서로 다른 하위 폴더에 저장됩니다.
{
"cmake.buildDirectory": "${workspaceFolder}/build/${buildKitVendor}-${buildKitVersion}-${variant:toolchain}-${variant:buildType}",
"lldb.library": "/usr/lib/x86_64-linux-gnu/liblldb-21.so"
}run-debug.sh
#! /bin/sh
echo 'Starting debugger session'
cd $1
qemu-s390x-static -g 2159 -L /usr/s390x-linux-gnu $2 $3 $4tasks.json
컴파일된 실행형을 바이너리 옆의 tmp 폴더에서 server 모드로 실행하고, programs/server/config.xml의 구성을 사용하도록 하는 작업을 정의합니다.
{
"version": "2.0.0",
"tasks": [
{
"label": "Run ClickHouse",
"type": "shell",
"isBackground": true,
"command": "${workspaceFolder}/.vscode/run-debug.sh",
"args": [
"${command:cmake.launchTargetDirectory}/tmp",
"${command:cmake.launchTargetPath}",
"server",
"--config-file=${workspaceFolder}/programs/server/config.xml"
],
"problemMatcher": [
{
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "^Starting debugger session",
"endsPattern": ".*"
}
}
]
}
]
}