diff options
author | 2024-11-20 22:18:11 +0000 | |
---|---|---|
committer | 2024-12-13 18:12:57 +0000 | |
commit | f4589017b4bf593c73741deeeaff1831882f9f29 (patch) | |
tree | 62fb64dbf1b5a3a95002f7a9208eca95185e0477 /rust/builder.go | |
parent | f7bbd2fe40e43f7fda7e08d08eeb9c2a93552ad9 (diff) |
rust: Add version scripts and symbol exports
This allows Rust modules to define a version_script for shared library
variants.
This requires using a wrapper for the linker (clang++) to intercept
the flags which rustc emits.
This also adds the ability to export additional symbols in addition
to those exported by rustc by default, e.g. whole_static_library
symbols.
Bug: 314309643
Test: New Soong tests pass.
Test: m
Test: m <simple version script module>
Test: m <simple extra symbols module>
Change-Id: I93c9552e5e1181df4663d194c4df4b7053553dd4
Diffstat (limited to 'rust/builder.go')
-rw-r--r-- | rust/builder.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/rust/builder.go b/rust/builder.go index a1e17fc3f..e5434efee 100644 --- a/rust/builder.go +++ b/rust/builder.go @@ -30,11 +30,11 @@ var ( rustc = pctx.AndroidStaticRule("rustc", blueprint.RuleParams{ Command: "$envVars $rustcCmd " + - "-C linker=${config.RustLinker} " + - "-C link-args=\"${crtBegin} ${earlyLinkFlags} ${linkFlags} ${crtEnd}\" " + + "-C linker=${RustcLinkerCmd} " + + "-C link-args=\"--android-clang-bin=${config.ClangCmd} ${crtBegin} ${earlyLinkFlags} ${linkFlags} ${crtEnd}\" " + "--emit link -o $out --emit dep-info=$out.d.raw $in ${libFlags} $rustcFlags" + " && grep ^$out: $out.d.raw > $out.d", - CommandDeps: []string{"$rustcCmd"}, + CommandDeps: []string{"$rustcCmd", "${RustcLinkerCmd}", "${config.ClangCmd}"}, // Rustc deps-info writes out make compatible dep files: https://github.com/rust-lang/rust/issues/7633 // Rustc emits unneeded dependency lines for the .d and input .rs files. // Those extra lines cause ninja warning: @@ -102,10 +102,10 @@ var ( `KYTHE_CANONICALIZE_VNAME_PATHS=prefer-relative ` + `$rustExtractor $envVars ` + `$rustcCmd ` + - `-C linker=${config.RustLinker} ` + - `-C link-args="${crtBegin} ${linkFlags} ${crtEnd}" ` + + `-C linker=${RustcLinkerCmd} ` + + `-C link-args="--android-clang-bin=${config.ClangCmd} ${crtBegin} ${linkFlags} ${crtEnd}" ` + `$in ${libFlags} $rustcFlags`, - CommandDeps: []string{"$rustExtractor", "$kytheVnames"}, + CommandDeps: []string{"$rustExtractor", "$kytheVnames", "${RustcLinkerCmd}", "${config.ClangCmd}"}, Rspfile: "${out}.rsp", RspfileContent: "$in", }, @@ -119,6 +119,7 @@ type buildOutput struct { func init() { pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") + pctx.HostBinToolVariable("RustcLinkerCmd", "rustc_linker") cc.TransformRlibstoStaticlib = TransformRlibstoStaticlib } @@ -411,6 +412,7 @@ func transformSrctoCrate(ctx android.ModuleContext, main android.Path, deps Path implicits = append(implicits, deps.SharedLibDeps...) implicits = append(implicits, deps.srcProviderFiles...) implicits = append(implicits, deps.AfdoProfiles...) + implicits = append(implicits, deps.LinkerDeps...) implicits = append(implicits, deps.CrtBegin...) implicits = append(implicits, deps.CrtEnd...) |