From 09554a66d8f3d841486119ef8283c8de29ce2677 Mon Sep 17 00:00:00 2001 From: "ocean (they/them)" Date: Tue, 29 Aug 2023 17:56:25 -0400 Subject: [PATCH] Build system: add option for MSVC incremental linking. (cherry picked from commit bbafe14970cf2a101b8b04dbfafeeaa9ddfb5d4d) --- methods.py | 3 +++ platform/windows/detect.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/methods.py b/methods.py index 5d7aa2e9dd4..c1ea3858a51 100644 --- a/methods.py +++ b/methods.py @@ -926,6 +926,9 @@ def generate_vs_project(env, num_jobs): if env["custom_modules"]: common_build_postfix.append("custom_modules=%s" % env["custom_modules"]) + if env["incremental_link"]: + common_build_postfix.append("incremental_link=yes") + result = " ^& ".join(common_build_prefix + [" ".join([commands] + common_build_postfix)]) return result diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 3a454e9a090..c3852985baf 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -72,6 +72,7 @@ def get_opts(): BoolVariable("use_llvm", "Use the LLVM compiler", False), BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True), BoolVariable("use_asan", "Use address sanitizer (ASAN)", False), + BoolVariable("incremental_link", "Use MSVC incremental linking. May increase or decrease build times.", False), ] @@ -214,8 +215,9 @@ def configure_msvc(env, manual_msvc_config): else: env.AppendUnique(CCFLAGS=["/MD"]) - # MSVC incremental linking is broken and _increases_ link time (GH-77968). - env.Append(LINKFLAGS=["/INCREMENTAL:NO"]) + # MSVC incremental linking is broken and may _increase_ link time (GH-77968). + if not env["incremental_link"]: + env.Append(LINKFLAGS=["/INCREMENTAL:NO"]) env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"]) env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding.