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
|
PUTCHAR_ ?= fb
|
||||||
|
|
||||||
CFLAGS := -ffreestanding -Wall -Wextra -g -fcommon -nostdinc
|
CFLAGS := -ffreestanding -Wall -Wextra -fcommon -nostdinc \
|
||||||
|
-fdata-sections -ffunction-sections
|
||||||
|
|
||||||
CFLAGS += -I. \
|
CFLAGS += -I. \
|
||||||
-I$(ROOT)/limine \
|
-I$(ROOT)/limine \
|
||||||
@ -24,7 +25,8 @@ CFLAGS += -I. \
|
|||||||
|
|
||||||
include arch/$(ARCH)/$(ARCH).mk
|
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 :=
|
SRCFILES :=
|
||||||
|
|
||||||
|
|||||||
@ -2,4 +2,4 @@ PREFIX := $(ROOT)/toolchain/root/bin
|
|||||||
|
|
||||||
CC := $(PREFIX)/x86_64-elf-gcc
|
CC := $(PREFIX)/x86_64-elf-gcc
|
||||||
LD := $(PREFIX)/x86_64-elf-ld
|
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 \
|
-fno-strict-aliasing \
|
||||||
-O0 \
|
-O0 \
|
||||||
-mno-tls-direct-seg-refs \
|
-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" \
|
../binutils-gdb/configure --prefix="$PREFIX" \
|
||||||
--disable-nls \
|
--disable-nls \
|
||||||
--disable-werror \
|
--disable-werror \
|
||||||
|
--enable-gold=yes \
|
||||||
--target=x86_64-elf
|
--target=x86_64-elf
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
make install
|
make install
|
||||||
|
|||||||
@ -10,6 +10,7 @@ cd build-gcc
|
|||||||
../gcc/configure --prefix="$PREFIX" \
|
../gcc/configure --prefix="$PREFIX" \
|
||||||
--disable-nls \
|
--disable-nls \
|
||||||
--enable-languages=c \
|
--enable-languages=c \
|
||||||
|
--enable-lto \
|
||||||
--target=x86_64-elf \
|
--target=x86_64-elf \
|
||||||
--disable-bootstrap \
|
--disable-bootstrap \
|
||||||
--without-headers \
|
--without-headers \
|
||||||
|
|||||||
@ -6,4 +6,5 @@ CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|||||||
|
|
||||||
include $(CURRENT_DIR)/arch/$(ARCH)/$(ARCH).mk
|
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);
|
. = ALIGN(4K);
|
||||||
_bss_end = .;
|
_bss_end = .;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.eh_frame)
|
||||||
|
*(.eh_frame_hdr)
|
||||||
|
*(.gcc_except_table*)
|
||||||
|
*(.note*)
|
||||||
|
*(.comment)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user