From bbb0c8304a7a6a614a6c7e28d6e07984aac987bc Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 24 Dec 2023 18:16:38 +0300 Subject: [PATCH] DRAFT 624 - test GH Actions for Zig build --- .appveyor.yml | 179 ------- .github/workflows/cmake-build.yml | 113 ----- .github/workflows/zig-xbuild.yml | 34 ++ .travis.yml | 805 ------------------------------ build.zig | 504 +++++++++++++++++++ include/private/gc_priv.h | 11 +- 6 files changed, 544 insertions(+), 1102 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .github/workflows/cmake-build.yml create mode 100644 .github/workflows/zig-xbuild.yml delete mode 100644 .travis.yml create mode 100644 build.zig diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 6a1cd270b..000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,179 +0,0 @@ -version: 8.3.0-{build} - -image: -- Visual Studio 2019 - -environment: - STUDIO_VERSION_EDITION: Studio\2019\Community - CMAKE_CONFIG: Debug - TEST_TARGET: check - matrix: - - TARGET: cmake - CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -Dbuild_tests=ON -Denable_cplusplus=ON -Denable_gc_assertions=ON -Werror=deprecated -Dwithout_libatomic_ops=ON - - TARGET: cmake - CMAKE_OPTIONS: -Dbuild_tests=ON -Denable_cplusplus=ON -Denable_throw_bad_alloc_library=OFF -Denable_gc_assertions=ON -Denable_gc_debug=ON -Denable_threads=OFF - - TARGET: cmake - CFLAGS_EXTRA: -DNO_MSGBOX_ON_ERROR -DNO_MPROTECT_VDB -DGC_READ_ENV_FILE - CMAKE_CONFIG: Release - CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Release -Dbuild_tests=ON -Denable_cplusplus=ON -Denable_large_config=ON -Ddisable_gc_debug=ON -Denable_dynamic_pointer_mask=ON -Denable_rwlock=ON - - TARGET: cmake - CMAKE_CONFIG: Release - CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=MinSizeRel -Denable_parallel_mark=OFF - - TARGET: cmake - CMAKE_OPTIONS: -Denable_gc_assertions=ON -Denable_thread_local_alloc=OFF -Ddisable_single_obj_compilation=ON - - TARGET: cmake - CFLAGS_EXTRA: -DGC_DISABLE_INCREMENTAL - CMAKE_OPTIONS: -Denable_gc_assertions=ON -Denable_gcj_support=OFF -Denable_parallel_mark=OFF -Denable_thread_local_alloc=OFF - - TARGET: cmake - CMAKE_OPTIONS: -A Win32 -Dbuild_tests=ON -Denable_cplusplus=ON -Denable_gc_assertions=ON -Denable_large_config=ON - - TARGET: cmake - CMAKE_OPTIONS: -A ARM -Denable_cplusplus=ON -Denable_gc_assertions=ON - - TARGET: cmake - CMAKE_OPTIONS: -A ARM64 -DCMAKE_BUILD_TYPE=Release -Denable_cplusplus=ON - CMAKE_CONFIG: Release - - TARGET: nmake - ARCH: x86 - NMAKE_OPTIONS: enable_static=1 - - TARGET: nmake - ARCH: x64 - CFLAGS_EXTRA: /J - - TARGET: nmake - ARCH: x86 - NMAKE_OPTIONS: nodebug=1 - - TARGET: nmake - ARCH: x64 - NMAKE_OPTIONS: disable_threads=1 - - TARGET: djgpp-no-make - CFLAGS_EXTRA: -O3 -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DENABLE_DISCLAIM -DGC_ATOMIC_UNCOLLECTABLE -DGC_GCJ_SUPPORT - - TARGET: dmc - CFLAGS_EXTRA: -s -DNO_MSGBOX_ON_ERROR - - TARGET: mingw - - TARGET: mingw - CFLAGS_EXTRA: -D GC_THREADS -D THREAD_LOCAL_ALLOC -D PARALLEL_MARK -D GC_ASSERTIONS -D EMPTY_GETENV_RESULTS -D GC_GCJ_SUPPORT -D USE_MUNMAP -D LARGE_CONFIG -D NO_MSGBOX_ON_ERROR - TEST_TARGET: check cord/de - - TARGET: mingw - CFLAGS_EXTRA: -O3 -march=native -D GC_THREADS -D GC_GCJ_SUPPORT -D GC_TIME_LIMIT=10 -D WINXP_USE_PERF_COUNTER -D NO_MSGBOX_ON_ERROR -D NO_TEST_ENDTHREADEX - - TARGET: mingw-shared-no-make - CFLAGS_EXTRA: -D GC_THREADS -D GC_ASSERTIONS -D ENABLE_DISCLAIM -D GC_GCJ_SUPPORT -D GC_PREFER_MPROTECT_VDB -D GC_CALL=__stdcall -D GC_CALLBACK=__fastcall -D CONSOLE_LOG -D NO_MSGBOX_ON_ERROR -D USE_RWLOCK -D _WIN32_WINNT=0x0600 - - TARGET: wcc - WCC_SYSTEM: OS2 - CFLAGS_EXTRA: -DGC_ASSERTIONS - ENABLE_STATIC_OPT: "ENABLE_STATIC=1" - TEST_TARGET: check-deps - WCC_INC_SUBDIR: os2 - - TARGET: wcc - WCC_SYSTEM: MSWIN32 - CFLAGS_EXTRA: -DCONSOLE_LOG -DUSE_MMAP -DUSE_MUNMAP - WCC_INC_SUBDIR: nt - - TARGET: mingw-w64 - CFLAGS_EXTRA: -D NO_MSGBOX_ON_ERROR - - TARGET: mingw-w64 - CFLAGS_EXTRA: -D GC_THREADS -D THREAD_LOCAL_ALLOC -D PARALLEL_MARK -D GC_ASSERTIONS -D GC_GCJ_SUPPORT -D NO_RETRY_GET_THREAD_CONTEXT - - TARGET: cygwin - CONF_OPTIONS: --enable-cplusplus - CFLAGS_EXTRA: -D GCTEST_PRINT_VERBOSE - - TARGET: cygwin64 - CONF_OPTIONS: --disable-threads - CFLAGS_EXTRA: -std=c11 -D USE_WINALLOC - - TARGET: cygwin64 - CONF_OPTIONS: --enable-cplusplus - CFLAGS_EXTRA: -D GCTEST_PRINT_VERBOSE - - TARGET: cygwin - CONF_OPTIONS: --enable-cplusplus --disable-munmap --enable-gc-assertions --enable-redirect-malloc - - TARGET: cygwin64 - CFLAGS_EXTRA: -D GC_ALWAYS_MULTITHREADED -D LINT2 -D TEST_MANUAL_VDB - CONF_OPTIONS: --enable-cplusplus --enable-gc-assertions --enable-rwlock --disable-shared - -clone_depth: 50 - -install: -- cmd: git clone --depth=50 https://github.com/ivmai/libatomic_ops.git - -build_script: -- cmd: if [%TARGET%]==[cmake] ( - mkdir out && cd out - && cmake %CMAKE_OPTIONS% -Denable_werror=ON -DCFLAGS_EXTRA="%CFLAGS_EXTRA%" .. - && cmake --build . --config %CMAKE_CONFIG% --verbose --parallel ) -- cmd: if [%TARGET%]==[nmake] ( - "C:\Program Files (x86)\Microsoft Visual %STUDIO_VERSION_EDITION%\VC\Auxiliary\Build\vcvarsall.bat" %ARCH% - && nmake /f NT_MAKEFILE %NMAKE_OPTIONS% CFLAGS_EXTRA="/WX %CFLAGS_EXTRA%" ) -- cmd: if [%TARGET%]==[cygwin] ( - C:\cygwin\bin\bash -e -l -c - "cd /cygdrive/c/projects/bdwgc && ./autogen.sh - && ./configure %CONF_OPTIONS% --enable-werror && cat include/config.h - && make -j CFLAGS_EXTRA='%CFLAGS_EXTRA%'" ) -- cmd: if [%TARGET%]==[cygwin64] ( - C:\cygwin64\bin\bash -e -l -c - "cd /cygdrive/c/projects/bdwgc && ./autogen.sh - && ./configure %CONF_OPTIONS% --enable-werror && cat include/config.h - && make -j CFLAGS_EXTRA='%CFLAGS_EXTRA%'" ) -- cmd: if [%TARGET%]==[djgpp-no-make] ( - appveyor DownloadFile "https://github.com/andrewwutw/build-djgpp/releases/download/v3.4/djgpp-mingw-gcc1220-standalone.zip" - && 7z x -o.. djgpp-mingw-gcc1220-standalone.zip > nul - && ..\djgpp\setenv.bat - && gcc -I include -Werror -Wall -Wextra -Wpedantic %CFLAGS_EXTRA% -c extra/gc.c ) -- cmd: if [%TARGET%]==[dmc] ( - appveyor DownloadFile "http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm857c.zip" - && 7z x -o.. dm857c.zip > nul && set "path=%cd%\..\dm\bin;%path%" - && make -f digimars.mak CFLAGS_EXTRA="-wx %CFLAGS_EXTRA%" ) -- cmd: if [%TARGET%]==[mingw] ( - C:\MinGW\msys\1.0\bin\bash -e -l -c - "cd /c/projects/bdwgc - && make -j -f Makefile.direct CC=gcc CFLAGS_EXTRA='-Werror -Wall -Wextra -Wpedantic %CFLAGS_EXTRA%'" ) -- cmd: if [%TARGET%]==[mingw-shared-no-make] ( - C:\MinGW\msys\1.0\bin\bash -e -l -c - "cd /c/projects/bdwgc - && gcc -I include -D GC_BUILTIN_ATOMIC -D GC_DLL -Werror -Wall -Wextra -Wpedantic %CFLAGS_EXTRA% -shared -o gc.dll extra/gc.c" ) -- cmd: if [%TARGET%]==[mingw-w64] ( - C:\msys64\usr\bin\bash -e -l -c - "cd /c/projects/bdwgc - && make -j -f Makefile.direct CC=gcc CFLAGS_EXTRA='-Werror -Wall -Wextra -Wpedantic %CFLAGS_EXTRA%'" ) -- cmd: if [%TARGET%]==[wcc] ( - appveyor DownloadFile "https://github.com/open-watcom/open-watcom-v2/releases/download/2023-12-01-Build/ow-snapshot.tar.xz" - && 7z x ow-snapshot.tar.xz > nul && 7z x -o..\watcom ow-snapshot.tar > nul - && set "watcom=%cd%\..\watcom" && set "path=%cd%\..\watcom\binnt64" - && set "include=%cd%\..\watcom\h\%WCC_INC_SUBDIR%;%cd%\..\watcom\h" - && wmake -f WCC_MAKEFILE SYSTEM=%WCC_SYSTEM% %ENABLE_STATIC_OPT% CFLAGS_EXTRA="-we %CFLAGS_EXTRA%" ) - -test_script: -- cmd: if [%TARGET%]==[cmake] ( - ctest --build-config %CMAKE_CONFIG% --verbose --parallel 4 ) -- cmd: if [%TARGET%]==[nmake] ( - "C:\Program Files (x86)\Microsoft Visual %STUDIO_VERSION_EDITION%\VC\Auxiliary\Build\vcvarsall.bat" %ARCH% - && nmake /f NT_MAKEFILE %TEST_TARGET% %NMAKE_OPTIONS% CFLAGS_EXTRA="/WX %CFLAGS_EXTRA%" - && nmake /f NT_MAKEFILE clean ) -- cmd: if [%TARGET%]==[cygwin] ( - C:\cygwin\bin\bash -e -l -c - "cd /cygdrive/c/projects/bdwgc - && make -j check-without-test-driver CFLAGS_EXTRA='%CFLAGS_EXTRA%'" ) -- cmd: if [%TARGET%]==[cygwin64] ( - C:\cygwin64\bin\bash -e -l -c - "cd /cygdrive/c/projects/bdwgc - && make -j check-without-test-driver CFLAGS_EXTRA='%CFLAGS_EXTRA%'" ) -- cmd: if [%TARGET%]==[djgpp-no-make] ( - ..\djgpp\setenv.bat - && gcc -I include -Werror -Wall -Wextra -Wpedantic %CFLAGS_EXTRA% -o cordtest.exe cord/tests/cordtest.c cord/*.c gc.o - && gcc -I include -Werror -Wall -Wextra -Wpedantic %CFLAGS_EXTRA% -v -o gctest.exe tests/gctest.c gc.o ) -- cmd: if [%TARGET%]==[dmc] ( - set "path=%cd%\..\dm\bin;%path%" - && make -f digimars.mak %TEST_TARGET% CFLAGS_EXTRA="-wx %CFLAGS_EXTRA%" - && type gctest.gc.log cpptest.gc.log - && make -f digimars.mak clean ) -- cmd: if [%TARGET%]==[mingw] ( - C:\MinGW\msys\1.0\bin\bash -e -l -c - "cd /c/projects/bdwgc - && make -j -f Makefile.direct %TEST_TARGET% CC=gcc CURSES=-lgdi32 CFLAGS_EXTRA='-DGC_NOT_DLL -Werror -Wall -Wextra -Wpedantic %CFLAGS_EXTRA%'" ) -- cmd: if [%TARGET%]==[mingw-shared-no-make] ( - C:\MinGW\msys\1.0\bin\bash -e -l -c - "cd /c/projects/bdwgc - && gcc -I include -D GC_BUILTIN_ATOMIC -D GC_DLL -Werror -Wall -Wextra -Wpedantic %CFLAGS_EXTRA% -o gctest.exe tests/gctest.c gc.dll - && gctest.exe" ) -- cmd: if [%TARGET%]==[mingw-w64] ( - C:\msys64\usr\bin\bash -e -l -c - "cd /c/projects/bdwgc - && make -j -f Makefile.direct %TEST_TARGET% CC=gcc CFLAGS_EXTRA='-Werror -Wall -Wextra -Wpedantic %CFLAGS_EXTRA%'" ) -- cmd: if [%TARGET%]==[wcc] ( - set "watcom=%cd%\..\watcom" && set "beginlibpath=%cd%\..\watcom\binp\dll" - && set "path=%cd%\..\watcom\binnt64;%cd%\..\watcom\binnt" - && wmake -f WCC_MAKEFILE %TEST_TARGET% SYSTEM=%WCC_SYSTEM% %ENABLE_STATIC_OPT% CFLAGS_EXTRA="-we %CFLAGS_EXTRA%" - && wmake -f WCC_MAKEFILE clean ) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml deleted file mode 100644 index 3f1f07bb1..000000000 --- a/.github/workflows/cmake-build.yml +++ /dev/null @@ -1,113 +0,0 @@ -# This workflow is for CMake-based build/test running on multiple platforms. -name: cmake build - -on: [push, pull_request] - -jobs: - build: - name: ${{ matrix.os }} ${{ matrix.c_compiler }} thr:${{ matrix.enable_threads }} rwlock::${{ matrix.enable_rwlock }} redir:${{ matrix.redirect_malloc }} dll:${{ matrix.shared_libs }} cpp::${{ matrix.enable_cplusplus }} - runs-on: ${{ matrix.os }} - - strategy: - # Deliver the feedback for all matrix combinations. - fail-fast: false - - matrix: - os: [ macos-latest, ubuntu-latest, windows-latest ] - c_compiler: [ cl, clang, gcc ] - cxx_compiler: [ cl, clang++, g++ ] - enable_cplusplus: [ off, on ] - build_type: [ Release ] - disable_gc_debug: [ off ] - gc_assertions: [ on ] - large_config: [ on ] - enable_threads: [ off, on ] - enable_rwlock: [ off, on ] - redirect_malloc: [ off, on ] - shared_libs: [ off, on ] - exclude: - - os: macos-latest - c_compiler: cl - - os: macos-latest - c_compiler: gcc - - os: ubuntu-latest - c_compiler: cl - - enable_threads: off - enable_rwlock: on - - c_compiler: cl - cxx_compiler: clang++ - - c_compiler: cl - cxx_compiler: g++ - - c_compiler: clang - cxx_compiler: cl - - c_compiler: clang - cxx_compiler: g++ - - c_compiler: gcc - cxx_compiler: cl - - c_compiler: gcc - cxx_compiler: clang++ - - os: macos-latest - enable_cplusplus: off - - os: ubuntu-latest - enable_cplusplus: off - - os: windows-latest - c_compiler: cl - enable_cplusplus: off - - os: windows-latest # TODO: replacement operator cannot be inline - c_compiler: clang - enable_cplusplus: on - - os: windows-latest - c_compiler: gcc - enable_cplusplus: off - - os: windows-latest # TODO: support dependency on libatomic_ops - c_compiler: cl - enable_threads: on - include: - - os: windows-latest - c_compiler: gcc - cmake_generator_opt: '-G "Unix Makefiles"' - - os: windows-latest - c_compiler: clang - cmake_generator_opt: '-G "Unix Makefiles"' - - steps: - - uses: actions/checkout@v4 - - - name: Set reusable strings - # Turn repeated input strings into step outputs. - id: strings - shell: bash - run: | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - - name: Configure CMake - # Configure CMake in a 'build' subdirectory. - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - ${{ matrix.cmake_generator_opt }} - -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -Dbuild_tests=ON - -Ddisable_gc_debug=${{ matrix.disable_gc_debug }} - -Denable_cplusplus=${{ matrix.enable_cplusplus }} - -Denable_gc_assertions=${{ matrix.gc_assertions }} - -Denable_large_config=${{ matrix.large_config }} - -Denable_redirect_malloc=${{ matrix.redirect_malloc }} - -Denable_rwlock=${{ matrix.enable_rwlock }} - -Denable_threads=${{ matrix.enable_threads }} - -Denable_werror=ON - -Werror=dev - -S ${{ github.workspace }} - - - name: Build - # Build the code with the given configuration. - run: > - cmake --build ${{ steps.strings.outputs.build-output-dir }} - --config ${{ matrix.build_type }} --verbose --parallel - - - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }} - # Execute tests defined by the CMake configuration. - run: ctest --build-config ${{ matrix.build_type }} --verbose --parallel 8 diff --git a/.github/workflows/zig-xbuild.yml b/.github/workflows/zig-xbuild.yml new file mode 100644 index 000000000..b695ce2ff --- /dev/null +++ b/.github/workflows/zig-xbuild.yml @@ -0,0 +1,34 @@ +# This workflow uses Zig and its excellent cross-compilation support to test +# compiling for multiple platforms. No tests are actually run since it would +# require emulation. +name: zig cross-compile + +on: [push, pull_request] + +jobs: + build: + name: ${{ matrix.ttriple }} thr:${{ matrix.enable_threads }} dll:${{ matrix.shared_libs }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + ttriple: [ armv7-unknown-linux-musleabihf, aarch64-linux-musl, riscv64-linux-musl, x86_64-linux-musl, wasm32-wasi, aarch64-macos-gnu, x86_64-macos-gnu, i686-pc-windows-gnu ] + #x86_64-linux-gnu.2.27, x86_64-windows-gnu ] + shared_libs: [ false, true ] + enable_threads: [ false, true ] + exclude: + - ttriple: wasm32-wasi + enable_threads: true + + # TODO: move from nightly to zig 0.12 when released. + steps: + - uses: actions/checkout@v4 + - name: "Install zig" + run: | + mkdir zig && curl https://ziglang.org/builds/zig-linux-x86_64-0.12.0-dev.1814+5c0d58b71.tar.xz | tar Jx --directory=zig --strip-components=1 + - name: Build + run: > + zig/zig build -Dtarget=${{ matrix.ttriple }} + -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} + -Denable_threads=${{ matrix.enable_threads }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0b9225c2f..000000000 --- a/.travis.yml +++ /dev/null @@ -1,805 +0,0 @@ -language: cpp -os: linux -dist: jammy - -jobs: - include: - - compiler: clang - env: - - CONF_OPTIONS="--enable-cplusplus" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CONF_OPTIONS="--enable-cplusplus" - - os: osx - env: - - CONF_OPTIONS="--enable-cplusplus" - - NO_CLONE_LIBATOMIC_OPS=true - - env: - - COVERITY_SCAN_BRANCH=1 - addons: - coverity_scan: - project: - name: ivmai/bdwgc - version: 8.3.0 - notification_email: ivmai@mail.ru - branch_pattern: master - build_command_prepend: "./configure --enable-cplusplus --disable-shared --enable-single-obj-compilation" - build_command: make -j check CFLAGS_EXTRA=-DLINT2 - - addons: - apt: - packages: - - lcov - compiler: gcc - env: - - CONF_OPTIONS="--enable-gcov --enable-single-obj-compilation --enable-cplusplus --disable-shared --enable-gc-assertions" - - CFLAGS_EXTRA="-D USE_CUSTOM_SPECIFIC" - - CC_FOR_CHECK=g++ - - MAKEFILE_TARGETS="all" - - MAKEFILE_TARGETS_CHECK="check" - - NO_CLONE_LIBATOMIC_OPS=true - - REPORT_COVERAGE=true - - TESTS_CUSTOM_RUN=true - - env: - - MAKEFILE_TARGETS="dist" - - os: osx - env: - - CSA_CHECK=true - - CFLAGS_EXTRA="-m32" - - compiler: clang - language: c - env: - - CSA_CHECK=true - - CFLAGS_EXTRA="-D ALL_INTERIOR_POINTERS -D CHECKSUMS -D DBG_HDRS_ALL -D DEBUG_THREADS -D ENABLE_TRACE -D GC_ALWAYS_MULTITHREADED -D GC_ASSERTIONS -D GC_ATOMIC_UNCOLLECTABLE -D GC_ENABLE_SUSPEND_THREAD -D GC_GCJ_SUPPORT -D GC_PRINT_BACK_HEIGHT -D GC_THREADS -D HANDLE_FORK -D JAVA_FINALIZATION -D KEEP_BACK_PTRS -D MAKE_BACK_GRAPH -D PARALLEL_MARK -D PRINT_BLACK_LIST -D THREAD_LOCAL_ALLOC -D USE_MMAP -D USE_MUNMAP" - - dist: xenial - env: - - CPPCHECK_ENABLE="--enable=unusedFunction -I libatomic_ops/src extra/gc.c tests/*.c" - - dist: xenial - env: - - CPPCHECK_ENABLE="--enable=unusedFunction --force -D GC_BUILTIN_ATOMIC *.cc cord/*.c cord/tests/*.c tests/*.c tests/*.cc" - - CPPCHECK_OUT_FILTER="Z" - - NO_CLONE_LIBATOMIC_OPS=true - - dist: xenial - env: - - CPPCHECK_ENABLE="-j4 --enable=information,performance,portability,style,warning --force -U GC_PRIVATE_H -I libatomic_ops/src a*.c b*.c c*.c d*.c f*.c g*.c h*.c m*.c" - - dist: xenial - env: - - CPPCHECK_ENABLE="-j4 --enable=information,performance,portability,style,warning --force -U GC_PRIVATE_H -I libatomic_ops/src n*.c o*.c p*.c r*.c s*.c t*.c w*.c" - - dist: xenial - env: - - CPPCHECK_ENABLE="-j4 --enable=information,performance,portability,style,warning --force -U GC_PRIVATE_H -I libatomic_ops/src *.cc cord/*.c cord/tests/*.c extra/AmigaOS.c extra/MacOS.c extra/msvc_dbg.c extra/symbian.cpp tests/*.c tests/*.cc tools/*.c" - - arch: arm64 - compiler: clang - - arch: arm64 - compiler: gcc - - arch: arm64 - compiler: clang - env: - - CFLAGS_EXTRA="-O3" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus --disable-shared" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: arm64 - compiler: gcc - env: - - CFLAGS_EXTRA="-O3 -D SIMULATE_LOST_SIGNALS -D TRACE_BUF" - - CONF_OPTIONS="--enable-cplusplus --disable-gcj-support" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - musl-tools - arch: arm64 - compiler: musl-gcc - dist: focal - language: c - env: - - CFLAGS_EXTRA="-O3 -D SOFT_VDB" - - CONF_OPTIONS="--enable-gc-assertions" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: arm64 - compiler: gcc - env: - - CONF_OPTIONS="--disable-threads" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: arm64 - addons: - apt: - packages: - - libatomic-ops-dev - compiler: gcc - env: - - CONF_OPTIONS="--with-libatomic-ops=yes --enable-gc-assertions --enable-cplusplus --disable-munmap" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: arm64 - compiler: clang - language: c - env: - - CFLAGS_EXTRA="-fsanitize=memory,undefined -fno-omit-frame-pointer" - - CONF_OPTIONS="--enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - TESTS_CUSTOM_RUN=true - - arch: arm64 - compiler: clang - env: - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=MinSizeRel -Dbuild_tests=ON -DBUILD_SHARED_LIBS=OFF -Denable_cplusplus=ON -Denable_gc_assertions=ON" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: arm64 - compiler: gcc - env: - - MAKEFILE_NAME=Makefile.direct - - MAKEFILE_TARGETS="check cord/de" - - arch: ppc64le - compiler: clang - - arch: ppc64le - compiler: gcc - env: - - CONF_OPTIONS="--disable-disclaim" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: ppc64le - compiler: clang - env: - - CFLAGS_EXTRA="-O3 -D _FORTIFY_SOURCE=2 -D FORCE_MPROTECT_BEFORE_MADVISE" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus --enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: ppc64le - compiler: gcc - env: - - CFLAGS_EXTRA="-O3 -D NO_MPROTECT_VDB" - - CONF_OPTIONS="--enable-cplusplus" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: ppc64le - compiler: clang - env: - - CFLAGS_EXTRA="-D CHECK_SOFT_VDB" - - CONF_OPTIONS="--enable-gc-assertions --enable-static --disable-thread-local-alloc" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: ppc64le - compiler: clang - language: c - env: - - CFLAGS_EXTRA="-fsanitize=memory,undefined -fno-omit-frame-pointer" - - CONF_OPTIONS="--disable-shared" - - NO_CLONE_LIBATOMIC_OPS=true - - TESTS_CUSTOM_RUN=true - - arch: ppc64le - compiler: clang - env: - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -Dbuild_tests=ON -Denable_cplusplus=ON -Denable_gc_assertions=ON" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: ppc64le - compiler: clang - env: - - MAKEFILE_NAME=Makefile.direct - - MAKEFILE_TARGETS="check cord/de" - - arch: s390x - compiler: clang - dist: focal - - arch: s390x - compiler: gcc - dist: focal - - addons: - apt: - packages: - - clang-12 - arch: s390x - compiler: clang-12 - dist: focal - env: - - CC=clang-12 - - CXX=clang++-12 - - CFLAGS_EXTRA="-O3 -flto -D _FORTIFY_SOURCE=2 -D NO_RETRY_SIGNALS" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus --enable-dynamic-pointer-mask" - - addons: - apt: - packages: - - g++-10 - arch: s390x - compiler: g++-10 - dist: focal - env: - - CC=gcc-10 - - CXX=g++-10 - - CFLAGS_EXTRA="-O3 -flto=auto -D _FORTIFY_SOURCE=2 -D PREFER_MMAP_PROT_NONE" - - CONF_OPTIONS="--enable-cplusplus --disable-shared" - - NO_CLONE_LIBATOMIC_OPS=true - - arch: s390x - compiler: gcc - dist: focal - env: - - MAKEFILE_NAME=Makefile.direct - - MAKEFILE_TARGETS="check cord/de" - - os: freebsd - compiler: gcc - env: - - CFLAGS_EXTRA="-O3 -D _FORTIFY_SOURCE=2" - - CONF_OPTIONS="--enable-cplusplus --enable-gc-assertions --enable-rwlock" - - MAKE_NPROC=8 - - NO_CLONE_LIBATOMIC_OPS=true - - os: freebsd - env: - - CONF_OPTIONS="--enable-cplusplus" - - MAKE_NPROC=8 - - NO_CLONE_LIBATOMIC_OPS=true - - os: freebsd - env: - - CONF_OPTIONS="--enable-gc-assertions --disable-shared" - - MAKE_NPROC=8 - - NO_CLONE_LIBATOMIC_OPS=true - - os: freebsd - env: - - CMAKE_BUILD_OPTIONS="--verbose" - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -Denable_cplusplus=ON" - - NO_CLONE_LIBATOMIC_OPS=true - - os: freebsd - compiler: clang - env: - - MAKEFILE_NAME=Makefile.direct - - MAKEFILE_TARGETS="check cord/de" - - MAKE_NPROC=8 - - compiler: gcc - env: - - CFLAGS_EXTRA="-O3 -march=native" - - CONF_OPTIONS="--enable-cplusplus" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CFLAGS_EXTRA="-D _FORTIFY_SOURCE=2" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus --enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - gcc-multilib - compiler: clang - env: - - CFLAGS_EXTRA="-m32 -funsigned-char -D _FORTIFY_SOURCE=2 -D NO_LONGLONG64" - - CONF_OPTIONS="--enable-gc-assertions" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - gcc-multilib - compiler: gcc - env: - - CFLAGS_EXTRA="-m32 -D _FORTIFY_SOURCE=2" - - CONF_OPTIONS="--enable-gc-assertions --enable-mmap --enable-rwlock" - - os: osx - env: - - CFLAGS_EXTRA="-m32 -D _FORTIFY_SOURCE=2" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CONF_OPTIONS="--disable-threads --enable-checksums --disable-munmap --enable-cplusplus" - - NO_CLONE_LIBATOMIC_OPS=true - - os: osx - env: - - CONF_OPTIONS="--disable-threads --enable-checksums --disable-handle-fork --disable-munmap --enable-gc-assertions --enable-large-config --enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: clang - env: - - CFLAGS_EXTRA="-D _FORTIFY_SOURCE=2 -D DBG_HDRS_ALL -D SHORT_DBG_HDRS" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus" - - NO_CLONE_LIBATOMIC_OPS=true - - os: osx - env: - - CFLAGS_EXTRA="-D DBG_HDRS_ALL -D SHORT_DBG_HDRS -D LINT2 -D PRINT_AND_CHECK_INT_LIST -D USE_GETSECTBYNAME" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus --enable-handle-fork=manual --disable-throw-bad-alloc-library" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CFLAGS_EXTRA="-D DEBUG_ADD_DEL_ROOTS -D DEBUG_THREADS -D GC_DEBUG -D GC_LOG_TO_FILE_ALWAYS" - - CONF_OPTIONS="--enable-cplusplus" - - compiler: gcc - env: - - CFLAGS_EXTRA="-D BSD_TIME -D DEFAULT_STACK_MAYBE_SMALL -D ENABLE_TRACE -D EMPTY_GETENV_RESULTS -D GC_ALWAYS_MULTITHREADED -D GC_NETBSD_THREADS_WORKAROUND -D CPPCHECK" - - CONF_OPTIONS="--enable-cplusplus --enable-gc-assertions" - - compiler: clang - env: - - CFLAGS_EXTRA="-march=native -D _FORTIFY_SOURCE=2 -D DEFAULT_VDB -D TEST_WITH_SYSTEM_MALLOC" - - CONF_OPTIONS="--without-libatomic-ops --enable-cplusplus --disable-handle-fork" - - addons: - apt: - packages: - - libatomic-ops-dev - compiler: gcc - env: - - CFLAGS_EXTRA="-D _FORTIFY_SOURCE=2 -D TEST_PAGES_EXECUTABLE" - - CONF_OPTIONS="--with-libatomic-ops=yes --enable-gc-assertions --enable-cplusplus --disable-throw-bad-alloc-library" - - NO_CLONE_LIBATOMIC_OPS=true - - os: osx - env: - - CFLAGS_EXTRA="-march=native -D _FORTIFY_SOURCE=2 -D AO_DISABLE_GCC_ATOMICS" - - CONF_OPTIONS="--without-libatomic-ops --enable-munmap --enable-cplusplus --enable-static" - - compiler: gcc - env: - - CONF_CFLAGS="-O3 -D _FORTIFY_SOURCE=2 -D AO_USE_PTHREAD_DEFS -D RANDOM_ONE_CPU_CORE" - - CONF_OPTIONS="--without-libatomic-ops --enable-gc-assertions --enable-cplusplus --enable-static" - - compiler: clang - env: - - CONF_CFLAGS="-D AO_USE_PTHREAD_DEFS" - - CONF_OPTIONS="--without-libatomic-ops" - - addons: - apt: - packages: - - libatomic-ops-dev - compiler: gcc - env: - - CONF_CFLAGS="-O3 -D AO_USE_PTHREAD_DEFS -D RANDOM_ONE_CPU_CORE" - - CONF_OPTIONS="--with-libatomic-ops=yes --enable-cplusplus" - - CFLAGS_EXTRA="-D GC_NO_FINALIZATION" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - libatomic-ops-dev - compiler: clang - env: - - CONF_CFLAGS="-O3 -D AO_USE_PTHREAD_DEFS -D RANDOM_ONE_CPU_CORE" - - CONF_OPTIONS="--with-libatomic-ops=yes --enable-gc-assertions --enable-cplusplus --disable-shared --enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CFLAGS_EXTRA="-funsigned-char -D _FORTIFY_SOURCE=2 -D DONT_ADD_BYTE_AT_END -D GC_TIME_LIMIT=3" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus" - - addons: - apt: - packages: - - gcc-multilib - compiler: gcc - env: - - CFLAGS_EXTRA="-m32 -D _FORTIFY_SOURCE=2 -D MARK_BIT_PER_OBJ -D USE_CUSTOM_SPECIFIC" - - CONF_OPTIONS="--enable-gc-assertions" - - compiler: clang - env: - - CFLAGS_EXTRA="-D MARK_BIT_PER_OBJ" - - CONF_OPTIONS="--enable-cplusplus --enable-rwlock --disable-shared" - - compiler: gcc - env: - - CFLAGS_EXTRA="-D _FORTIFY_SOURCE=2 -D NO_CLOCK -D POINTER_MASK=~0xf" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus --enable-handle-fork=manual" - - compiler: gcc - env: - - CFLAGS_EXTRA="-D PROC_VDB -D GC_NO_SYS_FAULT_H -D NO_INCREMENTAL -D DEBUG_DIRTY_BITS" - - CONF_OPTIONS="--enable-cplusplus --disable-docs" - - compiler: clang - env: - - CFLAGS_EXTRA="-D _FORTIFY_SOURCE=2 -D TEST_MANUAL_VDB" - - CONF_OPTIONS="--enable-gc-assertions --disable-parallel-mark" - - compiler: gcc - env: - - CFLAGS_EXTRA="-D TEST_MANUAL_VDB" - - CONF_OPTIONS="--enable-gc-assertions --disable-munmap" - - compiler: gcc - env: - - CFLAGS_EXTRA="-D _FORTIFY_SOURCE=2 -D FIND_LEAK -D SKIP_LEAKED_OBJECTS_PRINTING" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus" - - compiler: gcc - env: - - CFLAGS_EXTRA="-D SMALL_CONFIG -D NO_GETENV" - - CONF_OPTIONS="--enable-cplusplus" - - compiler: gcc - env: - - CFLAGS_EXTRA="-std=c11 -D _FORTIFY_SOURCE=2 -D GC_NO_SIGSETJMP" - - CONF_OPTIONS="--disable-threads --enable-gc-assertions" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: clang - env: - - CONF_OPTIONS="--disable-thread-local-alloc --enable-cplusplus --enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CFLAGS_EXTRA="-O3 -flto -D _FORTIFY_SOURCE=2 -D NO_MANUAL_VDB" - - CONF_OPTIONS="--disable-parallel-mark --disable-thread-local-alloc --enable-gc-assertions --enable-cplusplus" - - compiler: gcc - env: - - CONF_OPTIONS="--enable-gc-debug --enable-cplusplus" - - compiler: gcc - env: - - CONF_OPTIONS="--disable-gc-debug --enable-cplusplus" - - compiler: clang - env: - - CONF_OPTIONS="--enable-large-config --enable-cplusplus --disable-shared --enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - os: osx - env: - - CFLAGS_EXTRA="-D TEST_HANDLE_FORK" - - CONF_OPTIONS="--enable-cplusplus --disable-shared --enable-rwlock --enable-static" - - os: osx - env: - - CONF_OPTIONS="--enable-large-config --enable-cplusplus --disable-gc-debug --disable-handle-fork" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - gcc-multilib - compiler: gcc - env: - - CONF_OPTIONS="--enable-large-config --disable-munmap" - - CFLAGS_EXTRA="-m32" - - compiler: gcc - env: - - CONF_OPTIONS="--enable-large-config --enable-cplusplus --enable-gc-assertions --enable-static" - - CFLAGS_EXTRA="-D LINT2 -D NO_VDB_FOR_STATIC_ROOTS -D TEST_REUSE_SIG_SUSPEND" - - compiler: gcc - env: - - CONF_OPTIONS="--enable-large-config --enable-redirect-malloc --disable-threads" - - CFLAGS_EXTRA="-O3" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - gcc-multilib - compiler: clang - env: - - CONF_OPTIONS="--enable-redirect-malloc --enable-static --disable-threads" - - CFLAGS_EXTRA="-m32" - - NO_CLONE_LIBATOMIC_OPS=true - - os: osx - env: - - CONF_OPTIONS="--enable-redirect-malloc --enable-cplusplus --enable-static --disable-threads" - - CFLAGS_EXTRA="-m32" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CFLAGS_EXTRA="-D _FORTIFY_SOURCE=2" - - CONF_OPTIONS="--enable-redirect-malloc --enable-gc-debug --enable-cplusplus --enable-gc-assertions" - - compiler: clang - env: - - CONF_OPTIONS="--disable-threads --enable-cplusplus" - - CFLAGS_EXTRA="-O3 -march=native" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CONF_OPTIONS="--disable-static --disable-threads --enable-cplusplus" - - CFLAGS_EXTRA="-O3 -march=native -D GC_PREFER_MPROTECT_VDB" - - NO_CLONE_LIBATOMIC_OPS=true - - os: osx - env: - - CONF_OPTIONS="--disable-threads --enable-cplusplus" - - CFLAGS_EXTRA="-O3 -march=native" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: clang - env: - - CMAKE_OPTIONS="-Denable_cplusplus=ON -Denable_gc_assertions=ON" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - libatomic-ops-dev - compiler: clang - env: - - CMAKE_OPTIONS="-Denable_cplusplus=ON -Denable_munmap=OFF -Dwith_libatomic_ops=ON" - - compiler: gcc - env: - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -Denable_cplusplus=ON -Denable_large_config=ON" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -Denable_gc_debug=ON -Dwithout_libatomic_ops=ON" - - compiler: gcc - env: - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -Denable_threads=OFF" - - NO_CLONE_LIBATOMIC_OPS=true - - os: osx - env: - - CMAKE_BUILD_OPTIONS="--verbose" - - CMAKE_OPTIONS="-Denable_cplusplus=ON" - - NO_CLONE_LIBATOMIC_OPS=true - - os: osx - env: - - CMAKE_BUILD_OPTIONS="--verbose" - - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -Denable_cplusplus=ON -Denable_gc_assertions=ON -Denable_large_config=ON" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: clang - env: - - MAKEFILE_NAME=Makefile.direct - - MAKEFILE_TARGETS="check cord/de" - - compiler: gcc - env: - - MAKEFILE_NAME=Makefile.direct - - MAKEFILE_TARGETS="check cord/de" - - os: osx - env: - - MAKEFILE_NAME=Makefile.direct - - MAKEFILE_TARGETS="check cord/de" - - addons: - apt: - packages: - - musl-tools - compiler: musl-gcc - language: c - env: - - CONF_OPTIONS="--disable-parallel-mark --enable-gc-assertions" - - compiler: clang - dist: xenial - env: - - CFLAGS_EXTRA="-fsanitize=address -fno-common -fno-omit-frame-pointer" - - CONF_OPTIONS="--enable-cplusplus --enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - TESTS_CUSTOM_RUN=true - - addons: - apt: - packages: - - gcc-5 - sources: - - ubuntu-toolchain-r-test - compiler: gcc-5 - dist: xenial - language: c - env: - - CFLAGS_EXTRA="-fsanitize=address -O0" - - CONF_OPTIONS="--enable-gc-assertions" - - LDFLAGS="-fuse-ld=gold" - - os: osx - env: - - CFLAGS_EXTRA="-fsanitize=address -m32 -fno-omit-frame-pointer" - - CONF_OPTIONS="--disable-shared --enable-cplusplus" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: clang - language: c - env: - - CFLAGS_EXTRA="-fsanitize=memory -fno-omit-frame-pointer -std=gnu11" - - CONF_OPTIONS="--enable-static" - - TESTS_CUSTOM_RUN=true - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: clang - env: - - CFLAGS_EXTRA="-fsanitize=undefined -fno-common -fno-omit-frame-pointer" - - TESTS_CUSTOM_RUN=true - - CONF_OPTIONS="--enable-cplusplus --enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CFLAGS_EXTRA="-fsanitize=thread -fno-omit-frame-pointer" - - CONF_OPTIONS="--enable-gc-assertions" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - clang-12 - compiler: clang-12 - dist: focal - language: c - env: - - CFLAGS_EXTRA="-O3 -fsanitize=thread -fno-omit-frame-pointer" - - CONF_OPTIONS="--enable-static" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: clang - dist: focal - env: - - CFLAGS_EXTRA="-fsanitize=thread -D NO_INCREMENTAL -fno-omit-frame-pointer -D TEST_FORK_WITHOUT_ATFORK" - - CONF_OPTIONS="--enable-gc-assertions --enable-gc-debug --enable-handle-fork=manual --enable-large-config --without-libatomic-ops" - - compiler: clang - env: - - CFLAGS_EXTRA="-fsanitize=thread -D NO_INCREMENTAL -fno-omit-frame-pointer -D NTHREADS=0" - - CONF_OPTIONS="--disable-parallel-mark --disable-thread-local-alloc --disable-shared --enable-gc-assertions --without-libatomic-ops" - - compiler: clang - env: - - CFLAGS_EXTRA="-O3 -march=native -D NTHREADS=10" - - CONF_OPTIONS="--enable-cplusplus --enable-static --enable-single-obj-compilation" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - gcc-multilib - compiler: clang - env: - - CFLAGS_EXTRA="-m32 -D _FORTIFY_SOURCE=2 -D GC_DISABLE_INCREMENTAL -std=gnu11" - - CONF_OPTIONS="--enable-gc-assertions --enable-gc-debug" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CONF_OPTIONS="--enable-cplusplus --enable-gc-assertions --enable-static" - - CFLAGS_EXTRA="-D VERY_SMALL_CONFIG" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - gcc-multilib - compiler: gcc - env: - - CFLAGS_EXTRA="-m32 -O3 -std=gnu11" - - CONF_OPTIONS="--disable-shared --enable-static --enable-single-obj-compilation" - - NO_CLONE_LIBATOMIC_OPS=true - - addons: - apt: - packages: - - gcc-8 - - gcc-8-multilib - - gcc-multilib - compiler: gcc-8 - dist: focal - language: c - env: - - CFLAGS_EXTRA="-mx32 -march=native -D _FORTIFY_SOURCE=2" - - CONF_OPTIONS="--enable-large-config --enable-gc-assertions" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: clang - env: - - CFLAGS_EXTRA="-x c++" - - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus --enable-gc-debug --disable-shared" - - MAKEFILE_TARGETS="all" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: gcc - env: - - CC_FOR_CHECK=g++ - - CONF_OPTIONS="--enable-gc-assertions" - - MAKEFILE_TARGETS="all" - - MAKEFILE_TARGETS_CHECK="check" - - NO_CLONE_LIBATOMIC_OPS=true - - compiler: clang - env: - - CFLAGS_EXTRA="-O3 -Wall -Wextra -Werror -x c++" - - MAKEFILE_NAME=Makefile.direct - - MAKEFILE_TARGETS="cords" - - compiler: gcc - env: - - CC_FOR_CHECK=g++ - - CFLAGS_EXTRA="-O3 -Wall -Wextra -Werror -D TEST_MANUAL_VDB" - - MAKEFILE_NAME=Makefile.direct - - MAKEFILE_TARGETS="cords" - - MAKEFILE_TARGETS_CHECK="cord/de check" - - addons: - apt: - packages: - - g++-mingw-w64 - - gcc-mingw-w64 - compiler: x86_64-w64-mingw32-gcc - language: c - env: - - CXX=x86_64-w64-mingw32-g++ - - CONF_OPTIONS="--host=x86_64-w64-mingw32 --enable-cplusplus --disable-shared" - - MAKEFILE_TARGETS="all" - - addons: - apt: - packages: - - gcc-mingw-w64 - compiler: x86_64-w64-mingw32-gcc - language: c - env: - - CONF_OPTIONS="--host=x86_64-w64-mingw32 --enable-gc-assertions --enable-gc-debug --enable-threads=pthreads" - - MAKEFILE_TARGETS="all" - - addons: - apt: - packages: - - gcc-mingw-w64 - compiler: i686-w64-mingw32-gcc - language: c - env: - - CONF_OPTIONS="--host=i686-w64-mingw32" - - MAKEFILE_TARGETS="all" - - CFLAGS_EXTRA="-fno-omit-frame-pointer" - - dist: focal - env: - - MAKEFILE_TARGETS="distcheck" - - AUTOCONF_VER=2.71 - - AUTOMAKE_VER=1.16.5 - - LIBTOOL_VER=2.4.7 - - M4_VER=1.4.19 - - NO_CLONE_LIBATOMIC_OPS=true - -before_install: -- if [[ "$CPPCHECK_ENABLE" != "" ]]; then - CPPCHECK_VER=2.4.1; - git clone --depth=3 https://github.com/danmar/cppcheck.git - ~/cppcheck -b $CPPCHECK_VER; - make --directory ~/cppcheck -j8 CXXFLAGS="-O3 -march=native -D NDEBUG"; - fi -- if [[ "$AUTOCONF_VER" != "" || "$AUTOMAKE_VER" != "" - || "$LIBTOOL_VER" != "" || "$M4_VER" != "" ]]; then - GNUTOOLS_ROOT=`pwd`/../gnu-tools; - export PATH=$GNUTOOLS_ROOT/bin:$PATH; - GNU_DOWNLOAD_SITE=https://ftp.gnu.org/gnu; - fi -- if [[ "$M4_VER" != "" ]]; then - M4_XZ_URL=$GNU_DOWNLOAD_SITE/m4/m4-$M4_VER.tar.xz; - wget -O - $M4_XZ_URL | tar xf - --xz --directory ~; - (cd ~/m4-$M4_VER && ./configure --prefix=$GNUTOOLS_ROOT && make -j && make install); - fi -- if [[ "$LIBTOOL_VER" != "" ]]; then - LIBTOOL_XZ_URL=$GNU_DOWNLOAD_SITE/libtool/libtool-$LIBTOOL_VER.tar.xz; - wget -O - $LIBTOOL_XZ_URL | tar xf - --xz --directory ~; - (cd ~/libtool-$LIBTOOL_VER && ./configure --prefix=$GNUTOOLS_ROOT && make -j && make install); - fi -- if [[ "$AUTOCONF_VER" != "" ]]; then - AUTOCONF_XZ_URL=$GNU_DOWNLOAD_SITE/autoconf/autoconf-$AUTOCONF_VER.tar.xz; - wget -O - $AUTOCONF_XZ_URL | tar xf - --xz --directory ~; - (cd ~/autoconf-$AUTOCONF_VER && ./configure --prefix=$GNUTOOLS_ROOT && make -j && make install); - fi -- if [[ "$AUTOMAKE_VER" != "" ]]; then - AUTOMAKE_XZ_URL=$GNU_DOWNLOAD_SITE/automake/automake-$AUTOMAKE_VER.tar.xz; - wget -O - $AUTOMAKE_XZ_URL | tar xf - --xz --directory ~; - (cd ~/automake-$AUTOMAKE_VER && ./configure --prefix=$GNUTOOLS_ROOT && make -j && make install); - fi -- if [[ "$MAKEFILE_TARGETS" == *"dist"* ]]; then - autoconf --version; - automake --version; - m4 --version; - libtool --version || true; - fi -- if [[ "$CMAKE_OPTIONS" != "" ]]; then - cmake --version; - fi -- if [[ "$CONF_CFLAGS" == "" ]]; then CONF_CFLAGS="-g -O2"; fi -- if [[ "$MAKEFILE_NAME" == "" ]]; then MAKEFILE_NAME=Makefile; fi -- if [[ "$MAKEFILE_TARGETS" == "" ]]; then MAKEFILE_TARGETS="check"; fi - -install: -- if [[ "$NO_CLONE_LIBATOMIC_OPS" != true ]]; then - git clone --depth=50 https://github.com/ivmai/libatomic_ops.git; - fi -- if [[ "$CMAKE_OPTIONS" == "" ]]; then - ./autogen.sh; - fi -- if [[ "$GNUTOOLS_ROOT" != "" ]]; then mv $GNUTOOLS_ROOT $GNUTOOLS_ROOT-x; fi -- if [[ "$REPORT_COVERAGE" == true ]]; then gem install coveralls-lcov; fi - -script: -- if [[ "$CSA_CHECK" != true && "$CMAKE_OPTIONS" == "" - && "$CPPCHECK_ENABLE" == "" && "$MAKEFILE_NAME" != "Makefile.direct" - && "$COVERITY_SCAN_BRANCH" != 1 ]]; then - CFLAGS="$CONF_CFLAGS" ./configure $CONF_OPTIONS --enable-werror && - cat include/config.h; - fi -- if [[ "$CSA_CHECK" != true && "$CMAKE_OPTIONS" == "" - && "$CPPCHECK_ENABLE" == "" && "$COVERITY_SCAN_BRANCH" != 1 ]]; then - make -j$MAKE_NPROC -f $MAKEFILE_NAME $MAKEFILE_TARGETS - CFLAGS_EXTRA="$CFLAGS_EXTRA" LDFLAGS="$LDFLAGS"; - fi -- if [[ "$CMAKE_OPTIONS" != "" ]]; then - cmake $CMAKE_OPTIONS -Dbuild_tests=ON -Denable_werror=ON -Werror=dev . - && cmake --build . $CMAKE_BUILD_OPTIONS --parallel; - fi -- if [[ "$CMAKE_OPTIONS" != "" ]]; then - ctest --verbose --parallel 4; - fi -- if [[ "$CC_FOR_CHECK" != "" ]]; then - make -f $MAKEFILE_NAME $MAKEFILE_TARGETS_CHECK CC=$CC_FOR_CHECK - CFLAGS_EXTRA="$CFLAGS_EXTRA"; - fi -- if [ -f cordtest.log ]; then cat cordtest.log; fi -- if [ -f disclaim_bench.log ]; then cat disclaim_bench.log; fi -- if [ -f disclaimtest.log ]; then cat disclaimtest.log; fi -- if [ -f gctest.log ]; then cat gctest.log; fi -- if [ -f threadkeytest.log ]; then cat threadkeytest.log; fi -- if [ -f threadleaktest.log ]; then cat threadleaktest.log; fi -- if [ -f weakmaptest.log ]; then cat weakmaptest.log; fi -- if [[ "$CSA_CHECK" == true ]]; then - set -o pipefail; ${CC} --analyze -Xanalyzer -analyzer-output=text -Werror - -I include -I libatomic_ops/src $CFLAGS_EXTRA - *.c *.cc cord/*.c cord/tests/cordtest.c cord/tests/de.c extra/gc.c - extra/msvc_dbg.c extra/pcr_interface.c extra/real_malloc.c - tests/*.c tests/*.cc tools/*.c 2>&1 | tee clang-analyzer-output.log; - if [ -s clang-analyzer-output.log ]; then exit 1; fi; - fi -- if [[ "$CPPCHECK_ENABLE" != "" ]]; then - if [[ "$CPPCHECK_OUT_FILTER" == "" ]]; then CPPCHECK_OUT_FILTER="c "; fi; - set -o pipefail; ~/cppcheck/cppcheck --error-exitcode=2 - -U CORD_API -U GC_API -D __SIZEOF_POINTER__=8 -D CPPCHECK - -I include $CPPCHECK_ENABLE | - grep --line-buffered "$CPPCHECK_OUT_FILTER"; - fi -- if [[ "$TESTS_CUSTOM_RUN" == true ]]; then - ASAN_OPTIONS="detect_leaks=1" UBSAN_OPTIONS="halt_on_error=1" - make check-without-test-driver; - fi - -after_success: -- if [[ "$REPORT_COVERAGE" == true ]]; then - lcov --capture --base-directory . --directory . --output-file coverage.info; - lcov --remove coverage.info '/usr/*' 'cord/tests/*' 'libatomic_ops/*' 'tests/*' --output-file coverage.info; - lcov --list coverage.info; - coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage.info; - bash <(curl -s https://codecov.io/bash); - fi - -deploy: - provider: releases - edge: true - file: gc-*.tar.gz - file_glob: true - on: - condition: $MAKEFILE_TARGETS = distcheck - repo: ivmai/bdwgc - tags: true diff --git a/build.zig b/build.zig new file mode 100644 index 000000000..3d772848c --- /dev/null +++ b/build.zig @@ -0,0 +1,504 @@ +// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +// OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +// +// Permission is hereby granted to use or copy this program +// for any purpose, provided the above notices are retained on all copies. +// Permission to modify the code and to distribute modified code is granted, +// provided the above notices are retained, and a notice that the code was +// modified is included with the above copyright notice. + +// A script to build and test the collector using Zig build system. +// The script matches CMakeLists.txt as mach as possible. + +// TODO: this script assumes zig 0.12.0-dev.1814. + +const std = @import("std"); +const Path = std.Build.LazyPath; + +// TODO: specify PACKAGE_VERSION and LIB*_VER_INFO. + +// Compared to the CMake script, a lot more definitions and compiler options +// are hard-coded here, which is natural because build.zig is only built with +// the Zig build system and Zig ships with an embedded clang (as of zig 0.12). +// As a consequence, we do not have to support lots of different compilers. +// And, on the contrary, we know exactly what we get and thus we can align on +// clang's capabilities rather than having to discover compiler capabilities. +// Similarly, since Zig ships libc headers for many platforms, we can, with +// the knowledge of the platform, determine what capabilities should be +// enabled or not. + +pub fn build(b: *std.build.Builder) void { + const optimize = b.standardOptimizeOption(.{}); + const target = b.standardTargetOptions(.{}); + const t = target.toTarget(); + + const default_enable_threads = !t.isWasm(); // both emscripten and wasi + + // Customize build by passing "-D[=false]" in command line. + // TODO: support enable_cplusplus + const build_shared_libs = b.option(bool, "BUILD_SHARED_LIBS", + "Build shared libraries (otherwise static ones)") orelse true; + // TODO: support build_cord + const build_tests = b.option(bool, "build_tests", + "Build tests") orelse false; + // TODO: support enable_docs + const enable_threads = b.option(bool, "enable_threads", + "Support threads") orelse default_enable_threads; + const enable_parallel_mark = b.option(bool, "enable_parallel_mark", + "Parallelize marking and free list construction") orelse true; + const enable_thread_local_alloc = b.option(bool, + "enable_thread_local_alloc", + "Turn on thread-local allocation optimization") orelse true; + const enable_threads_discovery = b.option(bool, + "enable_threads_discovery", + "Enable threads discovery in GC") orelse true; + const enable_rwlock = b.option(bool, "enable_rwlock", + "Enable reader mode of the allocator lock") orelse false; + // TODO: support enable_throw_bad_alloc_library + const enable_gcj_support = b.option(bool, "enable_gcj_support", + "Support for gcj") orelse true; + const enable_sigrt_signals = b.option(bool, "enable_sigrt_signals", + "Use SIGRTMIN-based signals for thread suspend/resume") orelse false; + + const enable_gc_debug = b.option(bool, "enable_gc_debug", + "Support for pointer back-tracing") orelse false; + const disable_gc_debug = b.option(bool, "disable_gc_debug", + "Disable debugging like GC_dump and its callees") orelse false; + const enable_java_finalization = b.option(bool, + "enable_java_finalization", + "Support for java finalization") orelse true; + const enable_atomic_uncollectable = b.option(bool, + "enable_atomic_uncollectable", + "Support for atomic uncollectible allocation") orelse true; + const enable_redirect_malloc = b.option(bool, "enable_redirect_malloc", + "Redirect malloc and friend to GC routines") orelse false; + const enable_disclaim = b.option(bool, "enable_disclaim", + "Support alternative finalization interface") orelse true; + const enable_dynamic_pointer_mask = b.option(bool, + "enable_dynamic_pointer_mask", + "Support pointer mask/shift set at runtime") orelse false; + const enable_large_config = b.option(bool, "enable_large_config", + "Optimize for large heap or root set") orelse false; + const enable_gc_assertions = b.option(bool, "enable_gc_assertions", + "Enable collector-internal assertion checking") orelse false; + const enable_mmap = b.option(bool, "enable_mmap", + "Use mmap instead of sbrk to expand the heap") orelse false; + const enable_munmap = b.option(bool, "enable_munmap", + "Return page to the OS if empty for N collections") orelse true; + const enable_dynamic_loading = b.option(bool, "enable_dynamic_loading", + "Enable tracing of dynamic library data roots") orelse true; + const enable_register_main_static_data = b.option(bool, + "enable_register_main_static_data", + "Perform the initial guess of data root sets") orelse true; + const enable_checksums = b.option(bool, "enable_checksums", + "Report erroneously cleared dirty bits") orelse false; + const enable_werror = b.option(bool, "enable_werror", + "Pass -Werror to the C compiler (treat warnings as errors)") + orelse false; + const enable_single_obj_compilation = b.option(bool, + "enable_single_obj_compilation", + "Compile all libgc source files into single .o") orelse false; + const disable_single_obj_compilation = b.option(bool, + "disable_single_obj_compilation", + "Compile each libgc source file independently") orelse false; + const enable_handle_fork = b.option(bool, "enable_handle_fork", + "Attempt to ensure a usable collector after fork()") orelse true; + const disable_handle_fork = b.option(bool, "disable_handle_fork", + "Prohibit installation of pthread_atfork() handlers") orelse false; + // TODO: support enable_emscripten_asyncify + const install_headers = b.option(bool, "install_headers", + "Install header and pkg-config metadata files") orelse true; + // TODO: support with_libatomic_ops, without_libatomic_ops + + var lib = b.addStaticLibrary(.{ + .name = "gc", + .target = target, + .optimize = optimize, + }); + if (build_shared_libs) { + // TODO: convert VER_INFO values to [SO]VERSION ones + lib = b.addSharedLibrary(.{ + .name = "gc", + .target = target, + .optimize = optimize, + }); + } + + var source_files = std.ArrayList([]const u8).init(b.allocator); + defer source_files.deinit(); + var flags = std.ArrayList([]const u8).init(b.allocator); + defer flags.deinit(); + + // Always enabled. + flags.append("-D ALL_INTERIOR_POINTERS") catch unreachable; + flags.append("-D NO_EXECUTE_PERMISSION") catch unreachable; + + flags.appendSlice(&.{ + "-Wall", + "-Wextra", + "-Wpedantic", + //"-Wno-long-long", + }) catch unreachable; + + source_files.appendSlice(&.{ + "allchblk.c", + "alloc.c", + "blacklst.c", + "dbg_mlc.c", + "dyn_load.c", + "finalize.c", + "headers.c", + "mach_dep.c", + "malloc.c", + "mallocx.c", + "mark.c", + "mark_rts.c", + "misc.c", + "new_hblk.c", + "obj_map.c", + "os_dep.c", + "ptr_chck.c", + "reclaim.c", + "typd_mlc.c", + }) catch unreachable; + + if (enable_threads) { // assume pthreads + // Zig comes with clang which supports GCC atomic intrinsics. + flags.append("-D GC_BUILTIN_ATOMIC") catch unreachable; + // TODO: define and use THREADDLLIBS_LIST + + source_files.appendSlice(&.{ + "gc_dlopen.c", + "pthread_start.c", + "pthread_support.c", + }) catch unreachable; + if (target.isWindows()) { + source_files.appendSlice(&.{ + "win32_threads.c", + }) catch unreachable; + } else if (target.isDarwin()) { + source_files.appendSlice(&.{ + "darwin_stop_world.c", + }) catch unreachable; + } else { + source_files.appendSlice(&.{ + "pthread_stop_world.c", + }) catch unreachable; + } + // Common defines for POSIX platforms. + flags.append("-D GC_THREADS") catch unreachable; + flags.append("-D _REENTRANT") catch unreachable; + // TODO: some targets might need _PTHREADS defined too. + if (enable_parallel_mark) { + flags.append("-D PARALLEL_MARK") catch unreachable; + } + if (enable_thread_local_alloc) { + flags.append("-D THREAD_LOCAL_ALLOC") catch unreachable; + source_files.appendSlice(&.{ + "specific.c", + "thread_local_alloc.c", + }) catch unreachable; + } + // Message for clients: Explicit GC_INIT() calls may be required. + if (target.isWindows()) { + // Does not provide process fork functionality. + } else if (enable_handle_fork and !disable_handle_fork) { + flags.append("-D HANDLE_FORK") catch unreachable; + } + if (enable_sigrt_signals) { + flags.append("-D GC_USESIGRT_SIGNALS") catch unreachable; + } + } + + // TODO: define/use NEED_LIB_RT + + if (disable_handle_fork) { + flags.append("-D NO_HANDLE_FORK") catch unreachable; + } + + if (enable_gcj_support) { + flags.append("-D GC_GCJ_SUPPORT") catch unreachable; + // TODO: do not define GC_ENABLE_SUSPEND_THREAD on kFreeBSD + // if enable_thread_local_alloc (a workaround for some bug). + flags.append("-D GC_ENABLE_SUSPEND_THREAD") catch unreachable; + source_files.appendSlice(&.{ + "gcj_mlc.c", + }) catch unreachable; + } + + if (enable_disclaim) { + flags.append("-D ENABLE_DISCLAIM") catch unreachable; + source_files.appendSlice(&.{ + "fnlz_mlc.c", + }) catch unreachable; + } + + if (enable_dynamic_pointer_mask) { + flags.append("-D DYNAMIC_POINTER_MASK") catch unreachable; + } + + if (enable_java_finalization) { + flags.append("-D JAVA_FINALIZATION") catch unreachable; + } + + if (enable_atomic_uncollectable) { + flags.append("-D GC_ATOMIC_UNCOLLECTABLE") catch unreachable; + } + + if (enable_gc_debug) { + flags.append("-D DBG_HDRS_ALL") catch unreachable; + flags.append("-D KEEP_BACK_PTRS") catch unreachable; + if (target.isLinux()) { + flags.append("-D MAKE_BACK_GRAPH") catch unreachable; + // TODO: do not define SAVE_CALL_COUNT for e2k + flags.append("-D SAVE_CALL_COUNT=8") catch unreachable; + + source_files.appendSlice(&.{ + "backgraph.c", + }) catch unreachable; + } + } + + if (disable_gc_debug) { + flags.append("-D NO_DEBUGGING") catch unreachable; + } + if (optimize != .Debug) { + flags.append("-D NDEBUG") catch unreachable; + } + + if (enable_redirect_malloc) { + if (enable_gc_debug) { + flags.append("-D REDIRECT_MALLOC=GC_debug_malloc_replacement") + catch unreachable; + flags.append("-D REDIRECT_REALLOC=GC_debug_realloc_replacement") + catch unreachable; + flags.append("-D REDIRECT_FREE=GC_debug_free") catch unreachable; + } else { + flags.append("-D REDIRECT_MALLOC=GC_malloc") catch unreachable; + } + if (target.isWindows()) { + flags.append("-D REDIRECT_MALLOC_IN_HEADER") catch unreachable; + } else { + flags.append("-D GC_USE_DLOPEN_WRAP") catch unreachable; + } + } + + if (enable_mmap or enable_munmap) { + flags.append("-D USE_MMAP") catch unreachable; + } + + if (enable_munmap) { + flags.append("-D USE_MUNMAP") catch unreachable; + } + + if (!enable_dynamic_loading) { + flags.append("-D IGNORE_DDYNAMIC_LOADING") catch unreachable; + } + + if (!enable_register_main_static_data) { + flags.append("-D GC_DONT_REGISTER_MAIN_STATIC_DATA") catch unreachable; + } + + if (enable_large_config) { + flags.append("-D LARGE_CONFIG") catch unreachable; + } + + if (enable_gc_assertions) { + flags.append("-D GC_ASSERTIONS") catch unreachable; + } + + if (!enable_threads_discovery) { + flags.append("-D GC_NO_THREADS_DISCOVERY") catch unreachable; + } + + if (enable_rwlock) { + flags.append("-D USE_RWLOCK") catch unreachable; + } + + if (enable_checksums) { + if (enable_munmap or enable_threads) { + @panic("CHECKSUMS not compatible with USE_MUNMAP or threads"); + } + flags.append("-D CHECKSUMS") catch unreachable; + source_files.appendSlice(&.{ + "checksums.c", + }) catch unreachable; + } + + if (enable_werror) { + flags.appendSlice(&.{ + "-Werror", + }) catch unreachable; + } + + if (enable_single_obj_compilation + or (build_shared_libs and !disable_single_obj_compilation)) { + source_files.clearAndFree(); + source_files.appendSlice(&.{ + "extra/gc.c", + }) catch unreachable; + if (enable_threads and !(target.isDarwin() or target.isWindows())) { + flags.append("-D GC_PTHREAD_START_STANDALONE") catch unreachable; + source_files.appendSlice(&.{ + "pthread_start.c", + }) catch unreachable; + } + } + + // TODO: declare that the libraries do not refer to external symbols + // of build_shared_libs. + + // zig/clang supports these flags. + flags.appendSlice(&.{ + // TODO: -Wno-unused-command-line-argument + // Prevent "__builtin_return_address with nonzero argument is unsafe". + "-Wno-frame-address", + "-fno-strict-aliasing", + //"-O2", // FIXME: intermittent gctest failures w/o -O2 + }) catch unreachable; + + if (build_shared_libs) { + flags.append("-D GC_DLL") catch unreachable; + flags.append("-D GC_VISIBILITY_HIDDEN_SET") catch unreachable; + flags.appendSlice(&.{ + "-fvisibility=hidden", + }) catch unreachable; + } else { + flags.append("-D GC_NOT_DLL") catch unreachable; + if (target.isWindows()) { + // Do not require the clients to link with "user32" system library. + flags.append("-D DONT_USE_USER32_DLL") catch unreachable; + } + } + + // TODO: support CFLAGS_EXTRA (extra user-defined flags to pass to clang) + + // Note: Zig uses clang which ships with these so, unless another + // sysroot/libc, etc. headers location is pointed out, it is fine to + // hard-code enable this. + // -U GC_MISSING_EXECINFO_H + // -U GC_NO_SIGSETJMP + flags.append("-D HAVE_SYS_TYPES_H") catch unreachable; + flags.append("-D HAVE_UNISTD_H") catch unreachable; + + const have_getcontext = !t.abi.isMusl(); + if (!have_getcontext) { + flags.append("-D NO_GETCONTEXT") catch unreachable; + } + + // dl_iterate_phdr exists (as a strong symbol). + flags.append("-D HAVE_DL_ITERATE_PHDR") catch unreachable; + + if (enable_threads and !(target.isDarwin() or target.isWindows())) { + // pthread_sigmask() and sigset_t are available and needed. + flags.append("-D HAVE_PTHREAD_SIGMASK") catch unreachable; + } + + // Build with GC_wcsdup() support (wcslen is available). + flags.append("-D GC_REQUIRE_WCSDUP") catch unreachable; + + // pthread_setname_np, if available, may have 1, 2 or 3 arguments. + if (target.isDarwin()) { + flags.append("-D HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID") + catch unreachable; + } else if (target.isLinux()) { + flags.append("-D HAVE_PTHREAD_SETNAME_NP_WITH_TID") catch unreachable; + } else { + // TODO: support HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG + // and HAVE_PTHREAD_SET_NAME_NP targets. + } + + // Define to use 'dladdr' function (used for debugging). + flags.append("-D HAVE_DLADDR") catch unreachable; + + lib.addCSourceFiles(.{ + .files = source_files.items, + .flags = flags.items, + }); + lib.addIncludePath(.{ .path = "include" }); + lib.linkLibC(); + if (install_headers) { + installHeader(b, lib, "gc.h"); + installHeader(b, lib, "gc/gc.h"); + installHeader(b, lib, "gc/gc_backptr.h"); + installHeader(b, lib, "gc/gc_config_macros.h"); + installHeader(b, lib, "gc/gc_inline.h"); + installHeader(b, lib, "gc/gc_mark.h"); + installHeader(b, lib, "gc/gc_tiny_fl.h"); + installHeader(b, lib, "gc/gc_typed.h"); + installHeader(b, lib, "gc/gc_version.h"); + installHeader(b, lib, "gc/javaxfc.h"); + installHeader(b, lib, "gc/leak_detector.h"); + if (enable_disclaim) { + installHeader(b, lib, "gc/gc_disclaim.h"); + } + if (enable_gcj_support) { + installHeader(b, lib, "gc/gc_gcj.h"); + } + if (enable_threads) { + installHeader(b, lib, "gc/gc_pthread_redirects.h"); + } + // TODO: compose and install bdw-gc.pc and pkgconfig. + } + + b.installArtifact(lib); + + const test_step = b.step("test", "Run tests"); + if (build_tests) { + addTest(b, lib, test_step, flags, "gctest"); + addTest(b, lib, test_step, flags, "huge"); + addTest(b, lib, test_step, flags, "leak"); + addTest(b, lib, test_step, flags, "middle"); + addTest(b, lib, test_step, flags, "realloc"); + addTest(b, lib, test_step, flags, "smash"); + // TODO: add staticroots test + if (enable_gc_debug) { + addTest(b, lib, test_step, flags, "trace"); + } + if (enable_threads) { + addTest(b, lib, test_step, flags, "atomicops"); + addTest(b, lib, test_step, flags, "initfromthread"); + addTest(b, lib, test_step, flags, "subthreadcreate"); + addTest(b, lib, test_step, flags, "threadleak"); + addTest(b, lib, test_step, flags, "threadkey"); + } + if (enable_disclaim) { + addTest(b, lib, test_step, flags, "disclaim_bench"); + addTest(b, lib, test_step, flags, "disclaim"); + addTest(b, lib, test_step, flags, "weakmap"); + } + } +} + +fn addTest(b: *std.Build, lib: *std.Build.Step.Compile, + test_step: *std.Build.Step, flags: std.ArrayList([]const u8), + testname: []const u8) void { + const filename = b.allocator.alloc(u8, "tests/".len + testname.len + + ".c".len) catch @panic("OOM"); + _ = std.fmt.bufPrint(filename, "tests/{s}.c", .{testname}) + catch @panic("Error joining paths"); + const test_exe = b.addExecutable(.{ + .name = testname, + .optimize = lib.optimize, + .target = lib.target + }); + test_exe.addCSourceFile(.{ + .file = Path.relative(filename), + .flags = flags.items + }); + test_exe.addIncludePath(.{ .path = "include" }); + test_exe.linkLibrary(lib); + test_exe.linkLibC(); + const run_test_exe = b.addRunArtifact(test_exe); + test_step.dependOn(&run_test_exe.step); +} + +fn installHeader(b: *std.Build, lib: *std.Build.Step.Compile, + hfile: []const u8) void { + const inc_path = "include/"; + const src_path = b.allocator.alloc(u8, inc_path.len + hfile.len) + catch @panic("OOM"); + _ = std.fmt.bufPrint(src_path, "{s}{s}", .{inc_path, hfile}) + catch @panic("Error joining paths"); + lib.installHeader(src_path, hfile); +} diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 35474e9e7..410427b11 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -2786,10 +2786,8 @@ GC_EXTERN signed_word GC_bytes_found; # endif # endif /* MSWIN32 || MSWINCE */ -# if defined(GC_DISABLE_INCREMENTAL) || defined(HAVE_LOCKFREE_AO_OR) -# define GC_acquire_dirty_lock() (void)0 -# define GC_release_dirty_lock() (void)0 -# else +# if (!defined(NO_MANUAL_VDB) || defined(MPROTECT_VDB)) \ + && !defined(HAVE_LOCKFREE_AO_OR) && defined(AO_HAVE_test_and_set_acquire) /* Acquire the spin lock we use to update dirty bits. */ /* Threads should not get stopped holding it. But we may */ /* acquire and release it during GC_remove_protection call. */ @@ -2799,7 +2797,10 @@ GC_EXTERN signed_word GC_bytes_found; # define GC_release_dirty_lock() AO_CLEAR(&GC_fault_handler_lock) GC_EXTERN volatile AO_TS_t GC_fault_handler_lock; /* defined in os_dep.c */ -# endif +# else +# define GC_acquire_dirty_lock() (void)0 +# define GC_release_dirty_lock() (void)0 +# endif /* NO_MANUAL_VDB && !MPROTECT_VDB || HAVE_LOCKFREE_AO_OR */ # ifdef MSWINCE GC_EXTERN GC_bool GC_dont_query_stack_min; /* Defined and set in os_dep.c. */