summaryrefslogtreecommitdiff
path: root/rust/compiler.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2022-01-23 20:48:36 -0800
committer Colin Cross <ccross@android.com> 2022-01-24 17:33:05 -0800
commite32f09312019d7dea38b058cbc23dd0ea1186cf8 (patch)
treedf53ac616af099fe87d36d29a8364aa9db799775 /rust/compiler.go
parent018cbebd7149afb14a60e84e4fd9c53ff63cd676 (diff)
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
Diffstat (limited to 'rust/compiler.go')
-rw-r--r--rust/compiler.go16
1 files changed, 15 insertions, 1 deletions
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
}