@@ -216,22 +216,31 @@ COMPRT_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
216216COMPRT_LIB_$(1 ) := $$(RT_OUTPUT_DIR_$(1 ) ) /$$(COMPRT_NAME_$(1 ) )
217217COMPRT_BUILD_DIR_$(1 ) := $$(RT_OUTPUT_DIR_$(1 ) ) /compiler-rt
218218
219- # Note that on MSVC-targeting builds we hardwire CC/AR to gcc/ar even though
220- # we're targeting MSVC. This is because although compiler-rt has a CMake build
221- # config I can't actually figure out how to use it, so I'm not sure how to use
222- # cl.exe to build the objects. Additionally, the compiler-rt library when built
223- # with gcc has the same ABI as cl.exe, so they're largely compatible
224- COMPRT_CC_$(1 ) := $$(CC_$(1 ) )
225- COMPRT_AR_$(1 ) := $$(AR_$(1 ) )
226- COMPRT_CFLAGS_$(1 ) := $$(CFG_GCCISH_CFLAGS_$(1 ) )
227219ifeq ($$(findstring msvc,$(1 ) ) ,msvc)
228- COMPRT_CC_$(1) := gcc
229- COMPRT_AR_$(1) := ar
230- ifeq ($$(findstring i686,$(1 ) ) ,i686)
231- COMPRT_CFLAGS_$(1) := $$(CFG_GCCISH_CFLAGS_$(1 ) ) -m32
220+ $$(COMPRT_LIB_$(1 ) ) : $$(COMPRT_DEPS ) $$(MKFILE_DEPS ) $$(LLVM_CONFIG_$(1 ) )
221+ @$$(call E, cmake: compiler-rt)
222+ $$(Q ) cd " $$ (COMPRT_BUILD_DIR_$( 1) )" ; $$(CFG_CMAKE ) " $( S) src/compiler-rt" \
223+ -DCMAKE_BUILD_TYPE=$$(LLVM_BUILD_CONFIG_MODE ) \
224+ -DLLVM_CONFIG_PATH=$$(LLVM_CONFIG_$(1 ) ) \
225+ -G" $$ (CFG_CMAKE_GENERATOR)"
226+ $$(Q )$$(CFG_CMAKE ) --build " $$ (COMPRT_BUILD_DIR_$( 1) )" \
227+ --target lib/builtins/builtins \
228+ --config $$(LLVM_BUILD_CONFIG_MODE ) \
229+ -- //v:m //nologo
230+ $$(Q ) cp $$(COMPRT_BUILD_DIR_$(1 ) ) /lib/windows/$$(LLVM_BUILD_CONFIG_MODE ) /clang_rt.builtins-$$(HOST_$(1 ) ) .lib $$@
232231else
233- COMPRT_CFLAGS_$(1) := $$(CFG_GCCISH_CFLAGS_$(1 ) ) -m64
234- endif
232+ COMPRT_CC_$(1) := $$(CC_$(1 ) )
233+ COMPRT_AR_$(1) := $$(AR_$(1 ) )
234+ # We chomp -Werror here because GCC warns about the type signature of
235+ # builtins not matching its own and the build fails. It's a bit hacky,
236+ # but what can we do, we're building libclang-rt using GCC ......
237+ COMPRT_CFLAGS_$(1) := $$(subst -Werror,,$$(CFG_GCCISH_CFLAGS_$(1 ) ) ) -std=c99
238+
239+ # FreeBSD Clang's packaging is problematic; it doesn't copy unwind.h to
240+ # the standard include directory. This should really be in our changes to
241+ # compiler-rt, but we override the CFLAGS here so there isn't much choice
242+ ifeq ($$(findstring freebsd,$(1 ) ) ,freebsd)
243+ COMPRT_CFLAGS_$(1) += -I/usr/include/c++/v1
235244endif
236245
237246$$(COMPRT_LIB_$(1 ) ) : $$(COMPRT_DEPS ) $$(MKFILE_DEPS )
@@ -246,7 +255,7 @@ $$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS)
246255 TargetTriple=$(1 ) \
247256 triple-builtins
248257 $$(Q ) cp $$(COMPRT_BUILD_DIR_$(1 ) ) /triple/builtins/libcompiler_rt.a $$@
249-
258+ endif
250259# ###############################################################################
251260# libbacktrace
252261#
0 commit comments