Skip to content

Embed asInvoker UAC manifest in the Windows launcher stub#29822

Closed
rdesgroppes wants to merge 1 commit into
bazelbuild:masterfrom
rdesgroppes:windows-launcher-uac-manifest
Closed

Embed asInvoker UAC manifest in the Windows launcher stub#29822
rdesgroppes wants to merge 1 commit into
bazelbuild:masterfrom
rdesgroppes:windows-launcher-uac-manifest

Conversation

@rdesgroppes

@rdesgroppes rdesgroppes commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Description

Add win_manifest.xml (requestedExecutionLevel: asInvoker) and win_resources.rc to src/tools/launcher, link them via the existing windows_resources rule, and add a regression test.

Motivation

On Windows, manifest-less PE executables whose name contains keywords like "install", "setup", "update", or "patch" trigger the "UAC installer-detection heuristic" and demand elevation, even when the target does nothing privileged.

When running such executables without admin privileges, one indeed face errors resembling:

FATAL: ExecuteProgram(C:\[...]\install.exe) failed: ERROR: src/main/native/windows/process.cc(189): CreateProcessW("C:\[...]\install.exe"): The requested operation requires elevation.
 (error: 740)

Declaring asInvoker in the launcher stub bypasses the heuristic, similar to rust-lang/cargo#393 (cargo update triggered the same heuristic): cargo now ships a windows.manifest.xml embedded via its build script.

Because the manifest lives in the PE resource section, launcher_maker's byte-copy propagates it to every generated binary automatically.

Fixes #29819.

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES[NEW]: Windows launcher stubs now embed an asInvoker UAC manifest, preventing "The requested operation requires elevation. (error: 740)" for targets whose name matches the installer-detection heuristic.

@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label Jun 12, 2026

@quentindavis825-png quentindavis825-png left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rdesgroppes rdesgroppes changed the title Embed asInvoker UAC manifest in the Windows launcher stub Embed asInvoker UAC manifest in the Windows launcher stub Jun 12, 2026
@rdesgroppes rdesgroppes force-pushed the windows-launcher-uac-manifest branch 2 times, most recently from 49c387f to d29a672 Compare June 12, 2026 13:03
@rdesgroppes rdesgroppes force-pushed the windows-launcher-uac-manifest branch 2 times, most recently from 1a0cbc7 to b129f28 Compare June 12, 2026 14:51
@rdesgroppes

Copy link
Copy Markdown
Contributor Author

@meteorcloudy, may I request your review?

@iancha1992 iancha1992 added the team-Core Skyframe, bazel query, BEP, options parsing, bazelrc label Jun 15, 2026

@quentindavis825-png quentindavis825-png left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

### Description

Add `win_manifest.xml` (`requestedExecutionLevel asInvoker`) and
`win_resources.rc` to `src/tools/launcher`, link them via the
existing `windows_resources` rule, and add a regression test.

### Motivation

On Windows, manifest-less PE executables whose name contains
keywords like "install", "setup", "update", or "patch" trigger
the UAC installer-detection heuristic and demand elevation
(error 740), even when the target does nothing privileged.
Declaring `asInvoker` in the launcher stub bypasses the
heuristic. Because the manifest lives in the PE resource
section, `launcher_maker`'s byte-copy propagates it to every
generated binary automatically.

Fixes bazelbuild#29819.

### Build API Changes

No

### Checklist

- [x] I have added tests for the new use cases (if any).
- [ ] I have updated the documentation (if applicable).

### Release Notes

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker`
UAC manifest, preventing error 740 for targets whose name
matches the installer-detection heuristic.
@rdesgroppes rdesgroppes force-pushed the windows-launcher-uac-manifest branch from b129f28 to 81025f3 Compare June 22, 2026 12:05

@fmeum fmeum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could pribanoy also use this to enable UTF-8 awareness for more tools quite easily - thanks for fixing the rc build!

@github-actions github-actions Bot added the community-reviewed Reviewed by a trusted community contributor label Jun 22, 2026
@Wyverald Wyverald added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Jun 23, 2026
@rdesgroppes

rdesgroppes commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

We could pribanoy also use this to enable UTF-8 awareness for more tools quite easily - thanks for fixing the rc build!

probably 😉, and also declare "long path capability"?

@github-actions github-actions Bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Jun 25, 2026
@fmeum

fmeum commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

@bazel-io fork 9.2.0

@Wyverald

Copy link
Copy Markdown
Member

This ended up breaking our bootstrap builds on Windows (https://buildkite.com/bazel/bazel-bazel/builds/35912/list?sid=019eff63-e9b9-437e-bd31-1c19bcb531b3&tab=output), and we're reverting this commit. Sorry about the inconvenience; the breakage was not surfaced in the presubmit checks as the bootstrap test takes a long time to run, so we left it running in postsubmit only. Could you make sure //src/test/shell/bazel:bazel_bootstrap_distfile_test passes?

copybara-service Bot pushed a commit that referenced this pull request Jun 26, 2026
*** Reason for rollback ***

Breaks post-submit: https://buildkite.com/bazel/bazel-bazel/builds/35912

*** Original change description ***

Embed `asInvoker` UAC manifest in the Windows launcher stub (#29822)

### Description
Add `win_manifest.xml` (`requestedExecutionLevel`: `asInvoker`) and `win_resources.rc` to `src/tools/launcher`, link them via the existing `windows_resources` rule, and add a regression test.

### Motivation
On Windows, manifest-less PE executables whose name contains keywords like "install", "setup", "update", or "patch" trigger the "[UAC installer-detection heuristic](h...

***

PiperOrigin-RevId: 938607441
Change-Id: Ic272822bac15c4c80d6b6699d2da905b977c85e2
@rdesgroppes

Copy link
Copy Markdown
Contributor Author

Could you make sure //src/test/shell/bazel:bazel_bootstrap_distfile_test passes?

Sure thing, please bear with me.

rdesgroppes added a commit to rdesgroppes/bazel that referenced this pull request Jun 27, 2026
This reverts commit
bazelbuild@f5aeb71,
relanding bazelbuild#29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend
on a `windows_resources` target, but an rc toolchain was registered only
in the root `MODULE.bazel`.

The embedded `@bazel_tools` copy of the launcher requires
`@@bazel_tools//src/main/res:toolchain_type`, which nothing provided, so
the postsubmit `bazel_bootstrap_distfile_test` (which rebuilds
`@bazel_tools` from source, unlike presubmit) could not bootstrap Bazel
on Windows.

As the toolchain type label resolves relative to the repo that loads
`winsdk_toolchain.bzl`, each module must register its own rc toolchain,
so this:
- registers `@local_config_winsdk//:all` and `empty_rc_toolchain` in
  `src/MODULE.tools` (as in the root `MODULE.bazel`),
- drops the now-redundant `empty_rc_toolchain` registration from
  `testBuildLaunchersWithClangClOnWindows`.

Verified with `bazel_bootstrap_distfile_test` on Windows:
```
bazel.exe test //src/test/shell/bazel:bazel_bootstrap_distfile_test
[...]
INFO: Build completed successfully, 2 total actions
//src/test/shell/bazel:bazel_bootstrap_distfile_test   PASSED in 732.8s
Executed 1 out of 1 test: 1 test passes.
```

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC
manifest, preventing "The requested operation requires elevation.
(error: 740)" for targets whose name matches the installer-detection
heuristic.
rdesgroppes added a commit to rdesgroppes/bazel that referenced this pull request Jun 27, 2026
This reverts commit
bazelbuild@f5aeb71,
relanding bazelbuild#29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend
on a `windows_resources` target, but an rc toolchain was registered only
in the root `MODULE.bazel`.

The embedded `@bazel_tools` copy of the launcher requires
`@@bazel_tools//src/main/res:toolchain_type`, which nothing provided, so
the postsubmit `bazel_bootstrap_distfile_test` (which rebuilds
`@bazel_tools` from source, unlike presubmit) could not bootstrap Bazel
on Windows.

As the toolchain type label resolves relative to the repo that loads
`winsdk_toolchain.bzl`, each module must register its own rc toolchain,
so this:
- registers `@local_config_winsdk//:all` and `empty_rc_toolchain` in
  `src/MODULE.tools` (as in the root `MODULE.bazel`),
- drops the now-redundant `empty_rc_toolchain` registration from
  `testBuildLaunchersWithClangClOnWindows`.

Verified with `bazel_bootstrap_distfile_test` on Windows:
```
bazel.exe test //src/test/shell/bazel:bazel_bootstrap_distfile_test
[...]
INFO: Build completed successfully, 2 total actions
//src/test/shell/bazel:bazel_bootstrap_distfile_test   PASSED in 732.8s
Executed 1 out of 1 test: 1 test passes.
```

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC
manifest, preventing "The requested operation requires elevation.
(error: 740)" for targets whose name matches the installer-detection
heuristic.
@rdesgroppes

rdesgroppes commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Sorry about the inconvenience; the breakage was not surfaced in the presubmit checks as the bootstrap test takes a long time to run, so we left it running in postsubmit only. Could you make sure //src/test/shell/bazel:bazel_bootstrap_distfile_test passes?

@Wyverald I reverted f5aeb71 and found what broke: a missing toolchain registration in src/MODULE.tools. This is now fixed in #30043, if I may kindly ask you to take a look at it?

rdesgroppes added a commit to rdesgroppes/bazel that referenced this pull request Jun 27, 2026
This reverts commit
bazelbuild@f5aeb71,
relanding bazelbuild#29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend
on a `windows_resources` target, but an rc toolchain was registered only
in the root `MODULE.bazel`.

The embedded `@bazel_tools` copy of the launcher requires
`@@bazel_tools//src/main/res:toolchain_type`, which nothing provided, so
the postsubmit `bazel_bootstrap_distfile_test` (which rebuilds
`@bazel_tools` from source, unlike presubmit) could not bootstrap Bazel
on Windows.

As the toolchain type label resolves relative to the repo that loads
`winsdk_toolchain.bzl`, each module must register its own rc toolchain,
so this:
- registers `@local_config_winsdk//:all` and `empty_rc_toolchain` in
  `src/MODULE.tools` (as in the root `MODULE.bazel`),
- drops the now-redundant `empty_rc_toolchain` registration from
  `testBuildLaunchersWithClangClOnWindows`.

Verified with `bazel_bootstrap_distfile_test` on Windows:
```
bazel.exe test //src/test/shell/bazel:bazel_bootstrap_distfile_test
[...]
INFO: Build completed successfully, 2 total actions
//src/test/shell/bazel:bazel_bootstrap_distfile_test   PASSED in 732.8s
Executed 1 out of 1 test: 1 test passes.
```

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC
manifest, preventing "The requested operation requires elevation.
(error: 740)" for targets whose name matches the installer-detection
heuristic.
rdesgroppes added a commit to rdesgroppes/bazel that referenced this pull request Jun 27, 2026
This reverts commit
bazelbuild@f5aeb71,
relanding bazelbuild#29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend
on a `windows_resources` target, but an rc toolchain was registered only
in the root `MODULE.bazel`.

The embedded `@bazel_tools` copy of the launcher requires
`@@bazel_tools//src/main/res:toolchain_type`, which nothing provided, so
the postsubmit `bazel_bootstrap_distfile_test` (which rebuilds
`@bazel_tools` from source, unlike presubmit) could not bootstrap Bazel
on Windows.

As the toolchain type label resolves relative to the repo that loads
`winsdk_toolchain.bzl`, each module must register its own rc toolchain,
so this:
- registers `@local_config_winsdk//:all` and `empty_rc_toolchain` in
  `src/MODULE.tools` (as in the root `MODULE.bazel`),
- drops the now-redundant `empty_rc_toolchain` registration from
  `testBuildLaunchersWithClangClOnWindows`.

Verified with `bazel_bootstrap_distfile_test` on Windows:
```
bazel.exe test //src/test/shell/bazel:bazel_bootstrap_distfile_test
[...]
INFO: Build completed successfully, 2 total actions
//src/test/shell/bazel:bazel_bootstrap_distfile_test   PASSED in 732.8s
Executed 1 out of 1 test: 1 test passes.
```

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC
manifest, preventing "The requested operation requires elevation.
(error: 740)" for targets whose name matches the installer-detection
heuristic.
rdesgroppes added a commit to rdesgroppes/bazel that referenced this pull request Jun 27, 2026
This reverts commit
bazelbuild@f5aeb71,
relanding bazelbuild#29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend
on a `windows_resources` target, but an rc toolchain was registered only
in the root `MODULE.bazel`.

The embedded `@bazel_tools` copy of the launcher requires
`@@bazel_tools//src/main/res:toolchain_type`, which nothing provided, so
the postsubmit `bazel_bootstrap_distfile_test` (which rebuilds
`@bazel_tools` from source, unlike presubmit) could not bootstrap Bazel
on Windows.

As the toolchain type label resolves relative to the repo that loads
`winsdk_toolchain.bzl`, each module must register its own rc toolchain,
so this:
- registers `@local_config_winsdk//:all` and `empty_rc_toolchain` in
  `src/MODULE.tools` (as in the root `MODULE.bazel`),
- drops the now-redundant `empty_rc_toolchain` registration from
  `testBuildLaunchersWithClangClOnWindows`.

Verified with `bazel_bootstrap_distfile_test` on Windows:
```
bazel.exe test //src/test/shell/bazel:bazel_bootstrap_distfile_test
[...]
INFO: Build completed successfully, 2 total actions
//src/test/shell/bazel:bazel_bootstrap_distfile_test   PASSED in 732.8s
Executed 1 out of 1 test: 1 test passes.
```

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC
manifest, preventing "The requested operation requires elevation.
(error: 740)" for targets whose name matches the installer-detection
heuristic.
rdesgroppes added a commit to rdesgroppes/bazel that referenced this pull request Jun 27, 2026
This reverts commit
bazelbuild@f5aeb71,
relanding bazelbuild#29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend
on a `windows_resources` target, but its embedded `@bazel_tools` copy
had no rc toolchain for `toolchain_type`, so the postsubmit
`bazel_bootstrap_distfile_test` (which rebuilds `@bazel_tools` from
source, unlike presubmit) could not bootstrap Bazel on Windows.

The resource-compiler package lived at `src/main/res`, outside
`@bazel_tools`, so embedding it there required `@bazel_tools`-qualified
labels and hand-staging the package in the lockfile test.
Move it to `tools/res` instead, beside the other embedded toolchains, so
it is embedded and staged like its siblings and labels resolve relative
to the loading repo.

Each module must then register its own rc toolchain, so this registers
`@local_config_winsdk//:all` and `empty_rc_toolchain` in
`src/MODULE.tools` (as in the root `MODULE.bazel`) and drops the now
redundant `empty_rc_toolchain` registration from
`testBuildLaunchersWithClangClOnWindows`.

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC
manifest, preventing "The requested operation requires elevation.
(error: 740)" for targets whose name matches the installer-detection
heuristic.
rdesgroppes added a commit to rdesgroppes/bazel that referenced this pull request Jun 27, 2026
This reverts commit
bazelbuild@f5aeb71,
relanding bazelbuild#29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend
on a `windows_resources` target, but its embedded `@bazel_tools` copy
had no rc toolchain for `toolchain_type`, so the postsubmit
`bazel_bootstrap_distfile_test` (which rebuilds `@bazel_tools` from
source, unlike presubmit) could not bootstrap Bazel on Windows.

The resource-compiler package lived at `src/main/res`, outside
`@bazel_tools`, so embedding it there required `@bazel_tools`-qualified
labels and hand-staging the package in the lockfile test.
Move it to `tools/res` instead, beside the other embedded toolchains, so
it is embedded and staged like its siblings and labels resolve relative
to the loading repo.

Each module must then register its own rc toolchain, so this registers
`@local_config_winsdk//:all` and `empty_rc_toolchain` in
`src/MODULE.tools` (as in the root `MODULE.bazel`) and drops the now
redundant `empty_rc_toolchain` registration from
`testBuildLaunchersWithClangClOnWindows`.

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC
manifest, preventing "The requested operation requires elevation.
(error: 740)" for targets whose name matches the installer-detection
heuristic.
rdesgroppes added a commit to rdesgroppes/bazel that referenced this pull request Jun 29, 2026
This reverts commit
bazelbuild@f5aeb71,
relanding bazelbuild#29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend
on a `windows_resources` target, but its embedded `@bazel_tools` copy
had no rc toolchain for `toolchain_type`, so the postsubmit
`bazel_bootstrap_distfile_test` (which rebuilds `@bazel_tools` from
source, unlike presubmit) could not bootstrap Bazel on Windows.

The resource-compiler package lived at `src/main/res`, outside
`@bazel_tools`, so embedding it there required `@bazel_tools`-qualified
labels and hand-staging the package in the lockfile test.
Move it to `tools/res` instead, beside the other embedded toolchains, so
it is embedded and staged like its siblings and labels resolve relative
to the loading repo.

Each module must then register its own rc toolchain, so this registers
`@local_config_winsdk//:all` and `empty_rc_toolchain` in
`src/MODULE.tools` (as in the root `MODULE.bazel`) and drops the now
redundant `empty_rc_toolchain` registration from
`testBuildLaunchersWithClangClOnWindows`.

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC
manifest, preventing "The requested operation requires elevation.
(error: 740)" for targets whose name matches the installer-detection
heuristic.
kapunahelewong pushed a commit to kapunahelewong/bazel that referenced this pull request Jul 2, 2026
…ld#29822)

### Description
Add `win_manifest.xml` (`requestedExecutionLevel`: `asInvoker`) and `win_resources.rc` to `src/tools/launcher`, link them via the existing `windows_resources` rule, and add a regression test.

### Motivation
On Windows, manifest-less PE executables whose name contains keywords like "install", "setup", "update", or "patch" trigger the "[UAC installer-detection heuristic](https://www.advancedinstaller.com/user-guide/vista-uac.html)" and demand elevation, even when the target does nothing privileged.

When running such executables without admin privileges, one indeed face errors resembling:
```
FATAL: ExecuteProgram(C:\[...]\install.exe) failed: ERROR: src/main/native/windows/process.cc(189): CreateProcessW("C:\[...]\install.exe"): The requested operation requires elevation.
 (error: 740)
 ```

Declaring `asInvoker` in the launcher stub bypasses the heuristic, similar to rust-lang/cargo#393 (`cargo update` triggered the same heuristic): cargo now ships a `windows.manifest.xml` embedded via its build script.

Because the manifest lives in the PE resource section, `launcher_maker`'s byte-copy propagates it to every generated binary automatically.

Fixes bazelbuild#29819.

### Build API Changes
No

### Checklist
- [x] I have added tests for the new use cases (if any).
- [ ] I have updated the documentation (if applicable).

### Release Notes
RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC manifest, preventing "The requested operation requires elevation. (error: 740)" for targets whose name matches the installer-detection heuristic.

Closes bazelbuild#29822.

PiperOrigin-RevId: 937996732
Change-Id: I28684baa50ecf5b79c38c22bcc97ecdbc23677af
kapunahelewong pushed a commit to kapunahelewong/bazel that referenced this pull request Jul 2, 2026
*** Reason for rollback ***

Breaks post-submit: https://buildkite.com/bazel/bazel-bazel/builds/35912

*** Original change description ***

Embed `asInvoker` UAC manifest in the Windows launcher stub (bazelbuild#29822)

### Description
Add `win_manifest.xml` (`requestedExecutionLevel`: `asInvoker`) and `win_resources.rc` to `src/tools/launcher`, link them via the existing `windows_resources` rule, and add a regression test.

### Motivation
On Windows, manifest-less PE executables whose name contains keywords like "install", "setup", "update", or "patch" trigger the "[UAC installer-detection heuristic](h...

***

PiperOrigin-RevId: 938607441
Change-Id: Ic272822bac15c4c80d6b6699d2da905b977c85e2
copybara-service Bot pushed a commit that referenced this pull request Jul 8, 2026
…30043)

### Description
This reverts commit f5aeb71, relanding #29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend on a `windows_resources` target, but its embedded `@bazel_tools` copy had no rc toolchain for `toolchain_type`, so the postsubmit `bazel_bootstrap_distfile_test` (which rebuilds `@bazel_tools` from source, unlike presubmit) could not bootstrap Bazel on Windows.

The resource-compiler package lived at `src/main/res`, outside `@bazel_tools`, so embedding it there required `@bazel_tools`-qualified labels and hand-staging the package in the lockfile test.
Move it to `tools/res` instead, beside the other embedded toolchains, so it is embedded and staged like its siblings and labels resolve relative to the loading repo.

Each module must then register its own rc toolchain, so this registers `@local_config_winsdk//:all` and `empty_rc_toolchain` in `src/MODULE.tools` (as in the root `MODULE.bazel`) and drops the now redundant `empty_rc_toolchain` registration from `testBuildLaunchersWithClangClOnWindows`.

Verified with `bazel_bootstrap_distfile_test` on Windows:
```
bazel.exe test //src/test/shell/bazel:bazel_bootstrap_distfile_test
[...]
INFO: Build completed successfully, 2 total actions
//src/test/shell/bazel:bazel_bootstrap_distfile_test   PASSED in 732.8s
Executed 1 out of 1 test: 1 test passes.
```

### Motivation
Same as #29822:
> On Windows, manifest-less PE executables whose name contains keywords like "install", "setup", "update", or "patch" trigger the "[UAC installer-detection heuristic](https://www.advancedinstaller.com/user-guide/vista-uac.html)" and demand elevation, even when the target does nothing privileged.
>
> When running such executables without admin privileges, one indeed face errors resembling:
> ```
> FATAL: ExecuteProgram(C:\[...]\install.exe) failed: ERROR: src/main/native/windows/process.cc(189): CreateProcessW("C:\[...]\install.exe"): The requested operation requires elevation.
>  (error: 740)
>  ```
>
> Declaring `asInvoker` in the launcher stub bypasses the heuristic, similar to rust-lang/cargo#393 (`cargo update` triggered the same heuristic): cargo now ships a `windows.manifest.xml` embedded via its build script.
>
> Because the manifest lives in the PE resource section, `launcher_maker`'s byte-copy propagates it to every generated binary automatically.

Fixes #29819. (for real)

### Build API Changes
No

### Checklist
- [x] I have added tests for the new use cases (if any).
- [ ] I have updated the documentation (if applicable).

### Release Notes

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC manifest, preventing "The requested operation requires elevation. (error: 740)" for targets whose name matches the installer-detection heuristic.

Closes #30043.

PiperOrigin-RevId: 944416012
Change-Id: I37a388ad42ea8192af454a978de39dbe4ff2d100
rdesgroppes added a commit to rdesgroppes/bazel that referenced this pull request Jul 8, 2026
…azelbuild#30043)

### Description
This reverts commit f5aeb71, relanding bazelbuild#29822.

Additional fix: the change makes `//src/tools/launcher:launcher` depend on a `windows_resources` target, but its embedded `@bazel_tools` copy had no rc toolchain for `toolchain_type`, so the postsubmit `bazel_bootstrap_distfile_test` (which rebuilds `@bazel_tools` from source, unlike presubmit) could not bootstrap Bazel on Windows.

The resource-compiler package lived at `src/main/res`, outside `@bazel_tools`, so embedding it there required `@bazel_tools`-qualified labels and hand-staging the package in the lockfile test.
Move it to `tools/res` instead, beside the other embedded toolchains, so it is embedded and staged like its siblings and labels resolve relative to the loading repo.

Each module must then register its own rc toolchain, so this registers `@local_config_winsdk//:all` and `empty_rc_toolchain` in `src/MODULE.tools` (as in the root `MODULE.bazel`) and drops the now redundant `empty_rc_toolchain` registration from `testBuildLaunchersWithClangClOnWindows`.

Verified with `bazel_bootstrap_distfile_test` on Windows:
```
bazel.exe test //src/test/shell/bazel:bazel_bootstrap_distfile_test
[...]
INFO: Build completed successfully, 2 total actions
//src/test/shell/bazel:bazel_bootstrap_distfile_test   PASSED in 732.8s
Executed 1 out of 1 test: 1 test passes.
```

### Motivation
Same as bazelbuild#29822:
> On Windows, manifest-less PE executables whose name contains keywords like "install", "setup", "update", or "patch" trigger the "[UAC installer-detection heuristic](https://www.advancedinstaller.com/user-guide/vista-uac.html)" and demand elevation, even when the target does nothing privileged.
>
> When running such executables without admin privileges, one indeed face errors resembling:
> ```
> FATAL: ExecuteProgram(C:\[...]\install.exe) failed: ERROR: src/main/native/windows/process.cc(189): CreateProcessW("C:\[...]\install.exe"): The requested operation requires elevation.
>  (error: 740)
>  ```
>
> Declaring `asInvoker` in the launcher stub bypasses the heuristic, similar to rust-lang/cargo#393 (`cargo update` triggered the same heuristic): cargo now ships a `windows.manifest.xml` embedded via its build script.
>
> Because the manifest lives in the PE resource section, `launcher_maker`'s byte-copy propagates it to every generated binary automatically.

Fixes bazelbuild#29819. (for real)

### Build API Changes
No

### Checklist
- [x] I have added tests for the new use cases (if any).
- [ ] I have updated the documentation (if applicable).

### Release Notes

RELNOTES[NEW]: Windows launcher stubs now embed an `asInvoker` UAC manifest, preventing "The requested operation requires elevation. (error: 740)" for targets whose name matches the installer-detection heuristic.

Closes bazelbuild#30043.

PiperOrigin-RevId: 944416012
Change-Id: I37a388ad42ea8192af454a978de39dbe4ff2d100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed Reviewed by a trusted community contributor team-Core Skyframe, bazel query, BEP, options parsing, bazelrc team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows launcher triggers spurious UAC elevation (error 740)

5 participants