Skip to content

qtica/bazel-platform-rules-rust-duplicate-file-bug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

When trying to use two different platforms, where one inherits from the other, rules_rust runs into a file generated conflict.

I ran into this because we give developers the ability to mark their rust_test with a particular constraint to select a different platform for their tests. This alternative platform has different exec properties defined to use a different remote settings for their tests, such as a different Pool.

Users can define all the exec_properties they need, but going through a single constraint seemed cleaner and easier for users to understand.

I am unsure if this is a bazel bug, rules_rust bug, or a misuse of platforms on my side.

Details

Setup

Bazel

Bazel Version: 7.1.1

This setup worked in 6.4.0, the error observed has started to occur with the commit: https://github.com/bazelbuild/bazel/commit/d28922952c2668d982944eb7d0bbf01d5d533fa4

Constraint

//:alternate_constraint has two values:

  • //:alternate_off (default value)
  • //:alternate_on

Platforms

The extra platforms registed in .bazelrc.

//:main

  • Inherits from host

//:alternate

  • Adds additional constraint of alternate_on
  • Inherits from main

Targets

//:same

  • rust_library
  • no special constraints

//:same_test

  • rust_test
  • exec_comptable_with sets //:alternate_on
    • This is to ensure the //:alternate platform is picked up for this target

Results

I expect :same to select the //:main platform, and :same_test to select the //:alternate platform. Using the --toolchain_resolution_debug flag, this appears to be true.

I also expect the build to pass with this behaviour, but instead we get a conflicting file error in the action analysis.

ERROR: file 'external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/rust.sysroot' is generated by these conflicting actions:

Sample Builds

bazel build //:same
INFO: Analyzed target //:same (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:same up-to-date:
  bazel-bin/libsame-43929650.rlib
INFO: Elapsed time: 0.057s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
bazel build //:same_test
ERROR: file 'external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/rust.sysroot' is generated by these conflicting actions:
Label: @@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain
RuleClass: rust_toolchain rule
JavaActionClass: class com.google.devtools.build.lib.analysis.actions.FileWriteAction$CompressedFileWriteAction
Configuration: 2e5af25bbba14118de7013653a05a5c7f72e0380377c5a849fb81598e9ce97c5
Mnemonic: FileWrite
Action key: fb30e735f8561ed2099e4d23d2dbc01d45bf356d819d0848bb2e5a1b933ac6bd, 6d3c70acc0df307ded2503002356b3cab7c7745c59c325d67c70499b80118d02
Progress message: Writing file external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/rust.sysroot
Action describeKey: (null)
PrimaryInput: (null)
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-fastbuild/bin]external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/rust.sysroot
Owner information: ToolchainDependencyConfiguredTargetKey{label=@@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain, config=BuildConfigurationKey[2e5af25bbba14118de7013653a05a5c7f72e0380377c5a849fb81598e9ce97c5], executionPlatformLabel=//:main}, ToolchainDependencyConfiguredTargetKey{label=@@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain, config=BuildConfigurationKey[2e5af25bbba14118de7013653a05a5c7f72e0380377c5a849fb81598e9ce97c5], executionPlatformLabel=//:alternate}
MandatoryInputs: are equal
Outputs: are equal
INFO: Found 1 target...
Target //:same_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: command succeeded, but not all targets were analyzed
INFO: Elapsed time: 0.042s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published