# HG changeset patch # User Mike Hommey # Date 1548747494 0 # Node ID d0335e34cb16b1b59a49a262b9fd614c777a1677 # Parent 561be82df33dad97bd93843a8b17d8fb5b48ae79 Bug 1523204 - Streamline the DIA SDK setup. r=chmanchester We currently rely on WIN_DIA_SDK_BIN_DIR being passed, but we can actually derive it from the DIA SDK directory. So we now do that, except when it's given explicitly. While in the vicinity, move the dia2.h check to python configure. With WIN_DIA_SDK_BIN_DIR being derived and not set when dia2.h is not found, we don't really need MSVC_HAS_DIA_SDK anymore, so we just check for WIN_DIA_SDK_BIN_DIR to determine whether to build dump_syms or not. One exception to the above is when WIN_DIA_SDK_BIN_DIR is passed in, which we only keep for the in-tree mozconfigs for now. We'll remove that possibility after bug 1523201. Depends on D17892 Differential Revision: https://phabricator.services.mozilla.com/D17893 diff --git a/build/moz.configure/windows.configure b/build/moz.configure/windows.configure --- a/build/moz.configure/windows.configure +++ b/build/moz.configure/windows.configure @@ -285,28 +285,28 @@ def vc_path(c_compiler, toolchain_search option(env='DIA_SDK_PATH', nargs=1, help='Path to the Debug Interface Access SDK') @depends(vc_path, c_compiler, 'DIA_SDK_PATH') @checking('for the Debug Interface Access SDK', lambda x: x or 'not found') @imports('os') -@imports(_from='os.path', _import='isdir') def dia_sdk_dir(vc_path, c_compiler, dia_sdk_path): if dia_sdk_path: - return os.path.normpath(dia_sdk_path[0]) + path = os.path.normpath(dia_sdk_path[0]) - if vc_path: + elif vc_path: # This would be easier if we had the installationPath that # get_vc_paths works with, since 'DIA SDK' is relative to that. path = os.path.normpath(os.path.join( vc_path, r'..\..\..\..\DIA SDK')) - if isdir(path): - return path + + if os.path.exists(os.path.join(path, 'include', 'dia2.h')): + return path @depends(vc_path, valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_dir) @imports('os') def include_path(vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_dir): if not vc_path: return atlmfc_dir = os.path.join(vc_path, 'atlmfc', 'include') @@ -338,48 +338,78 @@ def include_path(vc_path, windows_sdk_di os.environ['INCLUDE'] = includes return includes set_config('INCLUDE', include_path) @template -def lib_path_for(host_or_target): - compiler = { - host: host_c_compiler, - target: c_compiler, - }[host_or_target] - - @depends(host_or_target, dependable(host_or_target is host), compiler, vc_path, - valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_dir) - @imports('os') - def lib_path(target, is_host, c_compiler, vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_dir): - if not vc_path: +def dia_sdk_subdir(host_or_target, subdir): + @depends(dia_sdk_dir, host_or_target, dependable(subdir)) + def dia_sdk_subdir(dia_sdk_dir, target, subdir): + if not dia_sdk_dir: return - sdk_target = { - 'x86': 'x86', - 'x86_64': 'x64', - 'arm': 'arm', - 'aarch64': 'arm64', - }.get(target.cpu) - + # For some reason the DIA SDK still uses the old-style targets + # even in a newer MSVC. old_target = { 'x86': '', 'x86_64': 'amd64', 'arm': 'arm', 'aarch64': 'arm64' }.get(target.cpu) if old_target is None: return # As old_target can be '', and os.path.join will happily use the empty # string, leading to a string ending with a backslash, that Make will # interpret as a "string continues on next line" indicator, use variable # args. old_target = (old_target,) if old_target else () + return os.path.join(dia_sdk_dir, subdir, *old_target) + + return dia_sdk_subdir + + +# XXX: remove after bug 1523201 +js_option(env='WIN_DIA_SDK_BIN_DIR', nargs=1, help='Path to the DIA DLLs') + + +@depends('WIN_DIA_SDK_BIN_DIR', dia_sdk_subdir(host, 'bin')) +@imports('os') +def dia_sdk_bin_dir(from_env, guessed): + if from_env: + if not os.path.isdir(from_env[0]): + die('Invalid Windows DIA SDK directory: {}'.format(from_env)) + return from_env[0] + return guessed + + +set_config('WIN_DIA_SDK_BIN_DIR', dia_sdk_bin_dir) + + +@template +def lib_path_for(host_or_target): + compiler = { + host: host_c_compiler, + target: c_compiler, + }[host_or_target] + + @depends(host_or_target, dependable(host_or_target is host), compiler, vc_path, + valid_windows_sdk_dir, valid_ucrt_sdk_dir, dia_sdk_subdir(host_or_target, 'lib')) + @imports('os') + def lib_path(target, is_host, c_compiler, vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_lib_dir): + if not vc_path: + return + sdk_target = { + 'x86': 'x86', + 'x86_64': 'x64', + 'arm': 'arm', + 'aarch64': 'arm64', + }.get(target.cpu) + # MSVC2017 switched to use the same target naming as the sdk. vc_target = (sdk_target,) atlmfc_dir = os.path.join(vc_path, 'atlmfc', 'lib', *vc_target) if not os.path.isdir(atlmfc_dir): die('Cannot find the ATL/MFC libraries in the Visual C++ directory ' '(%s). Please install them.' % vc_path) @@ -388,20 +418,18 @@ def lib_path_for(host_or_target): if lib_env and not is_host: libs.extend(lib_env.split(os.pathsep)) libs.extend(( os.path.join(vc_path, 'lib', *vc_target), atlmfc_dir, os.path.join(windows_sdk_dir.lib, 'um', sdk_target), os.path.join(ucrt_sdk_dir.lib, 'ucrt', sdk_target), )) - if dia_sdk_dir: - # For some reason the DIA SDK still uses the old-style targets - # even in a newer MSVC. - libs.append(os.path.join(dia_sdk_dir, 'lib', *old_target)) + if dia_sdk_lib_dir: + libs.append(dia_sdk_lib_dir) return libs return lib_path @depends(lib_path_for(target)) @imports('os') def lib_path(libs): diff --git a/old-configure.in b/old-configure.in --- a/old-configure.in +++ b/old-configure.in @@ -156,21 +156,16 @@ case "$target" in AC_DEFINE(_CRT_SECURE_NO_WARNINGS) AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS) AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI. _CC_SUITE=14 MSVC_C_RUNTIME_DLL=vcruntime140*.dll MSVC_CXX_RUNTIME_DLL=msvcp140*.dll - MOZ_CHECK_HEADER(dia2.h, MSVC_HAS_DIA_SDK=1) - if test -n "$MSVC_HAS_DIA_SDK"; then - AC_DEFINE(MSVC_HAS_DIA_SDK) - fi - # C5038: Enable initializer list order warnings # The -w1#### flag treats warning C#### as if it was a warning level # 1 warning, and thus enables it because we enable /W3 warnings. We # don't use -we#### because it would enable warning C#### but treat # it as an error, even in third-party code. # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level CXXFLAGS="$CXXFLAGS -w15038" @@ -196,24 +191,16 @@ case "$target" in if test -n "$WIN_UCRT_REDIST_DIR"; then if test ! -d "$WIN_UCRT_REDIST_DIR"; then AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}]) fi WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && pwd -W` fi - if test -n "$WIN_DIA_SDK_BIN_DIR"; then - if test ! -d "$WIN_DIA_SDK_BIN_DIR"; then - AC_MSG_ERROR([Invalid Windows DIA SDK directory: ${WIN_DIA_SDK_BIN_DIR}]) - fi - WIN_DIA_SDK_BIN_DIR=`cd "$WIN_DIA_SDK_BIN_DIR" && pwd -W` - fi - - AC_SUBST(MSVC_HAS_DIA_SDK) AC_SUBST(MSVC_C_RUNTIME_DLL) AC_SUBST(MSVC_CXX_RUNTIME_DLL) AC_DEFINE(HAVE_SEH_EXCEPTIONS) if test -n "$WIN32_REDIST_DIR"; then if test ! -d "$WIN32_REDIST_DIR"; then AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}]) @@ -3557,17 +3544,16 @@ if test -n "$MOZ_TELEMETRY_REPORTING" || MOZ_DATA_REPORTING=1 AC_DEFINE(MOZ_DATA_REPORTING) AC_SUBST(MOZ_DATA_REPORTING) fi dnl win32 options AC_SUBST(WIN32_REDIST_DIR) AC_SUBST(WIN_UCRT_REDIST_DIR) -AC_SUBST(WIN_DIA_SDK_BIN_DIR) dnl ======================================================== dnl ICU Support dnl ======================================================== _INTL_API=yes if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then diff --git a/toolkit/crashreporter/moz.build b/toolkit/crashreporter/moz.build --- a/toolkit/crashreporter/moz.build +++ b/toolkit/crashreporter/moz.build @@ -21,17 +21,17 @@ FINAL_LIBRARY = 'xul' if CONFIG['MOZ_CRASHREPORTER']: if CONFIG['OS_ARCH'] == 'WINNT': DIRS += [ 'google-breakpad/src/common', 'google-breakpad/src/processor', 'breakpad-windows-libxul', ] - if CONFIG['MSVC_HAS_DIA_SDK']: + if CONFIG['WIN_DIA_SDK_BIN_DIR']: DIRS += ['google-breakpad/src/tools/windows/dump_syms'] if CONFIG['MOZ_CRASHREPORTER_INJECTOR']: DIRS += ['breakpad-windows-standalone'] elif CONFIG['OS_ARCH'] == 'Darwin': DIRS += [ 'breakpad-client',