Skip to content

Commit

Permalink
Changed the meson build targets so that:
Browse files Browse the repository at this point in the history
1. The debug target does NOT turn on ASAN / UBSAN by default (the noise was slowing down debugging a lot). This *does* have our own internal memory checking enabled though.
2. There's a new 'cicd' target. It's accessible via `dev testbuild`
3. There's a separate target for enabling ASAN/UBSAN. That's not guaranteed to give good results.

CI/CD config is set up to use #2.
  • Loading branch information
viega committed Jul 6, 2024
1 parent c6a36f2 commit b7d6c93
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:

env:
TERM: dumb

ASAN_OPTIONS: halt_on_error=0
UBSAN_OPTIONS: print_stacktrace=1

permissions:
contents: read

Expand Down Expand Up @@ -75,7 +77,7 @@ jobs:
run: brew install meson ninja

- name: Build
run: ./dev build
run: ./dev testbuild

- name: Run
run: ./dev run
32 changes: 19 additions & 13 deletions dev
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ function log {
echo $(color blue "[-- libcon4m --]" $@)
}

function meson_build {

function meson_init_target {
echo ${1} > .meson_last
rm deps/local 2>/dev/null
ln -s ${PWD}/deps/${OS}-${ARCH} ${PWD}/deps/local


if [[ ! -d ${1} ]]; then
if [[ -f ${1} ]]; then
rm -rf ${1}
Expand All @@ -47,6 +45,10 @@ function meson_build {
log meson setup ${@}
meson setup ${@}
fi
}

function meson_build {
meson_init_target ${@}
cd ${1}

log Compiling meson target ${1}
Expand Down Expand Up @@ -75,7 +77,6 @@ function meson_build {
}

function meson_hatrack {

if [[ ! -d ${1} ]]; then
if [[ -f ${1} ]]; then
rm -rf ${1}
Expand Down Expand Up @@ -111,7 +112,7 @@ function meson_hatrack {
}

function libcon4m_dev_usage {
echo "Usage: ./dev [build | run | release | debug | clean]"
echo "Usage: ./dev [build | run | release | debug | testbuild | clean]"
exit 1
}

Expand All @@ -121,13 +122,8 @@ function debug_it {
DEBUGGER=${DEBUGGER:-$(which lldb)}
cd debug
log "Running debugger:v${DEBUGGER}"
echo
echo $(color RED 'Recommended environment variables:')
echo $(color CYAN 'export ASAN_OPTIONS=halt_on_error=0')
echo $(color CYAN 'export UBSAN_OPTIONS=print_stacktrace=1;halt_on_error=0')
${DEBUGGER} ./c4test
cd ..

}

function libcon4m_run_tests {
Expand Down Expand Up @@ -162,7 +158,7 @@ function libcon4m_run_tests {
}

function libcon4m_dev_clean {
for item in build debug release; do
for item in build debug release cicd .meson_last; do
if [[ -d ${item} ]]; then
log Cleaning ${item}
cd ${item}
Expand All @@ -183,10 +179,20 @@ case $1 in
;;
build) meson_build build --buildtype=plain
;;
debug) meson_build debug --buildtype=debug
meson configure debug -Duse_ubsan=true -Duse_asan=true -Duse_memcheck=true
debug) meson_init_target debug --buildtype=debug
meson configure debug -Duse_memcheck=true
meson_build debug
debug_it
;;
testbuild) meson_init_target cicd --buildtype=debug
meson configure cicd -Duse_memcheck=true
meson_build cicd
;;
sanitizers) meson_init_target sanitizers
meson configure sanitizers -Duse_ubsan=true -Duse_asan=true
meson build sanitizers
;;

release) meson_build release --buildtype=release
;;
run)
Expand Down
19 changes: 12 additions & 7 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ endif

if (get_option('use_ubsan') == true)
c_args = c_args + ['-fsanitize=undefined',
'-fsanitize-recover=all'
]
'-fsanitize-recover=all'
]
link_args = link_args + ['-fsanitize=undefined',
'-fsanitize-recover=all'
]
endif

if (get_option('use_memcheck') == true)
Expand Down Expand Up @@ -230,11 +233,7 @@ libc4m = static_library('con4m',
dependencies : all_deps,
c_args : c4m_c_args,
link_args: link_args)
libhat = static_library('hatrack',
lib_src,
include_directories : incdir,
c_args : c_args,
link_args : link_args)


if get_option('build_con4m_dll') == true
library('con4m-dll',
Expand All @@ -253,6 +252,12 @@ executable('c4test', test_src,
link_with : libc4m)

if get_option('build_hatrack') == true
libhat = static_library('hatrack',
lib_src,
include_directories : incdir,
c_args : c_args,
link_args : link_args)

executable('hash', hash_test_src,
include_directories : incdir,
dependencies : all_deps,
Expand Down

0 comments on commit b7d6c93

Please sign in to comment.