38.14. Optimization level of a build
The --optimization-level
option is available on all build scripts and sets the given GCC `-`O optimization level where it has been implemented for guest binaries.
The default optimization level is -O0
to improve guest visibility.
To keep things sane, you generally want to create a separate build variant for each optimization level, e.g. to create an -O3
build:
./build-userland --optimization-level 3 --userland-build-id o3 ./run --userland userland/c/hello.c --userland-build-id o3
Note that for some guest content, there are hard technical challenges why we are not able to forward -O
, notably the linux kernel: Disable kernel compiler optimizations.
Our emulators however are build with higher optimization levels by default otherwise running anything would be too unbearably slow.
Emulator builds are also controlled with other mechanisms instead of --optimization-level
as explained at: Debug the emulator.