From 64412a49bed9d6a743ed4d9108fc2da49ed5e9a9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 11 May 2015 14:09:25 -0700 Subject: [PATCH] mk: Fix building compiler-rt on MSVC It looks like compiler-rt has a cmake build sytem inside its source, but I have been unable to figure out how to use it and actually build the right library. For now this commit hard-wires MSVC-targeting builds of libcompiler-rt to continue using `make` as the primary bulid system, but some frobbing of the flags are necessary to ensure that the right compiler is used. --- mk/rt.mk | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/mk/rt.mk b/mk/rt.mk index 3d3e4c8866c..777a2a0fd3b 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -226,18 +226,32 @@ COMPRT_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt) COMPRT_LIB_$(1) := $$(RT_OUTPUT_DIR_$(1))/$$(COMPRT_NAME_$(1)) COMPRT_BUILD_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/compiler-rt +# Note that on MSVC-targeting builds we hardwire CC/AR to gcc/ar even though +# we're targeting MSVC. This is because although compiler-rt has a CMake build +# config I can't actually figure out how to use it, so I'm not sure how to use +# cl.exe to build the objects. Additionally, the compiler-rt library when built +# with gcc has the same ABI as cl.exe, so they're largely compatible +COMPRT_CC_$(1) := $$(CC_$(1)) +COMPRT_AR_$(1) := $$(AR_$(1)) +COMPRT_CFLAGS_$(1) := $$(CFG_GCCISH_CFLAGS_$(1)) +ifeq ($$(findstring msvc,$(1)),msvc) +COMPRT_CC_$(1) := gcc +COMPRT_AR_$(1) := ar +COMPRT_CFLAGS_$(1) := $$(CFG_GCCISH_CFLAGS_$(1)) -m64 +endif + $$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS) @$$(call E, make: compiler-rt) $$(Q)$$(MAKE) -C "$(S)src/compiler-rt" \ ProjSrcRoot="$(S)src/compiler-rt" \ ProjObjRoot="$$(abspath $$(COMPRT_BUILD_DIR_$(1)))" \ - CC="$$(CC_$(1))" \ - AR="$$(AR_$(1))" \ - RANLIB="$$(AR_$(1)) s" \ - CFLAGS="$$(CFG_GCCISH_CFLAGS_$(1))" \ + CC='$$(COMPRT_CC_$(1))' \ + AR='$$(COMPRT_AR_$(1))' \ + RANLIB='$$(COMPRT_AR_$(1)) s' \ + CFLAGS="$$(COMPRT_CFLAGS_$(1))" \ TargetTriple=$(1) \ triple-builtins - $$(Q)cp $$(COMPRT_BUILD_DIR_$(1))/triple/builtins/libcompiler_rt.a $$(COMPRT_LIB_$(1)) + $$(Q)cp $$(COMPRT_BUILD_DIR_$(1))/triple/builtins/libcompiler_rt.a $$@ ################################################################################ # libbacktrace