Merge bitcoin/bitcoin#32396: cmake: Add application manifests when cross-compiling for Windows

8f4fed7ec7 symbol-check: Add check for application manifest in Windows binaries (Hennadii Stepanov)
2bb6ab8f1b ci: Add "Get bitcoind manifest" steps to Windows CI jobs (Hennadii Stepanov)
282b4913c7 cmake: Add application manifests when cross-compiling for Windows (Hennadii Stepanov)

Pull request description:

  Windows [application manifests ](https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests) provide several benefits—such as enhanced security settings, and the ability to set a process-wide code page (required for https://github.com/bitcoin/bitcoin/pull/32380), as well as granular control over supported Windows versions. Most of these benefits lie beyond the scope of this PR and will be evaluated separately.

  On the current master branch @ fc6346dbc8, the linker generates and embeds a manifest only when building with MSVC:
  ```xml
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <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"></requestedExecutionLevel>
        </requestedPrivileges>
      </security>
    </trustInfo>
  </assembly>
  ```

  However, this manifest fails validation:
  ```
  > mt.exe -nologo -inputresource:build\bin\Release\bitcoind.exe -validate_manifest

  mt.exe : general error 10100ba: The manifest is missing the definition identity.
  ```

  This PR unifies manifest embedding for both native and cross-compilation builds.

  Here is the change in the manifest on Windows:
  ```diff
  --- bitcoind-master.manifest
  +++ bitcoind-pr.manifest
  @@ -1,5 +1,6 @@
   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  +  <assemblyIdentity type="win32" name="org.bitcoincore.bitcoind" version="29.99.0.0"></assemblyIdentity>
     <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
       <security>
         <requestedPrivileges>
  ```

  which effectively resolves the "missing the definition identity" error.

  Finally, “Get bitcoind manifest” steps have been added to the Windows CI jobs to ensure the manifest is embedded and validated.

ACKs for top commit:
  sipsorcery:
    re-tACK 8f4fed7ec7.
  hodlinator:
    re-ACK 8f4fed7ec7
  davidgumberg:
    Reviewed and tested ACK 8f4fed7ec7

Tree-SHA512: 6e2dbdc77083eafdc242410eb89a6678e37b11efd786505dcd7844f0bac8f44d68625e62924a03b26549bdb4aaec5330dc608e6b4d66789f0255092e23aef6cb
This commit is contained in:
merge-script
2025-05-16 09:19:13 +01:00
8 changed files with 74 additions and 2 deletions

View File

@@ -206,6 +206,7 @@ if(ENABLE_WALLET)
wallet/wallettool.cpp
)
add_windows_resources(bitcoin-wallet bitcoin-wallet-res.rc)
add_windows_application_manifest(bitcoin-wallet)
target_link_libraries(bitcoin-wallet
core_interface
bitcoin_wallet
@@ -339,6 +340,7 @@ if(BUILD_DAEMON)
init/bitcoind.cpp
)
add_windows_resources(bitcoind bitcoind-res.rc)
add_windows_application_manifest(bitcoind)
target_link_libraries(bitcoind
core_interface
bitcoin_node
@@ -392,6 +394,7 @@ target_link_libraries(bitcoin_cli
if(BUILD_CLI)
add_executable(bitcoin-cli bitcoin-cli.cpp)
add_windows_resources(bitcoin-cli bitcoin-cli-res.rc)
add_windows_application_manifest(bitcoin-cli)
target_link_libraries(bitcoin-cli
core_interface
bitcoin_cli
@@ -407,6 +410,7 @@ endif()
if(BUILD_TX)
add_executable(bitcoin-tx bitcoin-tx.cpp)
add_windows_resources(bitcoin-tx bitcoin-tx-res.rc)
add_windows_application_manifest(bitcoin-tx)
target_link_libraries(bitcoin-tx
core_interface
bitcoin_common
@@ -420,6 +424,7 @@ endif()
if(BUILD_UTIL)
add_executable(bitcoin-util bitcoin-util.cpp)
add_windows_resources(bitcoin-util bitcoin-util-res.rc)
add_windows_application_manifest(bitcoin-util)
target_link_libraries(bitcoin-util
core_interface
bitcoin_common

View File

@@ -256,6 +256,7 @@ add_executable(bitcoin-qt
)
add_windows_resources(bitcoin-qt res/bitcoin-qt-res.rc)
add_windows_application_manifest(bitcoin-qt)
target_link_libraries(bitcoin-qt
core_interface

View File

@@ -142,6 +142,8 @@ target_raw_data_sources(test_bitcoin NAMESPACE test::data
data/asmap.raw
)
add_windows_application_manifest(test_bitcoin)
target_link_libraries(test_bitcoin
core_interface
test_util