diff --git a/rust/config/arm64_device.go b/rust/config/arm64_device.go index 564168b9e..6c021c7ae 100644 --- a/rust/config/arm64_device.go +++ b/rust/config/arm64_device.go @@ -54,6 +54,7 @@ func init() { strings.Join(rustFlags, " ")) } + ExportedVars.ExportStringListStaticVariable("DEVICE_ARM64_RUSTC_FLAGS", Arm64RustFlags) } type toolchainArm64 struct { diff --git a/rust/config/global.go b/rust/config/global.go index c37ac4e21..4397d585c 100644 --- a/rust/config/global.go +++ b/rust/config/global.go @@ -23,7 +23,7 @@ import ( var ( pctx = android.NewPackageContext("android/soong/rust/config") - exportedVars = android.NewExportedVariables(pctx) + ExportedVars = android.NewExportedVariables(pctx) RustDefaultVersion = "1.72.0" RustDefaultBase = "prebuilts/rust/" @@ -111,9 +111,17 @@ func init() { pctx.StaticVariable("DeviceGlobalLinkFlags", strings.Join(deviceGlobalLinkFlags, " ")) - exportedVars.ExportStringStaticVariable("RUST_DEFAULT_VERSION", RustDefaultVersion) - exportedVars.ExportStringListStaticVariable("GLOBAL_RUSTC_FLAGS", GlobalRustFlags) - exportedVars.ExportStringListStaticVariable("LINUX_HOST_GLOBAL_LINK_FLAGS", LinuxHostGlobalLinkFlags) + ExportedVars.ExportStringStaticVariable("RUST_DEFAULT_VERSION", RustDefaultVersion) + ExportedVars.ExportStringListStaticVariable("GLOBAL_RUSTC_FLAGS", GlobalRustFlags) + ExportedVars.ExportStringListStaticVariable("LINUX_HOST_GLOBAL_LINK_FLAGS", LinuxHostGlobalLinkFlags) + + ExportedVars.ExportStringListStaticVariable("DEVICE_GLOBAL_RUSTC_FLAGS", deviceGlobalRustFlags) + ExportedVars.ExportStringListStaticVariable("DEVICE_GLOBAL_LINK_FLAGS", + android.RemoveListFromList(deviceGlobalLinkFlags, []string{ + // The cc_config flags are retrieved from cc_toolchain by rust rules. + "${cc_config.DeviceGlobalLldflags}", + "-B${cc_config.ClangBin}", + })) } func HostPrebuiltTag(config android.Config) string { @@ -137,5 +145,5 @@ func GetRustVersion(ctx android.PathContext) string { // BazelRustToolchainVars returns a string with func BazelRustToolchainVars(config android.Config) string { - return android.BazelToolchainVars(config, exportedVars) + return android.BazelToolchainVars(config, ExportedVars) }