windows: preserve external executable manifests (#31012)

This commit is contained in:
Alexander Medvednikov authored and GitHub committed 2026-10-23 10:18:49 +03:00
1 parent 9fee04bb68
commit ebec02a8aa
3 files changed
+25 -1

No files matched your search

+2
View File
@@ -12,6 +12,8 @@ such an executable can create, check and open files past `MAX_PATH`.
* An executable that its linker already gave a manifest keeps that manifest unchanged.
MinGW GCC links one that declares `longPathAware` already.
* If `<output>.manifest` exists beside the final executable, V leaves that external manifest
in control. Include `longPathAware` there if the program also needs long paths.
* Executables linked by MSVC get no manifest: they load `dbghelp.dll` at startup, and its
initialization would hang on a long `TMP` (see below) before any V code runs.
* Executables built with the FastC backend (`-b fastc`), shared libraries, and Windows
+1 -1
View File
@@ -16892,7 +16892,7 @@ Please install the corresponding development package/libraries and make sure the
// in a longPathAware process that loops forever on a TMP past MAX_PATH,
// before any V code can shorten it, so they stay as the linker made them.
if prefs.normalized_target_os() == 'windows' && !is_o && !is_shared
&& !c_compiler_is_msvc(c_compiler) {
&& !c_compiler_is_msvc(c_compiler) && !os.is_file('${bin_file}.manifest') {
add_windows_long_path_manifest(staged_binary) or {
// Long build paths need the manifest, so say so when it is missing for them.
if verbose || show_cc || cc_dir_moved {
@@ -66,3 +66,25 @@ fn test_v_builds_get_the_manifest() ! {
assert os.read_file(exe)!.contains('longPathAware')
assert cmdexec.run(exe, []).output.contains('Hello, World!')
}
fn test_side_by_side_manifest_at_final_output_is_kept() ! {
root := manifest_test_root('v3_external_manifest_build')!
defer { os.rmdir_all(root) or {} }
src := os.join_path(@VEXEROOT, 'examples', 'hello_world.v')
exe := os.join_path(root, 'hello_external.exe')
manifest := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
' +
'<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">' +
'<dependency><dependentAssembly><assemblyIdentity type="win32" ' +
'name="Microsoft.Windows.Common-Controls" version="6.0.0.0" ' +
'processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>' +
'</dependentAssembly></dependency></assembly>'
os.write_file('${exe}.manifest', manifest)!
for flags in [[]string{}, ['-nocache']] {
res := cmdexec.run(@VEXE, ['-cc', 'tcc', ...flags, '-o', exe, src])
assert res.exit_code == 0, res.output
assert !windows_executable_has_manifest(exe)!
assert os.read_file('${exe}.manifest')! == manifest
assert cmdexec.run(exe, []).output.contains('Hello, World!')
}
}