diff --git a/.woodpecker/workflow.yaml b/.woodpecker/workflow.yaml index 2e4b32a..dcabe9e 100644 --- a/.woodpecker/workflow.yaml +++ b/.woodpecker/workflow.yaml @@ -8,7 +8,7 @@ steps: commands: # we probably shouldn't install cmake every time - apt update && apt install -y cmake - mkdir -p build/ && cd build - - cmake .. + - cmake .. --toolchain ../toolchain/sanitize.cmake - make - name: test image: ubuntu diff --git a/README.md b/README.md index 7a1acad..01a4942 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ The end goal is to emit bytecode. The bytecode format is not decided yet. ## Build +All you need is: + +- CMake +- An appropriate C++ compiler + I use cmake for the build system. I prefer to build out-of-tree, here's how to build if you've never used cmake: @@ -35,6 +40,23 @@ cp compile_commands.json ../ After this, clangd should not give you errors on every included header. +### Toolchain + +C++ can be somewhat error-prone, so in order to reduce the possibility of +certain bugs, cmake toolchain options are provided that build the project +with the undefined behaviour sanitizer and the address sanitizer. + +You can build a sanitized version like this: + +``` +cd build +cmake .. --toolchain ../toolchain/sanitize.cmake +make +``` + +Catch2 testing framework is used to maintain code correctness. + + ## Progress Woodpecker CI/CD system is integrated. diff --git a/toolchain/sanitize.cmake b/toolchain/sanitize.cmake new file mode 100644 index 0000000..a6874c0 --- /dev/null +++ b/toolchain/sanitize.cmake @@ -0,0 +1,5 @@ +# We're assuming clang or gcc as the compiler. +# feel free to change if you're using msvc or something else +set(SANITIZERS_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS_INIT "${SANITIZERS_FLAGS}") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${SANITIZERS_FLAGS}") \ No newline at end of file