From e32f09312019d7dea38b058cbc23dd0ea1186cf8 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Sun, 23 Jan 2022 20:48:36 -0800 Subject: Support building rust modules against musl libc Add a rust toolchain for musl libc, use std library built from source, and add default dependencies on musl libc. Bug: 216192129 Test: m USE_HOST_MUSL=true host-native Change-Id: Ic5ff4487db9693aeb08a13405f4d18465eecdc4b --- rust/compiler.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'rust/compiler.go') diff --git a/rust/compiler.go b/rust/compiler.go index 3040e5d9e..c5d40f4dc 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -364,7 +364,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps { if !Bool(compiler.Properties.No_stdlibs) { for _, stdlib := range config.Stdlibs { // If we're building for the build host, use the prebuilt stdlibs - if ctx.Target().Os == ctx.Config().BuildOS { + if ctx.Target().Os == android.Linux || ctx.Target().Os == android.Darwin { stdlib = "prebuilt_" + stdlib } deps.Stdlibs = append(deps.Stdlibs, stdlib) @@ -394,6 +394,20 @@ func bionicDeps(ctx DepsContext, deps Deps, static bool) Deps { return deps } +func muslDeps(ctx DepsContext, deps Deps, static bool) Deps { + muslLibs := []string{"libc_musl"} + if static { + deps.StaticLibs = append(deps.StaticLibs, muslLibs...) + } else { + deps.SharedLibs = append(deps.SharedLibs, muslLibs...) + } + if libRuntimeBuiltins := config.BuiltinsRuntimeLibrary(ctx.toolchain()); libRuntimeBuiltins != "" { + deps.StaticLibs = append(deps.StaticLibs, libRuntimeBuiltins) + } + + return deps +} + func (compiler *baseCompiler) crateName() string { return compiler.Properties.Crate_name } -- cgit v1.2.3-59-g8ed1b