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 45 commits into
base: master
Choose a base branch
from
Open

Commits on Jul 27, 2023

  1. Configuration menu
    Copy the full SHA
    2b20db3 View commit details
    Browse the repository at this point in the history

Commits on Sep 9, 2023

  1. sysbench cmake port

    With this patch, sysbench can be built (on Linux, macOS, or FreeBSD at least)
    using cmake.
    
    Packaging using cpack works, too.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    e876cef View commit details
    Browse the repository at this point in the history
  2. CMake port - Test CMake build on CI (Ubuntu)

    Add just basic build and unit test, nothing fancy
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    aeb1561 View commit details
    Browse the repository at this point in the history
  3. CMake port - build and test on macOS

    This build actually runs some 30 seconds OLTP smoke
    tests against MySQL 8.0
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    d32fec9 View commit details
    Browse the repository at this point in the history
  4. Fix GCC 11.3 warning (stringop-truncation)

    __builtin_strncpy specified bound 4096 equals destination size
    [-Werror=stringop-truncation]
    
    strncpy wants output buffer to have place for terminating 0
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    f1e1297 View commit details
    Browse the repository at this point in the history
  5. Fix GCC 11.3 warning (-Werror=maybe-uninitialized)

    sysbench/src/tests/memory/sb_memory.c:199:18: error: ‘buffer’ may be used uninitialized
    in this function [-Werror=maybe-uninitialized]
      199 |       buffers[i] = buffer;
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    d240128 View commit details
    Browse the repository at this point in the history
  6. Fix AppleClang 14 warning - use C11 _Static_assert for compile time a…

    …ssert.
    
    This fixes warning about unused typedef - SB_ATTRIBUTE_UNUSED does not help
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    fd4241c View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    1e21765 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    3559b2f View commit details
    Browse the repository at this point in the history
  9. Windows port - add pthreads library from Lockless Inc

    The original URL is https://locklessinc.com/downloads/winpthreads.h
    
    mingw64 winpthreads is based on this library.
    Compared to other pthread implementations, this one does support pthread cancellation,
    which turns out to be important for sysbench.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    9c9198b View commit details
    Browse the repository at this point in the history
  10. Windows port - port several POSIX functions and definitions

    Functions used in sysbench were ported :
    alarm() ,clock_gettime(), basename(), pread(), pwrite(), fdatasync()
    
    It also contains an open() portability wrapper that supports O_SYNC and O_DIRECT
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    3dcd6af View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    5ade153 View commit details
    Browse the repository at this point in the history
  12. Windows port - partial port of Concurrency Kit

    Port some bits of ConcurrencyKit used by sysbench to MSVC compiler.
    Use native compiler intrinsics for ck_pr_{inc/dec/store} family functions.
    
    Copy ck_ring code from concurrency kit, as it is not possible to use
    the original header.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    1fbfaa0 View commit details
    Browse the repository at this point in the history
  13. Windows port - build or find LuaJit library on Windows

    Use instructions from Luajit documentation to build the library.
    Allow FindLuajit.cmake to find luajit if it is built by vcpkg, if system
    luajit library is requested.
    
    Also fix BuildLuajit.cmake to work with Ninja
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    fae8c83 View commit details
    Browse the repository at this point in the history
  14. Windows port - CMake option WITH_LIBMARIADB, build with libmariadb fr…

    …om source
    
    As Windows does not have system libraries for MySQL or MariaDB client,
    for the sake of simplicity, allow to build libmariadb as external project
    during sysbench build.
    
    That is, if WITH_LIBMARIADB is defined, libmariadb will be built from
    source https://github.com/mariadb-corporation/mariadb-connector-c,
    courtesy of CMake's ExternalProject_Add
    
    libmariadb is chosen because it is easy to build standalone
    (as opposed to libmysqlclient) and works well with named pipes,
    which libmysqlclient has problems with.
    
    WITH_LIBMARIADB defaults to ON on Windows, as to OFF elsewhere.
    It is built as shared library on Windows, as static elsewhere( to
    avoid linker warning about mix of C runtimes)
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    5a4c2f7 View commit details
    Browse the repository at this point in the history
  15. Windows port - fix for CK_CC_CACHELINE with MSVC.

    MSVC does not allow to use declspec(align) after the variable definition.
    So CK_CC_CACHELINE is moved before variable declaration.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    dfee295 View commit details
    Browse the repository at this point in the history
  16. Windows port - MSVC preprocessor fixes

    - Do not use #ifdef within macro
    - Use do{}while(0) instead of unportable GCC braces in xfree() macro
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    4b20112 View commit details
    Browse the repository at this point in the history
  17. Windows port - aligned memory allocation

    Use _aligned_malloc() for aligned allocation, and _aligned_free() for
    deallocation.
    
    Add sb_free_memaligned() instead of free() where appropriate.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    bb8dbd6 View commit details
    Browse the repository at this point in the history
  18. Windows port - implement nanosleep()/usleep()

    Implement cancellable sleeps.
    "Cancellable" property is important here, otherwise sysbench is going
    to hang, when used with --report-interval
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    e14e78b View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    d902b87 View commit details
    Browse the repository at this point in the history
  20. Windows port - fileio support for O_SYNC and O_DIRECT

    Internally, those are translated to FILE_FLAG_NO_BUFFERING
    and FILE_FLAG_WRITE_THROUGH
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    09d499b View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    aff8435 View commit details
    Browse the repository at this point in the history
  22. Windows port - luajit search directories

    Emulate search path logic on Windows from luajit code
    Search paths always relative to current executable, which is great
    for ZIP type distribution.
    
    Do not use Unixy path with "/usr/" etc on Windows.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    7a57f1c View commit details
    Browse the repository at this point in the history
  23. Windows port - export symbols from sysbench executable

    The list of symbols is extracted from ffi.cdef sections in internal
    lua files into "module definition file" sysbench.def, which is used by
    the linker to export symbols.
    
    Alternative to that could be WINDOWS_EXPORT_ALL_SYMBOLS in recent cmake,
    but that does not work with LTO/PGO, unfortunately.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    fe0c652 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    4127b30 View commit details
    Browse the repository at this point in the history
  25. Windows port - use 'size_t' instead of 'long' to fill io buffer

    long is 4 bytes , also on 64bit Windows, so that does not work as intended
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    9909d75 View commit details
    Browse the repository at this point in the history
  26. Windows port - fix warnings about function that is declared but not d…

    …efined.
    
    HAVE_MMAP was not ported so far, and sb_get_allocation_granularity() is
    only defined with HAVE_MMAP
    
    Also, sb_next_event() does not exist.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    925ae42 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    026529a View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    615d32b View commit details
    Browse the repository at this point in the history
  29. Windows port - prevent aggressive compiler optimizations in cpu_execu…

    …te_event()
    
    MSVC compiler understands that the function has no side-effects,
    and optimizes the function away, completely.
    
    Also, clang-16 complains about set-but-unused variable.
    
    To fix both, assign calculated prime count in cpu_execute_event()
    to a thread local variable, at the end of function
    
    This way, cpu_execute_event() function has _some_ side-effect and
    will not be optimized away.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    289a611 View commit details
    Browse the repository at this point in the history
  30. Windows port - Windows build/packaging fixes

    - Copy luajit and libmariadb DLLs next to sysbench
    executable, during build. This allows to test without packaging
    
    - Do not install Cram based test suite on Windows, it does not work
    
    - Install DLLs that sysbench depends on next to executable
      (luajit DLL, libmariadb, postgres client, and their dependencies
      such as openssl or zlib. Also install VC runtime DLLs, and
      ASAN runtime DLL, when built WITH_ASAN=1
    
    - Default to ZIP for CPack.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    d1a1540 View commit details
    Browse the repository at this point in the history
  31. Windows port - instruct C runtime to use its maximum open file handles.

    LuaJit opens source files using C runtime functions, and in sysbench
    it does so simultaneously in different threads.
    
    To avoid "Too many open files" error, use _setmaxstdio() with maximum
    possible value for open handles, which is 8K
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    eef167b View commit details
    Browse the repository at this point in the history
  32. Windows port - use timeBeginPeriod() for better Sleep() accuracy.

    Without this call, Sleep(1) can take as much as 14-15ms
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    fd4a841 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    57ac23e View commit details
    Browse the repository at this point in the history
  34. Windows port - build and test on CI (github workflows)

    The build utilizes vcpkg package manager in order to build with
    Postgres driver.
    
    A ZIP sysbench package is built and stored as build artifact,
    so if desired, someone can use extract it, and produce official binary
    release.
    
    The tests are smoke OLTP tests that run against installed MariaDB and
    Postgres.
    
    As Cram unit test does not work on Windows, so this is the only test option
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    9426021 View commit details
    Browse the repository at this point in the history
  35. Fix "Unknown extra flags value 5" when --file-extra-flags=sync,direct

    Combining flags in file-extra-flags in fileio should be allowed
    O_SYNC|O_DIRECT, or O_DSYNC|O_DIRECT is actually reasonable combination.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    b6dfe98 View commit details
    Browse the repository at this point in the history
  36. Fix diff in a single test

    On CI, the error code of the message "Unknown MySQL server host
    'non-existing' "  is -3,  not 0.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    4cf9338 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    66dc3c0 View commit details
    Browse the repository at this point in the history
  38. CI : Unify cmake-based build, test, and packagin on Github Actions

    Remove repetive copy-and-paste workflows, create a reusable one.
    
    Now the build and test, and ASAN, and building with non-default compilers
    runs on all supported (by CI) OSes (Windows, Linux, and macOS, as much
    uniform as possible.
    
    "make test" is not very portable in sysbench
    It does not work on Windows, does not work with either MariaDB
    client or server, does not work with recent poostgres
    
    Therefore on all combinations or OS(Windows, Linux, macOS)/database(MariaDB, MySQL, Postgres)
    some smoke tests (oltp) are also run.
    
    "make test" will run, where it is known to have worked before
    (non-Windows, server and client library are both recent MySQL)
    
    ASAN builds run on Windows and macOS. Due to a bug in ASAN on Ubuntu's gcc,
    google/sanitizers#1010 ,  we do not run it on
    ubuntu
    
    Ninja CMake generator is run on all OSes, and "alternative" compilers
    (clang on Linux, mingw64 gcc on Windows) are also tested.
    vaintroub committed Sep 9, 2023
    Configuration menu
    Copy the full SHA
    7a7da4f View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    6d18436 View commit details
    Browse the repository at this point in the history

Commits on Feb 19, 2024

  1. Update libmariadb git tag, remove older workarounds

    Also link MySQL-specific plugins statically.
    vaintroub committed Feb 19, 2024
    Configuration menu
    Copy the full SHA
    5f337bd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b691a7d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ddecca9 View commit details
    Browse the repository at this point in the history
  4. Test - Workaround Windows named pipe bugs in MySQL.

    Also disable Windows ASAN - something bad happened, it can't run on CI
    Reenable ASAN on Linux though
    vaintroub committed Feb 19, 2024
    Configuration menu
    Copy the full SHA
    5cfaa10 View commit details
    Browse the repository at this point in the history
  5. mysql_ssl_set replaced with mysql_options

    Michael Plugin authored and vaintroub committed Feb 19, 2024
    Configuration menu
    Copy the full SHA
    1edbba5 View commit details
    Browse the repository at this point in the history