Skip to content

Windows build fixes for Bazel ≥ 9.0.1#22

Open
walter-zeromatter wants to merge 1 commit into
hermeticbuild:mainfrom
walter-zeromatter:user/wgray/win-fixes
Open

Windows build fixes for Bazel ≥ 9.0.1#22
walter-zeromatter wants to merge 1 commit into
hermeticbuild:mainfrom
walter-zeromatter:user/wgray/win-fixes

Conversation

@walter-zeromatter
Copy link
Copy Markdown

  • 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.

- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant