From 8c55557094680c012bf7a8527c36b1bd68fc905a Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Fri, 6 Oct 2017 11:15:18 -0400 Subject: [PATCH 01/47] - applied m61 patch to m62 Rejected patch: `ortclib-sdk/webrtc/xplatform/chromium/build/config/compiler/BUILD.gn` ````diff diff a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn (rejected hunks) @@ -104,6 +104,9 @@ declare_args() { # on by default when goma is enabled because setting this to true may make # it harder to debug binaries. strip_absolute_paths_from_debug_symbols = false + + # WebRTC does not want to switch to C++14 yet. + use_cxx11 = true } if (is_clang && !is_nacl) { ```` --- config/BUILDCONFIG.gn | 17 ++- config/win/BUILD.gn | 51 +++++++-- secondary/testing/gmock/BUILD.gn | 3 + secondary/testing/gtest/BUILD.gn | 3 + secondary/third_party/libjpeg_turbo/BUILD.gn | 12 +- toolchain/win/BUILD.gn | 113 +++++++++++++++---- toolchain/win/setup_toolchain.py | 32 +++--- 7 files changed, 175 insertions(+), 56 deletions(-) diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index d0795d7d3..3590fe276 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -221,6 +221,7 @@ if (host_toolchain == "") { _default_toolchain = "" +is_winuwp = false if (target_os == "android") { assert(host_os == "linux" || host_os == "mac", "Android builds are only supported on Linux and Mac hosts.") @@ -253,9 +254,10 @@ if (target_os == "android") { } } else if (target_os == "aix") { _default_toolchain = "//build/toolchain/aix:$target_cpu" -} else if (target_os == "winrt_81" || target_os == "winrt_81_phone" || - target_os == "winrt_10") { - _default_toolchain = "//build/toolchain/win:winrt_$target_cpu" +} else if (target_os == "winuwp_81" || target_os == "winuwp_81_phone" || + target_os == "winuwp_10") { + is_winuwp = true + _default_toolchain = "//build/toolchain/win:winuwp_$target_cpu" } else { assert(false, "Unsupported target_os: $target_os") } @@ -286,8 +288,8 @@ if (custom_toolchain != "") { # aix or one of the BSDs. If you need to check these, just check the # current_os value directly. -if (current_os == "win" || current_os == "winrt_81" || - current_os == "winrt_81_phone" || current_os == "winrt_10") { +if (current_os == "win" || current_os == "winuwp_81" || + current_os == "winuwp_81_phone" || current_os == "winuwp_10") { is_android = false is_chromeos = false is_fuchsia = false @@ -529,12 +531,9 @@ if (is_win) { "//build/config/win:unicode", "//build/config/win:winver", "//build/config/win:vs_code_analysis", + "//build/config/win:target_winuwp", ] } -if (current_os == "winrt_81" || current_os == "winrt_81_phone" || - current_os == "winrt_10") { - default_compiler_configs += [ "//build/config/win:target_winrt" ] -} if (is_posix) { default_compiler_configs += [ "//build/config/gcc:no_exceptions" ] diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index c3745f90d..b64be4681 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -284,8 +284,8 @@ config("default_crt") { # exceptions on. configs = [ ":dynamic_crt" ] } else { - if (current_os != "win") { - # WindowsRT: use the dynamic CRT. + if (current_os != "win" || is_winuwp) { + # WindowsUWP: use the dynamic CRT. configs = [ ":dynamic_crt" ] } else { # Desktop Windows: static CRT. @@ -411,19 +411,46 @@ config("nominmax") { defines = [ "NOMINMAX" ] } -# Target WinRT ---------------------------------------------------------------- +# Target WinUWP ---------------------------------------------------------------- # When targeting Windows Runtime, certain compiler/linker flags are necessary. -config("target_winrt") { - defines = [ - "WINRT", - "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP", - ] - cflags_cc = [ - "/ZW", - "/EHsc", - ] +config("target_winuwp") { + should_define_winuwp = is_winuwp + if (current_toolchain != "//build/toolchain/win:winuwp_$target_cpu") { + should_define_winuwp = false + } + + if (should_define_winuwp) { + defines = [ + "WINUWP", + "WEBRTC_FEATURE_END_TO_END_DELAY", + "WEBRTC_BASE_QUEUED_TASK_USING_STDLIB", + ] + if (target_cpu == "arm") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP" ] + } + if ((target_cpu == "x64") || (target_cpu == "x86")) { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ] + } + cflags_cc = [ + "/ZW", + "/EHsc", + ] + arflags = [ + "/IGNORE:4264" + ] + } else { + defines = [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] + } + + if (target_os == "winuwp_81") { + defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] + } else if (target_os == "winuwp_81_phone") { + defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] + } else if (target_os == "winuwp_10") { + defines += [ "WIN10=_WIN32_WINNT_WIN10" ] + } } # Internal stuff -------------------------------------------------------------- diff --git a/secondary/testing/gmock/BUILD.gn b/secondary/testing/gmock/BUILD.gn index 9184d623c..c08a60b29 100644 --- a/secondary/testing/gmock/BUILD.gn +++ b/secondary/testing/gmock/BUILD.gn @@ -62,4 +62,7 @@ static_library("gmock_main") { deps = [ ":gmock", ] + if (is_winuwp) { + deps += [ "//third_party/winuwp_compat:wrap_main_utf8_cc" ] + } } diff --git a/secondary/testing/gtest/BUILD.gn b/secondary/testing/gtest/BUILD.gn index aa24d7eb4..b47c68d2e 100644 --- a/secondary/testing/gtest/BUILD.gn +++ b/secondary/testing/gtest/BUILD.gn @@ -140,6 +140,9 @@ source_set("gtest_main") { deps = [ ":gtest", ] + if (is_winuwp) { + deps += [ "//third_party/winuwp_compat:wrap_main_utf8_cc" ] + } } if (is_ios) { diff --git a/secondary/third_party/libjpeg_turbo/BUILD.gn b/secondary/third_party/libjpeg_turbo/BUILD.gn index 265d30b07..32542c66d 100644 --- a/secondary/third_party/libjpeg_turbo/BUILD.gn +++ b/secondary/third_party/libjpeg_turbo/BUILD.gn @@ -100,15 +100,20 @@ if (current_cpu == "x86" || current_cpu == "x64") { } static_library("simd") { + deps = [] + if (current_cpu == "x86") { - deps = [ + deps += [ ":simd_asm", ] sources = [ "simd/jsimd_i386.c", ] + if (is_winuwp) { + deps += [ "//third_party/winuwp_compat:force_include_std" ] + } } else if (current_cpu == "x64") { - deps = [ + deps += [ ":simd_asm", ] sources = [ @@ -133,6 +138,9 @@ static_library("simd") { if (is_win) { cflags = [ "/wd4245" ] + if (is_winuwp) { + deps += [ "//third_party/winuwp_compat:force_include_std" ] + } } } diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index bace7987c..96d16eca6 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -409,6 +409,42 @@ template("win_x64_toolchains") { } } +# arm toolchains. Only define these when the target architecture is 32-bit +# since we don't do any 32-bit cross compiles when targeting 64-bit (the +# build does generate some 64-bit stuff from 32-bit target builds). +if (target_cpu == "arm") { + arm_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "arm", + ], + "scope") + + msvc_toolchain("arm") { + environment = "environment.arm" + cl = "${goma_prefix}\"${arm_toolchain_data.vc_bin_dir}/cl.exe\"" + toolchain_args = { + current_cpu = "arm" + is_clang = false + } + } + + msvc_toolchain("clang_arm") { + environment = "environment.arm" + prefix = rebase_path("$clang_base_path/bin", root_build_dir) + cl = "${goma_prefix}$prefix/${clang_cl}" + sys_include_flags = "${arm_toolchain_data.include_flags_imsvc}" + + toolchain_args = { + current_cpu = "arm" + is_clang = true + } + } +} + + win_x64_toolchains("x64") { toolchain_args = { # Use the defaults. @@ -426,30 +462,67 @@ win_x64_toolchains("nacl_win64") { } } -# WinRT toolchains. Only define these when targeting them. -# -# NOTE: This is currently broken because it references vc_bin_dir. brettw@ -# changed this around a bit, and I don't know what this should be set to -# in terms of what setup_toolchain returns for a certain CPU architecture. -if (target_os == "winrt_81" || target_os == "winrt_81_phone" || - target_os == "winrt_10") { - msvc_toolchain("winrt_x86") { - environment = "environment.winrt_x86" - cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" - - toolchain_args = { - is_clang = false - current_cpu = "x86" +# WinUWP toolchains. Only define these when targeting them. +if (is_winuwp) { + if (target_cpu == "x86") { + winuwp_x86_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "x86", + "store", + ], + "scope") + + msvc_toolchain("winuwp_x86") { + environment = "environment.winuwp_x86" + cl = "${goma_prefix}\"${winuwp_x86_toolchain_data.vc_bin_dir}\cl.exe\"" + toolchain_args = { + is_clang = false + current_cpu = "x86" + } } } - msvc_toolchain("winrt_x64") { - environment = "environment.winrt_x64" - cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" + if (target_cpu == "x64") { + winuwp_x64_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "x64", + "store" + ], + "scope") + msvc_toolchain("winuwp_x64") { + environment = "environment.winuwp_x64" + cl = "${goma_prefix}\"${winuwp_x64_toolchain_data.vc_bin_dir}\cl.exe\"" + toolchain_args = { + is_clang = false + current_cpu = "x64" + } + } + } - toolchain_args = { - is_clang = false - current_cpu = "x64" + if (target_cpu == "arm") { + winuwp_arm_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "arm", + "store" + ], + "scope") + msvc_toolchain("winuwp_arm") { + environment = "environment.winuwp_arm" + cl = "${goma_prefix}\"${winuwp_arm_toolchain_data.vc_bin_dir}\cl.exe\"" + toolchain_args = { + is_clang = false + current_cpu = "arm" + } } } + } diff --git a/toolchain/win/setup_toolchain.py b/toolchain/win/setup_toolchain.py index 8150d3a4e..e5e67292b 100644 --- a/toolchain/win/setup_toolchain.py +++ b/toolchain/win/setup_toolchain.py @@ -83,13 +83,13 @@ def _LoadEnvFromBat(args): return variables -def _LoadToolchainEnv(cpu, sdk_dir): +def _LoadToolchainEnv(cpu, sdk_dir, target_store): """Returns a dictionary with environment variables that must be set while running binaries from the toolchain (e.g. INCLUDE and PATH for cl.exe).""" # Check if we are running in the SDK command line environment and use # the setup script from the SDK if so. |cpu| should be either - # 'x86' or 'x64'. - assert cpu in ('x86', 'x64') + # 'x86' or 'x64' or 'arm'. + assert cpu in ('x86', 'x64', 'arm') if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and sdk_dir: # Load environment from json file. env = os.path.normpath(os.path.join(sdk_dir, 'bin/SetEnv.%s.json' % cpu)) @@ -142,6 +142,8 @@ def _LoadToolchainEnv(cpu, sdk_dir): # Chromium requires the 10.0.14393.0 SDK or higher - previous versions don't # have all of the required declarations. args = [script_path, 'amd64_x86' if cpu == 'x86' else 'amd64'] + if (target_store): + args.extend(['store']) variables = _LoadEnvFromBat(args) return _ExtractImportantEnvironment(variables) @@ -159,16 +161,20 @@ def _FormatAsEnvironmentBlock(envvar_dict): def main(): - if len(sys.argv) != 5: + if (len(sys.argv) != 5) and (len(sys.argv) != 6): print('Usage setup_toolchain.py ' '<visual studio path> <win sdk path> ' - '<runtime dirs> <target_cpu> <include prefix>') + '<runtime dirs> <target_cpu> <store>') sys.exit(2) win_sdk_path = sys.argv[2] runtime_dirs = sys.argv[3] target_cpu = sys.argv[4] + target_store = False + if (len(sys.argv) == 6): + if (sys.argv[5] == 'store'): + target_store = True - cpus = ('x86', 'x64') + cpus = ('x86', 'x64', 'arm') assert target_cpu in cpus vc_bin_dir = '' include = '' @@ -178,7 +184,7 @@ def main(): for cpu in cpus: # Extract environment variables for subprocesses. - env = _LoadToolchainEnv(cpu, win_sdk_path) + env = _LoadToolchainEnv(cpu, win_sdk_path, target_store) env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] if cpu == target_cpu: @@ -197,12 +203,12 @@ def main(): f.write(env_block) # Create a store app version of the environment. - if 'LIB' in env: - env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') - if 'LIBPATH' in env: - env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') - env_block = _FormatAsEnvironmentBlock(env) - with open('environment.winrt_' + cpu, 'wb') as f: + #if 'LIB' in env: + # env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') + #if 'LIBPATH' in env: + # env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') + #env_block = _FormatAsEnvironmentBlock(env) + with open('environment.winuwp_' + cpu, 'wb') as f: f.write(env_block) assert vc_bin_dir From de1303786430d69069d5430c6ebd12c08bf0ea74 Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Thu, 26 Oct 2017 12:49:37 +0200 Subject: [PATCH 02/47] Updated vs_toolchain.py file to support VS2017 --- vs_toolchain.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vs_toolchain.py b/vs_toolchain.py index 93a04ceb2..f979dca14 100755 --- a/vs_toolchain.py +++ b/vs_toolchain.py @@ -23,7 +23,7 @@ # Use MSVS2015 as the default toolchain. -CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2015' +CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2017' def SetEnvironmentAndGetRuntimeDllDirs(): @@ -154,6 +154,7 @@ def DetectVisualStudioPath(): for path in ( os.environ.get('vs2017_install'), r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional', + r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise', r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community'): if path and os.path.exists(path): return path From 8b4c5bfebecfac61009421f8f37b17ebc102ddec Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Mon, 30 Oct 2017 02:29:02 +0100 Subject: [PATCH 03/47] Set proper include paths for ninja files for x64 platform. --- config/win/BUILD.gn | 14 ++++++++++++-- toolchain/win/setup_toolchain.py | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index b64be4681..7dc727284 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -208,11 +208,21 @@ config("winver") { # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. config("sdk_link") { if (current_cpu == "x64") { + winuwp_x64_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "x64", + ], + "scope") + vc_lib_path = winuwp_x64_toolchain_data.vc_lib_path + vc_atlmfc_lib_path = winuwp_x64_toolchain_data.vc_atlmfc_lib_path ldflags = [ "/MACHINE:X64" ] lib_dirs = [ "$windows_sdk_path\Lib\winv6.3\um\x64", - "$visual_studio_path\VC\lib\amd64", - "$visual_studio_path\VC\atlmfc\lib\amd64", + "$vc_lib_path", + "$vc_atlmfc_lib_path", ] } else { ldflags = [ diff --git a/toolchain/win/setup_toolchain.py b/toolchain/win/setup_toolchain.py index e5e67292b..88c07a410 100644 --- a/toolchain/win/setup_toolchain.py +++ b/toolchain/win/setup_toolchain.py @@ -177,6 +177,8 @@ def main(): cpus = ('x86', 'x64', 'arm') assert target_cpu in cpus vc_bin_dir = '' + vc_lib_dir = '' + vc_atlmfc_lib_dir = '' include = '' # TODO(scottmg|goma): Do we need an equivalent of @@ -192,12 +194,20 @@ def main(): if os.path.exists(os.path.join(path, 'cl.exe')): vc_bin_dir = os.path.realpath(path) break + + for path in env['LIB'].split(os.pathsep): + if os.path.exists(os.path.join(path, 'msvcrt.lib')): + vc_lib_dir = os.path.realpath(path) + break + + vc_atlmfc_lib_dir = vc_lib_dir.replace("lib","atlmfc//lib") + # The separator for INCLUDE here must match the one used in # _LoadToolchainEnv() above. include = [p.replace('"', r'\"') for p in env['INCLUDE'].split(';') if p] include_I = ' '.join(['"/I' + i + '"' for i in include]) include_imsvc = ' '.join(['"-imsvc' + i + '"' for i in include]) - + env_block = _FormatAsEnvironmentBlock(env) with open('environment.' + cpu, 'wb') as f: f.write(env_block) @@ -217,6 +227,10 @@ def main(): print 'include_flags_I = ' + gn_helpers.ToGNString(include_I) assert include_imsvc print 'include_flags_imsvc = ' + gn_helpers.ToGNString(include_imsvc) - + assert vc_lib_dir + print 'vc_lib_path = ' + gn_helpers.ToGNString(vc_lib_dir) + assert vc_atlmfc_lib_dir + print 'vc_atlmfc_lib_path = ' + gn_helpers.ToGNString(vc_atlmfc_lib_dir) + if __name__ == '__main__': main() From 29c99042a988ed5fdc4f23a0b243582c3425de9e Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Wed, 1 Nov 2017 16:29:27 +0100 Subject: [PATCH 04/47] Set proper include paths for ninja files for x86 platform. --- config/win/BUILD.gn | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 7dc727284..168e65c0f 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -225,6 +225,16 @@ config("sdk_link") { "$vc_atlmfc_lib_path", ] } else { + winuwp_x86_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "x86", + ], + "scope") + vc_lib_path = winuwp_x86_toolchain_data.vc_lib_path + vc_atlmfc_lib_path = winuwp_x86_toolchain_data.vc_atlmfc_lib_path ldflags = [ "/MACHINE:X86", "/SAFESEH", # Not compatible with x64 so use only for x86. @@ -232,8 +242,8 @@ config("sdk_link") { ] lib_dirs = [ "$windows_sdk_path\Lib\winv6.3\um\x86", - "$visual_studio_path\VC\lib", - "$visual_studio_path\VC\atlmfc\lib", + "$vc_lib_path", + "$vc_atlmfc_lib_path", ] } } From acffe8964729b8f9fd2f26c696ab42ce8a7dfb73 Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Tue, 7 Nov 2017 16:52:01 +0100 Subject: [PATCH 05/47] Changes to pass WACK and run on Xbox --- config/BUILD.gn | 15 ++++++++++++--- config/win/BUILD.gn | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/BUILD.gn b/config/BUILD.gn index 3febe8383..1ef582cfe 100644 --- a/config/BUILD.gn +++ b/config/BUILD.gn @@ -219,14 +219,11 @@ config("default_libs") { "advapi32.lib", "comdlg32.lib", "dbghelp.lib", - "delayimp.lib", "dnsapi.lib", "gdi32.lib", - "kernel32.lib", "msimg32.lib", "odbc32.lib", "odbccp32.lib", - "ole32.lib", "oleaut32.lib", "psapi.lib", "shell32.lib", @@ -245,6 +242,18 @@ config("default_libs") { # some extra libraries, please just add a libs = [ "foo.lib" ] to your # target that needs it. ] + if (is_winuwp) { + libs += [ + "dloadhelper.lib", + "WindowsApp.lib", + ] + } else { + libs += [ + "delayimp.lib", + "kernel32.lib", + "ole32.lib", + ] + } } else if (is_android) { libs = [ "dl", diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 168e65c0f..82e362589 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -444,6 +444,7 @@ config("target_winuwp") { if (should_define_winuwp) { defines = [ "WINUWP", + "__WRL_NO_DEFAULT_LIB__", "WEBRTC_FEATURE_END_TO_END_DELAY", "WEBRTC_BASE_QUEUED_TASK_USING_STDLIB", ] From 9b0c7e48481737f736fb9f33b99186068299f932 Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Tue, 7 Nov 2017 17:52:41 +0100 Subject: [PATCH 06/47] Replaced usage of system drive with appropriate environment variables --- vs_toolchain.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vs_toolchain.py b/vs_toolchain.py index f979dca14..111152891 100755 --- a/vs_toolchain.py +++ b/vs_toolchain.py @@ -91,8 +91,8 @@ def SetEnvironmentAndGetRuntimeDllDirs(): bitness = platform.architecture()[0] # When running 64-bit python the x64 DLLs will be in System32 x64_path = 'System32' if bitness == '64bit' else 'Sysnative' - x64_path = os.path.join(r'C:\Windows', x64_path) - vs_runtime_dll_dirs = [x64_path, r'C:\Windows\SysWOW64'] + x64_path = os.path.join(os.path.expandvars('%windir%'), x64_path) + vs_runtime_dll_dirs = [x64_path, os.path.expandvars('%windir%/SysWOW64')] return vs_runtime_dll_dirs @@ -153,9 +153,9 @@ def DetectVisualStudioPath(): # For now we use a hardcoded default with an environment variable override. for path in ( os.environ.get('vs2017_install'), - r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional', - r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise', - r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community'): + os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Professional'), + os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Enterprise'), + os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Community')): if path and os.path.exists(path): return path else: @@ -418,7 +418,7 @@ def SetEnvironmentAndGetSDKDir(): # If WINDOWSSDKDIR is not set, search the default SDK path and set it. if not 'WINDOWSSDKDIR' in os.environ: - default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\10' + default_sdk_path = os.path.expandvars('%ProgramFiles(x86)%\\Windows Kits\\10') if os.path.isdir(default_sdk_path): os.environ['WINDOWSSDKDIR'] = default_sdk_path From b8cc22a9d724e4de43783625dc53e0ec3ab10fb4 Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Tue, 30 Jan 2018 18:01:40 +0100 Subject: [PATCH 07/47] Added .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c58605ce4..0876da478 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,4 @@ /linux/ubuntu_*-sysroot/ /ios_files /mac_files - +*.pyc From 9851a7e8a075b94e52f9106758e1986ebcd7eff3 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Tue, 13 Feb 2018 16:32:12 -0500 Subject: [PATCH 08/47] Sync chromium/build with changes to be upstreamed to google --- config/BUILD.gn | 8 +- config/BUILDCONFIG.gn | 39 +++- config/win/BUILD.gn | 155 ++++++++++----- secondary/testing/gmock/BUILD.gn | 2 +- secondary/testing/gtest/BUILD.gn | 2 +- secondary/third_party/libjpeg_turbo/BUILD.gn | 4 +- toolchain/goma.gni | 4 + toolchain/win/BUILD.gn | 197 +++++++++++-------- toolchain/win/setup_toolchain.py | 86 +++++--- vs_toolchain.py | 2 +- 10 files changed, 317 insertions(+), 182 deletions(-) diff --git a/config/BUILD.gn b/config/BUILD.gn index 1ef582cfe..0f9ca6c58 100644 --- a/config/BUILD.gn +++ b/config/BUILD.gn @@ -242,14 +242,16 @@ config("default_libs") { # some extra libraries, please just add a libs = [ "foo.lib" ] to your # target that needs it. ] - if (is_winuwp) { + if (is_target_winuwp) { + # These libraries are needed for Windows UWP (i.e. store apps). libs += [ "dloadhelper.lib", "WindowsApp.lib", - ] + ] } else { + # These libraries are not compatible with Windows UWP (i.e. store apps.) libs += [ - "delayimp.lib", + "delayimp.lib", "kernel32.lib", "ole32.lib", ] diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index 3590fe276..02c6492f9 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -169,6 +169,11 @@ declare_args() { is_debug && current_os != "ios" && current_os != "fuchsia" } +declare_args() { + # Define target_os as "winuwp" if targetting a Windows UWP store application. + is_target_winuwp = (target_os == "winuwp") +} + assert(!(is_debug && is_official_build), "Can't do official debug builds") # ============================================================================== @@ -221,7 +226,6 @@ if (host_toolchain == "") { _default_toolchain = "" -is_winuwp = false if (target_os == "android") { assert(host_os == "linux" || host_os == "mac", "Android builds are only supported on Linux and Mac hosts.") @@ -252,12 +256,17 @@ if (target_os == "android") { } else { _default_toolchain = "//build/toolchain/win:$target_cpu" } +} else if (target_os == "winuwp") { + # Can only target WinUWP on a Windows platform and only x86, x64 and arm are + # supported target CPUs. + assert(target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm") + if (is_clang) { + _default_toolchain = "//build/toolchain/win:win_clang_$target_cpu" + } else { + _default_toolchain = "//build/toolchain/win:winuwp_$target_cpu" + } } else if (target_os == "aix") { _default_toolchain = "//build/toolchain/aix:$target_cpu" -} else if (target_os == "winuwp_81" || target_os == "winuwp_81_phone" || - target_os == "winuwp_10") { - is_winuwp = true - _default_toolchain = "//build/toolchain/win:winuwp_$target_cpu" } else { assert(false, "Unsupported target_os: $target_os") } @@ -288,8 +297,7 @@ if (custom_toolchain != "") { # aix or one of the BSDs. If you need to check these, just check the # current_os value directly. -if (current_os == "win" || current_os == "winuwp_81" || - current_os == "winuwp_81_phone" || current_os == "winuwp_10") { +if (current_os == "win") { is_android = false is_chromeos = false is_fuchsia = false @@ -420,6 +428,13 @@ if (!is_win) { "*.rc", ] } +if (!is_target_winuwp) { + sources_assignment_filter += [ + "*_winuwp.cc", + "*_winuwp.h", + "*_winuwp_unittest.cc", + ] +} if (!is_mac) { sources_assignment_filter += [ "*_mac.h", @@ -531,8 +546,16 @@ if (is_win) { "//build/config/win:unicode", "//build/config/win:winver", "//build/config/win:vs_code_analysis", - "//build/config/win:target_winuwp", ] + if (is_target_winuwp) { + default_compiler_configs += [ + "//build/config/win:winuwp", + ] + } else { + default_compiler_configs += [ + "//build/config/win:desktop", + ] + } } if (is_posix) { diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 82e362589..b57a1b425 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -6,10 +6,17 @@ import("//build/config/clang/clang.gni") import("//build/config/compiler/compiler.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/win/visual_studio_version.gni") +import("//build/toolchain/goma.gni") import("//build/toolchain/toolchain.gni") assert(is_win) +if (disable_goma) { + goma_disabled = "true" +} else { + goma_disabled = "false" +} + declare_args() { # Set this to true to enable static analysis through Visual Studio's # /analyze. This dramatically slows compiles and reports thousands of @@ -19,6 +26,29 @@ declare_args() { # Turn this on to have the linker output extra timing information. win_linker_timing = false + + if (is_target_winuwp) { + # possible values for target_winuwp_version: + # "10" - Windows UWP 10 + # "8.1" - Windows RT 8.1 + # "8.0" - Windows RT 8.0 + if (!defined(target_winuwp_version) || target_winuwp_version == "") { + target_winuwp_version = "10" + } + + # possible values: + # "app" - Windows Store Applications + # "phone" - Windows Phone Applications + # "system" - Windows Drivers and Tools + # "server" - Windows Server Applications + # "desktop" - Windows Desktop Applications + if (!defined(target_winuwp_family) || target_winuwp_family == "") { + target_winuwp_family = "app" + } + } else { + target_winuwp_version = "" + target_winuwp_family = "" + } } # This is included by reference in the //build/config/compiler config that @@ -207,44 +237,57 @@ config("winver") { # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. config("sdk_link") { + assert(current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm","Only supports x64, x86 and arm CPUs") if (current_cpu == "x64") { - winuwp_x64_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "x64", - ], - "scope") - vc_lib_path = winuwp_x64_toolchain_data.vc_lib_path - vc_atlmfc_lib_path = winuwp_x64_toolchain_data.vc_atlmfc_lib_path ldflags = [ "/MACHINE:X64" ] - lib_dirs = [ - "$windows_sdk_path\Lib\winv6.3\um\x64", - "$vc_lib_path", - "$vc_atlmfc_lib_path", - ] - } else { - winuwp_x86_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "x86", - ], - "scope") - vc_lib_path = winuwp_x86_toolchain_data.vc_lib_path - vc_atlmfc_lib_path = winuwp_x86_toolchain_data.vc_atlmfc_lib_path + } else if (current_cpu == "x86") { ldflags = [ "/MACHINE:X86", "/SAFESEH", # Not compatible with x64 so use only for x86. "/largeaddressaware", ] - lib_dirs = [ - "$windows_sdk_path\Lib\winv6.3\um\x86", - "$vc_lib_path", - "$vc_atlmfc_lib_path", - ] + } else if (current_cpu == "arm") { + ldflags = [ "/MACHINE:ARM" ] + } + + if (is_target_winuwp) { + vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + current_cpu, + "none", + goma_disabled, + "store", + ], + "scope") + } else { + vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + current_cpu, + "none", + goma_disabled, + "desktop", + ], + "scope") + } + + vc_lib_path = vcvars_toolchain_data.vc_lib_path + if (defined(vcvars_toolchain_data.vc_lib_atlmfc_path)) { + vc_lib_atlmfc_path = vcvars_toolchain_data.vc_lib_atlmfc_path + } + vc_lib_um_path = vcvars_toolchain_data.vc_lib_um_path + + lib_dirs = [ + "$vc_lib_um_path", + "$vc_lib_path", + ] + if (defined(vc_lib_atlmfc_path)) { + lib_dirs += [ "$vc_lib_atlmfc_path" ] } } @@ -304,7 +347,7 @@ config("default_crt") { # exceptions on. configs = [ ":dynamic_crt" ] } else { - if (current_os != "win" || is_winuwp) { + if (is_target_winuwp) { # WindowsUWP: use the dynamic CRT. configs = [ ":dynamic_crt" ] } else { @@ -431,28 +474,29 @@ config("nominmax") { defines = [ "NOMINMAX" ] } -# Target WinUWP ---------------------------------------------------------------- +# Target WinUWP --------------------------------------------------------------- # When targeting Windows Runtime, certain compiler/linker flags are necessary. -config("target_winuwp") { - should_define_winuwp = is_winuwp - if (current_toolchain != "//build/toolchain/win:winuwp_$target_cpu") { - should_define_winuwp = false - } +config("winuwp") { + if (current_toolchain != host_toolchain && is_target_winuwp) { + # this will only happen when current target is set to uwp + # (as host is never uwp) - if (should_define_winuwp) { defines = [ "WINUWP", "__WRL_NO_DEFAULT_LIB__", - "WEBRTC_FEATURE_END_TO_END_DELAY", - "WEBRTC_BASE_QUEUED_TASK_USING_STDLIB", ] - if (target_cpu == "arm") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP" ] - } - if ((target_cpu == "x64") || (target_cpu == "x86")) { + if (target_winuwp_family == "app") { defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ] + } else if (target_winuwp_family == "phone") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP" ] + } else if (target_winuwp_family == "system") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SYSTEM" ] + } else if (target_winuwp_family == "server") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SERVER" ] + } else { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] } cflags_cc = [ "/ZW", @@ -461,17 +505,22 @@ config("target_winuwp") { arflags = [ "/IGNORE:4264" ] + + if (target_winuwp_version == "10") { + defines += [ "WIN10=_WIN32_WINNT_WIN10" ] + } else if (target_winuwp_version == "8.1") { + defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] + } else if (target_winuwp_version == "8.0") { + defines += [ "WIN8=_WIN32_WINNT_WIN8" ] + } } else { - defines = [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] + configs = [ ":desktop" ] } +} - if (target_os == "winuwp_81") { - defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] - } else if (target_os == "winuwp_81_phone") { - defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] - } else if (target_os == "winuwp_10") { - defines += [ "WIN10=_WIN32_WINNT_WIN10" ] - } +# When not targeting Windows Runtime, make sure the WINAPI family is set to desktop +config("desktop") { + defines = [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] } # Internal stuff -------------------------------------------------------------- diff --git a/secondary/testing/gmock/BUILD.gn b/secondary/testing/gmock/BUILD.gn index c08a60b29..f7c6d5c02 100644 --- a/secondary/testing/gmock/BUILD.gn +++ b/secondary/testing/gmock/BUILD.gn @@ -62,7 +62,7 @@ static_library("gmock_main") { deps = [ ":gmock", ] - if (is_winuwp) { + if (is_target_winuwp) { deps += [ "//third_party/winuwp_compat:wrap_main_utf8_cc" ] } } diff --git a/secondary/testing/gtest/BUILD.gn b/secondary/testing/gtest/BUILD.gn index b47c68d2e..e300ef773 100644 --- a/secondary/testing/gtest/BUILD.gn +++ b/secondary/testing/gtest/BUILD.gn @@ -140,7 +140,7 @@ source_set("gtest_main") { deps = [ ":gtest", ] - if (is_winuwp) { + if (is_target_winuwp) { deps += [ "//third_party/winuwp_compat:wrap_main_utf8_cc" ] } } diff --git a/secondary/third_party/libjpeg_turbo/BUILD.gn b/secondary/third_party/libjpeg_turbo/BUILD.gn index 32542c66d..bbc53b490 100644 --- a/secondary/third_party/libjpeg_turbo/BUILD.gn +++ b/secondary/third_party/libjpeg_turbo/BUILD.gn @@ -109,7 +109,7 @@ static_library("simd") { sources = [ "simd/jsimd_i386.c", ] - if (is_winuwp) { + if (is_target_winuwp) { deps += [ "//third_party/winuwp_compat:force_include_std" ] } } else if (current_cpu == "x64") { @@ -138,7 +138,7 @@ static_library("simd") { if (is_win) { cflags = [ "/wd4245" ] - if (is_winuwp) { + if (is_target_winuwp) { deps += [ "//third_party/winuwp_compat:force_include_std" ] } } diff --git a/toolchain/goma.gni b/toolchain/goma.gni index aeabfa915..e32afceda 100644 --- a/toolchain/goma.gni +++ b/toolchain/goma.gni @@ -8,6 +8,10 @@ declare_args() { # Set to true to enable distributed compilation using Goma. use_goma = false + # Set to true to disable goma without update of command line. + # Changing this value does not cause full rebuild. + disable_goma = false + # Set the default value based on the platform. if (is_win) { # Absolute directory containing the gomacc.exe binary. diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 96d16eca6..2e1060639 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -23,11 +23,21 @@ assert(is_win) tool_wrapper_path = rebase_path("tool_wrapper.py", root_build_dir) if (use_goma) { - goma_prefix = "$goma_dir/gomacc.exe " + if (host_os == "win") { + goma_prefix = "$goma_dir/gomacc.exe " + } else { + goma_prefix = "$goma_dir/gomacc " + } } else { goma_prefix = "" } +if (disable_goma) { + goma_disabled = "true" +} else { + goma_disabled = "false" +} + # Copy the VS runtime DLL for the default toolchain to the root build directory # so things will run. if (current_toolchain == default_toolchain) { @@ -334,6 +344,46 @@ if (host_os == "win") { clang_cl = "clang-cl" } +# arm toolchains. Only define these when the target architecture is arm +# since we don't do any arm cross compiles when targeting 64-bit (the +# build does generate some 64-bit stuff from 32-bit/arm target builds). +if (target_cpu == "arm") { + arm_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "arm", + "environment.arm", + goma_disabled, + "desktop", + ], + "scope") + + msvc_toolchain("arm") { + environment = "environment.arm" + cl = "${goma_prefix}\"${arm_toolchain_data.vc_bin_dir}/cl.exe\"" + toolchain_args = { + current_cpu = "arm" + is_clang = false + is_target_winuwp = false + } + } + + msvc_toolchain("win_clang_arm") { + environment = "environment.arm" + prefix = rebase_path("$clang_base_path/bin", root_build_dir) + cl = "${goma_prefix}$prefix/${clang_cl}" + sys_include_flags = "${arm_toolchain_data.include_flags_imsvc}" + + toolchain_args = { + current_cpu = "arm" + is_clang = true + is_target_winuwp = false + } + } +} + # 32-bit toolchains. Only define these when the target architecture is 32-bit # since we don't do any 32-bit cross compiles when targeting 64-bit (the # build does generate some 64-bit stuff from 32-bit target builds). @@ -344,6 +394,9 @@ if (target_cpu == "x86") { windows_sdk_path, visual_studio_runtime_dirs, "x86", + "environment.x86", + goma_disabled, + "desktop", ], "scope") @@ -353,6 +406,7 @@ if (target_cpu == "x86") { toolchain_args = { current_cpu = "x86" is_clang = false + is_target_winuwp = false } } @@ -365,6 +419,7 @@ if (target_cpu == "x86") { toolchain_args = { current_cpu = "x86" is_clang = true + is_target_winuwp = false } } } @@ -376,6 +431,9 @@ x64_toolchain_data = exec_script("setup_toolchain.py", windows_sdk_path, visual_studio_runtime_dirs, "x64", + "environment.x64", + goma_disabled, + "desktop", ], "scope") @@ -390,6 +448,7 @@ template("win_x64_toolchains") { } is_clang = false current_cpu = "x64" + is_target_winuwp = false } } @@ -405,46 +464,11 @@ template("win_x64_toolchains") { } is_clang = true current_cpu = "x64" + is_target_winuwp = false } } } -# arm toolchains. Only define these when the target architecture is 32-bit -# since we don't do any 32-bit cross compiles when targeting 64-bit (the -# build does generate some 64-bit stuff from 32-bit target builds). -if (target_cpu == "arm") { - arm_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "arm", - ], - "scope") - - msvc_toolchain("arm") { - environment = "environment.arm" - cl = "${goma_prefix}\"${arm_toolchain_data.vc_bin_dir}/cl.exe\"" - toolchain_args = { - current_cpu = "arm" - is_clang = false - } - } - - msvc_toolchain("clang_arm") { - environment = "environment.arm" - prefix = rebase_path("$clang_base_path/bin", root_build_dir) - cl = "${goma_prefix}$prefix/${clang_cl}" - sys_include_flags = "${arm_toolchain_data.include_flags_imsvc}" - - toolchain_args = { - current_cpu = "arm" - is_clang = true - } - } -} - - win_x64_toolchains("x64") { toolchain_args = { # Use the defaults. @@ -463,66 +487,77 @@ win_x64_toolchains("nacl_win64") { } # WinUWP toolchains. Only define these when targeting them. -if (is_winuwp) { - if (target_cpu == "x86") { - winuwp_x86_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "x86", - "store", - ], - "scope") - msvc_toolchain("winuwp_x86") { - environment = "environment.winuwp_x86" - cl = "${goma_prefix}\"${winuwp_x86_toolchain_data.vc_bin_dir}\cl.exe\"" +if (is_target_winuwp) { + if (target_cpu == "arm") { + store_arm_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "arm", + "environment.store_arm", + goma_disabled, + "store", + ], + "scope") + + msvc_toolchain("winuwp_arm") { + environment = "environment.store_arm" + cl = "${goma_prefix}\"${store_arm_toolchain_data.vc_bin_dir}/cl.exe\"" toolchain_args = { + current_cpu = "arm" is_clang = false - current_cpu = "x86" + is_target_winuwp = true } } } - if (target_cpu == "x64") { - winuwp_x64_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "x64", - "store" - ], - "scope") - msvc_toolchain("winuwp_x64") { - environment = "environment.winuwp_x64" - cl = "${goma_prefix}\"${winuwp_x64_toolchain_data.vc_bin_dir}\cl.exe\"" + if (target_cpu == "x86") { + store_x86_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "x86", + "environment.store_x86", + goma_disabled, + "store", + ], + "scope") + + msvc_toolchain("winuwp_x86") { + environment = "environment.store_x86" + cl = "${goma_prefix}\"${store_x86_toolchain_data.vc_bin_dir}/cl.exe\"" toolchain_args = { + current_cpu = "x86" is_clang = false - current_cpu = "x64" + is_target_winuwp = true } } } - if (target_cpu == "arm") { - winuwp_arm_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "arm", - "store" - ], - "scope") - msvc_toolchain("winuwp_arm") { - environment = "environment.winuwp_arm" - cl = "${goma_prefix}\"${winuwp_arm_toolchain_data.vc_bin_dir}\cl.exe\"" + if (target_cpu == "x64") { + store_x64_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "x64", + "environment.store_x64", + goma_disabled, + "store", + ], + "scope") + + msvc_toolchain("winuwp_x64") { + environment = "environment.store_x64" + cl = "${goma_prefix}\"${store_x64_toolchain_data.vc_bin_dir}/cl.exe\"" toolchain_args = { + current_cpu = "x64" is_clang = false - current_cpu = "arm" + is_target_winuwp = true } } } - } diff --git a/toolchain/win/setup_toolchain.py b/toolchain/win/setup_toolchain.py index 88c07a410..32464f925 100644 --- a/toolchain/win/setup_toolchain.py +++ b/toolchain/win/setup_toolchain.py @@ -141,9 +141,16 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store): script_path = other_path # Chromium requires the 10.0.14393.0 SDK or higher - previous versions don't # have all of the required declarations. - args = [script_path, 'amd64_x86' if cpu == 'x86' else 'amd64'] + args = [script_path] + if (cpu == 'x86'): + args.append('amd64_x86') + if (cpu == 'x64'): + args.append('amd64') + if (cpu == 'arm'): + args.append('amd64_arm') + # Store target must come before any SDK version declaration if (target_store): - args.extend(['store']) + args.append(['store']) variables = _LoadEnvFromBat(args) return _ExtractImportantEnvironment(variables) @@ -161,24 +168,32 @@ def _FormatAsEnvironmentBlock(envvar_dict): def main(): - if (len(sys.argv) != 5) and (len(sys.argv) != 6): + if len(sys.argv) != 8: print('Usage setup_toolchain.py ' '<visual studio path> <win sdk path> ' - '<runtime dirs> <target_cpu> <store>') + '<runtime dirs> <target_cpu> ' + '<environment block name|none> <goma_disabled> <store|desktop>') sys.exit(2) win_sdk_path = sys.argv[2] runtime_dirs = sys.argv[3] target_cpu = sys.argv[4] - target_store = False - if (len(sys.argv) == 6): - if (sys.argv[5] == 'store'): - target_store = True - + environment_block_name = sys.argv[5] + if (environment_block_name == 'none'): + environment_block_name = '' + goma_disabled = sys.argv[6] + if (sys.argv[7] == 'store'): + target_store = True + elif (sys.argv[7] == 'desktop'): + target_store = False + else: + target_store = False + cpus = ('x86', 'x64', 'arm') assert target_cpu in cpus vc_bin_dir = '' - vc_lib_dir = '' - vc_atlmfc_lib_dir = '' + vc_lib_path = '' + vc_lib_atlmfc_path = '' + vc_lib_um_path = '' include = '' # TODO(scottmg|goma): Do we need an equivalent of @@ -194,13 +209,21 @@ def main(): if os.path.exists(os.path.join(path, 'cl.exe')): vc_bin_dir = os.path.realpath(path) break - + for path in env['LIB'].split(os.pathsep): if os.path.exists(os.path.join(path, 'msvcrt.lib')): - vc_lib_dir = os.path.realpath(path) + vc_lib_path = os.path.realpath(path) + break + + for path in env['LIB'].split(os.pathsep): + if os.path.exists(os.path.join(path, 'atls.lib')): + vc_lib_atlmfc_path = os.path.realpath(path) + break + + for path in env['LIB'].split(os.pathsep): + if os.path.exists(os.path.join(path, 'User32.Lib')): + vc_lib_um_path = os.path.realpath(path) break - - vc_atlmfc_lib_dir = vc_lib_dir.replace("lib","atlmfc//lib") # The separator for INCLUDE here must match the one used in # _LoadToolchainEnv() above. @@ -208,29 +231,28 @@ def main(): include_I = ' '.join(['"/I' + i + '"' for i in include]) include_imsvc = ' '.join(['"-imsvc' + i + '"' for i in include]) - env_block = _FormatAsEnvironmentBlock(env) - with open('environment.' + cpu, 'wb') as f: - f.write(env_block) - - # Create a store app version of the environment. - #if 'LIB' in env: - # env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') - #if 'LIBPATH' in env: - # env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') - #env_block = _FormatAsEnvironmentBlock(env) - with open('environment.winuwp_' + cpu, 'wb') as f: - f.write(env_block) - + if (environment_block_name != ''): + env_block = _FormatAsEnvironmentBlock(env) + with open(environment_block_name, 'wb') as f: + f.write(env_block) + assert vc_bin_dir print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir) assert include_I print 'include_flags_I = ' + gn_helpers.ToGNString(include_I) assert include_imsvc print 'include_flags_imsvc = ' + gn_helpers.ToGNString(include_imsvc) - assert vc_lib_dir - print 'vc_lib_path = ' + gn_helpers.ToGNString(vc_lib_dir) - assert vc_atlmfc_lib_dir - print 'vc_atlmfc_lib_path = ' + gn_helpers.ToGNString(vc_atlmfc_lib_dir) + assert vc_lib_path + print 'vc_lib_path = ' + gn_helpers.ToGNString(vc_lib_path) + if (target_store != True): + # Path is assumed not to exist for store applications + assert vc_lib_atlmfc_path + # Possible atlmfc library path gets introduced in the future for store thus + # output result if a result exists. + if (vc_lib_atlmfc_path != ''): + print 'vc_lib_atlmfc_path = ' + gn_helpers.ToGNString(vc_lib_atlmfc_path) + assert vc_lib_um_path + print 'vc_lib_um_path = ' + gn_helpers.ToGNString(vc_lib_um_path) if __name__ == '__main__': main() diff --git a/vs_toolchain.py b/vs_toolchain.py index 111152891..7be655512 100755 --- a/vs_toolchain.py +++ b/vs_toolchain.py @@ -153,8 +153,8 @@ def DetectVisualStudioPath(): # For now we use a hardcoded default with an environment variable override. for path in ( os.environ.get('vs2017_install'), - os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Professional'), os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Enterprise'), + os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Professional'), os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Community')): if path and os.path.exists(path): return path From 64a61fb16927b71ac86b2a7d766b77aa858ddbec Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Thu, 15 Feb 2018 11:04:12 -0500 Subject: [PATCH 09/47] - fixed incorrect comment regarding toolchain setup --- toolchain/win/setup_toolchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolchain/win/setup_toolchain.py b/toolchain/win/setup_toolchain.py index 32464f925..7d7758e4b 100644 --- a/toolchain/win/setup_toolchain.py +++ b/toolchain/win/setup_toolchain.py @@ -245,7 +245,7 @@ def main(): assert vc_lib_path print 'vc_lib_path = ' + gn_helpers.ToGNString(vc_lib_path) if (target_store != True): - # Path is assumed not to exist for store applications + # Path is assumed not to exist for desktop applications assert vc_lib_atlmfc_path # Possible atlmfc library path gets introduced in the future for store thus # output result if a result exists. From 179bc02d59f01350df7fadcc45e4e6630d3bbeca Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Thu, 15 Feb 2018 19:29:24 -0500 Subject: [PATCH 10/47] Sync with chromium code which reformated some of the upload to google chromium build --- config/BUILD.gn | 2 +- config/BUILDCONFIG.gn | 10 ++---- config/win/BUILD.gn | 53 ++++++++++++++++---------------- toolchain/win/setup_toolchain.py | 14 ++++----- vs_toolchain.py | 12 +++++--- 5 files changed, 46 insertions(+), 45 deletions(-) diff --git a/config/BUILD.gn b/config/BUILD.gn index 0f9ca6c58..b9bfd6a75 100644 --- a/config/BUILD.gn +++ b/config/BUILD.gn @@ -247,7 +247,7 @@ config("default_libs") { libs += [ "dloadhelper.lib", "WindowsApp.lib", - ] + ] } else { # These libraries are not compatible with Windows UWP (i.e. store apps.) libs += [ diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index 02c6492f9..7f9a04c30 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -171,7 +171,7 @@ declare_args() { declare_args() { # Define target_os as "winuwp" if targetting a Windows UWP store application. - is_target_winuwp = (target_os == "winuwp") + is_target_winuwp = target_os == "winuwp" } assert(!(is_debug && is_official_build), "Can't do official debug builds") @@ -548,13 +548,9 @@ if (is_win) { "//build/config/win:vs_code_analysis", ] if (is_target_winuwp) { - default_compiler_configs += [ - "//build/config/win:winuwp", - ] + default_compiler_configs += [ "//build/config/win:winuwp" ] } else { - default_compiler_configs += [ - "//build/config/win:desktop", - ] + default_compiler_configs += [ "//build/config/win:desktop" ] } } diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index b57a1b425..f7ba364b7 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -237,7 +237,8 @@ config("winver") { # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. config("sdk_link") { - assert(current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm","Only supports x64, x86 and arm CPUs") + assert(current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm", + "Only supports x64, x86 and arm CPUs") if (current_cpu == "x64") { ldflags = [ "/MACHINE:X64" ] } else if (current_cpu == "x86") { @@ -251,29 +252,31 @@ config("sdk_link") { } if (is_target_winuwp) { - vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - current_cpu, - "none", - goma_disabled, - "store", - ], - "scope") + vcvars_toolchain_data = + exec_script("../../toolchain/win/setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + current_cpu, + "none", + goma_disabled, + "store", + ], + "scope") } else { - vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - current_cpu, - "none", - goma_disabled, - "desktop", - ], - "scope") + vcvars_toolchain_data = + exec_script("../../toolchain/win/setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + current_cpu, + "none", + goma_disabled, + "desktop", + ], + "scope") } vc_lib_path = vcvars_toolchain_data.vc_lib_path @@ -502,9 +505,7 @@ config("winuwp") { "/ZW", "/EHsc", ] - arflags = [ - "/IGNORE:4264" - ] + arflags = [ "/IGNORE:4264" ] if (target_winuwp_version == "10") { defines += [ "WIN10=_WIN32_WINNT_WIN10" ] diff --git a/toolchain/win/setup_toolchain.py b/toolchain/win/setup_toolchain.py index 7d7758e4b..a38aa5154 100644 --- a/toolchain/win/setup_toolchain.py +++ b/toolchain/win/setup_toolchain.py @@ -187,7 +187,7 @@ def main(): target_store = False else: target_store = False - + cpus = ('x86', 'x64', 'arm') assert target_cpu in cpus vc_bin_dir = '' @@ -209,33 +209,33 @@ def main(): if os.path.exists(os.path.join(path, 'cl.exe')): vc_bin_dir = os.path.realpath(path) break - + for path in env['LIB'].split(os.pathsep): if os.path.exists(os.path.join(path, 'msvcrt.lib')): vc_lib_path = os.path.realpath(path) break - + for path in env['LIB'].split(os.pathsep): if os.path.exists(os.path.join(path, 'atls.lib')): vc_lib_atlmfc_path = os.path.realpath(path) break - + for path in env['LIB'].split(os.pathsep): if os.path.exists(os.path.join(path, 'User32.Lib')): vc_lib_um_path = os.path.realpath(path) break - + # The separator for INCLUDE here must match the one used in # _LoadToolchainEnv() above. include = [p.replace('"', r'\"') for p in env['INCLUDE'].split(';') if p] include_I = ' '.join(['"/I' + i + '"' for i in include]) include_imsvc = ' '.join(['"-imsvc' + i + '"' for i in include]) - + if (environment_block_name != ''): env_block = _FormatAsEnvironmentBlock(env) with open(environment_block_name, 'wb') as f: f.write(env_block) - + assert vc_bin_dir print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir) assert include_I diff --git a/vs_toolchain.py b/vs_toolchain.py index 7be655512..09651d502 100755 --- a/vs_toolchain.py +++ b/vs_toolchain.py @@ -153,9 +153,12 @@ def DetectVisualStudioPath(): # For now we use a hardcoded default with an environment variable override. for path in ( os.environ.get('vs2017_install'), - os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Enterprise'), - os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Professional'), - os.path.expandvars('%ProgramFiles(x86)%/Microsoft Visual Studio/2017/Community')): + os.path.expandvars('%ProgramFiles(x86)%' + '/Microsoft Visual Studio/2017/Enterprise'), + os.path.expandvars('%ProgramFiles(x86)%' + '/Microsoft Visual Studio/2017/Professional'), + os.path.expandvars('%ProgramFiles(x86)%' + '/Microsoft Visual Studio/2017/Community')): if path and os.path.exists(path): return path else: @@ -418,7 +421,8 @@ def SetEnvironmentAndGetSDKDir(): # If WINDOWSSDKDIR is not set, search the default SDK path and set it. if not 'WINDOWSSDKDIR' in os.environ: - default_sdk_path = os.path.expandvars('%ProgramFiles(x86)%\\Windows Kits\\10') + default_sdk_path = os.path.expandvars('%ProgramFiles(x86)%' + '\\Windows Kits\\10') if os.path.isdir(default_sdk_path): os.environ['WINDOWSSDKDIR'] = default_sdk_path From 6bbd16d49f15171a3143c4a65e00a6a6c1ebab89 Mon Sep 17 00:00:00 2001 From: Vladimir Mancic <v.mancic@gnedo.com> Date: Tue, 20 Feb 2018 14:27:03 +0100 Subject: [PATCH 11/47] fix for broken prepare for x86 on linux. --- config/sysroot.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/sysroot.gni b/config/sysroot.gni index fa361e6d3..a4960c177 100644 --- a/config/sysroot.gni +++ b/config/sysroot.gni @@ -68,7 +68,7 @@ if (current_os == target_os && current_cpu == target_cpu && exec_script("//build/dir_exists.py", [ rebase_path(sysroot) ], "string") == "True", - "Missing sysroot ($sysroot). To fix, run: build/linux/sysroot_scripts/install-sysroot.py --arch=$_script_arch") + "Missing sysroot ($sysroot). To fix, run from the current directory: webrtc/xplatform/chromium/build/linux/sysroot_scripts/install-sysroot-alt.py --arch=$_script_arch") } } else if (is_mac) { import("//build/config/mac/mac_sdk.gni") From a1534f604924a55cd4a51dd9d505b02298a1e6c6 Mon Sep 17 00:00:00 2001 From: Vladimir Mancic <v.mancic@gnedo.com> Date: Wed, 14 Mar 2018 17:13:59 +0100 Subject: [PATCH 12/47] Fix for prepare issue on linux x86. --- config/sysroot.gni | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/config/sysroot.gni b/config/sysroot.gni index a4960c177..6859eba5c 100644 --- a/config/sysroot.gni +++ b/config/sysroot.gni @@ -64,11 +64,10 @@ if (current_os == target_os && current_cpu == target_cpu && } else if (_script_arch == "x64") { _script_arch = "amd64" } - assert( - exec_script("//build/dir_exists.py", - [ rebase_path(sysroot) ], - "string") == "True", - "Missing sysroot ($sysroot). To fix, run from the current directory: webrtc/xplatform/chromium/build/linux/sysroot_scripts/install-sysroot-alt.py --arch=$_script_arch") + if (exec_script("//build/dir_exists.py", [ rebase_path(sysroot) ], "string") != "True") { + arch_arg = "--arch=$_script_arch" + exec_script("//build/linux/sysroot_scripts/install-sysroot-alt.py", [ arch_arg ]) + } } } else if (is_mac) { import("//build/config/mac/mac_sdk.gni") From bb7e263b2eebe6c654877c36815f5d874c796f14 Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Wed, 28 Mar 2018 16:34:12 +0200 Subject: [PATCH 13/47] Created winuwp_arm64 toolchain --- config/BUILDCONFIG.gn | 4 ++-- config/win/BUILD.gn | 4 ++-- toolchain/win/BUILD.gn | 24 ++++++++++++++++++++++++ toolchain/win/setup_toolchain.py | 6 ++++-- vs_toolchain.py | 9 +++++++-- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index 7f9a04c30..291b403e6 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -257,9 +257,9 @@ if (target_os == "android") { _default_toolchain = "//build/toolchain/win:$target_cpu" } } else if (target_os == "winuwp") { - # Can only target WinUWP on a Windows platform and only x86, x64 and arm are + # Can only target WinUWP on a Windows platform and only x86, x64, arm and arm64 are # supported target CPUs. - assert(target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm") + assert(target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm" || target_cpu == "arm64") if (is_clang) { _default_toolchain = "//build/toolchain/win:win_clang_$target_cpu" } else { diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index f7ba364b7..7e7de83e5 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -237,8 +237,8 @@ config("winver") { # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. config("sdk_link") { - assert(current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm", - "Only supports x64, x86 and arm CPUs") + assert(current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm" || current_cpu == "arm64", + "Only supports x64, x86, arm and arm64 CPUs") if (current_cpu == "x64") { ldflags = [ "/MACHINE:X64" ] } else if (current_cpu == "x86") { diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 2e1060639..e91936d39 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -513,6 +513,30 @@ if (is_target_winuwp) { } } + if (target_cpu == "arm64") { + store_arm_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + "arm64", + "environment.store_arm64", + goma_disabled, + "store", + ], + "scope") + + msvc_toolchain("winuwp_arm64") { + environment = "environment.store_arm64" + cl = "${goma_prefix}\"${store_arm_toolchain_data.vc_bin_dir}/cl.exe\"" + toolchain_args = { + current_cpu = "arm64" + is_clang = false + is_target_winuwp = true + } + } + } + if (target_cpu == "x86") { store_x86_toolchain_data = exec_script("setup_toolchain.py", [ diff --git a/toolchain/win/setup_toolchain.py b/toolchain/win/setup_toolchain.py index a38aa5154..1c421c39b 100644 --- a/toolchain/win/setup_toolchain.py +++ b/toolchain/win/setup_toolchain.py @@ -89,7 +89,7 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store): # Check if we are running in the SDK command line environment and use # the setup script from the SDK if so. |cpu| should be either # 'x86' or 'x64' or 'arm'. - assert cpu in ('x86', 'x64', 'arm') + assert cpu in ('x86', 'x64', 'arm', 'arm64') if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and sdk_dir: # Load environment from json file. env = os.path.normpath(os.path.join(sdk_dir, 'bin/SetEnv.%s.json' % cpu)) @@ -148,6 +148,8 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store): args.append('amd64') if (cpu == 'arm'): args.append('amd64_arm') + if (cpu == 'arm64'): + args.append('amd64_arm64') # Store target must come before any SDK version declaration if (target_store): args.append(['store']) @@ -188,7 +190,7 @@ def main(): else: target_store = False - cpus = ('x86', 'x64', 'arm') + cpus = ('x86', 'x64', 'arm', 'arm64') assert target_cpu in cpus vc_bin_dir = '' vc_lib_path = '' diff --git a/vs_toolchain.py b/vs_toolchain.py index 09651d502..dc3cd3c5f 100755 --- a/vs_toolchain.py +++ b/vs_toolchain.py @@ -211,8 +211,12 @@ def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix): win_sdk_dir = os.path.normpath( os.environ.get('WINDOWSSDKDIR', 'C:\\Program Files (x86)\\Windows Kits\\10')) - ucrt_dll_dirs = os.path.join(win_sdk_dir, 'Redist', 'ucrt', 'DLLs', + # SJ - CHECK: for arm64 target_cpu it will be copied 'api-ms-win-*.dll'files from arm folder + if target_cpu != 'arm64': + ucrt_dll_dirs = os.path.join(win_sdk_dir, 'Redist', 'ucrt', 'DLLs', target_cpu) + else: + ucrt_dll_dirs = os.path.join(win_sdk_dir, 'Redist', 'ucrt', 'DLLs', 'arm') ucrt_files = glob.glob(os.path.join(ucrt_dll_dirs, 'api-ms-win-*.dll')) assert len(ucrt_files) > 0 for ucrt_src_file in ucrt_files: @@ -310,7 +314,8 @@ def CopyDlls(target_dir, configuration, target_cpu): if configuration == 'Debug': _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True) else: - _CopyPGORuntime(target_dir, target_cpu) + if not (target_cpu in ('arm', 'arm64')): + _CopyPGORuntime(target_dir, target_cpu) _CopyDebugger(target_dir, target_cpu) From da87ccc34c05d3ea7f1ba8858d181094dd61b093 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Wed, 28 Mar 2018 11:35:49 -0400 Subject: [PATCH 14/47] applied accepted chromium build changes to uwp build --- config/BUILD.gn | 2 +- config/BUILDCONFIG.gn | 32 +---- config/win/BUILD.gn | 177 ++++++++++++---------------- toolchain/win/BUILD.gn | 195 +++++++++---------------------- toolchain/win/setup_toolchain.py | 50 ++++---- 5 files changed, 163 insertions(+), 293 deletions(-) diff --git a/config/BUILD.gn b/config/BUILD.gn index b9bfd6a75..451c640cc 100644 --- a/config/BUILD.gn +++ b/config/BUILD.gn @@ -242,7 +242,7 @@ config("default_libs") { # some extra libraries, please just add a libs = [ "foo.lib" ] to your # target that needs it. ] - if (is_target_winuwp) { + if (current_os == "winuwp") { # These libraries are needed for Windows UWP (i.e. store apps). libs += [ "dloadhelper.lib", diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index 7f9a04c30..80d725ec9 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -169,11 +169,6 @@ declare_args() { is_debug && current_os != "ios" && current_os != "fuchsia" } -declare_args() { - # Define target_os as "winuwp" if targetting a Windows UWP store application. - is_target_winuwp = target_os == "winuwp" -} - assert(!(is_debug && is_official_build), "Can't do official debug builds") # ============================================================================== @@ -257,14 +252,11 @@ if (target_os == "android") { _default_toolchain = "//build/toolchain/win:$target_cpu" } } else if (target_os == "winuwp") { - # Can only target WinUWP on a Windows platform and only x86, x64 and arm are - # supported target CPUs. - assert(target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm") - if (is_clang) { - _default_toolchain = "//build/toolchain/win:win_clang_$target_cpu" - } else { - _default_toolchain = "//build/toolchain/win:winuwp_$target_cpu" - } + # Only target WinUWP on for a Windows store application and only + # x86, x64 and arm are supported target CPUs. + assert(target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm" || + target_cpu == "arm64") + _default_toolchain = "//build/toolchain/win:uwp_$target_cpu" } else if (target_os == "aix") { _default_toolchain = "//build/toolchain/aix:$target_cpu" } else { @@ -297,7 +289,7 @@ if (custom_toolchain != "") { # aix or one of the BSDs. If you need to check these, just check the # current_os value directly. -if (current_os == "win") { +if (current_os == "win" || current_os == "winuwp") { is_android = false is_chromeos = false is_fuchsia = false @@ -428,13 +420,6 @@ if (!is_win) { "*.rc", ] } -if (!is_target_winuwp) { - sources_assignment_filter += [ - "*_winuwp.cc", - "*_winuwp.h", - "*_winuwp_unittest.cc", - ] -} if (!is_mac) { sources_assignment_filter += [ "*_mac.h", @@ -547,11 +532,6 @@ if (is_win) { "//build/config/win:winver", "//build/config/win:vs_code_analysis", ] - if (is_target_winuwp) { - default_compiler_configs += [ "//build/config/win:winuwp" ] - } else { - default_compiler_configs += [ "//build/config/win:desktop" ] - } } if (is_posix) { diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index f7ba364b7..5aaa915f5 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -27,28 +27,19 @@ declare_args() { # Turn this on to have the linker output extra timing information. win_linker_timing = false - if (is_target_winuwp) { - # possible values for target_winuwp_version: - # "10" - Windows UWP 10 - # "8.1" - Windows RT 8.1 - # "8.0" - Windows RT 8.0 - if (!defined(target_winuwp_version) || target_winuwp_version == "") { - target_winuwp_version = "10" - } - - # possible values: - # "app" - Windows Store Applications - # "phone" - Windows Phone Applications - # "system" - Windows Drivers and Tools - # "server" - Windows Server Applications - # "desktop" - Windows Desktop Applications - if (!defined(target_winuwp_family) || target_winuwp_family == "") { - target_winuwp_family = "app" - } - } else { - target_winuwp_version = "" - target_winuwp_family = "" - } + # possible values for target_winuwp_version: + # "10" - Windows UWP 10 + # "8.1" - Windows RT 8.1 + # "8.0" - Windows RT 8.0 + target_winuwp_version = "10" + + # possible values: + # "app" - Windows Store Applications + # "phone" - Windows Phone Applications + # "system" - Windows Drivers and Tools + # "server" - Windows Server Applications + # "desktop" - Windows Desktop Applications + target_winuwp_family = "app" } # This is included by reference in the //build/config/compiler config that @@ -223,6 +214,50 @@ config("runtime_library") { # However it is prohibited when using /analyze defines += [ "_USING_V110_SDK71_" ] } + + if (current_os == "winuwp") { + # When targeting Windows Runtime, certain compiler/linker flags are + # necessary. + defines += [ + "WINUWP", + "__WRL_NO_DEFAULT_LIB__", + ] + if (target_winuwp_family == "app") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ] + } else if (target_winuwp_family == "phone") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP" ] + } else if (target_winuwp_family == "system") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SYSTEM" ] + } else if (target_winuwp_family == "server") { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SERVER" ] + } else { + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] + } + cflags_cc += [ + "/ZW", + "/EHsc", + ] + + # This warning is given because the linker cannot tell the difference + # between consuming WinRT APIs versus authoring WinRT within static + # libraries as such this warning is always given by the linker. Since + # consuming WinRT APIs within a library is legitimate but authoring + # WinRT APis is not allowed, this warning is disabled to ignore the + # legitimate consumption of WinRT APIs within static library builds. + arflags = [ "/IGNORE:4264" ] + + if (target_winuwp_version == "10") { + defines += [ "WIN10=_WIN32_WINNT_WIN10" ] + } else if (target_winuwp_version == "8.1") { + defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] + } else if (target_winuwp_version == "8.0") { + defines += [ "WIN8=_WIN32_WINNT_WIN8" ] + } + } else { + # When not targeting Windows Runtime, make sure the WINAPI family is set + # to desktop. + defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] + } } # Sets the default Windows build version. This is separated because some @@ -237,8 +272,9 @@ config("winver") { # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. config("sdk_link") { - assert(current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm", - "Only supports x64, x86 and arm CPUs") + assert(current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm" || + current_cpu == "arm64", + "Only supports x64, x86, arm and arm64 CPUs") if (current_cpu == "x64") { ldflags = [ "/MACHINE:X64" ] } else if (current_cpu == "x86") { @@ -249,35 +285,21 @@ config("sdk_link") { ] } else if (current_cpu == "arm") { ldflags = [ "/MACHINE:ARM" ] + } else if (current_cpu == "arm64") { + ldflags = [ "/MACHINE:ARM64" ] } - if (is_target_winuwp) { - vcvars_toolchain_data = - exec_script("../../toolchain/win/setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - current_cpu, - "none", - goma_disabled, - "store", - ], - "scope") - } else { - vcvars_toolchain_data = - exec_script("../../toolchain/win/setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - current_cpu, - "none", - goma_disabled, - "desktop", - ], - "scope") - } + vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + current_os, + current_cpu, + "none", + goma_disabled, + ], + "scope") vc_lib_path = vcvars_toolchain_data.vc_lib_path if (defined(vcvars_toolchain_data.vc_lib_atlmfc_path)) { @@ -350,8 +372,10 @@ config("default_crt") { # exceptions on. configs = [ ":dynamic_crt" ] } else { - if (is_target_winuwp) { - # WindowsUWP: use the dynamic CRT. + if (current_os == "winuwp") { + # https://blogs.msdn.microsoft.com/vcblog/2014/06/10/the-great-c-runtime-crt-refactoring/ + # contains a details explanation of what is happening with the Windows + # CRT in Visual Studio releases related to Windows store applications. configs = [ ":dynamic_crt" ] } else { # Desktop Windows: static CRT. @@ -477,53 +501,6 @@ config("nominmax") { defines = [ "NOMINMAX" ] } -# Target WinUWP --------------------------------------------------------------- - -# When targeting Windows Runtime, certain compiler/linker flags are necessary. - -config("winuwp") { - if (current_toolchain != host_toolchain && is_target_winuwp) { - # this will only happen when current target is set to uwp - # (as host is never uwp) - - defines = [ - "WINUWP", - "__WRL_NO_DEFAULT_LIB__", - ] - if (target_winuwp_family == "app") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ] - } else if (target_winuwp_family == "phone") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP" ] - } else if (target_winuwp_family == "system") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SYSTEM" ] - } else if (target_winuwp_family == "server") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SERVER" ] - } else { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] - } - cflags_cc = [ - "/ZW", - "/EHsc", - ] - arflags = [ "/IGNORE:4264" ] - - if (target_winuwp_version == "10") { - defines += [ "WIN10=_WIN32_WINNT_WIN10" ] - } else if (target_winuwp_version == "8.1") { - defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] - } else if (target_winuwp_version == "8.0") { - defines += [ "WIN8=_WIN32_WINNT_WIN8" ] - } - } else { - configs = [ ":desktop" ] - } -} - -# When not targeting Windows Runtime, make sure the WINAPI family is set to desktop -config("desktop") { - defines = [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] -} - # Internal stuff -------------------------------------------------------------- # Config used by the MIDL template to disable warnings. diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 2e1060639..8892fcf8e 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -73,8 +73,6 @@ template("msvc_toolchain") { # This value needs to be passed through unchanged. host_toolchain = host_toolchain - - current_os = "win" } # Make these apply to all tools below. @@ -344,96 +342,60 @@ if (host_os == "win") { clang_cl = "clang-cl" } -# arm toolchains. Only define these when the target architecture is arm -# since we don't do any arm cross compiles when targeting 64-bit (the -# build does generate some 64-bit stuff from 32-bit/arm target builds). -if (target_cpu == "arm") { - arm_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "arm", - "environment.arm", - goma_disabled, - "desktop", - ], - "scope") - - msvc_toolchain("arm") { - environment = "environment.arm" - cl = "${goma_prefix}\"${arm_toolchain_data.vc_bin_dir}/cl.exe\"" - toolchain_args = { - current_cpu = "arm" - is_clang = false - is_target_winuwp = false - } - } - - msvc_toolchain("win_clang_arm") { - environment = "environment.arm" - prefix = rebase_path("$clang_base_path/bin", root_build_dir) - cl = "${goma_prefix}$prefix/${clang_cl}" - sys_include_flags = "${arm_toolchain_data.include_flags_imsvc}" - - toolchain_args = { - current_cpu = "arm" - is_clang = true - is_target_winuwp = false - } - } -} -# 32-bit toolchains. Only define these when the target architecture is 32-bit -# since we don't do any 32-bit cross compiles when targeting 64-bit (the -# build does generate some 64-bit stuff from 32-bit target builds). -if (target_cpu == "x86") { - x86_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "x86", - "environment.x86", - goma_disabled, - "desktop", - ], - "scope") - - msvc_toolchain("x86") { - environment = "environment.x86" - cl = "${goma_prefix}\"${x86_toolchain_data.vc_bin_dir}/cl.exe\"" +# x86, arm and arm64 toolchains for Windows (not WinUWP). Only define when the +# target architecture is one of these architectures since we don't do any arm +# cross compiles when targeting 64-bit (the build does generate some 64-bit +# stuff from 32-bit/arm/arm64 target builds). +if (target_os == "win" && + (target_cpu == "x86" || target_cpu == "arm" || target_cpu == "arm64")) { + target_cpu_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + target_os, + target_cpu, + "environment." + target_cpu, + goma_disabled, + ], + "scope") + + msvc_toolchain(target_cpu) { + environment = "environment." + target_cpu + cl = "${goma_prefix}\"${target_cpu_toolchain_data.vc_bin_dir}/cl.exe\"" toolchain_args = { - current_cpu = "x86" + current_os = "win" + current_cpu = target_cpu is_clang = false - is_target_winuwp = false } } - msvc_toolchain("win_clang_x86") { - environment = "environment.x86" + msvc_toolchain("win_clang_" + target_cpu) { + environment = "environment." + target_cpu prefix = rebase_path("$clang_base_path/bin", root_build_dir) cl = "${goma_prefix}$prefix/${clang_cl}" - sys_include_flags = "${x86_toolchain_data.include_flags_imsvc}" + sys_include_flags = "${target_cpu_toolchain_data.include_flags_imsvc}" toolchain_args = { - current_cpu = "x86" + current_os = "win" + current_cpu = target_cpu is_clang = true - is_target_winuwp = false } } } + # 64-bit toolchains. x64_toolchain_data = exec_script("setup_toolchain.py", [ visual_studio_path, windows_sdk_path, visual_studio_runtime_dirs, + "win", "x64", "environment.x64", goma_disabled, - "desktop", ], "scope") @@ -447,8 +409,8 @@ template("win_x64_toolchains") { forward_variables_from(invoker.toolchain_args, "*") } is_clang = false + current_os = "win" current_cpu = "x64" - is_target_winuwp = false } } @@ -463,8 +425,8 @@ template("win_x64_toolchains") { forward_variables_from(invoker.toolchain_args, "*") } is_clang = true + current_os = "win" current_cpu = "x64" - is_target_winuwp = false } } } @@ -486,78 +448,31 @@ win_x64_toolchains("nacl_win64") { } } -# WinUWP toolchains. Only define these when targeting them. - -if (is_target_winuwp) { - if (target_cpu == "arm") { - store_arm_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "arm", - "environment.store_arm", - goma_disabled, - "store", - ], - "scope") - - msvc_toolchain("winuwp_arm") { - environment = "environment.store_arm" - cl = "${goma_prefix}\"${store_arm_toolchain_data.vc_bin_dir}/cl.exe\"" - toolchain_args = { - current_cpu = "arm" - is_clang = false - is_target_winuwp = true - } - } - } - if (target_cpu == "x86") { - store_x86_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "x86", - "environment.store_x86", - goma_disabled, - "store", - ], - "scope") - - msvc_toolchain("winuwp_x86") { - environment = "environment.store_x86" - cl = "${goma_prefix}\"${store_x86_toolchain_data.vc_bin_dir}/cl.exe\"" - toolchain_args = { - current_cpu = "x86" - is_clang = false - is_target_winuwp = true - } - } - } +# WinUWP toolchains. Only define these when targeting them. - if (target_cpu == "x64") { - store_x64_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - "x64", - "environment.store_x64", - goma_disabled, - "store", - ], - "scope") - - msvc_toolchain("winuwp_x64") { - environment = "environment.store_x64" - cl = "${goma_prefix}\"${store_x64_toolchain_data.vc_bin_dir}/cl.exe\"" - toolchain_args = { - current_cpu = "x64" - is_clang = false - is_target_winuwp = true - } +if (target_os == "winuwp") { + assert(target_cpu == "x64" || target_cpu == "x86" || target_cpu == "arm" || + target_cpu == "arm64") + store_cpu_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + target_os, + target_cpu, + "environment.store_" + target_cpu, + goma_disabled, + ], + "scope") + + msvc_toolchain("uwp_" + target_cpu) { + environment = "environment.store_" + target_cpu + cl = "${goma_prefix}\"${store_cpu_toolchain_data.vc_bin_dir}/cl.exe\"" + toolchain_args = { + current_os = "winuwp" + current_cpu = target_cpu + is_clang = false } } } diff --git a/toolchain/win/setup_toolchain.py b/toolchain/win/setup_toolchain.py index a38aa5154..2192c7eca 100644 --- a/toolchain/win/setup_toolchain.py +++ b/toolchain/win/setup_toolchain.py @@ -88,8 +88,8 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store): running binaries from the toolchain (e.g. INCLUDE and PATH for cl.exe).""" # Check if we are running in the SDK command line environment and use # the setup script from the SDK if so. |cpu| should be either - # 'x86' or 'x64' or 'arm'. - assert cpu in ('x86', 'x64', 'arm') + # 'x86' or 'x64' or 'arm' or 'arm64'. + assert cpu in ('x86', 'x64', 'arm', 'arm64') if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and sdk_dir: # Load environment from json file. env = os.path.normpath(os.path.join(sdk_dir, 'bin/SetEnv.%s.json' % cpu)) @@ -141,13 +141,11 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store): script_path = other_path # Chromium requires the 10.0.14393.0 SDK or higher - previous versions don't # have all of the required declarations. - args = [script_path] - if (cpu == 'x86'): - args.append('amd64_x86') - if (cpu == 'x64'): - args.append('amd64') - if (cpu == 'arm'): - args.append('amd64_arm') + cpu_arg = "amd64" + if (cpu != 'x64'): + # x64 is default target CPU thus any other CPU requires a target set + cpu_arg += '_' + cpu + args = [script_path, cpu_arg] # Store target must come before any SDK version declaration if (target_store): args.append(['store']) @@ -171,24 +169,24 @@ def main(): if len(sys.argv) != 8: print('Usage setup_toolchain.py ' '<visual studio path> <win sdk path> ' - '<runtime dirs> <target_cpu> ' - '<environment block name|none> <goma_disabled> <store|desktop>') + '<runtime dirs> <target_os> <target_cpu> ' + '<environment block name|none> <goma_disabled>') sys.exit(2) win_sdk_path = sys.argv[2] runtime_dirs = sys.argv[3] - target_cpu = sys.argv[4] - environment_block_name = sys.argv[5] + target_os = sys.argv[4] + target_cpu = sys.argv[5] + environment_block_name = sys.argv[6] if (environment_block_name == 'none'): environment_block_name = '' - goma_disabled = sys.argv[6] - if (sys.argv[7] == 'store'): + goma_disabled = sys.argv[7] + + if (target_os == 'winuwp'): target_store = True - elif (sys.argv[7] == 'desktop'): - target_store = False else: target_store = False - cpus = ('x86', 'x64', 'arm') + cpus = ('x86', 'x64', 'arm', 'arm64') assert target_cpu in cpus vc_bin_dir = '' vc_lib_path = '' @@ -200,27 +198,27 @@ def main(): # ninja_use_custom_environment_files? for cpu in cpus: - # Extract environment variables for subprocesses. - env = _LoadToolchainEnv(cpu, win_sdk_path, target_store) - env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] - if cpu == target_cpu: - for path in env['PATH'].split(os.pathsep): + # Extract environment variables for subprocesses. + env = _LoadToolchainEnv(cpu, win_sdk_path, target_store) + env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] + + for path in env['PATH'].split(';'): if os.path.exists(os.path.join(path, 'cl.exe')): vc_bin_dir = os.path.realpath(path) break - for path in env['LIB'].split(os.pathsep): + for path in env['LIB'].split(';'): if os.path.exists(os.path.join(path, 'msvcrt.lib')): vc_lib_path = os.path.realpath(path) break - for path in env['LIB'].split(os.pathsep): + for path in env['LIB'].split(';'): if os.path.exists(os.path.join(path, 'atls.lib')): vc_lib_atlmfc_path = os.path.realpath(path) break - for path in env['LIB'].split(os.pathsep): + for path in env['LIB'].split(';'): if os.path.exists(os.path.join(path, 'User32.Lib')): vc_lib_um_path = os.path.realpath(path) break From 8057d7a2f5e1b1d8b4afb90c4cbb56b408c39c63 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Wed, 28 Mar 2018 14:28:51 -0400 Subject: [PATCH 15/47] applied accepted chromium build changes to uwp build --- secondary/testing/gmock/BUILD.gn | 2 +- secondary/testing/gtest/BUILD.gn | 2 +- secondary/third_party/libjpeg_turbo/BUILD.gn | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/secondary/testing/gmock/BUILD.gn b/secondary/testing/gmock/BUILD.gn index f7c6d5c02..f00f29b39 100644 --- a/secondary/testing/gmock/BUILD.gn +++ b/secondary/testing/gmock/BUILD.gn @@ -62,7 +62,7 @@ static_library("gmock_main") { deps = [ ":gmock", ] - if (is_target_winuwp) { + if (current_os == "winuwp") { deps += [ "//third_party/winuwp_compat:wrap_main_utf8_cc" ] } } diff --git a/secondary/testing/gtest/BUILD.gn b/secondary/testing/gtest/BUILD.gn index e300ef773..f889999a0 100644 --- a/secondary/testing/gtest/BUILD.gn +++ b/secondary/testing/gtest/BUILD.gn @@ -140,7 +140,7 @@ source_set("gtest_main") { deps = [ ":gtest", ] - if (is_target_winuwp) { + if (current_os == "winuwp") { deps += [ "//third_party/winuwp_compat:wrap_main_utf8_cc" ] } } diff --git a/secondary/third_party/libjpeg_turbo/BUILD.gn b/secondary/third_party/libjpeg_turbo/BUILD.gn index bbc53b490..a824f4716 100644 --- a/secondary/third_party/libjpeg_turbo/BUILD.gn +++ b/secondary/third_party/libjpeg_turbo/BUILD.gn @@ -109,7 +109,7 @@ static_library("simd") { sources = [ "simd/jsimd_i386.c", ] - if (is_target_winuwp) { + if (current_os == "winuwp") { deps += [ "//third_party/winuwp_compat:force_include_std" ] } } else if (current_cpu == "x64") { @@ -138,7 +138,7 @@ static_library("simd") { if (is_win) { cflags = [ "/wd4245" ] - if (is_target_winuwp) { + if (current_os == "winuwp") { deps += [ "//third_party/winuwp_compat:force_include_std" ] } } From 9603dd026f88d2aa4ad70dc041ed972556b91c7e Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Wed, 4 Apr 2018 13:57:15 +0200 Subject: [PATCH 16/47] Added Microsoft ARM assembler for asm tool --- toolchain/win/BUILD.gn | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index e91936d39..898758bd1 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -197,9 +197,12 @@ template("msvc_toolchain") { tool("asm") { if (toolchain_args.current_cpu == "x64") { ml = "ml64.exe" - } else { + } else if (toolchain_args.current_cpu == "x86") { ml = "ml.exe" } + else { + ml = "armasm.exe" + } command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" description = "ASM {{output}}" outputs = [ From 698ec30e16d690ecf755b967354d6e0c47412ca8 Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Wed, 11 Apr 2018 20:25:32 +0200 Subject: [PATCH 17/47] Updated input parameters for armasm compiler --- toolchain/win/BUILD.gn | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 898758bd1..7c43844d0 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -203,7 +203,11 @@ template("msvc_toolchain") { else { ml = "armasm.exe" } - command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" + if (toolchain_args.current_cpu == "x64" || toolchain_args.current_cpu == "x86") { + command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" + } else { + command = "$python_path $tool_wrapper_path asm-wrapper $env $ml -oldit -16 {{include_dirs}} {{source}} -o {{output}}" + } description = "ASM {{output}}" outputs = [ "$object_subdir/{{source_name_part}}.obj", From dedb4efdddcdb2434a54409284faea3880280d1c Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Wed, 18 Apr 2018 15:50:34 +0200 Subject: [PATCH 18/47] ATTENTION!!! host_toolchain is set to win:$host_cpu instead of win:$target_cpu. Removed link flag /DYNAMICBASE:NO in debug configuration for arm and arm64. Removed simd/jsimd_arm.C and simd/jsimd_arm_neon.S files from sources for arm and arm64 for winuwp target. Disabled warning 4267 for arm and arm64. By default it was disabled for x64. --- config/BUILDCONFIG.gn | 2 +- config/compiler/BUILD.gn | 4 ++-- config/win/BUILD.gn | 4 +++- secondary/third_party/libjpeg_turbo/BUILD.gn | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index 291b403e6..177c96059 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -215,7 +215,7 @@ if (host_toolchain == "") { if (is_clang) { host_toolchain = "//build/toolchain/win:win_clang_$target_cpu" } else { - host_toolchain = "//build/toolchain/win:$target_cpu" + host_toolchain = "//build/toolchain/win:$host_cpu" } } else if (host_os == "aix") { host_toolchain = "//build/toolchain/aix:$host_cpu" diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn index ddd491bde..ab1bf5cf3 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn @@ -908,7 +908,7 @@ config("clang_stackrealign") { } config("compiler_arm_fpu") { - if (current_cpu == "arm" && !is_ios && !is_nacl) { + if ((current_cpu == "arm" || current_cpu == "arm64") && !is_ios && !is_nacl && !is_win) { cflags = [ "-mfpu=$arm_fpu" ] asmflags = cflags } @@ -1378,7 +1378,7 @@ config("wexit_time_destructors") { # # TODO(jschuh): crbug.com/167187 fix this and delete this config. config("no_size_t_to_int_warning") { - if (is_win && current_cpu == "x64") { + if (is_win && (current_cpu == "x64" || current_cpu == "arm" || current_cpu == "arm64")) { cflags = [ "/wd4267" ] } } diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 7e7de83e5..8f67c1488 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -313,7 +313,9 @@ config("common_linker_setup") { # Chrome.dll don't stick from one launch to the next. For this reason, we # turn ASLR off in debug builds. if (is_debug) { - ldflags += [ "/DYNAMICBASE:NO" ] + if (current_cpu != "arm" && current_cpu != "arm64") { + ldflags += [ "/DYNAMICBASE:NO" ] + } } else { ldflags += [ "/DYNAMICBASE" ] } diff --git a/secondary/third_party/libjpeg_turbo/BUILD.gn b/secondary/third_party/libjpeg_turbo/BUILD.gn index bbc53b490..d6c9fec35 100644 --- a/secondary/third_party/libjpeg_turbo/BUILD.gn +++ b/secondary/third_party/libjpeg_turbo/BUILD.gn @@ -119,13 +119,13 @@ static_library("simd") { sources = [ "simd/jsimd_x86_64.c", ] - } else if (current_cpu == "arm" && arm_version >= 7 && - (arm_use_neon || arm_optionally_use_neon)) { + } else if ((target_os != "winuwp") && (current_cpu == "arm" && arm_version >= 7 && + (arm_use_neon || arm_optionally_use_neon))) { sources = [ "simd/jsimd_arm.c", "simd/jsimd_arm_neon.S", ] - } else if (current_cpu == "arm64") { + } else if ((target_os != "winuwp") && (current_cpu == "arm64")) { sources = [ "simd/jsimd_arm64.c", "simd/jsimd_arm64_neon.S", From feea55564099c6ecb9a46cf97ab1a71dca56a9bd Mon Sep 17 00:00:00 2001 From: Vladimir Mancic <v.mancic@gnedo.com> Date: Wed, 18 Apr 2018 19:36:48 +0200 Subject: [PATCH 19/47] fix for undefined identifier cflags_cc. --- config/win/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 5aaa915f5..5a1e003cf 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -233,6 +233,7 @@ config("runtime_library") { } else { defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] } + cflags_cc = [] cflags_cc += [ "/ZW", "/EHsc", From 751c5ad0e35ada0434e1036948bba454b0051442 Mon Sep 17 00:00:00 2001 From: Vladimir Mancic <v.mancic@gnedo.com> Date: Tue, 24 Apr 2018 19:19:22 +0200 Subject: [PATCH 20/47] Fix for "Unresolved dependencies" during preparation phase of WebRTC development environment, for x86 (task #246) --- toolchain/win/BUILD.gn | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 8892fcf8e..c7bf456c7 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -347,39 +347,39 @@ if (host_os == "win") { # target architecture is one of these architectures since we don't do any arm # cross compiles when targeting 64-bit (the build does generate some 64-bit # stuff from 32-bit/arm/arm64 target builds). -if (target_os == "win" && - (target_cpu == "x86" || target_cpu == "arm" || target_cpu == "arm64")) { +if (target_cpu == "x86" || + ((target_cpu == "arm" || target_cpu == "arm64") && host_cpu == "x86")) { target_cpu_toolchain_data = exec_script("setup_toolchain.py", [ visual_studio_path, windows_sdk_path, visual_studio_runtime_dirs, target_os, - target_cpu, - "environment." + target_cpu, + "x86", + "environment.x86", goma_disabled, ], "scope") - msvc_toolchain(target_cpu) { - environment = "environment." + target_cpu + msvc_toolchain("x86") { + environment = "environment.x86" cl = "${goma_prefix}\"${target_cpu_toolchain_data.vc_bin_dir}/cl.exe\"" toolchain_args = { current_os = "win" - current_cpu = target_cpu + current_cpu = "x86" is_clang = false } } - msvc_toolchain("win_clang_" + target_cpu) { - environment = "environment." + target_cpu + msvc_toolchain("win_clang_x86") { + environment = "environment.x86" prefix = rebase_path("$clang_base_path/bin", root_build_dir) cl = "${goma_prefix}$prefix/${clang_cl}" sys_include_flags = "${target_cpu_toolchain_data.include_flags_imsvc}" toolchain_args = { current_os = "win" - current_cpu = target_cpu + current_cpu = "x86" is_clang = true } } From e8c23ed6c240cb3a2b2890a4d4f89970d756752b Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Wed, 25 Apr 2018 15:22:12 -0400 Subject: [PATCH 21/47] merged latest changes from google push to fixes branch --- config/BUILDCONFIG.gn | 11 +++++--- config/win/BUILD.gn | 2 +- toolchain/win/BUILD.gn | 59 ++++++++++++++++++++++-------------------- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index 80d725ec9..e66bb428f 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -205,12 +205,17 @@ if (host_toolchain == "") { } else if (host_os == "mac") { host_toolchain = "//build/toolchain/mac:clang_$host_cpu" } else if (host_os == "win") { - # On Windows always use the target CPU for host builds. On the + # On Windows always use the target CPU for host builds for x86/x64. On the # configurations we support this will always work and it saves build steps. + if (target_cpu == "x86" || target_cpu == "x64") { + win_build_host_cpu = target_cpu + } else { + win_build_host_cpu = host_cpu + } if (is_clang) { - host_toolchain = "//build/toolchain/win:win_clang_$target_cpu" + host_toolchain = "//build/toolchain/win:win_clang_$win_build_host_cpu" } else { - host_toolchain = "//build/toolchain/win:$target_cpu" + host_toolchain = "//build/toolchain/win:$win_build_host_cpu" } } else if (host_os == "aix") { host_toolchain = "//build/toolchain/aix:$host_cpu" diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 5a1e003cf..c429af341 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -189,6 +189,7 @@ config("vs_code_analysis") { # :runtime_library vs. :compiler. config("runtime_library") { cflags = [] + cflags_cc = [] # Defines that set up the CRT. defines = [ @@ -233,7 +234,6 @@ config("runtime_library") { } else { defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] } - cflags_cc = [] cflags_cc += [ "/ZW", "/EHsc", diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index c7bf456c7..383eb8434 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -342,50 +342,53 @@ if (host_os == "win") { clang_cl = "clang-cl" } - -# x86, arm and arm64 toolchains for Windows (not WinUWP). Only define when the -# target architecture is one of these architectures since we don't do any arm -# cross compiles when targeting 64-bit (the build does generate some 64-bit -# stuff from 32-bit/arm/arm64 target builds). -if (target_cpu == "x86" || - ((target_cpu == "arm" || target_cpu == "arm64") && host_cpu == "x86")) { - target_cpu_toolchain_data = exec_script("setup_toolchain.py", - [ - visual_studio_path, - windows_sdk_path, - visual_studio_runtime_dirs, - target_os, - "x86", - "environment.x86", +if (target_cpu == "x86" || target_cpu == "x64") { + win_build_host_cpu = target_cpu +} else { + win_build_host_cpu = host_cpu +} + +# x86, arm and arm64 build cpu toolchains for Windows (not WinUWP). Only +# define when the build cpu is one of these architectures since we don't +# do any cross compiles when targeting x64-bit (the build does generate +# some 64-bit stuff from x86/arm/arm64 target builds). +if (win_build_host_cpu != "x64") { + build_cpu_toolchain_data = exec_script("setup_toolchain.py", + [ + visual_studio_path, + windows_sdk_path, + visual_studio_runtime_dirs, + host_os, + win_build_host_cpu, + "environment." + win_build_host_cpu, goma_disabled, - ], - "scope") + ], + "scope") - msvc_toolchain("x86") { - environment = "environment.x86" - cl = "${goma_prefix}\"${target_cpu_toolchain_data.vc_bin_dir}/cl.exe\"" + msvc_toolchain(win_build_host_cpu) { + environment = "environment." + win_build_host_cpu + cl = "${goma_prefix}\"${build_cpu_toolchain_data.vc_bin_dir}/cl.exe\"" toolchain_args = { current_os = "win" - current_cpu = "x86" + current_cpu = win_build_host_cpu is_clang = false } } - - msvc_toolchain("win_clang_x86") { - environment = "environment.x86" + + msvc_toolchain("win_clang_" + win_build_host_cpu) { + environment = "environment." + win_build_host_cpu prefix = rebase_path("$clang_base_path/bin", root_build_dir) cl = "${goma_prefix}$prefix/${clang_cl}" - sys_include_flags = "${target_cpu_toolchain_data.include_flags_imsvc}" - + sys_include_flags = "${build_cpu_toolchain_data.include_flags_imsvc}" + toolchain_args = { current_os = "win" - current_cpu = "x86" + current_cpu = win_build_host_cpu is_clang = true } } } - # 64-bit toolchains. x64_toolchain_data = exec_script("setup_toolchain.py", [ From 1fc19f3419225b15838c74638b9dd4506c78ecde Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Thu, 26 Apr 2018 17:35:25 +0200 Subject: [PATCH 22/47] Added armasm64 compiler for windows arm64 platform --- toolchain/win/BUILD.gn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 7c43844d0..7e1215e0d 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -200,8 +200,10 @@ template("msvc_toolchain") { } else if (toolchain_args.current_cpu == "x86") { ml = "ml.exe" } - else { + else if (toolchain_args.current_cpu == "arm"){ ml = "armasm.exe" + } else { + ml = "armasm64.exe" } if (toolchain_args.current_cpu == "x64" || toolchain_args.current_cpu == "x86") { command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" From 45c72c413d1a1000fce2d30a6d7b0db1ead6b5c0 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Mon, 30 Apr 2018 12:26:08 -0400 Subject: [PATCH 23/47] merged latest changes from google push to fixes branch --- config/BUILDCONFIG.gn | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index e66bb428f..8aa6f5893 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -208,14 +208,15 @@ if (host_toolchain == "") { # On Windows always use the target CPU for host builds for x86/x64. On the # configurations we support this will always work and it saves build steps. if (target_cpu == "x86" || target_cpu == "x64") { - win_build_host_cpu = target_cpu - } else { - win_build_host_cpu = host_cpu - } - if (is_clang) { - host_toolchain = "//build/toolchain/win:win_clang_$win_build_host_cpu" + if (is_clang) { + host_toolchain = "//build/toolchain/win:win_clang_$target_cpu" + } else { + host_toolchain = "//build/toolchain/win:$target_cpu" + } + } else if (is_clang) { + host_toolchain = "//build/toolchain/win:win_clang_$host_cpu" } else { - host_toolchain = "//build/toolchain/win:$win_build_host_cpu" + host_toolchain = "//build/toolchain/win:$host_cpu" } } else if (host_os == "aix") { host_toolchain = "//build/toolchain/aix:$host_cpu" From be194b25538b8de7a11da0efe13a808ec72b7bfa Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Wed, 16 May 2018 18:31:13 +0200 Subject: [PATCH 24/47] Resolved winuwp arm build issues when used clang-cl. Pay attention on confing/compiler/BUILD.gn when /Zi build option is removed when clang is used! --- config/compiler/BUILD.gn | 6 +++++- config/win/BUILD.gn | 2 +- toolchain/win/BUILD.gn | 25 ++++++++++++++++++------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn index ab1bf5cf3..ce05cdd77 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn @@ -1745,7 +1745,11 @@ config("symbols") { # Note that this requires is_win_fastlink, enforced elsewhere. cflags = [ "/Z7" ] # Debug information in the .obj files. } else { - cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. + if (is_clang) { + cflags = [ "" ] + } else { + cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. + } } if (is_win_fastlink) { diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 8f67c1488..69162aabd 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -92,7 +92,7 @@ config("compiler") { if (is_clang) { cflags += [ "-fmsc-version=1900" ] - if (current_cpu == "x86") { + if (current_cpu == "x86" || current_cpu == "arm") { cflags += [ "-m32" ] } else { cflags += [ "-m64" ] diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 7e1215e0d..bea7c549c 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -153,37 +153,48 @@ template("msvc_toolchain") { } tool("cc") { - rspfile = "{{output}}.rsp" - precompiled_header_type = "msvc" + precompiled_header_type = "msvc" pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" # Label names may have spaces in them so the pdbname must be quoted. The # source and output don't need to be quoted because GN knows they're a # full file name and will quote automatically when necessary. - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" depsformat = "msvc" description = "CC {{output}}" outputs = [ "$object_subdir/{{source_name_part}}.obj", ] - rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" + if (target_name == "win_clang_arm") { + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=armv7-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + } else { + rspfile = "{{output}}.rsp" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" + rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" + } } tool("cxx") { - rspfile = "{{output}}.rsp" + precompiled_header_type = "msvc" # The PDB name needs to be different between C and C++ compiled files. pdbname = "{{target_out_dir}}/{{label_name}}_cc.pdb" # See comment in CC tool about quoting. - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" + depsformat = "msvc" description = "CXX {{output}}" outputs = [ "$object_subdir/{{source_name_part}}.obj", ] - rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" + + if (target_name == "win_clang_arm") { + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=armv7-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + } else { + rspfile = "{{output}}.rsp" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" + rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" + } } tool("rc") { From 2e8dba49ac051743af5efd671f90e56065065e01 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Fri, 22 Jun 2018 20:31:46 -0400 Subject: [PATCH 25/47] - reapply change to remove defines += [ "_USING_V110_SDK71_" ] for winuwp that was applied to wrong branch --- config/win/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index c429af341..36ee5cde6 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -210,7 +210,7 @@ config("runtime_library") { "_SECURE_ATL", ] - if (!use_vs_code_analysis) { + if ((!use_vs_code_analysis) && (current_os != "winuwp")) { # This is required for ATL to use XP-safe versions of its functions. # However it is prohibited when using /analyze defines += [ "_USING_V110_SDK71_" ] From c52de61b40f905ec33c68d38f0f09cd285c3e8eb Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Sat, 23 Jun 2018 15:00:48 -0400 Subject: [PATCH 26/47] cannot build unless default libs are dynamicly link --- config/win/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 36ee5cde6..510a02479 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -380,7 +380,7 @@ config("default_crt") { configs = [ ":dynamic_crt" ] } else { # Desktop Windows: static CRT. - configs = [ ":static_crt" ] + configs = [ ":dynamic_crt" ] } } } From d5a2139bb3bdfb60699a9014cd0c720facd01592 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Sat, 23 Jun 2018 22:47:03 -0400 Subject: [PATCH 27/47] compiling with C++17 enabled for WINUWP --- config/win/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 510a02479..395c0346c 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -237,6 +237,8 @@ config("runtime_library") { cflags_cc += [ "/ZW", "/EHsc", + "/std:c++17", + "/Zc:__cplusplus", ] # This warning is given because the linker cannot tell the difference From 542b170c7b00d39979697646f0478f18a4ad0c61 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Fri, 22 Jun 2018 20:31:46 -0400 Subject: [PATCH 28/47] - reapply change to remove defines += [ "_USING_V110_SDK71_" ] for winuwp that was applied to wrong branch --- config/win/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index c93e94cd1..156b40488 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -235,7 +235,7 @@ config("runtime_library") { "_SECURE_ATL", ] - if (!use_vs_code_analysis) { + if ((!use_vs_code_analysis) && (current_os != "winuwp")) { # This is required for ATL to use XP-safe versions of its functions. # However it is prohibited when using /analyze defines += [ "_USING_V110_SDK71_" ] From 497094e313338ac4228cb3514230eea5e825c997 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Sat, 23 Jun 2018 15:00:48 -0400 Subject: [PATCH 29/47] cannot build unless default libs are dynamicly link --- config/win/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 156b40488..78bc35cda 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -411,7 +411,7 @@ config("default_crt") { configs = [ ":dynamic_crt" ] } else { # Desktop Windows: static CRT. - configs = [ ":static_crt" ] + configs = [ ":dynamic_crt" ] } } } From 914501adf69b188b2fe732cd02c987654c04fe90 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Sat, 23 Jun 2018 22:47:03 -0400 Subject: [PATCH 30/47] compiling with C++17 enabled for WINUWP --- config/win/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 78bc35cda..6a78671ed 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -275,6 +275,8 @@ config("runtime_library") { cflags_cc += [ "/ZW", "/EHsc", + "/std:c++17", + "/Zc:__cplusplus", ] # This warning is given because the linker cannot tell the difference From 813c5e3ad1b6e1efdea0e71ec5db0ca6cf8750bb Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Mon, 25 Jun 2018 08:31:50 -0400 Subject: [PATCH 31/47] SDK must use 17134 --- toolchain/win/setup_toolchain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolchain/win/setup_toolchain.py b/toolchain/win/setup_toolchain.py index a820e8601..0c6e730a3 100644 --- a/toolchain/win/setup_toolchain.py +++ b/toolchain/win/setup_toolchain.py @@ -149,10 +149,10 @@ def _LoadToolchainEnv(cpu, sdk_dir, target_store): # Store target must come before any SDK version declaration if (target_store): args.append(['store']) - # Chromium requires the 10.0.15063.468 SDK - previous versions don't have + # Chromium requires the 10.0.17134.468 SDK - previous versions don't have # all of the required declarations and 10.0.16299.0 has some # incompatibilities (crbug.com/773476). - args.append('10.0.15063.0') + args.append('10.0.17134.0') variables = _LoadEnvFromBat(args) return _ExtractImportantEnvironment(variables) From d357f52e4472aeb5c6d2221b0424383969d24d4f Mon Sep 17 00:00:00 2001 From: Vladimir Mancic <v.mancic@gnedo.com> Date: Thu, 5 Jul 2018 17:43:07 +0200 Subject: [PATCH 32/47] Fix for AssertionError in ARM prepare phase --- toolchain/win/setup_toolchain.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/toolchain/win/setup_toolchain.py b/toolchain/win/setup_toolchain.py index 2192c7eca..5ee26fb25 100644 --- a/toolchain/win/setup_toolchain.py +++ b/toolchain/win/setup_toolchain.py @@ -213,10 +213,11 @@ def main(): vc_lib_path = os.path.realpath(path) break - for path in env['LIB'].split(';'): - if os.path.exists(os.path.join(path, 'atls.lib')): - vc_lib_atlmfc_path = os.path.realpath(path) - break + if (cpu != 'arm' and cpu != 'arm64'): + for path in env['LIB'].split(';'): + if os.path.exists(os.path.join(path, 'atls.lib')): + vc_lib_atlmfc_path = os.path.realpath(path) + break for path in env['LIB'].split(';'): if os.path.exists(os.path.join(path, 'User32.Lib')): @@ -244,7 +245,8 @@ def main(): print 'vc_lib_path = ' + gn_helpers.ToGNString(vc_lib_path) if (target_store != True): # Path is assumed not to exist for desktop applications - assert vc_lib_atlmfc_path + if (cpu != 'arm' and cpu != 'arm64'): + assert vc_lib_atlmfc_path # Possible atlmfc library path gets introduced in the future for store thus # output result if a result exists. if (vc_lib_atlmfc_path != ''): From 3579185e7b6be5ecb3add026737a4eb9637c7200 Mon Sep 17 00:00:00 2001 From: Vladimir Mancic <v.mancic@gnedo.com> Date: Fri, 6 Jul 2018 13:20:22 +0200 Subject: [PATCH 33/47] Fix for "Unexpected target_cpu value: arm" --- vs_toolchain.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vs_toolchain.py b/vs_toolchain.py index 6060415bd..ddf66b96b 100755 --- a/vs_toolchain.py +++ b/vs_toolchain.py @@ -249,10 +249,12 @@ def _CopyPGORuntime(target_dir, target_cpu): if env_version == '2017': pgo_runtime_root = FindVCToolsRoot() assert pgo_runtime_root + print 'pgo_runtime_root %s ' % (pgo_runtime_root) # There's no version of pgosweep.exe in HostX64/x86, so we use the copy # from HostX86/x86. pgo_x86_runtime_dir = os.path.join(pgo_runtime_root, 'HostX86', 'x86') pgo_x64_runtime_dir = os.path.join(pgo_runtime_root, 'HostX64', 'x64') + pgo_arm_runtime_dir = os.path.join(pgo_runtime_root, 'arm') else: raise Exception('Unexpected toolchain version: %s.' % env_version) @@ -265,6 +267,8 @@ def _CopyPGORuntime(target_dir, target_cpu): source = os.path.join(pgo_x86_runtime_dir, runtime) elif target_cpu == 'x64': source = os.path.join(pgo_x64_runtime_dir, runtime) + elif target_cpu == 'arm': + source = os.path.join(pgo_arm_runtime_dir, runtime) else: raise NotImplementedError("Unexpected target_cpu value: " + target_cpu) if not os.path.exists(source): From cba7ef1fe05bdf0abbd48dfa5d5e8496e32bfcf7 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Tue, 2 Oct 2018 09:36:35 -0400 Subject: [PATCH 34/47] missing } in BUILD.GN --- toolchain/win/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index ca812264d..ffbbbac67 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -506,6 +506,7 @@ if (target_os == "winuwp") { current_os = "winuwp" current_cpu = target_cpu is_clang = false + } } msvc_toolchain("uwp_clang_" + target_cpu) { environment = "environment.store_" + target_cpu From f0ce0a79b73cb91a1cc4280a262ec50baf15e9bc Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Tue, 2 Oct 2018 11:25:07 -0400 Subject: [PATCH 35/47] removed code for goma check that is no longer needed --- config/win/BUILD.gn | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 5b2ecf565..a3b1e7a98 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -14,12 +14,6 @@ import("//build/toolchain/toolchain.gni") assert(is_win) -if (disable_goma) { - goma_disabled = "true" -} else { - goma_disabled = "false" -} - declare_args() { # Set this to true to enable static analysis through Visual Studio's # /analyze. This dramatically slows compiles and reports thousands of From 9941608d08493d1b9b0ea1282ad938210201e05a Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Tue, 2 Oct 2018 12:06:23 -0400 Subject: [PATCH 36/47] support for arm build with win targets --- toolchain/win/BUILD.gn | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index ffbbbac67..eaa3d9a49 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -360,30 +360,24 @@ if (host_os == "win") { clang_cl = "clang-cl" } -if (target_cpu == "x86" || target_cpu == "x64") { - win_build_host_cpu = target_cpu -} else { - win_build_host_cpu = host_cpu -} - # x86, arm and arm64 build cpu toolchains for Windows (not WinUWP). Only # define when the build cpu is one of these architectures since we don't # do any cross compiles when targeting x64-bit (the build does generate # some 64-bit stuff from x86/arm/arm64 target builds). -if (win_build_host_cpu != "x64") { +if (target_cpu != "x64") { build_cpu_toolchain_data = exec_script("setup_toolchain.py", [ visual_studio_path, windows_sdk_path, visual_studio_runtime_dirs, host_os, - win_build_host_cpu, - "environment." + win_build_host_cpu, + target_cpu, + "environment." + target_cpu, ], "scope") - msvc_toolchain(win_build_host_cpu) { - environment = "environment." + win_build_host_cpu + msvc_toolchain(target_cpu) { + environment = "environment." + target_cpu cl = "${goma_prefix}\"${build_cpu_toolchain_data.vc_bin_dir}/cl.exe\"" if (host_os != "win") { # For win cross build. @@ -391,13 +385,13 @@ if (win_build_host_cpu != "x64") { } toolchain_args = { current_os = "win" - current_cpu = win_build_host_cpu + current_cpu = target_cpu is_clang = false } } - msvc_toolchain("win_clang_" + win_build_host_cpu) { - environment = "environment." + win_build_host_cpu + msvc_toolchain("win_clang_" + target_cpu) { + environment = "environment." + target_cpu prefix = rebase_path("$clang_base_path/bin", root_build_dir) cl = "${goma_prefix}$prefix/${clang_cl}" sys_include_flags = "${build_cpu_toolchain_data.include_flags_imsvc}" @@ -408,7 +402,7 @@ if (win_build_host_cpu != "x64") { toolchain_args = { current_os = "win" - current_cpu = win_build_host_cpu + current_cpu = target_cpu is_clang = true } } From 170c225a2514e4e42a5366fd3c38ef7e21cb3991 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Tue, 2 Oct 2018 13:22:34 -0400 Subject: [PATCH 37/47] removed ZW compilation option --- config/win/BUILD.gn | 1 - 1 file changed, 1 deletion(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index a3b1e7a98..325d442ab 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -282,7 +282,6 @@ config("runtime_library") { defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] } cflags_cc += [ - "/ZW", "/EHsc", "/std:c++17", "/Zc:__cplusplus", From 0946a25565437a0403c613a39ddecf20dc51d878 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Thu, 4 Oct 2018 19:14:22 -0400 Subject: [PATCH 38/47] fixed uwp clang default toolchain --- config/BUILDCONFIG.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index 6e27fc1e3..a44e5206a 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -258,7 +258,7 @@ if (target_os == "android") { assert(target_cpu == "x86" || target_cpu == "x64" || target_cpu == "arm" || target_cpu == "arm64") if (is_clang) { - _default_toolchain = "//build/toolchain/win:win_clang_$target_cpu" + _default_toolchain = "//build/toolchain/win:uwp_clang_$target_cpu" } else { _default_toolchain = "//build/toolchain/win:uwp_$target_cpu" } From f80b4449a1b792b7a8e036ad1f222fa35b4d85cf Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Thu, 11 Oct 2018 19:48:57 +0200 Subject: [PATCH 39/47] cflag_cc - added /ZW when built for winuwp with ms compiler --- config/win/BUILD.gn | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 325d442ab..b8a7385fe 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -286,6 +286,10 @@ config("runtime_library") { "/std:c++17", "/Zc:__cplusplus", ] + + if (!is_clang) { + cflags_cc += [ "/ZW", ] + } # This warning is given because the linker cannot tell the difference # between consuming WinRT APIs versus authoring WinRT within static From 8ba94076adfe2bcba4d8cc9c7c68b45ff31aed1d Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Fri, 12 Oct 2018 00:03:20 +0200 Subject: [PATCH 40/47] Removed /ZW because winrt code is not supported anymore --- config/win/BUILD.gn | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index b8a7385fe..325d442ab 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -286,10 +286,6 @@ config("runtime_library") { "/std:c++17", "/Zc:__cplusplus", ] - - if (!is_clang) { - cflags_cc += [ "/ZW", ] - } # This warning is given because the linker cannot tell the difference # between consuming WinRT APIs versus authoring WinRT within static From b32cf4793bebb9438d9ee7774155502c074f9e8f Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Thu, 27 Dec 2018 16:55:55 +0100 Subject: [PATCH 41/47] Updated cc and ccx tools to support arm64. /Z7 flag is removed for arm and arm64 when project is built with clang-cl Temporary /EHs-c- is used for arm and arm64 when project is built with clang-cl --- config/compiler/BUILD.gn | 14 +++++++------- config/win/BUILD.gn | 12 +++++++++++- toolchain/win/BUILD.gn | 8 ++++++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn index 69f8bf8e7..d622f82c5 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn @@ -2194,15 +2194,15 @@ config("afdo") { # Full symbols. config("symbols") { if (is_win) { + cflags = [] if (use_goma || is_clang) { - # Note that with VC++ this requires is_win_fastlink, enforced elsewhere. - cflags = [ "/Z7" ] # Debug information in the .obj files. - } else { - if (is_clang) { - cflags = [ "" ] - } else { - cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. + # This check is added because Calng-Cl.exe doesn't emmit CodeView debug information for arm and arm64. + if (!(is_clang && current_os == "winuwp" && (current_cpu == "arm" || current_cpu == "arm64"))) { + # Note that with VC++ this requires is_win_fastlink, enforced elsewhere. + cflags = [ "/Z7" ] # Debug information in the .obj files. } + } else { + cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. } if (is_win_fastlink && !use_lld) { diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 325d442ab..7ed56507b 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -282,10 +282,20 @@ config("runtime_library") { defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] } cflags_cc += [ - "/EHsc", "/std:c++17", "/Zc:__cplusplus", ] + + #TEMPORARY!!! Clang-cl.exe missing unwind support for Windows arm and arm64. This will generate errors in places where try/catch are used + if (is_clang && (current_cpu == "arm" || current_cpu == "arm64")) { + cflags_cc += [ + "/EHs-c-", + ] + } else { + cflags_cc += [ + "/EHsc" + ] + } # This warning is given because the linker cannot tell the difference # between consuming WinRT APIs versus authoring WinRT within static diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index eaa3d9a49..4596de391 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -172,7 +172,9 @@ template("msvc_toolchain") { "$object_subdir/{{source_name_part}}.obj", ] if (target_name == "uwp_clang_arm" || target_name == "win_clang_arm") { - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=armv7-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + } else if (target_name == "uwp_clang_arm64" || target_name == "win_clang_arm64") { + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=aarch64-windows-msvc /DWindowsSDKDesktopARM64Support=1" } else { rspfile = "{{output}}.rsp" command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" @@ -196,7 +198,9 @@ template("msvc_toolchain") { ] if (target_name == "uwp_clang_arm" || target_name == "win_clang_arm") { - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=armv7-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + } else if (target_name == "uwp_clang_arm64" || target_name == "win_clang_arm64") { + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=aarch64-windows-msvc /DWindowsSDKDesktopARM64Support=1" } else { rspfile = "{{output}}.rsp" command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" From ffa7641574f8a5e02b5bab9f509f0b841295dfe7 Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Fri, 18 Jan 2019 22:36:10 +0100 Subject: [PATCH 42/47] Fixed potential linker issue when for building is used Microsoft's cl.exe and for linking lld-link.exe --- toolchain/win/BUILD.gn | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 4596de391..2742b7b0f 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -82,6 +82,12 @@ template("msvc_toolchain") { # toolchain args, use those values, otherwise default to the global one. # This works because the only reasonable override that toolchains might # supply for these values are to force-disable them. + if (defined(toolchain_args.use_lld)) { + toolchain_uses_lld = toolchain_args.use_lld + } else { + toolchain_uses_lld = use_lld + } + if (defined(toolchain_args.is_clang)) { toolchain_uses_clang = toolchain_args.is_clang } else { @@ -98,7 +104,7 @@ template("msvc_toolchain") { cl = "${analyzer_prefix} ${cl}" } - if (use_lld) { + if (toolchain_uses_lld) { if (host_os == "win") { lld_link = "lld-link.exe" } else { @@ -138,7 +144,7 @@ template("msvc_toolchain") { if (defined(invoker.sys_lib_flags)) { linker_wrapper = "" sys_lib_flags = "${invoker.sys_lib_flags} " # Note trailing space - } else if (use_lld) { + } else if (toolchain_uses_lld) { # Invoke ninja as wrapper instead of tool wrapper, because python # invocation requires higher cpu usage compared to ninja invocation, and # the python wrapper is only needed to work around link.exe problems. @@ -391,6 +397,7 @@ if (target_cpu != "x64") { current_os = "win" current_cpu = target_cpu is_clang = false + use_lld = false } } @@ -408,6 +415,7 @@ if (target_cpu != "x64") { current_os = "win" current_cpu = target_cpu is_clang = true + use_lld = true } } } @@ -440,6 +448,7 @@ template("win_x64_toolchains") { is_clang = false current_os = "win" current_cpu = "x64" + use_lld = false } } @@ -460,6 +469,7 @@ template("win_x64_toolchains") { is_clang = true current_os = "win" current_cpu = "x64" + use_lld = true } } } @@ -504,6 +514,7 @@ if (target_os == "winuwp") { current_os = "winuwp" current_cpu = target_cpu is_clang = false + use_lld = false } } msvc_toolchain("uwp_clang_" + target_cpu) { @@ -516,6 +527,7 @@ if (target_os == "winuwp") { current_os = "winuwp" current_cpu = target_cpu is_clang = true + use_lld = true } } } From a6ce039949b8b90d1666ef5c93a6cdd1439dc33c Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Tue, 22 Jan 2019 15:30:50 +0100 Subject: [PATCH 43/47] Made changes based on comments for PRs: https://github.com/webrtc-uwp/chromium-build/pull/3 https://github.com/webrtc-uwp/chromium-build/pull/4 --- config/compiler/BUILD.gn | 2 +- config/win/BUILD.gn | 2 +- toolchain/win/BUILD.gn | 53 ++++++++++++++++++++++++++-------------- vs_toolchain.py | 11 ++++++--- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn index d622f82c5..0a052b5bc 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn @@ -2196,7 +2196,7 @@ config("symbols") { if (is_win) { cflags = [] if (use_goma || is_clang) { - # This check is added because Calng-Cl.exe doesn't emmit CodeView debug information for arm and arm64. + # This check is added because clang-cl.exe doesn't emmit CodeView debug information for arm and arm64. if (!(is_clang && current_os == "winuwp" && (current_cpu == "arm" || current_cpu == "arm64"))) { # Note that with VC++ this requires is_win_fastlink, enforced elsewhere. cflags = [ "/Z7" ] # Debug information in the .obj files. diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 7ed56507b..09f5fb25e 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -446,7 +446,7 @@ config("default_crt") { configs = [ ":dynamic_crt" ] } else { # Desktop Windows: static CRT. - configs = [ ":dynamic_crt" ] + configs = [ ":static_crt" ] } } } diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 2742b7b0f..826cc2914 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -55,6 +55,13 @@ if (current_toolchain == default_toolchain) { # You would also define a toolchain_args variable with at least these set: # current_cpu: current_cpu to pass as a build arg # current_os: current_os to pass as a build arg +# Some other supported variables are: +# is_clang : flag whether to use or not clang compiler. Used when +# invoking this toolchain not as the default one. +# use_lld : flag whether to use or not lld linker. Used when +# invoking this toolchain not as the default one. Added +# because some runtime issues are discovered when lld is +# used for linking libs and apps build with msvc cl.exe template("msvc_toolchain") { toolchain(target_name) { # When invoking this toolchain not as the default one, these args will be @@ -82,12 +89,6 @@ template("msvc_toolchain") { # toolchain args, use those values, otherwise default to the global one. # This works because the only reasonable override that toolchains might # supply for these values are to force-disable them. - if (defined(toolchain_args.use_lld)) { - toolchain_uses_lld = toolchain_args.use_lld - } else { - toolchain_uses_lld = use_lld - } - if (defined(toolchain_args.is_clang)) { toolchain_uses_clang = toolchain_args.is_clang } else { @@ -104,6 +105,13 @@ template("msvc_toolchain") { cl = "${analyzer_prefix} ${cl}" } + # Override use_lld value from default toolchain when passed like input argument + if (defined(toolchain_args.use_lld)) { + toolchain_uses_lld = toolchain_args.use_lld + } else { + toolchain_uses_lld = use_lld + } + if (toolchain_uses_lld) { if (host_os == "win") { lld_link = "lld-link.exe" @@ -177,38 +185,43 @@ template("msvc_toolchain") { outputs = [ "$object_subdir/{{source_name_part}}.obj", ] + + rspfile = "{{output}}.rsp" + if (target_name == "uwp_clang_arm" || target_name == "win_clang_arm") { - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" } else if (target_name == "uwp_clang_arm64" || target_name == "win_clang_arm64") { - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=aarch64-windows-msvc /DWindowsSDKDesktopARM64Support=1" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=aarch64-windows-msvc /DWindowsSDKDesktopARM64Support=1" + rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" } else { - rspfile = "{{output}}.rsp" - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" - rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" + rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" } } tool("cxx") { - precompiled_header_type = "msvc" # The PDB name needs to be different between C and C++ compiled files. pdbname = "{{target_out_dir}}/{{label_name}}_cc.pdb" # See comment in CC tool about quoting. - depsformat = "msvc" description = "CXX {{output}}" outputs = [ "$object_subdir/{{source_name_part}}.obj", ] + rspfile = "{{output}}.rsp" + if (target_name == "uwp_clang_arm" || target_name == "win_clang_arm") { - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" } else if (target_name == "uwp_clang_arm64" || target_name == "win_clang_arm64") { - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=aarch64-windows-msvc /DWindowsSDKDesktopARM64Support=1" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=aarch64-windows-msvc /DWindowsSDKDesktopARM64Support=1" + rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" } else { - rspfile = "{{output}}.rsp" command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" } @@ -228,12 +241,14 @@ template("msvc_toolchain") { ml = "ml64.exe" } else if (toolchain_args.current_cpu == "x86") { ml = "ml.exe" - } - else if (toolchain_args.current_cpu == "arm"){ + } else if (toolchain_args.current_cpu == "arm"){ ml = "armasm.exe" - } else { + } else if (toolchain_args.current_cpu == "arm64"){ ml = "armasm64.exe" + } else { + assert(false, "Unsupported CPU tartget") } + if (toolchain_args.current_cpu == "x64" || toolchain_args.current_cpu == "x86") { command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" } else { diff --git a/vs_toolchain.py b/vs_toolchain.py index 433594964..36da3fef6 100755 --- a/vs_toolchain.py +++ b/vs_toolchain.py @@ -190,12 +190,12 @@ def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix): os.environ.get('WINDOWSSDKDIR', os.path.expandvars('%ProgramFiles(x86)%' '\\Windows Kits\\10'))) - if target_cpu != 'arm64': + if target_cpu == 'arm64': ucrt_dll_dirs = os.path.join(win_sdk_dir, 'Redist', 'ucrt', 'DLLs', - target_cpu) + 'arm') else: ucrt_dll_dirs = os.path.join(win_sdk_dir, 'Redist', 'ucrt', 'DLLs', - 'arm') + target_cpu) ucrt_files = glob.glob(os.path.join(ucrt_dll_dirs, 'api-ms-win-*.dll')) assert len(ucrt_files) > 0 for ucrt_src_file in ucrt_files: @@ -244,6 +244,7 @@ def _CopyPGORuntime(target_dir, target_cpu): pgo_x86_runtime_dir = os.path.join(pgo_runtime_root, 'HostX86', 'x86') pgo_x64_runtime_dir = os.path.join(pgo_runtime_root, 'HostX64', 'x64') pgo_arm_runtime_dir = os.path.join(pgo_runtime_root, 'arm') + pgo_arm64_runtime_dir = os.path.join(pgo_runtime_root, 'arm64') else: raise Exception('Unexpected toolchain version: %s.' % env_version) @@ -257,7 +258,9 @@ def _CopyPGORuntime(target_dir, target_cpu): elif target_cpu == 'x64': source = os.path.join(pgo_x64_runtime_dir, runtime) elif target_cpu == 'arm': - source = os.path.join(pgo_arm_runtime_dir, runtime) + source = os.path.join(pgo_arm_runtime_dir, runtime) + elif target_cpu == 'arm64': + source = os.path.join(pgo_arm64_runtime_dir, runtime) else: raise NotImplementedError("Unexpected target_cpu value: " + target_cpu) if not os.path.exists(source): From 4ea2218e153eccebe0dc2e892605e5a368d7227e Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Tue, 19 Feb 2019 18:43:01 +0100 Subject: [PATCH 44/47] Update arm assembly build action in win build toolchain --- toolchain/win/BUILD.gn | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 826cc2914..54f418d25 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -189,7 +189,7 @@ template("msvc_toolchain") { rspfile = "{{output}}.rsp" if (target_name == "uwp_clang_arm" || target_name == "win_clang_arm") { - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE -Wno-unknown-argument" rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" } else if (target_name == "uwp_clang_arm64" || target_name == "win_clang_arm64") { command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=aarch64-windows-msvc /DWindowsSDKDesktopARM64Support=1" @@ -216,7 +216,7 @@ template("msvc_toolchain") { rspfile = "{{output}}.rsp" if (target_name == "uwp_clang_arm" || target_name == "win_clang_arm") { - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=arm-windows-msvc /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE -Wno-unknown-argument" rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" } else if (target_name == "uwp_clang_arm64" || target_name == "win_clang_arm64") { command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\" --target=aarch64-windows-msvc /DWindowsSDKDesktopARM64Support=1" @@ -237,22 +237,30 @@ template("msvc_toolchain") { } tool("asm") { - if (toolchain_args.current_cpu == "x64") { - ml = "ml64.exe" - } else if (toolchain_args.current_cpu == "x86") { - ml = "ml.exe" - } else if (toolchain_args.current_cpu == "arm"){ - ml = "armasm.exe" - } else if (toolchain_args.current_cpu == "arm64"){ - ml = "armasm64.exe" - } else { - assert(false, "Unsupported CPU tartget") + if (!is_clang) { + if (toolchain_args.current_cpu == "x64") { + ml = "ml64.exe" + } else if (toolchain_args.current_cpu == "x86") { + ml = "ml.exe" + } else if (toolchain_args.current_cpu == "arm"){ + ml = "armasm.exe" + } else if (toolchain_args.current_cpu == "arm64"){ + ml = "armasm64.exe" + } else { + assert(false, "Unsupported CPU tartget") + } } - if (toolchain_args.current_cpu == "x64" || toolchain_args.current_cpu == "x86") { - command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" + if (is_clang) { + rspfile = "{{output}}.rsp" + command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} --target=arm-arm-windows -march=armv7-a -Wno-unused-command-line-argument -Wno-unknown-argument" + rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" } else { - command = "$python_path $tool_wrapper_path asm-wrapper $env $ml -oldit -16 {{include_dirs}} {{source}} -o {{output}}" + if (toolchain_args.current_cpu == "x64" || toolchain_args.current_cpu == "x86") { + command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" + } else { + command = "$python_path $tool_wrapper_path asm-wrapper $env $ml -oldit -16 {{include_dirs}} {{source}} -o {{output}}" + } } description = "ASM {{output}}" outputs = [ From 0139ca4aa7ad898a37f1413999d9f14c8c392fe1 Mon Sep 17 00:00:00 2001 From: Sergej Jovanovic <sergej@gnedo.com> Date: Fri, 22 Mar 2019 09:36:22 +0100 Subject: [PATCH 45/47] Updated asm tool to support clang-cl and armasm. --- toolchain/win/BUILD.gn | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn index 54f418d25..34a57eefe 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -237,7 +237,7 @@ template("msvc_toolchain") { } tool("asm") { - if (!is_clang) { + if (!toolchain_uses_clang) { if (toolchain_args.current_cpu == "x64") { ml = "ml64.exe" } else if (toolchain_args.current_cpu == "x86") { @@ -249,19 +249,19 @@ template("msvc_toolchain") { } else { assert(false, "Unsupported CPU tartget") } + } else { + ml = "$env_wrapper$cl" } - if (is_clang) { - rspfile = "{{output}}.rsp" - command = "$env_wrapper$cl /nologo /showIncludes ${clflags} @$rspfile /c {{source}} /Fo{{output}} --target=arm-arm-windows -march=armv7-a -Wno-unused-command-line-argument -Wno-unknown-argument" - rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" + if (toolchain_args.current_cpu == "x64" || toolchain_args.current_cpu == "x86") { + command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" } else { - if (toolchain_args.current_cpu == "x64" || toolchain_args.current_cpu == "x86") { - command = "$python_path $tool_wrapper_path asm-wrapper $env $ml {{defines}} {{include_dirs}} {{asmflags}} /c /Fo{{output}} {{source}}" - } else { - command = "$python_path $tool_wrapper_path asm-wrapper $env $ml -oldit -16 {{include_dirs}} {{source}} -o {{output}}" + command = "$python_path $tool_wrapper_path asm-wrapper $env $ml -oldit -16 {{include_dirs}} {{source}} -o {{output}}" + if (is_clang && toolchain_args.current_cpu == "arm") { + command += " --target=arm-pc-windows" } } + description = "ASM {{output}}" outputs = [ "$object_subdir/{{source_name_part}}.obj", From 8d91370203c1899ee7746a55d9e41c52c3b7ff12 Mon Sep 17 00:00:00 2001 From: Robin Raymond <robin@opticaltone.com> Date: Sat, 23 Mar 2019 17:02:22 -0400 Subject: [PATCH 46/47] added cpp17 flags to build engine --- config/win/BUILD.gn | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 09f5fb25e..16255dbed 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -319,6 +319,13 @@ config("runtime_library") { } } +config("cpp17") { + cflags_cc = [ + "/std:c++17", + "/Zc:__cplusplus", + ] +} + # Sets the default Windows build version. This is separated because some # targets need to manually override it for their compiles. config("winver") { From 5c4a1bc14859db46feaa23886e7f584f3a7192e6 Mon Sep 17 00:00:00 2001 From: Jerome Humbert <jerome.humbert@microsoft.com> Date: Fri, 14 Jun 2019 17:29:03 +0100 Subject: [PATCH 47/47] Enable forcing `/std:c++17` via GN argument Use a new `std_cpp17` argument in Windows builds to enable forcing Win32 MSVC builds to use `/std:c++17`. This is already forced for UWP, but is needed for Win32 if a module compiled with C++17 needs to link against the `webrtc.lib` compiled from this repository. Otherwise the layout mismatch between `absl::optional` (non-c++17) and `std::optional` (c++17) produces a link error. --- config/win/BUILD.gn | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 16255dbed..541933d33 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -46,12 +46,27 @@ declare_args() { # and with this switch, clang emits it like this: # foo/bar.cc:12:34: error: something went wrong use_clang_diagnostics_format = false + + # Enable C++17 even on Win32. + # For UWP, C++17 is always enabled because it is needed for C++/WinRT to + # compile the wrappers. + # This is needed to work around the fact that Abseil defines an incompatible + # absl::optional in pre-c++17 mode while std::optional is used in c++17 mode. + # So programs linking against webrtc.lib need to compile with the correct mode. + std_cpp17 = false } # This is included by reference in the //build/config/compiler config that # is applied to all targets. It is here to separate out the logic that is # Windows-only. config("compiler") { + configs = [] + if (current_os == "winuwp") { + std_cpp17 = true + } + if (std_cpp17) { + configs += [ "//build/config/win:cpp17" ] + } if (current_cpu == "x86") { asmflags = [ # When /safeseh is specified, the linker will only produce an image if it @@ -281,10 +296,6 @@ config("runtime_library") { } else { defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] } - cflags_cc += [ - "/std:c++17", - "/Zc:__cplusplus", - ] #TEMPORARY!!! Clang-cl.exe missing unwind support for Windows arm and arm64. This will generate errors in places where try/catch are used if (is_clang && (current_cpu == "arm" || current_cpu == "arm64")) {