From 13d664b914462e2410570d6f7d6258caac1662af Mon Sep 17 00:00:00 2001 From: Minep Date: Sun, 23 Oct 2022 02:16:07 +0100 Subject: [PATCH] fix: temporary disable the cse optimizations that cause kernel misbehave. --- README.md | 6 +++--- lunaix-os/config/make-cc | 13 ++++++++++--- lunaix-os/makefile | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index aa08848..cdeecbe 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,8 @@ LunaixOS - 一个简单的,详细的,POSIX兼容的(但愿!),带有 本项目支持的make命令: | 命令 | 用途 | |---|---| -| `make all` | 构建镜像(`-O1`) | -| `make instable` | 构建镜像(`-O2`)**※** | +| `make all` | 构建镜像(`-O2`,但禁用CSE相关的优化项 **※** ) | +| `make instable` | 构建镜像(`-O2`,开启CSE相关优化) | | `make all-debug` | 构建适合调试用的镜像(`-Og`) | | `make run` | 使用QEMU运行build目录下的镜像| | `make debug-qemu` | 构建并使用QEMU进行调试 | @@ -72,7 +72,7 @@ LunaixOS - 一个简单的,详细的,POSIX兼容的(但愿!),带有 | `make debug-qemu-vscode` | 用于vscode整合 | | `make clean` | 删除build目录 | -**※:由于在`-O2`模式下,GCC会进行大量的优化,这导致LunaixOS会出现一些非常奇怪、离谱的bug,从而影响到基本运行。调试这些bug需要大量的汗水与时间,属于日后维护的任务。所以,在目前,LunaixOS将默认最大的优化程度设置为比较安全的`-O1`。`make instable`仅用于方便日后的对该问题的进一步调试。** +**※:由于在`-O2`模式下,GCC会进行CSE优化,这导致LunaixOS会出现一些非常奇怪、离谱的bug,从而影响到基本运行。具体原因有待调查。** ## 运行以及Issue diff --git a/lunaix-os/config/make-cc b/lunaix-os/config/make-cc index 71f3b76..ed1f678 100644 --- a/lunaix-os/config/make-cc +++ b/lunaix-os/config/make-cc @@ -3,13 +3,20 @@ AS := i686-elf-as ARCH_OPT := -D__ARCH_IA32 -O := -O1 +O := -O2 W := -Wall -Wextra -Wno-unknown-pragmas \ -Wno-unused-function \ -Wno-unused-but-set-variable \ -Wno-unused-parameter \ -Wno-unused-variable\ -Werror=incompatible-pointer-types - -CFLAGS := -std=gnu99 -ffreestanding $(O) $(W) $(ARCH_OPT) + +OFLAGS := -fno-gcse\ + -fno-gcse-lm\ + -fno-cse-follow-jumps\ + -fno-cse-skip-blocks\ + -fno-optimize-strlen\ + -fno-tree-builtin-call-dce + +CFLAGS := -std=gnu99 -ffreestanding $(O) $(OFLAGS) $(W) $(ARCH_OPT) LDFLAGS := -ffreestanding $(O) -nostdlib -lgcc \ No newline at end of file diff --git a/lunaix-os/makefile b/lunaix-os/makefile index 2735946..058bcc8 100644 --- a/lunaix-os/makefile +++ b/lunaix-os/makefile @@ -39,7 +39,7 @@ $(BUILD_DIR)/$(OS_ISO): $(ISO_DIR) $(BIN_DIR)/$(OS_BIN) GRUB_TEMPLATE all: clean $(BUILD_DIR)/$(OS_ISO) -instable: O := -O2 +instable: CFLAGS := -g -std=gnu99 -ffreestanding $(O) $(W) $(ARCH_OPT) -D__LUNAIXOS_DEBUG__ instable: all all-debug: O := -Og -- 2.27.0