Windows build fixes for Bazel ≥ 9.0.1#22
Open
walter-zeromatter wants to merge 1 commit into
Open
Conversation
- bootstrap_process_wrapper.cc: rewrite `@response-files` to convert the
rustc `--sysroot=` value to its 8.3 short form via `GetShortPathNameA`
before spawning rustc. The MSVC `link.exe` shipped with VS 2022
BuildTools lacks `longPathAware`, so the resolved
`<sysroot>/lib/rustlib/.../libstd-*.rlib` paths overflow MAX_PATH (260)
and fail with LNK1181. Also restrict `get_output_base` to follow
`external/` only when it's a symlink (Bazel ≥ 9.0.1 made it a real
directory on Windows).
- options.rs: same external-is-real-dir fix for the regular
process_wrapper. Falls back to deriving output_base from `current_dir`'s
grandparent when `external/` is not a symlink.
- incremental_cache.rs: `find_output_base` prefers an ancestor whose
basename is not `execroot`. Bazel writes `DO_NOT_BUILD_HERE` in both the
real output_base and `execroot/` on Windows ≥ 9.0.1, and picking the
closer one yields a doubled `…/execroot/execroot/_main/…` path.
- main.rs: skip `*.rcgu.{o,bc,bc.z}` codegen intermediates when building
the unified `-Ldependency` dir, and tolerate `NotFound` on the copy
fallback. Pipelined sibling actions can garbage-collect those
temporaries between `read_dir` and the hardlink/copy.
- cargo_build_script_runner/bin.rs: track exec_root symlinks for cleanup
only when `symlink_if_not_exists` actually created the symlink (was
hitting DirectoryNotEmpty trying to `remove_dir` real dirs created by
runfiles staging, e.g. `.github`). Also skip `.git` from execroot
symlinks so `ring` ≤ 0.17.x doesn't enter its "local hacking" mode
that hardcodes `./target/tools/windows/nasm/nasm`.
- cargo_build_script_runner/cargo_manifest_dir.rs: use `symlink_metadata`
in `remove_symlink` so dangling directory symlinks (Bazel's
`local-spawn-runner.*` sandboxes cleaned up before this runs) get
`remove_dir`'d instead of failing `remove_file` with ACCESS_DENIED.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bootstrap_process_wrapper.cc: rewrite
@response-filesto convert the rustc--sysroot=value to its 8.3 short form viaGetShortPathNameAbefore spawning rustc. The MSVClink.exeshipped with VS 2022 BuildTools lackslongPathAware, so the resolved<sysroot>/lib/rustlib/.../libstd-*.rlibpaths overflow MAX_PATH (260) and fail with LNK1181. Also restrictget_output_baseto followexternal/only when it's a symlink (Bazel ≥ 9.0.1 made it a real directory on Windows).options.rs: same external-is-real-dir fix for the regular process_wrapper. Falls back to deriving output_base from
current_dir's grandparent whenexternal/is not a symlink.incremental_cache.rs:
find_output_baseprefers an ancestor whose basename is notexecroot. Bazel writesDO_NOT_BUILD_HEREin both the real output_base andexecroot/on Windows ≥ 9.0.1, and picking the closer one yields a doubled…/execroot/execroot/_main/…path.main.rs: skip
*.rcgu.{o,bc,bc.z}codegen intermediates when building the unified-Ldependencydir, and tolerateNotFoundon the copy fallback. Pipelined sibling actions can garbage-collect those temporaries betweenread_dirand the hardlink/copy.cargo_build_script_runner/bin.rs: track exec_root symlinks for cleanup only when
symlink_if_not_existsactually created the symlink (was hitting DirectoryNotEmpty trying toremove_dirreal dirs created by runfiles staging, e.g..github). Also skip.gitfrom execroot symlinks soring≤ 0.17.x doesn't enter its "local hacking" mode that hardcodes./target/tools/windows/nasm/nasm.cargo_build_script_runner/cargo_manifest_dir.rs: use
symlink_metadatainremove_symlinkso dangling directory symlinks (Bazel'slocal-spawn-runner.*sandboxes cleaned up before this runs) getremove_dir'd instead of failingremove_filewith ACCESS_DENIED.