rust: set STD_ENV_ARCH

In 1.47.0, std::env requires the STD_ENV_ARCH environment variable to be
set to the target architecture [1].

[1] 8e8939b804/library/std/src/env.rs (L866)

Bug: 171280890
Test: cd external/rust; mm
Change-Id: If4ddf4b9bad2a1a7518a358a5fb597170a97c67e
This commit is contained in:
Thiébaud Weksteen
2020-11-03 15:17:51 +01:00
parent 37f5a8fb86
commit 71512f3265
2 changed files with 17 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ import (
"android/soong/android"
"android/soong/cc"
"android/soong/rust/config"
)
var (
@@ -138,6 +139,13 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
crate_name := ctx.RustModule().CrateName()
targetTriple := ctx.toolchain().RustTriple()
// libstd requires a specific environment variable to be set. This is
// not officially documented and may be removed in the future. See
// https://github.com/rust-lang/rust/blob/master/library/std/src/env.rs#L866.
if crate_name == "std" {
envVars = append(envVars, "STD_ENV_ARCH="+config.StdEnvArch[ctx.RustModule().Arch().ArchType])
}
inputs = append(inputs, main)
// Collect rustc flags