Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions clang/cmake/caches/Fuchsia-stage2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL "")
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")

# Enable FatLTO for Linux and baremetal runtimes
set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "")
set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "")

# Use .build-id link.
list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
endif()
Expand Down Expand Up @@ -274,6 +278,10 @@ if(FUCHSIA_SDK)
set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")

# Enable FatLTO for Fuchsia runtimes
set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "")
set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "")

# Use .build-id link.
list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
endforeach()
Expand Down Expand Up @@ -360,6 +368,10 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv8m.main-none-eabi)
set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "")

# Enable FatLTO for baremetal runtimes
set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "")
set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "")
endforeach()

foreach(target riscv32-unknown-elf)
Expand Down Expand Up @@ -412,6 +424,10 @@ foreach(target riscv32-unknown-elf)
set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "")

# Enable FatLTO for baremetal runtimes
set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "")
set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "")
endforeach()

set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")
Expand Down
6 changes: 6 additions & 0 deletions libcxxabi/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ if (NOT APPLE) # On Apple platforms, we always use -nostdlib++ so we don't need
add_library_flags_if(LIBCXXABI_HAS_C_LIB c)
endif()

if (FUCHSIA)
# TODO use CMAKE_LINK_LIBRARY_USING_FEATURE once our minimum CMake is at least 3.24
# https://cmake.org/cmake/help/latest/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.html
add_link_flags("-Wl,--push-state,--as-needed,-lzircon,--pop-state")
endif()

if (NOT LIBCXXABI_USE_COMPILER_RT)
add_library_flags_if(LIBCXXABI_HAS_GCC_LIB gcc)
endif()
Expand Down
2 changes: 1 addition & 1 deletion llvm/cmake/modules/HandleLLVMOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ elseif(LLVM_ENABLE_LTO)
endif()
endif()

if(LLVM_ENABLE_FATLTO AND UNIX AND NOT APPLE)
if(LLVM_ENABLE_FATLTO AND ((UNIX AND NOT APPLE) OR FUCHSIA))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why that diff is required since you're setting it properly in your cache files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Fuchsia Targets aren't UNIX. Without this change -ffat-lto-objects won't be passed to clang through CMake. The additional logic is basically to restrict the flag to ELF targets, and it missed Fuchsia when we added it, since we weren't building our runtimes with FatLTO initially, just the toolchain + tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I think I initially read if (LLVM_ENABLE_FATLTO OR ((UNIX AND NOT APPLE) OR FUCHSIA)).

append("-ffat-lto-objects" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if(NOT LINKER_IS_LLD_LINK)
append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS)
Expand Down