From d156a5bf40f16b968152e80f6c9c63fe1f6ff1cc Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 15 Mar 2021 17:40:19 +0200 Subject: Enable ThinLTO --- linker.ld | 2 +- makefile | 5 +++-- toolchain.makefile | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/linker.ld b/linker.ld index a9c6ec8..764b78b 100644 --- a/linker.ld +++ b/linker.ld @@ -51,7 +51,7 @@ SECTIONS .bss ALIGN(4K) : AT(ADDR(.bss) - VADDR_BASE + 4M) { begin_bss = .; *(.pages) - *(.bss) + *(.bss*) *(.stack) end_bss = .; } diff --git a/makefile b/makefile index 5be61c0..5ebde01 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ -include toolchain.makefile include .config OBJ_DIR != echo $(CONFIG_OBJ_DIR) +include toolchain.makefile .PHONY: default clean test todo run menuconfig default: $(OBJ_DIR)/glitch.elf @@ -18,7 +18,8 @@ CXX_SYSTEM_INCLUDE := $(addprefix -isystem, $(CXX_SYSTEM_INCLUDE)) $(OBJ_DIR)/glitch.elf: $(autogen) $(AS_OBJ) $(CXX_OBJ) linker.ld @echo " LD $@" - @$(LD) $(LD_FLAGS) -o $@ $(AS_OBJ) $(CXX_OBJ) -T $(CURDIR)/linker.ld + @mkdir -p $(OBJ_DIR)/thinlto_cache + @$(LD) $(LD_FLAGS) -o $@ $(AS_OBJ) $(CXX_OBJ) $(AS_OBJ): $(OBJ_DIR)/%.o: %.S @mkdir -p $(@D) diff --git a/toolchain.makefile b/toolchain.makefile index c3ac2d8..d8f09f7 100644 --- a/toolchain.makefile +++ b/toolchain.makefile @@ -8,13 +8,13 @@ AS := clang AS_FLAGS := LD := ld.lld -LD_FLAGS := +LD_FLAGS := -T linker.ld --thinlto-cache-dir=$(OBJ_DIR)/thinlto_cache CXX := clang++ TEST_CXX := clang++ CXX_FLAGS := -std=c++20 -g \ -mkernel -ffreestanding -nostdlib -nostdinc -nostdinc++ \ - -Wall -Wextra -Werror=pedantic -O2 \ + -Wall -Wextra -Werror=pedantic -O2 -flto=thin \ -Werror=date-time \ -Werror=shadow-all \ -Wold-style-cast -Wconversion \ -- cgit v1.2.1