From 350d4d3543a0acca95877c7cec72c1eaca34513f Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Fri, 1 Jan 2021 06:12:20 -0700 Subject: [PATCH] Meta: Enable RTTI for Userspace programs RTTI is still disabled for the Kernel, and for the Dynamic Loader. This allows for much less awkward navigation of class heirarchies in LibCore, LibGUI, LibWeb, and LibJS (eventually). Measured RootFS size increase was < 1%, and libgui.so binary size was ~3.3%. The small binary size increase here seems worth it :^) --- CMakeLists.txt | 2 +- Kernel/CMakeLists.txt | 2 +- Toolchain/CMakeToolchain.txt | 2 +- Userland/DynamicLoader/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d37e760f5f..7597e97fab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,7 @@ endif() #FIXME: -fstack-protector -add_compile_options(-Os -g1 -fno-exceptions -fno-rtti -Wno-address-of-packed-member -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -Wno-nonnull-compare -Wno-deprecated-copy -Wno-expansion-to-defined) +add_compile_options(-Os -g1 -fno-exceptions -Wno-address-of-packed-member -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -Wno-nonnull-compare -Wno-deprecated-copy -Wno-expansion-to-defined) add_compile_options(-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.) add_compile_definitions(DEBUG SANITIZE_PTRS) diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 91a1ac8172..cb8368c663 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -261,7 +261,7 @@ set(SOURCES ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -DKERNEL") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fPIE -ffreestanding -fbuiltin") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fPIE -fno-rtti -ffreestanding -fbuiltin") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-80387 -mno-mmx -mno-sse -mno-sse2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-asynchronous-unwind-tables") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -nostdinc -nostdinc++") diff --git a/Toolchain/CMakeToolchain.txt b/Toolchain/CMakeToolchain.txt index 676ec1c133..c4178da464 100644 --- a/Toolchain/CMakeToolchain.txt +++ b/Toolchain/CMakeToolchain.txt @@ -8,7 +8,7 @@ if (NOT DEFINED ENV{SERENITY_ROOT}) message(FATAL_ERROR "SERENITY_ROOT not set.") endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") # where to read from/write to set(CMAKE_SYSROOT $ENV{SERENITY_ROOT}/Build/Root) diff --git a/Userland/DynamicLoader/CMakeLists.txt b/Userland/DynamicLoader/CMakeLists.txt index 4b022f4f78..7c763f0557 100644 --- a/Userland/DynamicLoader/CMakeLists.txt +++ b/Userland/DynamicLoader/CMakeLists.txt @@ -16,7 +16,7 @@ list(FILTER LIBC_SOURCES1 EXCLUDE REGEX ".+crt0.+.cpp") set(SOURCES ${LOADER_SOURCES} ${AK_SOURCES} ${ELF_SOURCES} ${LIBC_SOURCES1} ${LIBC_SOURCES2} ${LIBC_SOURCES3}) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -pie -fpic -DNO_TLS") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -nostdlib -pie -fpic -DNO_TLS") add_executable(Loader.so ${SOURCES}) target_link_options(Loader.so PRIVATE LINKER:--no-dynamic-linker)