mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-21 19:45:10 +00:00
Add profiling compile option
This commit is contained in:
parent
2be9f7f0c3
commit
cdb7701905
2 changed files with 34 additions and 11 deletions
29
Makefile
29
Makefile
|
@ -59,6 +59,8 @@ DISCORD_SDK ?= 1
|
||||||
DOCKERBUILD ?= 0
|
DOCKERBUILD ?= 0
|
||||||
# Enable compiling with more debug info.
|
# Enable compiling with more debug info.
|
||||||
DEBUG_INFO_LEVEL ?= 2
|
DEBUG_INFO_LEVEL ?= 2
|
||||||
|
# Enable profiling
|
||||||
|
PROFILE ?= 0
|
||||||
|
|
||||||
# Various workarounds for weird toolchains
|
# Various workarounds for weird toolchains
|
||||||
|
|
||||||
|
@ -211,7 +213,6 @@ endif
|
||||||
# Level 1 produces minimal information, enough for making backtraces in parts of the program that you don’t plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.
|
# Level 1 produces minimal information, enough for making backtraces in parts of the program that you don’t plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.
|
||||||
# Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.
|
# Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.
|
||||||
# From https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
|
# From https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
|
||||||
|
|
||||||
ifeq ($(DEBUG_INFO_LEVEL),3)
|
ifeq ($(DEBUG_INFO_LEVEL),3)
|
||||||
OPT_FLAGS += -g -g3
|
OPT_FLAGS += -g -g3
|
||||||
else ifeq ($(DEBUG_INFO_LEVEL),1)
|
else ifeq ($(DEBUG_INFO_LEVEL),1)
|
||||||
|
@ -224,6 +225,12 @@ else
|
||||||
OPT_FLAGS += -g
|
OPT_FLAGS += -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(PROFILE),1)
|
||||||
|
PROF_FLAGS := -pg
|
||||||
|
else
|
||||||
|
PROF_FLAGS :=
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET_WEB),1)
|
ifeq ($(TARGET_WEB),1)
|
||||||
OPT_FLAGS := -O2 -g4 --source-map-base http://localhost:8080/
|
OPT_FLAGS := -O2 -g4 --source-map-base http://localhost:8080/
|
||||||
endif
|
endif
|
||||||
|
@ -1228,13 +1235,13 @@ ifeq ($(TARGET_N64),1)
|
||||||
# TODO: ideally this would be `-Trodata-segment=0x07000000` but that doesn't set the address
|
# TODO: ideally this would be `-Trodata-segment=0x07000000` but that doesn't set the address
|
||||||
$(BUILD_DIR)/%.elf: $(BUILD_DIR)/%.o
|
$(BUILD_DIR)/%.elf: $(BUILD_DIR)/%.o
|
||||||
$(call print,Linking ELF file:,$<,$@)
|
$(call print,Linking ELF file:,$<,$@)
|
||||||
$(V)$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $<
|
$(V)$(LD) $(PROF_FLAGS) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $<
|
||||||
|
|
||||||
# Override for leveldata.elf, which otherwise matches the above pattern
|
# Override for leveldata.elf, which otherwise matches the above pattern
|
||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
$(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf
|
$(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf
|
||||||
$(call print,Linking ELF file:,$<,$@)
|
$(call print,Linking ELF file:,$<,$@)
|
||||||
$(V)$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map --just-symbols=$(BUILD_DIR)/bin/$(TEXTURE_BIN).elf -o $@ $<
|
$(V)$(LD) $(PROF_FLAGS) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map --just-symbols=$(BUILD_DIR)/bin/$(TEXTURE_BIN).elf -o $@ $<
|
||||||
|
|
||||||
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf
|
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf
|
||||||
$(call print,Extracting compressionable data from:,$<,$@)
|
$(call print,Extracting compressionable data from:,$<,$@)
|
||||||
|
@ -1340,15 +1347,15 @@ $(BUILD_DIR)/include/text_menu_strings.h: include/text_menu_strings.h.in
|
||||||
$(V)$(TEXTCONV) charmap_menu.txt $< $@
|
$(V)$(TEXTCONV) charmap_menu.txt $< $@
|
||||||
$(BUILD_DIR)/text/%/define_courses.inc.c: text/define_courses.inc.c text/%/courses.h
|
$(BUILD_DIR)/text/%/define_courses.inc.c: text/define_courses.inc.c text/%/courses.h
|
||||||
@$(PRINT) "$(GREEN)Preprocessing: $(BLUE)$@ $(NO_COL)\n"
|
@$(PRINT) "$(GREEN)Preprocessing: $(BLUE)$@ $(NO_COL)\n"
|
||||||
$(V)$(CPP) $(CPPFLAGS) $< -o - -I text/$*/ | $(TEXTCONV) charmap.txt - $@
|
$(V)$(CPP) $(PROF_FLAGS) $(CPPFLAGS) $< -o - -I text/$*/ | $(TEXTCONV) charmap.txt - $@
|
||||||
$(BUILD_DIR)/text/%/define_text.inc.c: text/define_text.inc.c text/%/courses.h text/%/dialogs.h
|
$(BUILD_DIR)/text/%/define_text.inc.c: text/define_text.inc.c text/%/courses.h text/%/dialogs.h
|
||||||
@$(PRINT) "$(GREEN)Preprocessing: $(BLUE)$@ $(NO_COL)\n"
|
@$(PRINT) "$(GREEN)Preprocessing: $(BLUE)$@ $(NO_COL)\n"
|
||||||
$(V)$(CPP) $(CPPFLAGS) $< -o - -I text/$*/ | $(TEXTCONV) charmap.txt - $@
|
$(V)$(CPP) $(PROF_FLAGS) $(CPPFLAGS) $< -o - -I text/$*/ | $(TEXTCONV) charmap.txt - $@
|
||||||
|
|
||||||
# Level headers
|
# Level headers
|
||||||
$(BUILD_DIR)/include/level_headers.h: levels/level_headers.h.in
|
$(BUILD_DIR)/include/level_headers.h: levels/level_headers.h.in
|
||||||
$(call print,Preprocessing level headers:,$<,$@)
|
$(call print,Preprocessing level headers:,$<,$@)
|
||||||
$(V)$(CPP) $(CPPFLAGS) -I . levels/level_headers.h.in | $(PYTHON) $(TOOLS_DIR)/output_level_headers.py > $(BUILD_DIR)/include/level_headers.h
|
$(V)$(CPP) $(PROF_FLAGS) $(CPPFLAGS) -I . levels/level_headers.h.in | $(PYTHON) $(TOOLS_DIR)/output_level_headers.py > $(BUILD_DIR)/include/level_headers.h
|
||||||
|
|
||||||
# Run asm_processor on files that have NON_MATCHING code
|
# Run asm_processor on files that have NON_MATCHING code
|
||||||
ifeq ($(NON_MATCHING),0)
|
ifeq ($(NON_MATCHING),0)
|
||||||
|
@ -1369,8 +1376,8 @@ $(GLOBAL_ASM_DEP).$(NON_MATCHING):
|
||||||
# Compile C++ code
|
# Compile C++ code
|
||||||
$(BUILD_DIR)/%.o: %.cpp
|
$(BUILD_DIR)/%.o: %.cpp
|
||||||
$(call print,Compiling:,$<,$@)
|
$(call print,Compiling:,$<,$@)
|
||||||
@$(CXX) -fsyntax-only $(EXTRA_CPP_FLAGS) $(EXTRA_CPP_INCLUDES) $(CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
@$(CXX) $(PROF_FLAGS) -fsyntax-only $(EXTRA_CPP_FLAGS) $(EXTRA_CPP_INCLUDES) $(CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
||||||
$(V)$(CXX) -c $(EXTRA_CPP_FLAGS) $(EXTRA_CPP_INCLUDES) $(CFLAGS) -o $@ $<
|
$(V)$(CXX) $(PROF_FLAGS) -c $(EXTRA_CPP_FLAGS) $(EXTRA_CPP_INCLUDES) $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
# Compile C code
|
# Compile C code
|
||||||
$(BUILD_DIR)/%.o: %.c
|
$(BUILD_DIR)/%.o: %.c
|
||||||
|
@ -1450,7 +1457,7 @@ endif
|
||||||
# Run linker script through the C preprocessor
|
# Run linker script through the C preprocessor
|
||||||
$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
|
$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
|
||||||
$(call print,Preprocessing linker script:,$<,$@)
|
$(call print,Preprocessing linker script:,$<,$@)
|
||||||
$(V)$(CPP) $(CPPFLAGS) -DBUILD_DIR=$(BUILD_DIR) -MMD -MP -MT $@ -MF $@.d -o $@ $<
|
$(V)$(CPP) $(PROF_FLAGS) $(CPPFLAGS) -DBUILD_DIR=$(BUILD_DIR) -MMD -MP -MT $@ -MF $@.d -o $@ $<
|
||||||
|
|
||||||
# Assemble assembly code
|
# Assemble assembly code
|
||||||
$(BUILD_DIR)/%.o: %.s
|
$(BUILD_DIR)/%.o: %.s
|
||||||
|
@ -1477,7 +1484,7 @@ ifeq ($(TARGET_N64),1)
|
||||||
# Link SM64 ELF file
|
# Link SM64 ELF file
|
||||||
$(ELF): $(O_FILES) $(MIO0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt $(BUILD_DIR)/libultra.a $(BUILD_DIR)/libgoddard.a
|
$(ELF): $(O_FILES) $(MIO0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt $(BUILD_DIR)/libultra.a $(BUILD_DIR)/libgoddard.a
|
||||||
@$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n"
|
@$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n"
|
||||||
$(V)$(LD) -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -lultra -lgoddard
|
$(V)$(LD) $(PROF_FLAGS) -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -lultra -lgoddard
|
||||||
|
|
||||||
# Build ROM
|
# Build ROM
|
||||||
$(ROM): $(ELF)
|
$(ROM): $(ELF)
|
||||||
|
@ -1489,7 +1496,7 @@ ifeq ($(TARGET_N64),1)
|
||||||
$(OBJDUMP) -D $< > $@
|
$(OBJDUMP) -D $< > $@
|
||||||
else
|
else
|
||||||
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/$(RPC_LIBS) $(BUILD_DIR)/$(DISCORD_SDK_LIBS) $(BUILD_DIR)/$(MOD_DIR)
|
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/$(RPC_LIBS) $(BUILD_DIR)/$(DISCORD_SDK_LIBS) $(BUILD_DIR)/$(MOD_DIR)
|
||||||
$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS) $(EXTRA_INCLUDES)
|
$(LD) $(PROF_FLAGS) -L $(BUILD_DIR) -o $@ $(O_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS) $(EXTRA_INCLUDES)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
16
developer/profile.sh
Executable file
16
developer/profile.sh
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
make DEBUG=1 DEVELOPMENT=1 STRICT=1 PROFILE=1 -j
|
||||||
|
else
|
||||||
|
make DEBUG=1 DEVELOPMENT=1 PROFILE=1 -j
|
||||||
|
fi
|
||||||
|
|
||||||
|
# find file
|
||||||
|
FILE=./build/us_pc/sm64.us.f3dex2e.exe
|
||||||
|
if [ ! -f "$FILE" ]; then
|
||||||
|
FILE=./build/us_pc/sm64.us.f3dex2e
|
||||||
|
fi
|
||||||
|
|
||||||
|
$FILE &
|
Loading…
Reference in a new issue