CROSS_COMPILE
: Optional variable for cross-compilation. If set, it prefixes the compiler and archiver commands.CC
: The C compiler to use. Defaults togcc
, or$(CROSS_COMPILE)gcc
ifCROSS_COMPILE
is set.AR
: The archiver to use. Defaults toar
, or$(CROSS_COMPILE)ar
ifCROSS_COMPILE
is set.- The
CROSS_COMPILE
option format should be similar to this example, if wanting to use gcc: CROSS_COMPILE=aarch64-linux-gnu-
These flags are included in all build modes:
-I$(INCLUDE_DIR)
: Include directory for project headers.-I$(MBEDTLS_DIR)/include
: Include directory for mbedTLS headers.- Warning and standard enforcement flags:
-Wall
: Enable most warnings.-Wextra
: Enable extra warnings.-Werror
: Treat warnings as errors.
-std=c11
: Enforce the C11 standard.
Used for debugging builds:
-g
: Generate debug information for use with debuggers like GDB.-O0
: Disable optimizations for easier debugging.-DDEBUG
: Define theDEBUG
macro.
Used for optimized builds:
- Optimization:
-O3
,-Ofast
: Aggressive optimizations.-funroll-loops
,-finline-functions
: Loop unrolling and function inlining.-flto
: Link-time optimization for improved performance.
- Loop optimizations:
-fgraphite-identity
,-floop-nest-optimize
: Use Graphite framework for loop optimizations.
- Miscellaneous:
-fomit-frame-pointer
: Exclude the frame pointer to reduce overhead.-ffunction-sections
,-fdata-sections
: Place each function and data item in its own section for better dead-code
The CFLAGS
variable is determined by the MODE
setting:
MODE=debug
: IncludesCFLAGS_COMMON
andDEBUG_FLAGS
.MODE=optimize
: IncludesCFLAGS_COMMON
andOPTIMIZE_FLAGS
.
SRC_DIR
: Directory containing source files (src
).INCLUDE_DIR
: Directory containing header files (include
).BUILD_DIR
: Directory for compiled output files (build
).TEST_DIR
: Directory for test files (test
).
To build the project with debugging options:
make MODE=debug
To build and run the test binaries:
make MODE=debug BUILD_TEST=1
./debug.sh
To check the logs go to the valgrind_logs directory
cd test/gramine/
sudo ./debug_gramine.sh
To check the logs go to gramine_logs