From 0dcd62e8a0a8f6a2028142584aa46bc736114518 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 31 Mar 2023 23:05:16 -0700 Subject: [PATCH] Set OUT_DIR=out with no src_deps. Some Rust crates with no src_deps have generated files checked in in an "out" subdirectory and included via a reference to $OUT_DIR, such as external/rust/crates/userfaultfd-sys. Astonishingly, some people must be leaving $OUT_DIR set to the default value of "out", because with $OUT_DIR set to this value, building these crates would presumably succeed. For everyone else, the build fails when building one of these crates because it will attempt to load from the wrong directory. Presumably these crates should be using src_deps instead (and once that's fixed, we should probably *unset* $OUT_DIR in rustc invocations to prevent the same thing from happening again), but for now, fix the build with non-default OUT_DIR by explicitly setting OUT_DIR to "out" if there are no src_deps. Change-Id: I09f99424fc01a1e42e910622c77ab8f7312819bd --- rust/builder.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust/builder.go b/rust/builder.go index 4b20e2b9a..180abf682 100644 --- a/rust/builder.go +++ b/rust/builder.go @@ -208,6 +208,9 @@ func rustEnvVars(ctx ModuleContext, deps PathDeps) []string { outDirPrefix = "" } envVars = append(envVars, "OUT_DIR="+filepath.Join(outDirPrefix, moduleGenDir.String())) + } else { + // TODO(pcc): Change this to "OUT_DIR=" after fixing crates to not rely on this value. + envVars = append(envVars, "OUT_DIR=out") } return envVars