sotn-decomp icon indicating copy to clipboard operation
sotn-decomp copied to clipboard

Make 4.4 does not work when building in parallel

Open Xeeynamo opened this issue 2 years ago • 0 comments

What

The latest minor version bump of GNU Make does not work well with this project due to some documented breaking changes. The problem only occurs when building happens in parallel (e.g. make -j build. The problem is GCC wants to compile C files and output them to directories that do not yet exist.

This good first issue will help you to familiarise with our build chain.

Technical details

In the Makefile there are targets that are responsible for creating the output directories:

tt_%_dirs:
	$(foreach dir,$(ASM_DIR)/servant/tt_$* $(ASM_DIR)/servant/tt_$*/data $(SRC_DIR)/servant/tt_$* $(ASSETS_DIR)/servant/tt_$*,$(shell mkdir -p $(BUILD_DIR)/$(dir)))
st%_dirs:
	$(foreach dir,$(ASM_DIR)/st/$* $(ASM_DIR)/st/$*/data $(SRC_DIR)/st/$* $(ASSETS_DIR)/st/$*,$(shell mkdir -p $(BUILD_DIR)/$(dir)))
%_dirs:
	$(foreach dir,$(ASM_DIR)/$* $(ASM_DIR)/$*/data $(SRC_DIR)/$* $(ASSETS_DIR)/$*,$(shell mkdir -p $(BUILD_DIR)/$(dir)))

When an overlay is built, these targets are called. For example doing make cen calls the target cen: stcen_dirs $(BUILD_DIR)/CEN.BIN to first create the directories and then the output binary. This behaviour was working on Make 4.3 and below as dependent targets were always processed in order.

Potential solution

Before GCC is called, mkdir -p $(dir $@) can be called to ensure the directory exists. This is already done in Makefile.saturn.mk. Once this part is done, the various targets %_dirs can be deleted.

On Arch Linux I personally made a back-up of make 4.3-5.1 to easily downgrade and test things around.

What is affected

What is NOT affected

Acceptance criteria

Any of the affected operating systems, or Debian/Ubuntu with make 4.4 installed, needs to be able to run make -j build successfully and consistently.

Xeeynamo avatar Nov 07 '23 18:11 Xeeynamo