make: Ensure main object file is first
Per the SDCC manual, the object that declares main must be passed first to the linker. The resulting binary is identical, and this has not caused a problem yet, so I'm unsure how "required" this is. Ref: Section 3.2.3 Projects with Multiple Source Files Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
		
				
					committed by
					
						 Tim Crawford
						Tim Crawford
					
				
			
			
				
	
			
			
			
						parent
						
							7ebec4f7b1
						
					
				
				
					commit
					f46360fb45
				
			| @@ -5,6 +5,11 @@ CC = sdcc -mmcs51 --model-large --code-size $(CODE_SIZE) --xram-size $(SRAM_SIZE | ||||
| AS = sdas8051 | ||||
| ASFLAGS = -plosgff | ||||
|  | ||||
| # XXX: SDCC "requires" main() to be in the first item passed to the linker. | ||||
| # Ref: SDCC Manual 4.2.8; Section 3.2.3 Projects with Multiple Source Files | ||||
| MAIN_SRC = $(filter %/main.c, $(SRC)) | ||||
| MAIN_OBJ = $(sort $(patsubst src/%.c, $(BUILD)/%.rel, $(MAIN_SRC))) | ||||
|  | ||||
| # NOTE: sdas *must* be used for assembly files as sdcc cannot compile them | ||||
| # itself. They must use an extension of `.asm` so they can be filtered here. | ||||
|  | ||||
| @@ -14,7 +19,7 @@ ASM_OBJ = $(sort $(patsubst src/%.asm, $(BUILD)/%.rel, $(ASM_SRC))) | ||||
| C_SRC = $(filter %.c, $(SRC)) | ||||
| C_OBJ = $(sort $(patsubst src/%.c, $(BUILD)/%.rel, $(C_SRC))) | ||||
|  | ||||
| OBJ = $(sort $(ASM_OBJ) $(C_OBJ)) | ||||
| OBJ = $(MAIN_OBJ) $(sort $(ASM_OBJ) $(C_OBJ)) | ||||
|  | ||||
| # Run EC rom in simulator | ||||
| sim: $(BUILD)/ec.rom | ||||
|   | ||||
		Reference in New Issue
	
	Block a user