@@ -226,18 +226,32 @@ COMPRT_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
226
226
COMPRT_LIB_$(1 ) := $$(RT_OUTPUT_DIR_$(1 ) ) /$$(COMPRT_NAME_$(1 ) )
227
227
COMPRT_BUILD_DIR_$(1 ) := $$(RT_OUTPUT_DIR_$(1 ) ) /compiler-rt
228
228
229
+ # Note that on MSVC-targeting builds we hardwire CC/AR to gcc/ar even though
230
+ # we're targeting MSVC. This is because although compiler-rt has a CMake build
231
+ # config I can't actually figure out how to use it, so I'm not sure how to use
232
+ # cl.exe to build the objects. Additionally, the compiler-rt library when built
233
+ # with gcc has the same ABI as cl.exe, so they're largely compatible
234
+ COMPRT_CC_$(1 ) := $$(CC_$(1 ) )
235
+ COMPRT_AR_$(1 ) := $$(AR_$(1 ) )
236
+ COMPRT_CFLAGS_$(1 ) := $$(CFG_GCCISH_CFLAGS_$(1 ) )
237
+ ifeq ($$(findstring msvc,$(1 ) ) ,msvc)
238
+ COMPRT_CC_$(1) := gcc
239
+ COMPRT_AR_$(1) := ar
240
+ COMPRT_CFLAGS_$(1) := $$(CFG_GCCISH_CFLAGS_$(1 ) ) -m64
241
+ endif
242
+
229
243
$$(COMPRT_LIB_$(1 ) ) : $$(COMPRT_DEPS ) $$(MKFILE_DEPS )
230
244
@$$(call E, make: compiler-rt)
231
245
$$(Q )$$(MAKE ) -C "$(S ) src/compiler-rt" \
232
246
ProjSrcRoot="$(S ) src/compiler-rt" \
233
247
ProjObjRoot="$$(abspath $$(COMPRT_BUILD_DIR_$(1 ) ) ) " \
234
- CC=" $$(CC_ $(1 ) ) " \
235
- AR=" $$(AR_ $(1 ) ) " \
236
- RANLIB=" $$(AR_ $(1 ) ) s" \
237
- CFLAGS="$$(CFG_GCCISH_CFLAGS_ $(1 ) ) " \
248
+ CC=' $$(COMPRT_CC_ $(1 ) ) ' \
249
+ AR=' $$(COMPRT_AR_ $(1 ) ) ' \
250
+ RANLIB=' $$(COMPRT_AR_ $(1 ) ) s' \
251
+ CFLAGS="$$(COMPRT_CFLAGS_ $(1 ) ) " \
238
252
TargetTriple=$(1 ) \
239
253
triple-builtins
240
- $$(Q ) cp $$(COMPRT_BUILD_DIR_$(1 ) ) /triple/builtins/libcompiler_rt.a $$( COMPRT_LIB_ $( 1 ) )
254
+ $$(Q ) cp $$(COMPRT_BUILD_DIR_$(1 ) ) /triple/builtins/libcompiler_rt.a $$@
241
255
242
256
# ###############################################################################
243
257
# libbacktrace
0 commit comments