Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a make flag to produce a seperate debug archive #74067

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ jobs:
libbacktrace: 1
native: linux64
pch: 1
cxxflags: -gsplit-dwarf
title: GCC 9, Curses, LTO
# ~850MB in a clean build
# ~370MB compressed
Expand Down
28 changes: 24 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
# make RUNTESTS=1
# Build source files in order of how often the matching header is included
# make HEADERPOPULARITY=1
# Split debug symbols to seperate files. Can improve linker overheads.
# make SPLIT_DEBUG=1
# Generate debug symbols even in release builds.
# make DEBUG_SYMBOLS=1

# comment these to toggle them as one sees fit.
# DEBUG is best turned on if you plan to debug in gdb -- please do!
Expand Down Expand Up @@ -481,6 +485,15 @@ else
CXXFLAGS += $(OPTLEVEL)
endif

ifeq ($(SPLIT_DEBUG), 1)
# macos already does this by default.
ifneq ($(NATIVE), osx)
ifneq ($(LTO), 1)
CXX_OFLAGS = -gsplit-dwarf -gz=zlib
endif
endif
endif

ifeq ($(shell sh -c 'uname -o 2>/dev/null || echo not'),Cygwin)
OTHERS += -std=gnu++17
else
Expand Down Expand Up @@ -1039,6 +1052,13 @@ all: version prefix $(CHECKS) $(TARGET) $(L10N) $(TESTSTARGET)

$(TARGET): $(OBJS)
+$(LD) $(W32FLAGS) -o $(TARGET) $(OBJS) $(LDFLAGS)
ifeq ($(SPLIT_DEBUG), 1)
ifneq ($(NATIVE), osx)
ifneq ($(LTO), 1)
+dwp --exec $(TARGET)
endif
endif
endif
ifeq ($(RELEASE), 1)
ifndef DEBUG_SYMBOLS
ifneq ($(BACKTRACE),1)
Expand Down Expand Up @@ -1089,13 +1109,13 @@ includes: $(OBJS:.o=.inc)
+make -C tests includes

$(ODIR)/third-party/imgui/%.o: $(IMGUI_DIR)/%.cpp
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -w -MMD -MP -c $< -o $@
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) $(CXX_OFLAGS) -w -MMD -MP -c $< -o $@

$(ODIR)/third-party/imtui/%.o: $(IMTUI_DIR)/%.cpp
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -w -MMD -MP -c $< -o $@
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) $(CXX_OFLAGS) -w -MMD -MP -c $< -o $@

$(ODIR)/%.o: $(SRC_DIR)/%.cpp $(PCH_P)
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -MMD -MP $(PCHFLAGS) -c $< -o $@
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) $(CXX_OFLAGS) -MMD -MP $(PCHFLAGS) -c $< -o $@

$(ODIR)/%.o: $(SRC_DIR)/%.rc
$(RC) $(RFLAGS) $< -o $@
Expand Down Expand Up @@ -1129,7 +1149,7 @@ json-check: $(CHKJSON_BIN)
./$(CHKJSON_BIN)

clean: clean-tests clean-object_creator clean-pch clean-lang
rm -rf *$(TARGET_NAME) *$(TILES_TARGET_NAME)
rm -rf *$(TARGET_NAME) *$(TILES_TARGET_NAME) *$(TARGET_NAME).dwp
rm -rf *$(TILES_TARGET_NAME).exe *$(TARGET_NAME).exe *$(TARGET_NAME).a
rm -rf *obj *objwin
rm -rf *$(BINDIST_DIR) *cataclysmdda-*.tar.gz *cataclysmdda-*.zip
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/gha_compile_only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ then
..
make -j$num_jobs
else
make -j "$num_jobs" CCACHE=1 CROSS="$CROSS_COMPILATION" LINTJSON=0 FRAMEWORK=1 UNIVERSAL_BINARY=1 DEBUG_SYMBOLS=1
make -j "$num_jobs" CCACHE=1 CROSS="$CROSS_COMPILATION" LINTJSON=0 FRAMEWORK=1 UNIVERSAL_BINARY=1 DEBUG_SYMBOLS=1 SPLIT_DEBUG=1

# For CI on macOS, patch the test binary so it can find SDL2 libraries.
if [[ ! -z "$OS" && "$OS" = "macos-12" ]]
Expand Down
9 changes: 8 additions & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ tests: $(TEST_TARGET)

$(TEST_TARGET): $(OBJS) $(CATA_LIB)
+$(CXX) $(W32FLAGS) -o $@ $(DEFINES) $(OBJS) $(CATA_LIB) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS)
ifeq ($(SPLIT_DEBUG), 1)
ifneq ($(NATIVE), osx)
ifneq ($(LTO), 1)
cd .. && dwp --exec tests/$(TEST_TARGET) -o tests/$(TEST_TARGET).dwp
endif
endif
endif

$(PCH_P): $(PCH_H)
-$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -MMD -MP -Wno-error -Wno-non-virtual-dtor -Wno-unused-macros -I. -c $(PCH_H) -o $(PCH_P)
Expand Down Expand Up @@ -84,7 +91,7 @@ $(shell mkdir -p $(ODIR))

# Adding ../tests/ so that the directory appears in __FILE__ for log messages
$(ODIR)/%.o: %.cpp $(PCH_P)
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -MMD -MP $(subst main-pch,tests-pch,$(PCHFLAGS)) -c ../tests/$< -o $@
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) $(CXX_OFLAGS) -MMD -MP $(subst main-pch,tests-pch,$(PCHFLAGS)) -c ../tests/$< -o $@

$(ODIR)/%.inc: %.cpp
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -H -E $< -o /dev/null 2> $@
Expand Down
Loading