@@ -44,6 +44,16 @@ set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
4444set (LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "" )
4545set (LLVM_RELEASE_ENABLE_RUNTIMES ${DEFAULT_RUNTIMES} CACHE STRING "" )
4646set (LLVM_RELEASE_ENABLE_PROJECTS ${DEFAULT_PROJECTS} CACHE STRING "" )
47+
48+ if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin" )
49+ # Don't link against the just built runtimes due to:
50+ # https://github.com/llvm/llvm-project/issues/77653
51+ set (DEFAULT_LINK_LOCAL_RUNTIMES OFF )
52+ else ()
53+ set (DEFAULT_LINK_LOCAL_RUNTIMES ON )
54+ endif ()
55+ set (LLVM_RELEASE_LINK_LOCAL_RUNTIMES ${DEFAULT_LINK_LOCAL_RUNTIMES} CACHE BOOL "" )
56+
4757# Note we don't need to add install here, since it is one of the pre-defined
4858# steps.
4959set (LLVM_RELEASE_FINAL_STAGE_TARGETS "clang;package;check-all;check-llvm;check-clang" CACHE STRING "" )
@@ -55,8 +65,12 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
5565
5666set (STAGE1_PROJECTS "clang" )
5767
68+ # Need to build compiler-rt in order to use PGO for later stages.
69+ set (STAGE1_RUNTIMES "compiler-rt" )
5870# Build all runtimes so we can statically link them into the stage2 compiler.
59- set (STAGE1_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" )
71+ if (DEFAULT_LINK_LOCAL_RUNTIMES)
72+ list (APPEND STAGE1_RUNTIMES "libcxx;libcxxabi;libunwind" )
73+ endif ()
6074
6175if (LLVM_RELEASE_ENABLE_PGO)
6276 list (APPEND STAGE1_PROJECTS "lld" )
@@ -118,11 +132,13 @@ set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}"
118132if (LLVM_RELEASE_ENABLE_LTO)
119133 set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL )
120134endif ()
121- set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL )
122- set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL )
123- set (RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind" )
124- if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin" )
125- set (RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc" )
135+ if (DEFAULT_LINK_LOCAL_RUNTIMES)
136+ set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL )
137+ set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL )
138+ set (RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind" )
139+ if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin" )
140+ set (RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc" )
141+ endif ()
126142endif ()
127143
128144# Set flags for bolt
0 commit comments