Kaydet (Commit) 3b65852f authored tarafından Michael Stahl's avatar Michael Stahl

gbuild: add support for building against MSVC debug runtime

Mainly this means using /MDd instead of /MD and /MTd instead of /MT in
the CFLAGS, and also re-mapping of .lib files to ones with "d".

Change-Id: Ifc56b53a66d5eb522c1695a34d68b08cad1d8338
üst 54ba172d
...@@ -58,15 +58,9 @@ $(eval $(call gb_Library_use_system_win32_libs,emser,\ ...@@ -58,15 +58,9 @@ $(eval $(call gb_Library_use_system_win32_libs,emser,\
uuid \ uuid \
)) ))
ifeq ($(USE_DEBUG_RUNTIME),)
$(eval $(call gb_Library_add_libs,emser,\ $(eval $(call gb_Library_add_libs,emser,\
$(ATL_LIB)/atls.lib \ $(ATL_LIB)/$(if $(MSVC_USE_DEBUG_RUNTIME),atlsd.lib,atls.lib) \
)) ))
else
$(eval $(call gb_Library_add_libs,emser,\
$(ATL_LIB)/atlsd.lib \
))
endif
$(eval $(call gb_Library_add_ldflags,emser,\ $(eval $(call gb_Library_add_ldflags,emser,\
-LIBPATH:$(ATL_LIB) \ -LIBPATH:$(ATL_LIB) \
......
...@@ -59,15 +59,9 @@ $(eval $(call gb_Library_use_system_win32_libs,oleautobridge,\ ...@@ -59,15 +59,9 @@ $(eval $(call gb_Library_use_system_win32_libs,oleautobridge,\
)) ))
ifeq ($(COM),MSC) ifeq ($(COM),MSC)
ifneq ($(USE_DEBUG_RUNTIME),)
$(eval $(call gb_Library_add_libs,oleautobridge,\ $(eval $(call gb_Library_add_libs,oleautobridge,\
$(ATL_LIB)/atlsd.lib \ $(ATL_LIB)/$(if $(MSVC_USE_DEBUG_RUNTIME),atlsd.lib,atls.lib) \
)) ))
else
$(eval $(call gb_Library_add_libs,oleautobridge,\
$(ATL_LIB)/atls.lib \
))
endif
endif endif
$(eval $(call gb_Library_add_exception_objects,oleautobridge,\ $(eval $(call gb_Library_add_exception_objects,oleautobridge,\
......
...@@ -65,14 +65,8 @@ $(eval $(call gb_Library_use_system_win32_libs,so_activex,\ ...@@ -65,14 +65,8 @@ $(eval $(call gb_Library_use_system_win32_libs,so_activex,\
uuid \ uuid \
)) ))
ifneq ($(USE_DEBUG_RUNTIME),)
$(eval $(call gb_Library_add_libs,so_activex,\ $(eval $(call gb_Library_add_libs,so_activex,\
$(ATL_LIB)/atlsd.lib \ $(ATL_LIB)/$(if $(MSVC_USE_DEBUG_RUNTIME),atlsd.lib,atls.lib) \
)) ))
else
$(eval $(call gb_Library_add_libs,so_activex,\
$(ATL_LIB)/atls.lib \
))
endif
# vim:set noet sw=4 ts=4: # vim:set noet sw=4 ts=4:
...@@ -68,14 +68,8 @@ $(eval $(call gb_Library_use_system_win32_libs,so_activex_x64,\ ...@@ -68,14 +68,8 @@ $(eval $(call gb_Library_use_system_win32_libs,so_activex_x64,\
uuid \ uuid \
)) ))
ifneq ($(USE_DEBUG_RUNTIME),)
$(eval $(call gb_Library_add_libs,so_activex_x64,\ $(eval $(call gb_Library_add_libs,so_activex_x64,\
$(ATL_LIB)/amd64/atlsd.lib \ $(ATL_LIB)/amd64/$(if $(MSVC_USE_DEBUG_RUNTIME),atlsd.lib,atls.lib) \
)) ))
else
$(eval $(call gb_Library_add_libs,so_activex_x64,\
$(ATL_LIB)/amd64/atls.lib \
))
endif
# vim:set noet sw=4 ts=4: # vim:set noet sw=4 ts=4:
...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,instooofiltmsi,\ ...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,instooofiltmsi,\
)) ))
$(eval $(call gb_Library_add_cxxflags,instooofiltmsi,\ $(eval $(call gb_Library_add_cxxflags,instooofiltmsi,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_Library_add_ldflags,instooofiltmsi,\ $(eval $(call gb_Library_add_ldflags,instooofiltmsi,\
......
...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,qslnkmsi,\ ...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,qslnkmsi,\
)) ))
$(eval $(call gb_Library_add_cxxflags,qslnkmsi,\ $(eval $(call gb_Library_add_cxxflags,qslnkmsi,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_Library_add_ldflags,qslnkmsi,\ $(eval $(call gb_Library_add_ldflags,qslnkmsi,\
......
...@@ -16,7 +16,7 @@ $(eval $(call gb_Library_add_defs,reg4allmsdoc,\ ...@@ -16,7 +16,7 @@ $(eval $(call gb_Library_add_defs,reg4allmsdoc,\
)) ))
$(eval $(call gb_Library_add_cxxflags,reg4allmsdoc,\ $(eval $(call gb_Library_add_cxxflags,reg4allmsdoc,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_Library_add_ldflags,reg4allmsdoc,\ $(eval $(call gb_Library_add_ldflags,reg4allmsdoc,\
......
...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,regactivex,\ ...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,regactivex,\
)) ))
$(eval $(call gb_Library_add_cxxflags,regactivex,\ $(eval $(call gb_Library_add_cxxflags,regactivex,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_Library_add_ldflags,regactivex,\ $(eval $(call gb_Library_add_ldflags,regactivex,\
......
...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,regpatchactivex,\ ...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,regpatchactivex,\
)) ))
$(eval $(call gb_Library_add_cxxflags,regpatchactivex,\ $(eval $(call gb_Library_add_cxxflags,regpatchactivex,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_Library_add_ldflags,regpatchactivex,\ $(eval $(call gb_Library_add_ldflags,regpatchactivex,\
......
...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,sdqsmsi,\ ...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,sdqsmsi,\
)) ))
$(eval $(call gb_Library_add_cxxflags,sdqsmsi,\ $(eval $(call gb_Library_add_cxxflags,sdqsmsi,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_Library_add_ldflags,sdqsmsi,\ $(eval $(call gb_Library_add_ldflags,sdqsmsi,\
......
...@@ -18,7 +18,7 @@ $(eval $(call gb_Library_add_defs,sellangmsi,\ ...@@ -18,7 +18,7 @@ $(eval $(call gb_Library_add_defs,sellangmsi,\
)) ))
$(eval $(call gb_Library_add_cxxflags,sellangmsi,\ $(eval $(call gb_Library_add_cxxflags,sellangmsi,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_Library_add_ldflags,sellangmsi,\ $(eval $(call gb_Library_add_ldflags,sellangmsi,\
......
...@@ -16,7 +16,7 @@ $(eval $(call gb_Library_add_defs,shlxtmsi,\ ...@@ -16,7 +16,7 @@ $(eval $(call gb_Library_add_defs,shlxtmsi,\
)) ))
$(eval $(call gb_Library_add_cxxflags,shlxtmsi,\ $(eval $(call gb_Library_add_cxxflags,shlxtmsi,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_Library_add_ldflags,shlxtmsi,\ $(eval $(call gb_Library_add_ldflags,shlxtmsi,\
......
...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,sn_tools,\ ...@@ -14,7 +14,7 @@ $(eval $(call gb_Library_add_defs,sn_tools,\
)) ))
$(eval $(call gb_Library_add_cxxflags,sn_tools,\ $(eval $(call gb_Library_add_cxxflags,sn_tools,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_Library_add_ldflags,sn_tools,\ $(eval $(call gb_Library_add_ldflags,sn_tools,\
......
...@@ -14,7 +14,7 @@ $(eval $(call gb_StaticLibrary_add_defs,quickstarter,\ ...@@ -14,7 +14,7 @@ $(eval $(call gb_StaticLibrary_add_defs,quickstarter,\
)) ))
$(eval $(call gb_StaticLibrary_add_cxxflags,quickstarter,\ $(eval $(call gb_StaticLibrary_add_cxxflags,quickstarter,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_StaticLibrary_add_exception_objects,quickstarter,\ $(eval $(call gb_StaticLibrary_add_exception_objects,quickstarter,\
......
...@@ -14,7 +14,7 @@ $(eval $(call gb_StaticLibrary_add_defs,seterror,\ ...@@ -14,7 +14,7 @@ $(eval $(call gb_StaticLibrary_add_defs,seterror,\
)) ))
$(eval $(call gb_StaticLibrary_add_cxxflags,seterror,\ $(eval $(call gb_StaticLibrary_add_cxxflags,seterror,\
/MT \ $(if $(MSVC_USE_DEBUG_RUNTIME),/MTd,/MT) \
)) ))
$(eval $(call gb_StaticLibrary_add_exception_objects,seterror,\ $(eval $(call gb_StaticLibrary_add_exception_objects,seterror,\
......
...@@ -224,11 +224,10 @@ gb_GLOBALDEFS += \ ...@@ -224,11 +224,10 @@ gb_GLOBALDEFS += \
-DLIBO_INTERNAL_ONLY \ -DLIBO_INTERNAL_ONLY \
ifeq ($(gb_ENABLE_DBGUTIL),$(true)) ifeq ($(gb_ENABLE_DBGUTIL),$(true))
gb_GLOBALDEFS += -DDBG_UTIL \ gb_GLOBALDEFS += -DDBG_UTIL
ifneq ($(COM),MSC)
gb_GLOBALDEFS += -D_DEBUG \
ifneq ($(COM)-$(MSVC_USE_DEBUG_RUNTIME),MSC-)
gb_GLOBALDEFS += -D_DEBUG
endif endif
endif endif
......
...@@ -218,8 +218,12 @@ $(call gb_Helper_abbreviate_dirs,\ ...@@ -218,8 +218,12 @@ $(call gb_Helper_abbreviate_dirs,\
; exit $$RC) ; exit $$RC)
endef endef
define gb_MSVCRT_subst
$(if $(MSVC_USE_DEBUG_RUNTIME),$(subst msvcrt,msvcrtd,$(subst msvcprt,msvcprtd,$(subst libcmt,libcmtd,$(subst libcpmt,libcpmtd,$(subst msvcmrt,msvcmrtd,$(1)))))),$(1))
endef
define gb_LinkTarget_use_system_win32_libs define gb_LinkTarget_use_system_win32_libs
$(call gb_LinkTarget_add_libs,$(1),$(foreach lib,$(2),$(lib).lib)) $(call gb_LinkTarget_add_libs,$(1),$(foreach lib,$(2),$(call gb_MSVCRT_subst,$(lib)).lib))
endef endef
# Flags common for PE executables (EXEs and DLLs) # Flags common for PE executables (EXEs and DLLs)
......
...@@ -148,7 +148,7 @@ gb_CFLAGS := \ ...@@ -148,7 +148,7 @@ gb_CFLAGS := \
-GR \ -GR \
-Gs \ -Gs \
-GS \ -GS \
-MD \ $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
-nologo \ -nologo \
-W4 \ -W4 \
-wd4127 \ -wd4127 \
...@@ -181,7 +181,7 @@ gb_CXXFLAGS := \ ...@@ -181,7 +181,7 @@ gb_CXXFLAGS := \
-Gs \ -Gs \
-GS \ -GS \
-Gy \ -Gy \
-MD \ $(if $(MSVC_USE_DEBUG_RUNTIME),-MDd,-MD) \
-nologo \ -nologo \
-W4 \ -W4 \
-wd4127 \ -wd4127 \
......
...@@ -72,7 +72,11 @@ string processccargs(vector<string> rawargs) { ...@@ -72,7 +72,11 @@ string processccargs(vector<string> rawargs) {
string args=" -nologo"; string args=" -nologo";
// TODO: should these options be enabled globally? // TODO: should these options be enabled globally?
args.append(" -EHsc"); args.append(" -EHsc");
args.append(" -MD"); const char *const pDebugRuntime(getenv("MSVC_USE_DEBUG_RUNTIME"));
if (pDebugRuntime && !strcmp(pDebugRuntime, "TRUE"))
args.append(" -MDd");
else
args.append(" -MD");
args.append(" -Gy"); args.append(" -Gy");
args.append(" -Zc:wchar_t-"); args.append(" -Zc:wchar_t-");
args.append(" -Ob1 -Oxs -Oy-"); args.append(" -Ob1 -Oxs -Oy-");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment