Remove unnecessary linker script preprocessing

The previous build process ran sed against the linker scripts twice:
once to replace <X> with the contents of sym_x.ld, a second time to
correct any paths referencing tools/.

The first can be replaced with INCLUDE commands, as was done in
pret/pokeemerald@7c57699 (in 2018).

The second has been unnecessary since 942c248 (also 2018).

With both of these removed there is no longer a need to have a build
step for them, and $(ELF) can take the sym_x.ld files as prerequisites
instead.
This commit is contained in:
Sophia 2023-05-21 03:32:06 +01:00
parent cea26f20c5
commit cb6409224f
5 changed files with 7 additions and 26 deletions

1
.gitignore vendored
View File

@ -22,7 +22,6 @@
*.id1
*.id2
*.latfont
*.ld
*.lz
*.map
*.nam

View File

@ -327,19 +327,15 @@ $(OBJ_DIR)/sym_ewram.ld: sym_ewram.txt
$(RAMSCRGEN) ewram_data $< ENGLISH > $@
ifeq ($(MODERN),0)
LD_SCRIPT := ld_script.txt
LD_SCRIPT := ld_script.ld
LD_SCRIPT_DEPS := $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld
else
LD_SCRIPT := ld_script_modern.txt
LD_SCRIPT := ld_script_modern.ld
LD_SCRIPT_DEPS :=
endif
$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS)
cd $(OBJ_DIR) && sed -f ../../ld_script.sed ../../$< | sed "s#tools/#../../tools/#g" > ld_script.ld
$(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS)
@echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ <objects> <lib>"
@cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
$(ELF): $(LD_SCRIPT) $(LD_SCRIPT_DEPS) $(OBJS)
@cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< -o ../../$@ $(OBJS_REL) $(LIB)
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(GAME_REVISION) --silent
$(ROM): $(ELF)

View File

@ -11,7 +11,7 @@ SECTIONS {
. = 0x1C000;
<EWRAM>
INCLUDE "sym_ewram.ld"
src/*.o(.ewram_data);
*libc.a:impure.o(.data);
@ -26,7 +26,7 @@ SECTIONS {
ALIGN(4)
{
/* .bss starts at 0x3000000 */
<BSS>
INCLUDE "sym_bss.ld"
src/*.o(.bss);
data/*.o(.bss);
@ -34,7 +34,7 @@ SECTIONS {
src/m4a.o(.bss.code);
/* COMMON starts at 0x30030E0 */
<COMMON>
INCLUDE "sym_common.ld"
*libc.a:sbrkr.o(COMMON);
end = .;

View File

@ -1,14 +0,0 @@
/<EWRAM>/ {
r sym_ewram.ld
d
}
/<BSS>/ {
r sym_bss.ld
d
}
/<COMMON>/ {
r sym_common.ld
d
}