Compare commits

..

2 Commits

Author SHA1 Message Date
1571c52012 Add some building documentation that clarifies the make targets
All checks were successful
Validate the build / validate-build (push) Successful in 26s
2025-04-04 02:18:11 +02:00
0f9ced8eb1 Rework the build system to be more modular
Split most of the work off into make/base.mk and allow for easy wrappers
to be created around that that can build with different instrumentation
in their own build directory.

Create wrappers for the following:
 - release build
 - debug build
 - afl++ fuzzing build
 - static analysis with clang
 - clang memory sanitizer
 - clang address/undefined sanitizer
2025-04-04 02:18:02 +02:00
6 changed files with 33 additions and 6 deletions

View File

@ -19,7 +19,7 @@ asan:
make -rRf make/asan.mk all
msan:
make -rRf make/asan.mk all
make -rRf make/msan.mk all
validate: asan msan debug
./validate.sh

29
doc/BUILDING.md Normal file
View File

@ -0,0 +1,29 @@
# Building
To build oas in the default configuration you just need (gnu) make and a
sufficiently modern clang.
```
make
```
## Make targets
There are a number of make targets available to build various instrumented
builds that are used in validation, analysis and sanitizing. Some of these may
require extra dependencies.
- `debug`: Creates the debug build in `build/debug`. This is the default target.
- `all`: Builds all binary executable targets. These are
`debug`, `release`, `msan`, `asan` and `afl`. All executables can be found
in `build/` in a subdirectory matching their target names.
- `release`: Creates the release build in `build/release`
- `afl`: Creates a build with AFL++ instrumentation for fuzzing
- `fuzz`: Starts the fuzzer with the instrumented afl executable
- `asan`: builds with the address and undefined clang sanitizers
- `msan`: builds with the memory clang sanitizer
- `validate`: Builds `debug`, `msan`, and `asan` targets, then runs the
validation script. This script executes the sanitizer targets and runs
Valgrind on the debug target across multiple modes and test input files.

View File

@ -2,7 +2,7 @@ BUILD_DIR=build/analyze/
-include make/base.mk
analyze:
mkdir z-p reports/static-analysis
mkdir -p reports/static-analysis
scan-build -o reports/static-analysis/ -plist-html --status-bugs make -rRf make/analyze.mk all
distclean: clean

View File

@ -1,5 +1,5 @@
CFLAGS=-Wall -Wextra -Wpedantic -O0 -g3 -std=c23 -fno-omit-frame-pointer -fno-optimize-sibling-calls -D_POSIX_C_SOURCE=200809L -fsanitize=address,undefined
LDFLAGS=-fsanitize=address,undefined
BUILD_DIR=build/msan/
BUILD_DIR=build/asan/
-include make/base.mk

View File

@ -24,4 +24,4 @@ $(BUILD_DIR)%.o: %.c
-include $(DEPENDENCIES)
clean:
rm -f $(BUILD_DIR)$(TARGET) $(OBJECTS)
rm -rf $(BUILD_DIR)

View File

@ -1,5 +1,3 @@
CC?=clang
LD?=clang
CFLAGS?=-Wall -Wextra -Wpedantic -O2 -std=c23 -flto -fomit-frame-pointer -DNDEBUG -D_POSIX_C_SOURCE=200809L
LDFLAGS?=-flto -s -Wl,--gc-sections
BUILD_DIR?=build/release/