Skip to content

refactor: update leak sanitizer options in Makefile for better leak d… #80

refactor: update leak sanitizer options in Makefile for better leak d…

refactor: update leak sanitizer options in Makefile for better leak d… #80

Workflow file for this run

name: easymem-ci
on:
push:
branches: [ "main", "master" ]
paths:
- 'easy_memory.h'
- 'Makefile'
- 'tests/**'
- '.github/workflows/**'
pull_request:
branches: [ "main", "master" ]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
# ==========================================
# 1. LINUX GCC (x86_64, x86_32, Native ARM64)
# ==========================================
linux-gcc:
name: linux-gcc-${{ matrix.os }}-arch${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
arch: [64, 32]
exclude:
- os: ubuntu-24.04-arm
arch: 32
steps:
- uses: actions/checkout@v6
- name: install-dependencies
run: |
sudo apt-get update && sudo apt-get install -y build-essential valgrind lcov
if [ "${{ matrix.arch }}" == "32" ]; then sudo apt-get install -y gcc-multilib g++-multilib; fi
echo "CC_CMD=$([ "${{ matrix.arch }}" == "32" ] && echo 'gcc -m32' || echo 'gcc')" >> $GITHUB_ENV
- name: run-matrix-tests
run: make test_matrix CC="${CC_CMD}" MATRIX_OPTS="O0 O1 O2 O3 Os" -j$(nproc) -Otarget
- name: verify-ctz-fallback
run: make test_fallback CC="${CC_CMD}" EXTRA_CFLAGS="-O2 -DEM_SAFETY_POLICY=1"
- name: strict-alignment-test-arm64
if: matrix.os == 'ubuntu-24.04-arm'
env:
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1
run: make tests_full CC="${CC_CMD}" SAN_FLAGS="-fsanitize=alignment,undefined" EXTRA_CFLAGS="-O2 -DEM_SAFETY_POLICY=1"
- name: valgrind-memory-check
if: matrix.os == 'ubuntu-latest' && matrix.arch == '64'
run: make valgrind CC="${CC_CMD}" EXTRA_CFLAGS="-O0 -DEM_SAFETY_POLICY=1"
- name: generate-coverage
if: github.repository == 'EasyMem/easy_memory'
run: make coverage CC="${CC_CMD}" STD_C=c99 EXTRA_CFLAGS="-O0 -DEM_SAFETY_POLICY=1"
- name: upload-codecov
if: github.repository == 'EasyMem/easy_memory'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
codecov_yml_path: ./.github/codecov.yml
files: ./coverage.info
flags: linux-gcc-${{ matrix.os }}-arch${{ matrix.arch }}
fail_ci_if_error: false
# ==========================================
# 2. LINUX CLANG (x86_64, x86_32, Native ARM64)
# ==========================================
linux-clang:
name: linux-clang-${{ matrix.os }}-arch${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
arch: [64, 32]
exclude:
- os: ubuntu-24.04-arm
arch: 32
steps:
- uses: actions/checkout@v6
- name: install-dependencies
run: |
sudo apt-get update && sudo apt-get install -y clang
if [ "${{ matrix.arch }}" == "32" ]; then sudo apt-get install -y gcc-multilib; fi
echo "CC_CMD=$([ "${{ matrix.arch }}" == "32" ] && echo 'clang -m32' || echo 'clang')" >> $GITHUB_ENV
- name: run-matrix-tests
run: make test_matrix CC="${CC_CMD}" -j$(nproc) -Otarget
# ==========================================
# 3. MACOS (Intel x86_64 & M-series ARM64)
# ==========================================
macos-tests:
name: macos-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-15-intel, macos-latest]
steps:
- uses: actions/checkout@v6
- name: install-lcov
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: brew install lcov
- name: run-matrix-tests
run: make test_matrix CC=clang -j$(sysctl -n hw.logicalcpu)
- name: generate-coverage
run: make coverage CC=clang STD_C=c99 EXTRA_CFLAGS="-O0"
- name: upload-codecov
if: github.repository == 'EasyMem/easy_memory'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
codecov_yml_path: ./.github/codecov.yml
files: ./coverage.info
flags: macos-${{ matrix.os }}
fail_ci_if_error: false
# ==========================================
# 4. EXOTIC (Big Endian s390x & ARM32)
# ==========================================
exotic-tests:
name: exotic-${{ matrix.arch_name }}-opt${{ matrix.build_config.opt }}-std${{ matrix.build_config.std }}-pol${{ matrix.policy }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch_name: arm32
platform: linux/arm/v7
image: ghcr.io/easymem/easy_memory:arm32
- arch_name: s390x
platform: linux/s390x
image: ghcr.io/easymem/easy_memory:s390x
policy: [1]
build_config:
- { std: c99, opt: "-O0" }
- { std: c99, opt: "-O2" }
- { std: c99, opt: "-O3" }
steps:
- uses: actions/checkout@v6
- uses: docker/setup-qemu-action@v4
- name: build-and-test-emulated
run: |
docker run --rm --platform ${{ matrix.platform }} \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
${{ matrix.image }} \
make tests_full CC=gcc STD_C=${{ matrix.build_config.std }} SAN_FLAGS='' EXTRA_CFLAGS="${{ matrix.build_config.opt }} -DEM_SAFETY_POLICY=${{ matrix.policy }} -DEM_ASSERT_STAYS"
- name: generate-coverage-emulated
if: matrix.policy == 1 && matrix.build_config.opt == '-O0' && matrix.build_config.std == 'c99'
run: |
docker run --rm --platform ${{ matrix.platform }} \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
${{ matrix.image }} \
/bin/bash -c "make coverage CC=gcc STD_C=${{ matrix.build_config.std }} EXTRA_CFLAGS='${{ matrix.build_config.opt }}' && chmod 777 coverage.info"
- name: upload-codecov
if: matrix.policy == 1 && matrix.build_config.opt == '-O0' && matrix.build_config.std == 'c99' && github.repository == 'EasyMem/easy_memory'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
codecov_yml_path: ./.github/codecov.yml
files: ./coverage.info
flags: exotic-${{ matrix.arch_name }}
fail_ci_if_error: false
# ==========================================
# 5. WINDOWS (x64, x86, ARM64)
# ==========================================
windows-tests:
name: windows-arch${{ matrix.arch }}-tc-${{ matrix.toolchain }}
runs-on: ${{ matrix.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }}
strategy:
fail-fast: false
matrix:
arch: [x64, x86, arm64]
toolchain: [msvc, mingw]
exclude:
- toolchain: mingw
arch: arm64
steps:
- uses: actions/checkout@v6
- name: setup-mingw
if: matrix.toolchain == 'mingw'
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.arch == 'x64' && 'MINGW64' || 'MINGW32' }}
update: true
install: ${{ matrix.arch == 'x64' && 'mingw-w64-x86_64-toolchain' || 'mingw-w64-i686-toolchain' }} make lcov
cache: true
- name: build-and-test-mingw
if: matrix.toolchain == 'mingw'
shell: msys2 {0}
run: make test_matrix CC=gcc MATRIX_OPTS="O0 O1 O2 O3 Os" -j$(nproc)
- name: build-and-test-msvc
if: matrix.toolchain == 'msvc'
shell: cmd
run: |
if "${{ matrix.arch }}"=="x86" ( call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat" ) else if "${{ matrix.arch }}"=="arm64" ( call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsarm64.bat" ) else ( call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" )
cd tests
setlocal EnableDelayedExpansion
set "FAILED=0"
FOR %%O IN (/Od /O2 /Ox) DO (
FOR %%P IN (0 1) DO (
echo === MSVC Opt:%%O Pol:%%P ===
FOR %%f IN (*.c) DO (
cl.exe /nologo /W4 /WX /DDEBUG /DEM_SAFETY_POLICY=%%P /DEM_ASSERT_STAYS %%O /I.. /Fe:%%~nf.exe %%f
if %errorlevel% neq 0 (
echo [FAIL] Compile %%f
set FAILED=1
) else (
echo [Running] %%~nf.exe
%%~nf.exe
if %errorlevel% neq 0 (
echo [FAIL] Run %%f
set FAILED=1
) else (
echo [OK] %%f
)
)
)
)
)
if "!FAILED!"=="1" exit /b 1
- name: generate-coverage-mingw
if: matrix.toolchain == 'mingw' && github.repository == 'EasyMem/easy_memory'
shell: msys2 {0}
run: make coverage CC=gcc EXTRA_CFLAGS="-O0 -DEM_SAFETY_POLICY=1"
- name: upload-codecov
if: matrix.toolchain == 'mingw' && github.repository == 'EasyMem/easy_memory'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
codecov_yml_path: ./.github/codecov.yml
files: ./coverage.info
flags: windows-mingw-${{ matrix.arch }}
fail_ci_if_error: false
# ==========================================
# 6. BARE METAL / 16-BIT VERIFICATION
# ==========================================
avr-16bit-tests:
name: bare-metal-avr-16bit-opt${{ matrix.opt }}
runs-on: ubuntu-latest
strategy:
matrix:
opt: [-O0, -O1, -O2, -O3, -Os]
steps:
- uses: actions/checkout@v6
- name: install-avr-toolchain
run: sudo apt-get update && sudo apt-get install -y gcc-avr avr-libc
- name: compile-library-no-malloc
run: |
avr-gcc -mmcu=atmega328p ${{ matrix.opt }} -Wall -Wextra -Werror \
-Wshadow -Wconversion -Wsign-conversion -Wcast-align \
-DEM_NO_MALLOC -DEASY_MEMORY_IMPLEMENTATION \
-x c -c easy_memory.h -o easy_memory.o
- name: verify-binary-size
run: avr-size easy_memory.o