misc: Compile stage 2 with -Os and stage 3 with -O3

This commit is contained in:
mintsuki 2021-03-04 23:12:40 +01:00
parent cbcf3779b6
commit 8939c3421c
4 changed files with 19 additions and 4 deletions

View File

@ -20,7 +20,8 @@ E9_OUTPUT = false
BUILD_ID := $(shell dd if=/dev/urandom count=8 bs=1 | od -An -t x8 | sed 's/^ /0x/') BUILD_ID := $(shell dd if=/dev/urandom count=8 bs=1 | od -An -t x8 | sed 's/^ /0x/')
LIMINE_VERSION := $(shell git describe --exact-match --tags `git log -n1 --pretty='%h'` || git log -n1 --pretty='%h') LIMINE_VERSION := $(shell git describe --exact-match --tags `git log -n1 --pretty='%h'` || git log -n1 --pretty='%h')
WERROR = -Werror WERROR = -Werror
CFLAGS = -Os -g -pipe -Wall -Wextra $(WERROR) CFLAGS = -O3 -g -pipe -Wall -Wextra $(WERROR)
S2CFLAGS = -Os -g -pipe -Wall -Wextra $(WERROR)
INTERNAL_CFLAGS := \ INTERNAL_CFLAGS := \
-std=gnu11 \ -std=gnu11 \
@ -54,7 +55,7 @@ ifeq ($(TARGET), uefi)
-mno-red-zone -mno-red-zone
endif endif
LDFLAGS = -Os -g LDFLAGS = -O3 -g
INTERNAL_LDFLAGS := \ INTERNAL_LDFLAGS := \
-fno-lto \ -fno-lto \
@ -133,6 +134,11 @@ limine_efi.elf: $(OBJ) font.o sys/smp_trampoline.o
%.o: %.c %.o: %.c
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
ifeq ($(TARGET), bios)
%.s2.o: %.s2.c
$(CC) $(S2CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
endif
%.o: %.asm %.o: %.asm
nasm $< -F dwarf -g -f elf32 -o $@ nasm $< -F dwarf -g -f elf32 -o $@

View File

@ -191,6 +191,9 @@ static int fat32_open_in(struct fat32_context* context, struct fat32_directory_e
size_t dir_chain_len; size_t dir_chain_len;
uint32_t *directory_cluster_chain = cache_cluster_chain(context, current_cluster_number, &dir_chain_len); uint32_t *directory_cluster_chain = cache_cluster_chain(context, current_cluster_number, &dir_chain_len);
if (directory_cluster_chain == NULL)
return -1;
struct fat32_directory_entry *directory_entries = ext_mem_alloc(dir_chain_len * block_size); struct fat32_directory_entry *directory_entries = ext_mem_alloc(dir_chain_len * block_size);
if (!read_cluster_chain(context, directory_cluster_chain, directory_entries, 0, dir_chain_len * block_size)) if (!read_cluster_chain(context, directory_cluster_chain, directory_entries, 0, dir_chain_len * block_size))
return -1; return -1;

View File

@ -26,7 +26,10 @@ static void spinup(uint8_t drive) {
"mov eax, cr0\n\t" "mov eax, cr0\n\t"
"and al, 0xfe\n\t" "and al, 0xfe\n\t"
"mov cr0, eax\n\t" "mov cr0, eax\n\t"
"jmp 0x0000:1f\n\t" "mov eax, OFFSET 1f\n\t"
"push eax\n\t"
"push 0\n\t"
"retf\n\t"
"1:\n\t" "1:\n\t"
"mov ax, 0\n\t" "mov ax, 0\n\t"
"mov ds, ax\n\t" "mov ds, ax\n\t"

View File

@ -34,7 +34,10 @@ static void spinup(uint16_t real_mode_code_seg, uint16_t kernel_entry_seg,
"mov eax, cr0\n\t" "mov eax, cr0\n\t"
"and al, 0xfe\n\t" "and al, 0xfe\n\t"
"mov cr0, eax\n\t" "mov cr0, eax\n\t"
"jmp 0x0000:1f\n\t" "mov eax, OFFSET 1f\n\t"
"push eax\n\t"
"push 0\n\t"
"retf\n\t"
"1:\n\t" "1:\n\t"
"mov ds, bx\n\t" "mov ds, bx\n\t"
"mov es, bx\n\t" "mov es, bx\n\t"