Skip to content

Commit

Permalink
Add address sanitizer option SANITIZER in config.mk
Browse files Browse the repository at this point in the history
  • Loading branch information
ipatix committed Nov 8, 2024
1 parent b74057f commit a54a56a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions bench/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ else
DEBUG_FLAGS =
endif

ifeq ($(strip $(SANITIZE)),true)
DEBUG_FLAGS += -fsanitize=address -fno-omit-frame-pointer
endif

VPATH = $(SRC_DIR)
OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c))
ifeq ($(SHARED_LIBRARY),false)
Expand Down
3 changes: 3 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ SHARED_LIBRARY = true#NO SPACE
# Build LIKWID with debug flags
DEBUG = false#NO SPACE

# Build LIKWID with address sanitizer flags
SANITIZE = false#NO SPACE

# Basic configuration for some internal arrays.
# Maximal number of hardware threads
MAX_NUM_THREADS = 512
Expand Down
5 changes: 4 additions & 1 deletion ext/GOTCHA/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ DEBUG_FLAGS = -g
else
DEBUG_FLAGS =
endif
ifeq ($(strip $(SANITIZE)),true)
DEBUG_FLAGS += -fsanitize=address -fno-omit-frame-pointer
endif
ifeq ($(strip $(COMPILER)),MIC)
CFLAGS += -mmic
LFLAGS += -mmic
Expand Down Expand Up @@ -50,7 +53,7 @@ $(STATIC_LIBGOTCHA): $(OBJ)
#$(Q)${AR} -cq $(LIBGOTCHA) $(OBJ)

$(SHARED_LIBGOTCHA): $(OBJ)
$(Q)$(CC) $(LFLAGS) -Wl,-soname,$(LIBGOTCHA).$(VERSION).$(RELEASE) -shared -fPIC -o $(LIBGOTCHA) $(OBJ) $(LIBS)
$(Q)$(CC) $(DEBUG_FLAGS) $(LFLAGS) -Wl,-soname,$(LIBGOTCHA).$(VERSION).$(RELEASE) -shared -fPIC -o $(LIBGOTCHA) $(OBJ) $(LIBS)

#PATTERN RULES
$(BUILD_DIR)/%.o: %.c
Expand Down
3 changes: 3 additions & 0 deletions ext/hwloc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ DEBUG_FLAGS = -g
else
DEBUG_FLAGS =
endif
ifeq ($(strip $(SANITIZE)),true)
DEBUG_FLAGS += -fsanitize=address -fno-omit-frame-pointer
endif
ifeq ($(COMPILER),MIC)
CFLAGS += -mmic
LFLAGS += -mmic
Expand Down
7 changes: 5 additions & 2 deletions ext/lua/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ DEBUG_FLAGS = -g
else
DEBUG_FLAGS =
endif
ifeq ($(strip $(SANITIZE)),true)
DEBUG_FLAGS += -fsanitize=address -fno-omit-frame-pointer
endif
ifeq ($(strip $(COMPILER)),MIC)
CFLAGS += -mmic
LFLAGS += -mmic
Expand Down Expand Up @@ -48,10 +51,10 @@ $(STATIC_LIBLUA): $(OBJ)
$(Q)${AR} -cq $(LIBLUA) $(OBJ)

$(SHARED_LIBLUA): $(OBJ)
$(Q)$(CC) $(LFLAGS) -Wl,-soname,$(LIBLUA).$(VERSION).$(RELEASE) -shared -fPIC -o $(LIBLUA) $(OBJ) $(LIBS)
$(Q)$(CC) $(DEBUG_FLAGS) $(LFLAGS) -Wl,-soname,$(LIBLUA).$(VERSION).$(RELEASE) -shared -fPIC -o $(LIBLUA) $(OBJ) $(LIBS)

$(INTERPRETER): $(LIBLUA) $(BUILD_DIR)/lua.o
$(Q)$(CC) -o $@ $(LFLAGS) $(BUILD_DIR)/lua.o $(RPATHS) $(LIBLUA) $(LIBS)
$(Q)$(CC) $(DEBUG_FLAGS) -o $@ $(LFLAGS) $(BUILD_DIR)/lua.o $(RPATHS) $(LIBLUA) $(LIBS)

#PATTERN RULES
$(BUILD_DIR)/%.o: %.c
Expand Down
3 changes: 3 additions & 0 deletions make/config_defines.mk
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,6 @@ else
DEBUG_FLAGS =
endif

ifeq ($(strip $(SANITIZE)),true)
DEBUG_FLAGS += -fsanitize=address -fno-omit-frame-pointer
endif

0 comments on commit a54a56a

Please sign in to comment.