Reduce binary sizes for the kernel and userspace apps
This commit is contained in:
@ -4,7 +4,8 @@ include $(ROOT)/mk/grabsrc.mk
|
||||
|
||||
PUTCHAR_ ?= fb
|
||||
|
||||
CFLAGS := -ffreestanding -Wall -Wextra -g -fcommon -nostdinc
|
||||
CFLAGS := -ffreestanding -Wall -Wextra -fcommon -nostdinc \
|
||||
-fdata-sections -ffunction-sections
|
||||
|
||||
CFLAGS += -I. \
|
||||
-I$(ROOT)/limine \
|
||||
@ -24,7 +25,8 @@ CFLAGS += -I. \
|
||||
|
||||
include arch/$(ARCH)/$(ARCH).mk
|
||||
|
||||
LDFLAGS += -nostdlib -static -T arch/$(ARCH)/link.ld $(shell $(CC) -print-libgcc-file-name)
|
||||
LDFLAGS += -nostdlib -static -T arch/$(ARCH)/link.ld $(shell $(CC) -print-libgcc-file-name) \
|
||||
--gc-sections --strip-all
|
||||
|
||||
SRCFILES :=
|
||||
|
||||
|
||||
@ -2,4 +2,4 @@ PREFIX := $(ROOT)/toolchain/root/bin
|
||||
|
||||
CC := $(PREFIX)/x86_64-elf-gcc
|
||||
LD := $(PREFIX)/x86_64-elf-ld
|
||||
AR := $(PREFIX)/x86_64-elf-ar
|
||||
AR := $(PREFIX)/x86_64-elf-gcc-ar
|
||||
|
||||
@ -13,4 +13,8 @@ CFLAGS += -m64 \
|
||||
-fno-strict-aliasing \
|
||||
-O0 \
|
||||
-mno-tls-direct-seg-refs \
|
||||
# -fsanitize=undefined
|
||||
-fdata-sections \
|
||||
-ffunction-sections \
|
||||
|
||||
LDFLAGS += --gc-sections \
|
||||
--strip-all
|
||||
|
||||
@ -7,6 +7,7 @@ cd build-bintuils-gdb
|
||||
../binutils-gdb/configure --prefix="$PREFIX" \
|
||||
--disable-nls \
|
||||
--disable-werror \
|
||||
--enable-gold=yes \
|
||||
--target=x86_64-elf
|
||||
make -j$(nproc)
|
||||
make install
|
||||
|
||||
@ -10,6 +10,7 @@ cd build-gcc
|
||||
../gcc/configure --prefix="$PREFIX" \
|
||||
--disable-nls \
|
||||
--enable-languages=c \
|
||||
--enable-lto \
|
||||
--target=x86_64-elf \
|
||||
--disable-bootstrap \
|
||||
--without-headers \
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
CFLAGS := -ffreestanding -Wall -Wextra -g -fcommon -nostdinc \
|
||||
-isystem $(ROOT)/std/include -isystem $(ROOT)/ulib -isystem $(ROOT)/share \
|
||||
-isystem $(ROOT)/ulib/std
|
||||
-isystem $(ROOT)/std/include -isystem $(ROOT)/ulib -isystem $(ROOT)/share \
|
||||
-isystem $(ROOT)/ulib/std
|
||||
|
||||
CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
include $(CURRENT_DIR)/arch/$(ARCH)/$(ARCH).mk
|
||||
|
||||
LDFLAGS += -nostdlib -static $(shell $(CC) -print-libgcc-file-name) -T $(CURRENT_DIR)/arch/$(ARCH)/link.ld
|
||||
LDFLAGS += -nostdlib -static $(shell $(CC) -print-libgcc-file-name) \
|
||||
-T $(CURRENT_DIR)/arch/$(ARCH)/link.ld
|
||||
|
||||
@ -25,4 +25,12 @@ SECTIONS {
|
||||
. = ALIGN(4K);
|
||||
_bss_end = .;
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.eh_frame)
|
||||
*(.eh_frame_hdr)
|
||||
*(.gcc_except_table*)
|
||||
*(.note*)
|
||||
*(.comment)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user