From 13680ae0380367217358d94d1fe877b88fd7bea3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 14 Dec 2021 09:42:26 +0100 Subject: [PATCH] Kernel: Build with -O2 by default We used to build with -Os in order to fit within a certain size, but there isn't really a good reason for that kind of restriction. Switching to -O2 yields a significant improvement in throughput, for example `test-js` is roughly 20% faster on my machine. :^) --- Documentation/AdvancedBuildInstructions.md | 2 +- Kernel/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/AdvancedBuildInstructions.md b/Documentation/AdvancedBuildInstructions.md index 890205d53c..e5bf99a48b 100644 --- a/Documentation/AdvancedBuildInstructions.md +++ b/Documentation/AdvancedBuildInstructions.md @@ -45,7 +45,7 @@ There are some optional features that can be enabled during compilation that are - `ENABLE_MEMORY_SANITIZER`: enables runtime checks for uninitialized memory accesses in Lagom test cases. - `ENABLE_UNDEFINED_SANITIZER`: builds in runtime checks for [undefined behavior](https://en.wikipedia.org/wiki/Undefined_behavior) (like null pointer dereferences and signed integer overflows) in Lagom test cases. - `ENABLE_FUZZER_SANITIZER`: builds [fuzzers](https://en.wikipedia.org/wiki/Fuzzing) for various parts of the system. -- `ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS`: sets -Og and -ggdb3 compile options for building the Kernel. Allows for easier debugging of Kernel code. By default, the Kernel is built with -Os instead. +- `ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS`: sets -Og and -ggdb3 compile options for building the Kernel. Allows for easier debugging of Kernel code. By default, the Kernel is built with -O2 instead. - `ENABLE_ALL_THE_DEBUG_MACROS`: used for checking whether debug code compiles on CI. This should not be set normally, as it clutters the console output and makes the system run very slowly. Instead, enable only the needed debug macros, as described below. - `ENABLE_ALL_DEBUG_FACILITIES`: used for checking whether debug code compiles on CI. Enables both `ENABLE_ALL_THE_DEBUG_MACROS` and `ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS`. - `ENABLE_COMPILETIME_FORMAT_CHECK`: checks for the validity of `std::format`-style format string during compilation. Enabled by default. diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 41655c5cba..00d4c80cfc 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -2,7 +2,7 @@ if (ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS) add_compile_options(-Og) add_compile_options(-ggdb3) else() - add_compile_options(-Os) + add_compile_options(-O2) endif() if ("${SERENITY_ARCH}" STREQUAL "aarch64")