aboutsummaryrefslogtreecommitdiffstats
path: root/rust/compiler.go
diff options
context:
space:
mode:
authorJeffrey Vander Stoep <jeffv@google.com>2019-11-14 18:28:13 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-11-14 18:28:13 +0000
commitf3a2d5abc3b3106a73eb48dc865b5855cb33db42 (patch)
tree894aa3eb10290a15346dd47e67f2be388a395e62 /rust/compiler.go
parent263dcb7397844bd6d4005b8aaffbb01120da85d0 (diff)
parent51feafad57da137b3476de84e8e9fd8fd3732cb4 (diff)
downloadbuild_soong-f3a2d5abc3b3106a73eb48dc865b5855cb33db42.tar.gz
build_soong-f3a2d5abc3b3106a73eb48dc865b5855cb33db42.tar.bz2
build_soong-f3a2d5abc3b3106a73eb48dc865b5855cb33db42.zip
Merge changes from topic "rust-sysroot"
* changes: Enable x86_64 device support Build Rust Device Sysroots in Soong
Diffstat (limited to 'rust/compiler.go')
-rw-r--r--rust/compiler.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/rust/compiler.go b/rust/compiler.go
index 85e8ba6a..88e3fb2c 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -32,6 +32,10 @@ func getDenyWarnings(compiler *baseCompiler) bool {
return BoolDefault(compiler.Properties.Deny_warnings, config.DefaultDenyWarnings)
}
+func (compiler *baseCompiler) setNoStdlibs() {
+ compiler.Properties.No_stdlibs = proptools.BoolPtr(true)
+}
+
func NewBaseCompiler(dir, dir64 string) *baseCompiler {
return &baseCompiler{
Properties: BaseCompilerProperties{},
@@ -82,6 +86,9 @@ type BaseCompilerProperties struct {
// install to a subdirectory of the default install path for the module
Relative_install_path *string `android:"arch_variant"`
+
+ // whether to suppress inclusion of standard crates - defaults to false
+ No_stdlibs *bool
}
type baseCompiler struct {
@@ -161,6 +168,23 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps.StaticLibs = append(deps.StaticLibs, compiler.Properties.Static_libs...)
deps.SharedLibs = append(deps.SharedLibs, compiler.Properties.Shared_libs...)
+ if !Bool(compiler.Properties.No_stdlibs) {
+ for _, stdlib := range config.Stdlibs {
+ // If we're building for host, use the compiler's stdlibs
+ if ctx.Host() {
+ stdlib = stdlib + "_" + ctx.toolchain().RustTriple()
+ }
+
+ // This check is technically insufficient - on the host, where
+ // static linking is the default, if one of our static
+ // dependencies uses a dynamic library, we need to dynamically
+ // link the stdlib as well.
+ if (len(deps.Dylibs) > 0) || (!ctx.Host()) {
+ // Dynamically linked stdlib
+ deps.Dylibs = append(deps.Dylibs, stdlib)
+ }
+ }
+ }
return deps
}