return [expr {![is_aarch32_target]}]
}
+# Return true if the target is Windows-based.
+
+proc is_windows_based_target {} {
+ return [expr {[istarget *-*-cygwin*] || [istarget *-*-mingw*]}]
+}
+
# Return 1 if displaced stepping is supported on target, otherwise, return 0.
proc support_displaced_stepping {} {
return $str
}
+# Set while linker_supports_manifest_embed is running its test link,
+# so that the inner gdb_compile that link goes through skips the
+# manifest-embedding logic and doesn't recurse back into the probe.
+set gdb_probing_manifest_embed 0
+
+# Return the ldflags (as a list of "ldflags=..." options) that make
+# lld-link embed our application manifest into the executable.
+
+proc gdb_windows_manifest_embed_lld_link_ldflags {} {
+ global srcdir
+
+ set ldflags {}
+
+ # Turn on embedding (off by default).
+ lappend ldflags ldflags=-Wl,/manifest:embed
+
+ # Stop lld-link from also generating its own UAC block. With
+ # this, lld-link embeds our input as-is, while without it lld-link
+ # runs its manifest merger, which before LLVM 21 reprefixes
+ # trustInfo into the asm.v1 namespace and produces a manifest the
+ # Windows loader rejects. See
+ # <https://github.com/llvm/llvm-project/issues/120394>.
+ lappend ldflags ldflags=-Wl,/manifestuac:no
+
+ # Embed our manifest file. Pass it in Windows-native form.
+ # MSYS2's argument conversion treats a "/foo:/bar" argument as a
+ # colon-separated list of POSIX paths and mistakenly rewrites it
+ # to a semicolon-separated list of Windows paths. E.g.:
+ #
+ # "/manifestinput:/c/gdb/.../windows.manifest"
+ # =>
+ # "C:\msys64\manifestinput;C:\gdb\...\windows.manifest"
+ #
+ # I.e., the flag name itself gets converted as if it were a path,
+ # and the ":" becomes ";".
+ #
+ # What triggers the conversion is the value after the colon looking
+ # like an absolute POSIX path (a leading "/"). "/manifest:embed"
+ # above is left alone because "embed" doesn't. Passing the value
+ # as a native "C:/..." path likewise avoids it.
+ set manifest [host_file_normalize ${srcdir}/lib/windows.manifest]
+ lappend ldflags ldflags=-Wl,/manifestinput:${manifest}
+
+ return $ldflags
+}
+
+# Compile lib/windows.rc into an object embedding our application
+# manifest and return the object path, so that gdb_compile can link it
+# into every Windows test executable. The result is cached. Returns
+# the empty string on failure. This is used when linking with GNU ld,
+# which cannot embed a manifest by itself.
+
+proc gdb_windows_manifest_obj {} {
+ global srcdir objdir
+ global gdb_saved_windows_manifest_obj
+
+ if {[info exists gdb_saved_windows_manifest_obj]} {
+ return $gdb_saved_windows_manifest_obj
+ }
+
+ set rc_src ${srcdir}/lib/windows.rc
+ set obj_basename windows-manifest.o
+ set obj [standard_temp_file $obj_basename]
+
+ set windres [gdb_find_windres]
+ set cmd [list $windres -I [file dirname $rc_src] \
+ -i $rc_src -o $obj -O coff]
+ verbose -log "Executing $cmd"
+ if {[catch {exec {*}$cmd} output]} {
+ verbose -log "gdb_windows_manifest_obj: windres failed: $output"
+ return ""
+ }
+
+ if {[is_remote host]} {
+ set saved $obj_basename
+ } else {
+ set saved ${objdir}/$obj_basename
+ }
+ # Link a copy of the output object, because the original may be
+ # automatically deleted.
+ if {[info exists ::GDB_PARALLEL]} {
+ # Make sure to write the .o file atomically. (Note
+ # GDB_PARALLEL mode does not support remote host testing.)
+ file rename -force -- $obj $saved
+ } else {
+ remote_download host $obj $saved
+ }
+ set gdb_saved_windows_manifest_obj $saved
+ return $saved
+}
+
# Compile source files specified by SOURCE into a binary of type TYPE at path
# DEST. gdb_compile is implemented using DejaGnu's target_compile, so the type
# parameter and most options are passed directly to it.
}
}
+ # On Windows, embed an "asInvoker" application manifest, so that
+ # Windows doesn't refuse to launch executables (with
+ # ERROR_ELEVATION_REQUIRED/740) whose file name happens to contain
+ # an installer-detection keyword such as "update", "setup" or
+ # "install".
+ #
+ # There are two ways to get the manifest in, depending on the
+ # linker:
+ #
+ # - GNU ld can't embed a manifest by itself, so compile the
+ # manifest into a resource object with windres and link that
+ # in.
+ #
+ # - lld-link can embed a manifest by itself, no resource compiler
+ # needed. Note that the LLVM toolchain has llvm-windres and
+ # llvm-rc, but not all LLVM-based toolchain distributions ship
+ # them.
+ #
+ # Probe whether the linker supports embedding a manifest rather
+ # than trying to guess which linker is in use from the compiler or
+ # target.
+ if { $type == "executable"
+ && [is_windows_based_target]
+ && !$::gdb_probing_manifest_embed } {
+ if { [linker_supports_manifest_embed] } {
+ lappend options {*}[gdb_windows_manifest_embed_lld_link_ldflags]
+ } else {
+ set manifest_obj [gdb_windows_manifest_obj]
+ if { $manifest_obj != "" } {
+ lappend options "ldflags=$manifest_obj"
+ }
+ }
+ }
+
# Automatically handle includes in testsuite/lib/.
auto_lappend_include_files options $source
return [gdb_simple_compile $me $src executable $flags]
}
+# Return 1 if the linker is lld-link which can embed our application
+# manifest by itself, otherwise 0. Probes the exact flag combination
+# gdb_compile uses.
+gdb_caching_proc linker_supports_manifest_embed {} {
+ set me "linker_supports_manifest_embed"
+ set flags [gdb_windows_manifest_embed_lld_link_ldflags]
+ set src { int main() { return 0; } }
+
+ # Guard against infinite recursion: the test link below itself
+ # goes through gdb_compile, which consults this proc to decide
+ # whether to embed the manifest. The guard makes that inner
+ # gdb_compile skip the manifest logic.
+ set ::gdb_probing_manifest_embed 1
+ set result [gdb_simple_compile $me $src executable $flags]
+ set ::gdb_probing_manifest_embed 0
+
+ return $result
+}
+
# Return 1 if compiler supports scalar_storage_order attribute, otherwise
# return 0.
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Copyright (C) 2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<!-- Windows' installer-detection heuristic refuses to launch an
+ executable whose file name contains words such as "update",
+ "setup" or "install" unless the PE embeds an application manifest
+ that declares the "asInvoker" execution level. gdb_compile embeds
+ this manifest in every test executable: with GNU ld via the
+ windows.rc resource script, with lld-link via
+ /manifest:embed /manifestinput. See gdb_compile in lib/gdb.exp.
+
+ The compatibility section declares the supported Windows versions.
+ Without it, the version-reporting APIs (GetVersionEx and friends)
+ cap out at Windows 8. -->
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+ <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+ <application>
+ <!-- Windows Vista -->
+ <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
+ <!-- Windows 7 -->
+ <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
+ <!-- Windows 8 -->
+ <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
+ <!-- Windows 8.1 -->
+ <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
+ <!-- Windows 10 and Windows 11 -->
+ <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
+ </application>
+ </compatibility>
+</assembly>