@@ -18,27 +18,41 @@ define DEF_RUSTLLVM_TARGETS
18
18
# to find the llvm includes (probably because we're not actually installing
19
19
# llvm, but using it straight out of the build directory)
20
20
ifdef CFG_WINDOWSY_$(1)
21
- LLVM_EXTRA_INCDIRS_$(1) = -iquote $(S ) src/llvm/include \
22
- -iquote $$(CFG_LLVM_BUILD_DIR_$(1 ) ) /include
21
+ LLVM_EXTRA_INCDIRS_$(1) = $$(call CFG_CC_INCLUDE_$(1 ) ,$(S ) src/llvm/include) \
22
+ $$(call CFG_CC_INCLUDE_$(1 ) ,\
23
+ $$(CFG_LLVM_BUILD_DIR_$(1 ) ) /include)
23
24
endif
24
25
25
26
RUSTLLVM_OBJS_CS_$(1 ) := $$(addprefix rustllvm/, \
26
27
ExecutionEngineWrapper.cpp RustWrapper.cpp PassWrapper.cpp)
27
28
28
29
RUSTLLVM_INCS_$(1 ) = $$(LLVM_EXTRA_INCDIRS_$(1 ) ) \
29
- -iquote $$ (LLVM_INCDIR_$(1 ) ) \
30
- -iquote $$ (S ) src/rustllvm/include
30
+ $$( call CFG_CC_INCLUDE_ $( 1 ) , $$ (LLVM_INCDIR_$(1 ) ) ) \
31
+ $$( call CFG_CC_INCLUDE_ $( 1 ) , $$ (S ) src/rustllvm/include)
31
32
RUSTLLVM_OBJS_OBJS_$(1 ) := $$(RUSTLLVM_OBJS_CS_$(1 ) :rustllvm/%.cpp=$(1 ) /rustllvm/%.o )
32
- ALL_OBJ_FILES += $$(RUSTLLVM_OBJS_OBJS_$(1 ) )
33
+
34
+ # Note that we appease `cl.exe` and its need for some sort of exception
35
+ # handling flag with the `EHsc` argument here as well.
36
+ ifeq ($$(findstring msvc,$(1 ) ) ,msvc)
37
+ EXTRA_RUSTLLVM_CXXFLAGS_$(1) := //EHsc
38
+ endif
33
39
34
40
$$(RT_OUTPUT_DIR_$(1 ) ) /$$(call CFG_STATIC_LIB_NAME_$(1 ) ,rustllvm) : \
35
41
$$(RUSTLLVM_OBJS_OBJS_$(1 ) )
36
42
@$$(call E, link: $$@ )
37
- $$(Q )$$(AR_ $(1 ) ) rcs $$@ $$( RUSTLLVM_OBJS_OBJS_ $( 1 ) )
43
+ $$(Q )$$(call CFG_CREATE_ARCHIVE_ $(1 ) , $$@ ) $$^
38
44
45
+ # On MSVC we need to double-escape arguments that llvm-config printed which
46
+ # start with a '/'. The shell we're running in will auto-translate the argument
47
+ # `/foo` to `C:/msys64/foo` but we really want it to be passed through as `/foo`
48
+ # so the argument passed to our shell must be `//foo`.
39
49
$(1 ) /rustllvm/%.o: $(S ) src/rustllvm/%.cpp $$(MKFILE_DEPS ) $$(LLVM_CONFIG_$(1 ) )
40
50
@$$(call E, compile: $$@ )
41
- $$(Q )$$(call CFG_COMPILE_CXX_$(1 ) , $$@ , $$(LLVM_CXXFLAGS_$(1 ) ) $$(RUSTLLVM_INCS_$(1 ) ) ) $$<
51
+ $$(Q )$$(call CFG_COMPILE_CXX_$(1 ) , $$@ ,) \
52
+ $$(subst /,//,$$(LLVM_CXXFLAGS_$(1 ) ) ) \
53
+ $$(EXTRA_RUSTLLVM_CXXFLAGS_$(1 ) ) \
54
+ $$(RUSTLLVM_INCS_$(1 ) ) \
55
+ $$<
42
56
endef
43
57
44
58
# Instantiate template for all stages
0 commit comments