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

CMake and Windows support #512

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2b20db3
Fix build with MariaDB connector
vaintroub Jul 27, 2023
e876cef
sysbench cmake port
vaintroub Sep 9, 2023
aeb1561
CMake port - Test CMake build on CI (Ubuntu)
vaintroub Sep 9, 2023
d32fec9
CMake port - build and test on macOS
vaintroub Sep 9, 2023
f1e1297
Fix GCC 11.3 warning (stringop-truncation)
vaintroub Sep 9, 2023
d240128
Fix GCC 11.3 warning (-Werror=maybe-uninitialized)
vaintroub Sep 9, 2023
fd4241c
Fix AppleClang 14 warning - use C11 _Static_assert for compile time a…
vaintroub Sep 9, 2023
1e21765
CMake port - handle compile warning as error on CI
vaintroub Sep 9, 2023
3559b2f
Windows port - MSVC/MinGW compile flags
vaintroub Sep 9, 2023
9c9198b
Windows port - add pthreads library from Lockless Inc
vaintroub Sep 9, 2023
3dcd6af
Windows port - port several POSIX functions and definitions
vaintroub Sep 9, 2023
5ade153
Windows port - declaration of TLS variables for MSVC
vaintroub Sep 9, 2023
1fbfaa0
Windows port - partial port of Concurrency Kit
vaintroub Sep 9, 2023
fae8c83
Windows port - build or find LuaJit library on Windows
vaintroub Sep 9, 2023
5a4c2f7
Windows port - CMake option WITH_LIBMARIADB, build with libmariadb fr…
vaintroub Sep 9, 2023
dfee295
Windows port - fix for CK_CC_CACHELINE with MSVC.
vaintroub Sep 9, 2023
4b20112
Windows port - MSVC preprocessor fixes
vaintroub Sep 9, 2023
bb8dbd6
Windows port - aligned memory allocation
vaintroub Sep 9, 2023
e14e78b
Windows port - implement nanosleep()/usleep()
vaintroub Sep 9, 2023
d902b87
Windows port - implement sb_getpagesize()
vaintroub Sep 9, 2023
09d499b
Windows port - fileio support for O_SYNC and O_DIRECT
vaintroub Sep 9, 2023
aff8435
Windows port - mysql driver to use named pipe on Windows, if --socket…
vaintroub Sep 9, 2023
7a57f1c
Windows port - luajit search directories
vaintroub Sep 9, 2023
fe0c652
Windows port - export symbols from sysbench executable
vaintroub Sep 9, 2023
4127b30
Windows port - shared library extension is ".dll"
vaintroub Sep 9, 2023
9909d75
Windows port - use 'size_t' instead of 'long' to fill io buffer
vaintroub Sep 9, 2023
925ae42
Windows port - fix warnings about function that is declared but not d…
vaintroub Sep 9, 2023
026529a
Windows port - fix warnings about potential NULL pointer derefence
vaintroub Sep 9, 2023
615d32b
Windows port - fix conversion/truncation warnings.
vaintroub Sep 9, 2023
289a611
Windows port - prevent aggressive compiler optimizations in cpu_execu…
vaintroub Sep 9, 2023
d1a1540
Windows port - Windows build/packaging fixes
vaintroub Sep 9, 2023
eef167b
Windows port - instruct C runtime to use its maximum open file handles.
vaintroub Sep 9, 2023
fd4a841
Windows port - use timeBeginPeriod() for better Sleep() accuracy.
vaintroub Sep 9, 2023
57ac23e
Windows port - adjust .gitignore
vaintroub Sep 9, 2023
9426021
Windows port - build and test on CI (github workflows)
vaintroub Sep 9, 2023
b6dfe98
Fix "Unknown extra flags value 5" when --file-extra-flags=sync,direct
vaintroub Sep 9, 2023
4cf9338
Fix diff in a single test
vaintroub Sep 9, 2023
66dc3c0
Fix clang-16 warning about old(pre-ANSI C) syntax.
vaintroub Sep 9, 2023
7a7da4f
CI : Unify cmake-based build, test, and packagin on Github Actions
vaintroub Sep 9, 2023
6d18436
Update README.md with instructions on how to build with CMake
vaintroub Sep 9, 2023
5f337bd
Update libmariadb git tag, remove older workarounds
vaintroub Feb 18, 2024
b691a7d
Fixes for new mingw and clang.
vaintroub Feb 18, 2024
ddecca9
Windows : export one more symbol from sysbench executable, for sysben…
vaintroub Feb 18, 2024
5cfaa10
Test - Workaround Windows named pipe bugs in MySQL.
vaintroub Feb 18, 2024
1edbba5
mysql_ssl_set replaced with mysql_options
Jan 30, 2024
22b39a0
Merge branch 'master' into master
vaintroub Jul 29, 2024
cad7037
Disable CI on macOS for now
vaintroub Jul 4, 2024
71a02ba
New MariaDB Connector/C
vaintroub Aug 7, 2024
80de759
Disable SSL in new libmariadb unless --mysql-ssl=on
vaintroub Nov 21, 2024
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
284 changes: 284 additions & 0 deletions .github/workflows/cmake-single-os.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
name: CMake-reusable-workflow

on:
workflow_call:
inputs:
os:
required: true
type: string

jobs:
build:
runs-on: ${{ inputs.os }}
name: Build
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v3


# On Windows, use vcpkg to build, as pgsql driver on build box is bad (crashes during tests)
- name: vcpkg_cache(Windows)
uses: actions/cache@v3
if: runner.os == 'Windows'
id: vcpkg_cache
with:
path: ~\AppData\Local\vcpkg
key: ${{ runner.os }}-vcpkg-libpq-zlib

- name: install build preprequisites (macOS)
if: runner.os == 'macOS'
run : |
HOMEBREW_NO_AUTO_UPDATE=1 brew install mysql-client libpq ninja
brew link --force mysql-client

- name: install build prerequisites (Windows)
if: runner.os == 'Windows'
run: |
vcpkg install libpq zlib --triplet=x64-windows-release

- name: install build prerequisites (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install ninja-build

- name: configure
env:
CMAKE_VCPKG_PARAMS: ${{ runner.os == 'Windows' && '-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-release' || ' ' }}
run: cmake . -DWITH_PGSQL=1 -DCMAKE_COMPILE_WARNING_AS_ERROR=1 ${{ env.CMAKE_VCPKG_PARAMS }}

- name: build package
run: cmake --build . --config Release --target package -j

- name: setup mysql for unit tests
if: runner.os != 'Windows'
uses: shogo82148/actions-setup-mysql@v1
with:
my-cnf: |
innodb_redo_log_capacity=4G
innodb_buffer_pool_size=4G
skip-log-bin

- name: unit test
if: runner.os != 'Windows'
run: |
mysql -uroot -e "create database sbtest"
SBTEST_MYSQL_ARGS=" --mysql-user=root --mysql-host=127.0.0.1 " cmake --build . --config Release --target test

- name: upload package(Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.os }}-package
path: ./*.zip

- name: test_install
run: |
cmake --install . --config Release --prefix install_dir

- name: Archive build
uses: actions/upload-artifact@v3
with:
name: build-${{ inputs.os }}
retention-days: 1
path: |
install_dir

# Tests Ninja generator, non-standard compiler (clang on Linux and gcc on Windows and macOS)
build-ninja:
runs-on: ${{ inputs.os }}
name: Build-ninja
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v3
- name: install ninja (macOS)
if: runner.os == 'macOS'
run : |
HOMEBREW_NO_AUTO_UPDATE=1 brew install ninja mysql-client libpq
brew link --force mysql-client

- name: install ninja (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install ninja-build

- name: install ninja (Windows)
if: runner.os == 'Windows'
run: |
choco install ninja

- name: configure and build
run: |
mkdir build
cmake -S . -B build -GNinja -DCMAKE_COMPILE_WARNING_AS_ERROR=1 -DCMAKE_BUILD_TYPE=Debug -DWITH_PGSQL=1 -DCMAKE_C_COMPILER=${{ runner.os == 'Linux' && 'clang' || 'gcc' }}
cmake --build build

- uses: seanmiddleditch/gha-setup-vsdevenv@master
if: runner.os == 'Windows'

- name: build with clang-cl
if: runner.os == 'Windows'
run: |
choco install llvm
mkdir clang_build
cmake -S . -B clang_build -GNinja -DCMAKE_C_COMPILER=clang-cl -DCMAKE_COMPILE_WARNING_AS_ERROR=1 -DCMAKE_BUILD_TYPE=Debug -DWITH_PGSQL=1
cmake --build clang_build

test-asan:
runs-on: ${{ inputs.os }}
# Linux is excluded, due to buggy ASAN ubuntu
if: ${{ !contains(inputs.os,'windows') }}
name: test-asan
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v3
- name: install client libs (macOS)
if: runner.os == 'macOS'
run : |
HOMEBREW_NO_AUTO_UPDATE=1 brew install mysql-client
brew link --force mysql-client
- name: compile
run: |
mkdir asan_build
cmake -S . -B asan_build -DCMAKE_BUILD_TYPE=Debug -DWITH_ASAN=1
cmake --build asan_build --config Debug
cmake --install asan_build --config Debug --prefix install_dir

- name: install mysql
uses: shogo82148/actions-setup-mysql@v1
env:
TMPDIR: ${{ runner.temp }}
TMP: ${{ runner.temp }}
TEMP: ${{ runner.temp }}
with:
my-cnf: |
skip-log-bin

- name: update env (Windows)
if: runner.os == 'Windows'
run: |
echo "$pwd\install_dir\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: update env (non-Windows)
if: runner.os != 'Windows'
run: |
echo "$PWD/install_dir/bin" >> $GITHUB_PATH
echo "LUA_PATH=$PWD/install_dir/share/sysbench/?.lua" >> $GITHUB_ENV
- name: smoke test
run: |
mysql -uroot --host=127.0.0.1 -e "create database sbtest"
sysbench --version
sysbench --help
sysbench oltp_read_write --mysql-user=root --mysql-host=127.0.0.1 prepare
sysbench oltp_read_write --mysql-user=root --mysql-host=127.0.0.1 run --threads=2 --histogram
sysbench oltp_read_write --mysql-user=root --mysql-host=127.0.0.1 cleanup
sysbench cpu run --threads=2
sysbench fileio --file-test-mode=seqrewr prepare
sysbench fileio --file-test-mode=seqrewr run
sysbench fileio --file-test-mode=seqrewr cleanup
sysbench mutex run --threads=2

test-oltp:
strategy:
fail-fast: false
matrix:
db: [mariadb, mysql, postgres]
needs: build
runs-on: ${{ inputs.os }}
#if: contains(inputs.os,'windows')
name: test-${{matrix.db}}
env:
COMMON_SYSBENCH_PARAMS: ${{ matrix.db == 'postgres' && '--db-driver=pgsql --pgsql-password=sbtest' || '--mysql-user=root'}} --mysql-socket=${{ contains(inputs.os,'windows') && 'mysql.sock' || '/tmp/mysql.sock' }} --time=30 --table-size=1000000 --report-interval=1 --thread-init-timeout=300 --histogram

steps:
- name: Download build
uses: actions/download-artifact@v3
with:
name: build-${{ inputs.os }}

- name: test fixups
shell: bash
if: runner.os != 'Windows'
run: |
ls -l bin
chmod +x bin/sysbench

- name: install client drivers (macOS)
if: runner.os == 'macOS'
run : |
HOMEBREW_NO_AUTO_UPDATE=1 brew install mysql-client libpq
brew link --force mysql-client

- name: update environment (Windows)
if: runner.os == 'Windows'
run: |
echo "$pwd\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
cat $env:GITHUB_PATH

- name: update environment (non-Windows)
if: runner.os != 'Windows'
run: |
echo "$PWD/bin" >> $GITHUB_PATH
cat $GITHUB_PATH
echo "LUA_PATH=$PWD/share/sysbench/?.lua" >> $GITHUB_ENV

- name: actions-setup-pgsql
if: matrix.db =='postgres'
uses: ikalnytskyi/action-setup-postgres@v4
with:
username: sbtest
password: sbtest
database: sbtest

- name: actions-setup-mysql
if: matrix.db != 'postgres'
uses: shogo82148/actions-setup-mysql@v1
env: # set temp directory, so that datadir ends up on fast disk
TMPDIR: ${{ runner.temp }}
TMP: ${{ runner.temp }}
TEMP: ${{ runner.temp }}
with:
distribution: ${{ matrix.db }}
my-cnf: |
${{ matrix.db == 'mysql' && 'innodb_redo_log_capacity' || 'innodb_log_file_size' }}=4G
innodb_buffer_pool_size=512MB
max_allowed_packet=16MB
skip-log-bin
loose-enable-named-pipe
socket=${{ runner.os == 'Windows' && 'mysql.sock' || '/tmp/mysql.sock' }}
max_connections=1000
innodb_max_dirty_pages_pct_lwm=10

- name: create database sbtest
if: matrix.db != 'postgres'
run: |
mysql -uroot --host=127.0.0.1 --port=3306 -e "create database sbtest"

- name: oltp_read_write prepare
run: sysbench oltp_read_write ${{ env.COMMON_SYSBENCH_PARAMS }} prepare
- name: oltp_point_select run
run: sysbench oltp_point_select ${{ env.COMMON_SYSBENCH_PARAMS }} --threads=20 run
- name: oltp_read_write
run: sysbench oltp_read_write ${{ env.COMMON_SYSBENCH_PARAMS }} --threads=20 run
- name: oltp_read_only
run: sysbench oltp_read_only ${{ env.COMMON_SYSBENCH_PARAMS }} --threads=20 run
- name: oltp_update_index run (1 thread)
run: sysbench oltp_update_index ${{ env.COMMON_SYSBENCH_PARAMS }} --threads=1 run
- name: oltp_update_index run (20 threads)
run: sysbench oltp_update_index ${{ env.COMMON_SYSBENCH_PARAMS }} --threads=20 run
- name: oltp_read_write cleanup
run: sysbench oltp_update_index ${{ env.COMMON_SYSBENCH_PARAMS }} cleanup


# The below fileio test help estimate whether DBMS has "relaxed" durability, in other words cheats on
#
# oltp_update_index test with 1 user can't have qps much higher than sequential rewrite test with fdatasync
# if it does, durability is mostly likely "relaxed"
- name: fileio seqrewr prepare
run: sysbench fileio --file-block-size=4096 --file-test-mode=seqrewr --file-num=1 prepare
- name: fileio seqrewr run fdatasync
if: runner.os != 'macOS'
run: sysbench fileio --file-block-size=4096 --file-test-mode=seqrewr --file-fsync-mode=fdatasync --file-fsync-all=on --file-num=1 --report-interval=1 --time=20 --histogram run
- name: fileio seqrewr run fsync
run: sysbench fileio --file-block-size=4096 --file-test-mode=seqrewr --file-fsync-mode=fsync --file-fsync-all=on --file-num=1 --report-interval=1 --time=20 --histogram run
14 changes: 14 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CMake
on: [push, pull_request]


jobs:
CI:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
uses: ./.github/workflows/cmake-single-os.yml
with:
os: ${{ matrix.os}}

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,8 @@ prime
stage
*.snap
/snap/snapcraft.yaml
/build*
.vscode
*.bak
src/libmariadb-src
*.pdb
39 changes: 39 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
if(WIN32)
# new-ish cmake features, install(runtime_dependencies etc)
cmake_minimum_required(VERSION 3.21..3.26)
else()
cmake_minimum_required(VERSION 3.12..3.26)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
if(APPLE)
# Add homebrew search paths on Mac
foreach(pkg openssl mysql-client mariadb-connector-c libpq)
set(pkgpath /usr/local/opt/${pkg})
if(EXISTS ${pkgpath})
list(APPEND CMAKE_PREFIX_PATH ${pkg})
endif()
endforeach()
endif()

project(
sysbench
VERSION "1.1.0"
LANGUAGES C)

# Set default build type, if none is given
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(default_build_type Release)
message(
STATUS
"Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE
"${default_build_type}"
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
include(compile_flags)
include(sanitizer)
add_subdirectory(src)
Loading