Use musl rust prebuilts for USE_HOST_MUSL=true
Building rust code with musl enabled can load proc macro crates built against musl into rustc, so we have to use a version of rustc also built against musl. Bug: 216192129 Test: m USE_HOST_MUSL=true host-native Change-Id: Icd23b542a4b64a975850a8a4bb4b69183cc6c2c6
This commit is contained in:
parent
39a1814f24
commit
567d342ed8
3 changed files with 25 additions and 4 deletions
|
@ -41,10 +41,25 @@ var (
|
||||||
|
|
||||||
//TODO(b/160803703) Use a prebuilt bindgen instead of the built bindgen.
|
//TODO(b/160803703) Use a prebuilt bindgen instead of the built bindgen.
|
||||||
_ = pctx.HostBinToolVariable("bindgenCmd", "bindgen")
|
_ = pctx.HostBinToolVariable("bindgenCmd", "bindgen")
|
||||||
|
_ = pctx.VariableFunc("bindgenHostPrebuiltTag", func(ctx android.PackageVarContext) string {
|
||||||
|
if ctx.Config().UseHostMusl() {
|
||||||
|
// This is a hack to use the glibc bindgen binary until we have a musl version checked in.
|
||||||
|
return "linux-x86"
|
||||||
|
} else {
|
||||||
|
return "${config.HostPrebuiltTag}"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
_ = pctx.VariableFunc("bindgenClangLibdir", func(ctx android.PackageVarContext) string {
|
||||||
|
if ctx.Config().UseHostMusl() {
|
||||||
|
return "musl/lib64/"
|
||||||
|
} else {
|
||||||
|
return "lib64/"
|
||||||
|
}
|
||||||
|
})
|
||||||
_ = pctx.SourcePathVariable("bindgenClang",
|
_ = pctx.SourcePathVariable("bindgenClang",
|
||||||
"${cc_config.ClangBase}/${config.HostPrebuiltTag}/${bindgenClangVersion}/bin/clang")
|
"${cc_config.ClangBase}/${bindgenHostPrebuiltTag}/${bindgenClangVersion}/bin/clang")
|
||||||
_ = pctx.SourcePathVariable("bindgenLibClang",
|
_ = pctx.SourcePathVariable("bindgenLibClang",
|
||||||
"${cc_config.ClangBase}/${config.HostPrebuiltTag}/${bindgenClangVersion}/lib64/")
|
"${cc_config.ClangBase}/${bindgenHostPrebuiltTag}/${bindgenClangVersion}/${bindgenClangLibdir}")
|
||||||
|
|
||||||
//TODO(ivanlozano) Switch this to RuleBuilder
|
//TODO(ivanlozano) Switch this to RuleBuilder
|
||||||
bindgen = pctx.AndroidStaticRule("bindgen",
|
bindgen = pctx.AndroidStaticRule("bindgen",
|
||||||
|
|
|
@ -372,7 +372,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
||||||
if !Bool(compiler.Properties.No_stdlibs) {
|
if !Bool(compiler.Properties.No_stdlibs) {
|
||||||
for _, stdlib := range config.Stdlibs {
|
for _, stdlib := range config.Stdlibs {
|
||||||
// If we're building for the build host, use the prebuilt stdlibs
|
// If we're building for the build host, use the prebuilt stdlibs
|
||||||
if ctx.Target().Os == android.Linux || ctx.Target().Os == android.Darwin {
|
if ctx.Host() && !ctx.Target().HostCross {
|
||||||
stdlib = "prebuilt_" + stdlib
|
stdlib = "prebuilt_" + stdlib
|
||||||
}
|
}
|
||||||
deps.Stdlibs = append(deps.Stdlibs, stdlib)
|
deps.Stdlibs = append(deps.Stdlibs, stdlib)
|
||||||
|
|
|
@ -78,7 +78,13 @@ var (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pctx.SourcePathVariable("RustDefaultBase", RustDefaultBase)
|
pctx.SourcePathVariable("RustDefaultBase", RustDefaultBase)
|
||||||
pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS)
|
pctx.VariableConfigMethod("HostPrebuiltTag", func(config android.Config) string {
|
||||||
|
if config.UseHostMusl() {
|
||||||
|
return "linux-musl-x86"
|
||||||
|
} else {
|
||||||
|
return config.PrebuiltOS()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
pctx.VariableFunc("RustBase", func(ctx android.PackageVarContext) string {
|
pctx.VariableFunc("RustBase", func(ctx android.PackageVarContext) string {
|
||||||
if override := ctx.Config().Getenv("RUST_PREBUILTS_BASE"); override != "" {
|
if override := ctx.Config().Getenv("RUST_PREBUILTS_BASE"); override != "" {
|
||||||
|
|
Loading…
Reference in a new issue