mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
c0cf6e3744
The C++ semantics of `inline` dictate that such functions might be defined in multiple translation units. As with all other functions, they must have the same address in all TUs. Because of this, the compiler emits `inline` functions as weak symbols, which the dynamic linker can then resolve to the same address everywhere. This rule is responsible for a significant overhead at startup, as such lookups happen by name. Namely, 86'000 of the 114'000 by-name symbol lookups when loading LibWeb can be attributed to this. Most of these are only ever defined in a single object, making this even more pointless. As nothing in our code relies on either ELF symbol interposition rules or function address equality, we can use the -fvisibility-inlines-hidden escape hatch, which causes this rule to be disregarded. As the symbols are now hidden, no load-time symbol lookup is needed. This flag is used without issues in other large C++ codebases like Chromium and LLVM. Some relevant light reading, suggested by Nico: - https://ridiculousfish.com/blog/posts/i-didnt-order-that-so-why-is-it-on-my-bill-episode-1.html - https://www.cs.dartmouth.edu/~sergey/cs258/ABI/UlrichDrepper-How-To-Write-Shared-Libraries.pdf - https://blog.llvm.org/2018/11/30-faster-windows-builds-with-clang-cl_14.html - https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-fvisibility-inlines-hidden
39 lines
1.5 KiB
CMake
39 lines
1.5 KiB
CMake
# Flags shared by Lagom (including Ladybird) and Serenity.
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
add_compile_options(-Wall)
|
|
add_compile_options(-Wextra)
|
|
|
|
add_compile_options(-Wno-unknown-warning-option)
|
|
add_compile_options(-Wno-unused-command-line-argument)
|
|
|
|
add_compile_options(-fdiagnostics-color=always)
|
|
add_compile_options(-fno-exceptions)
|
|
|
|
if (NOT CMAKE_HOST_SYSTEM_NAME MATCHES SerenityOS)
|
|
# FIXME: Something makes this go crazy and flag unused variables that aren't flagged as such when building with the toolchain.
|
|
# Disable -Werror for now.
|
|
add_compile_options(-Werror)
|
|
endif()
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
|
# Clang's default constexpr-steps limit is 1048576(2^20), GCC doesn't have one
|
|
add_compile_options(-fconstexpr-steps=16777216)
|
|
|
|
add_compile_options(-Wno-implicit-const-int-float-conversion)
|
|
add_compile_options(-Wno-user-defined-literals)
|
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
# Only ignore expansion-to-defined for g++, clang's implementation doesn't complain about function-like macros
|
|
add_compile_options(-Wno-expansion-to-defined)
|
|
add_compile_options(-Wno-literal-suffix)
|
|
|
|
# FIXME: This warning seems useful but has too many false positives with GCC 13.
|
|
add_compile_options(-Wno-dangling-reference)
|
|
endif()
|
|
|
|
if (UNIX AND NOT APPLE AND NOT ENABLE_FUZZERS)
|
|
add_compile_options(-fno-semantic-interposition)
|
|
add_compile_options(-fvisibility-inlines-hidden)
|
|
endif()
|