Skip to content

Commit 46fceb9

Browse files
David Tolnayfacebook-github-bot
David Tolnay
authored andcommitted
Abbreviate subdirectory of output paths
Summary: CI is failing on {D73682867} with the following error: ```lang=text,counterexample Action failed: fbcode//eden/scm/saplingnative/bindings/modules/pyrevisionstore:pyrevisionstore (cfg:opt-windows-x86_64-msvc-clang17-no-san#22e83ae67b4bf3f7) (failure_filter diag) Remote action, reproduce with: `frecli cas download-action e30dc7db928804472fd94a2d8b310ce03697146e469871c6da4d382cab97af64:144` error[E0463]: can't find crate for `revisionstore` --> fbcode\eden\scm\saplingnative\bindings\modules\pyrevisionstore\src\lib.rs:31:5 | 31 | use revisionstore::ContentHash; | ^^^^^^^^^^^^^ can't find crate Missing required input file rlib-pic-static_pic-metadata-fast-diag/libpyrevisionstore-51bbe2c5.rmeta (buck-out\v2\gen\fbcode\22e83ae67b4bf3f7\eden\scm\saplingnative\bindings\modules\pyrevisionstore\__pyrevisionstore__\rlib-pic-static_pic-metadata-fast-diag\libpyrevisionstore-51bbe2c5.rmeta) ``` I tried `buck2 build fbcode//mode/opt-win fbcode//eden/scm/saplingnative/bindings/modules/pyrevisionstore:pyrevisionstore` from a devserver in order to reproduce, and while it did reproduce the exact platform hash that CI was also trying to build (`cfg:opt-windows-x86_64-msvc-clang17-no-san#22e83ae67b4bf3f7`), it did not reproduce the failure. I tried rebasing the diff and CI hit the same failure again in the same target, so it does not seem like one-off corruption. I checked the CAS action and everything seems to be in order; it **does** contain the file `buck-out/v2/gen/fbcode/22e83ae67b4bf3f7/eden/scm/saplingnative/bindings/modules/pyrevisionstore/__pyrevisionstore__/rlib-pic-static_pic-metadata-fast-diag/libpyrevisionstore-51bbe2c5.rmeta` that the last line of the failure says is missing. I can't see anything wrong except the filepaths being relatively long. This diff tries abbreviating filepaths to try to create more headroom on Windows systems running with a short filepath length limit. Reviewed By: JakobDegen Differential Revision: D73722362 fbshipit-source-id: d3d08b0ccbfbf6e7ee3edf555f68e4de3fc2473a
1 parent be3b43a commit 46fceb9

File tree

1 file changed

+82
-10
lines changed

1 file changed

+82
-10
lines changed

prelude/rust/build.bzl

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ load(
5757
"Emit",
5858
"MetadataKind",
5959
"ProfileMode", # @unused Used as a type
60+
"RelocModel",
6061
"crate_type_codegen",
6162
"crate_type_linked",
6263
"dep_metadata_of_emit",
@@ -910,6 +911,77 @@ def _rustc_flags(flags: list[[str, ResolvedStringWithMacros, Artifact]]) -> list
910911

911912
return flags
912913

914+
# Differently parameterized build outputs need to be assigned nonoverlapping
915+
# output paths. For example the pic and non-pic rlib cannot both be written to
916+
# libfoo.rlib. We place artifacts into a unique subdirectory for each
917+
# permutation of build parameters.
918+
#
919+
# Keep this short or it exacerbates filepath length limits on Windows.
920+
#
921+
# Common examples:
922+
# rlib pic static_pic metadata-fast diag => "LPPMD"
923+
# bin pic shared link => "XPHL"
924+
def _abbreviated_subdir(
925+
crate_type: CrateType,
926+
reloc_model: RelocModel,
927+
dep_link_strategy: LinkStrategy,
928+
emit: Emit,
929+
is_rustdoc_test: bool,
930+
infallible_diagnostics: bool,
931+
incremental_enabled: bool,
932+
profile_mode: ProfileMode | None) -> str:
933+
crate_type = {
934+
CrateType("bin"): "X", # mnemonic: "eXecutable"
935+
CrateType("rlib"): "L", # "Library"
936+
CrateType("dylib"): "D",
937+
CrateType("proc-macro"): "M", # "Macro"
938+
CrateType("cdylib"): "C",
939+
CrateType("staticlib"): "S",
940+
}[crate_type]
941+
942+
reloc_model = {
943+
RelocModel("static"): "S",
944+
RelocModel("pic"): "P",
945+
RelocModel("dynamic-no-pic"): "N",
946+
RelocModel("ropi"): "O",
947+
RelocModel("rwpi"): "W",
948+
RelocModel("ropi-rwpi"): "R",
949+
RelocModel("default"): "D",
950+
}[reloc_model]
951+
952+
dep_link_strategy = {
953+
LinkStrategy("static"): "T",
954+
LinkStrategy("static_pic"): "P",
955+
LinkStrategy("shared"): "H",
956+
}[dep_link_strategy]
957+
958+
emit = {
959+
Emit("asm"): "s",
960+
Emit("llvm-bc"): "b",
961+
Emit("llvm-ir"): "i",
962+
Emit("llvm-ir-noopt"): "n",
963+
Emit("obj"): "o",
964+
Emit("link"): "L",
965+
Emit("dep-info"): "d",
966+
Emit("mir"): "m",
967+
Emit("expand"): "e",
968+
Emit("clippy"): "c",
969+
Emit("metadata-full"): "F", # "Full metadata"
970+
Emit("metadata-fast"): "M", # "Metadata"
971+
}[emit]
972+
973+
profile_mode = {
974+
None: "",
975+
ProfileMode("llvm-time-trace"): "L",
976+
ProfileMode("self-profile"): "P",
977+
}[profile_mode]
978+
979+
return crate_type + reloc_model + dep_link_strategy + emit + \
980+
("T" if is_rustdoc_test else "") + \
981+
("D" if infallible_diagnostics else "") + \
982+
("I" if incremental_enabled else "") + \
983+
profile_mode
984+
913985
# Compute which are common to both rustc and rustdoc
914986
def _compute_common_args(
915987
ctx: AnalysisContext,
@@ -931,16 +1003,16 @@ def _compute_common_args(
9311003
if args_key in compile_ctx.common_args:
9321004
return compile_ctx.common_args[args_key]
9331005

934-
# Keep filenames distinct in per-flavour subdirs
935-
subdir = "{}-{}-{}-{}".format(crate_type.value, params.reloc_model.value, params.dep_link_strategy.value, emit.value)
936-
if is_rustdoc_test:
937-
subdir = "{}-rustdoc-test".format(subdir)
938-
if infallible_diagnostics:
939-
subdir = "{}-diag".format(subdir)
940-
if incremental_enabled:
941-
subdir = "{}-incr".format(subdir)
942-
if profile_mode:
943-
subdir = "{}-prof-{}".format(subdir, profile_mode.value)
1006+
subdir = _abbreviated_subdir(
1007+
crate_type = crate_type,
1008+
reloc_model = params.reloc_model,
1009+
dep_link_strategy = params.dep_link_strategy,
1010+
emit = emit,
1011+
is_rustdoc_test = is_rustdoc_test,
1012+
infallible_diagnostics = infallible_diagnostics,
1013+
incremental_enabled = incremental_enabled,
1014+
profile_mode = profile_mode,
1015+
)
9441016

9451017
# Included in tempfiles
9461018
tempfile = "{}-{}".format(attr_simple_crate_for_filenames(ctx), emit.value)

0 commit comments

Comments
 (0)