Merge changes I620cfd7b,I8ed1919a into main
* changes: remove rust deps on clang prebuilts rustSetToolchainSource to use linux-x86 srcs
This commit is contained in:
commit
eba2a2af22
4 changed files with 31 additions and 44 deletions
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
cc_config "android/soong/cc/config"
|
||||||
"android/soong/rust/config"
|
"android/soong/rust/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -204,7 +205,9 @@ func rustEnvVars(ctx ModuleContext, deps PathDeps, cmd *android.RuleBuilderComma
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
envVars = append(envVars, "AR="+cmd.PathForTool(deps.Llvm_ar))
|
envVars = append(envVars, "AR="+cmd.PathForInput(
|
||||||
|
cc_config.ClangPath(ctx, "bin/llvm-ar")),
|
||||||
|
)
|
||||||
|
|
||||||
if ctx.Darwin() {
|
if ctx.Darwin() {
|
||||||
envVars = append(envVars, "ANDROID_RUST_DARWIN=true")
|
envVars = append(envVars, "ANDROID_RUST_DARWIN=true")
|
||||||
|
@ -292,11 +295,6 @@ func transformSrctoCrate(ctx ModuleContext, comp compiler, main android.Path, de
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.Clippy {
|
if flags.Clippy {
|
||||||
// TODO(b/298461712) remove this hack to let slim manifest branches build
|
|
||||||
if deps.Clippy_driver == nil {
|
|
||||||
deps.Clippy_driver = config.RustPath(ctx, "bin/clippy-driver")
|
|
||||||
}
|
|
||||||
|
|
||||||
clippyRule := getRuleBuilder(ctx, pctx, false, "clippy")
|
clippyRule := getRuleBuilder(ctx, pctx, false, "clippy")
|
||||||
clippyCmd := clippyRule.Command()
|
clippyCmd := clippyRule.Command()
|
||||||
clippyFile := android.PathForModuleOut(ctx, outputFile.Base()+".clippy")
|
clippyFile := android.PathForModuleOut(ctx, outputFile.Base()+".clippy")
|
||||||
|
@ -305,7 +303,7 @@ func transformSrctoCrate(ctx ModuleContext, comp compiler, main android.Path, de
|
||||||
|
|
||||||
clippyCmd.
|
clippyCmd.
|
||||||
Flags(rustEnvVars(ctx, deps, clippyCmd)).
|
Flags(rustEnvVars(ctx, deps, clippyCmd)).
|
||||||
Tool(deps.Clippy_driver).
|
Tool(config.RustPath(ctx, "bin/clippy-driver")).
|
||||||
Flag("--emit metadata").
|
Flag("--emit metadata").
|
||||||
FlagWithOutput("-o ", clippyFile).
|
FlagWithOutput("-o ", clippyFile).
|
||||||
FlagWithOutput("--emit dep-info=", clippyDepInfoFile).
|
FlagWithOutput("--emit dep-info=", clippyDepInfoFile).
|
||||||
|
@ -365,14 +363,18 @@ func transformSrctoCrate(ctx ModuleContext, comp compiler, main android.Path, de
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/298461712) remove this hack to let slim manifest branches build
|
clangTools := android.Paths{
|
||||||
if deps.Rustc == nil {
|
cc_config.ClangPath(ctx, "bin/llvm-ar"),
|
||||||
deps.Rustc = config.RustPath(ctx, "bin/rustc")
|
}
|
||||||
|
if ctx.Config().BuildOS != android.Darwin {
|
||||||
|
clangTools = append(clangTools,
|
||||||
|
cc_config.ClangPath(ctx, "lib/libc++.so"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
rustcCmd.
|
rustcCmd.
|
||||||
Flags(rustEnvVars(ctx, deps, rustcCmd)).
|
Flags(rustEnvVars(ctx, deps, rustcCmd)).
|
||||||
Tool(deps.Rustc).
|
Tool(config.RustPath(ctx, "bin/rustc")).
|
||||||
FlagWithInput("-C linker=", android.PathForSource(ctx, "build", "soong", "scripts", "mkcratersp.py")).
|
FlagWithInput("-C linker=", android.PathForSource(ctx, "build", "soong", "scripts", "mkcratersp.py")).
|
||||||
Flag("--emit link").
|
Flag("--emit link").
|
||||||
Flag("-o").
|
Flag("-o").
|
||||||
|
@ -380,6 +382,7 @@ func transformSrctoCrate(ctx ModuleContext, comp compiler, main android.Path, de
|
||||||
FlagWithOutput("--emit dep-info=", depInfoFile).
|
FlagWithOutput("--emit dep-info=", depInfoFile).
|
||||||
Inputs(inputs).
|
Inputs(inputs).
|
||||||
Flags(libFlags).
|
Flags(libFlags).
|
||||||
|
Implicits(clangTools).
|
||||||
ImplicitTools(toolImplicits).
|
ImplicitTools(toolImplicits).
|
||||||
Implicits(implicits).
|
Implicits(implicits).
|
||||||
Flags(rustcFlags).
|
Flags(rustcFlags).
|
||||||
|
@ -406,9 +409,20 @@ func transformSrctoCrate(ctx ModuleContext, comp compiler, main android.Path, de
|
||||||
// those need to be renamed/symlinked to something in the rustLink sandbox
|
// those need to be renamed/symlinked to something in the rustLink sandbox
|
||||||
// if we want to separate the rules
|
// if we want to separate the rules
|
||||||
linkerSboxOutputFile := android.PathForModuleOut(ctx, sboxDirectory, outputFile.Base())
|
linkerSboxOutputFile := android.PathForModuleOut(ctx, sboxDirectory, outputFile.Base())
|
||||||
|
clangTools := android.Paths{
|
||||||
|
cc_config.ClangPath(ctx, "bin/clang++"),
|
||||||
|
cc_config.ClangPath(ctx, "bin/lld"),
|
||||||
|
cc_config.ClangPath(ctx, "bin/ld.lld"),
|
||||||
|
}
|
||||||
|
if ctx.Config().BuildOS != android.Darwin {
|
||||||
|
clangTools = append(clangTools,
|
||||||
|
cc_config.ClangPath(ctx, "bin/clang++.real"),
|
||||||
|
cc_config.ClangPath(ctx, "lib/libc++.so"),
|
||||||
|
)
|
||||||
|
}
|
||||||
rustLinkCmd := rustcRule.Command()
|
rustLinkCmd := rustcRule.Command()
|
||||||
rustLinkCmd.
|
rustLinkCmd.
|
||||||
Tool(deps.Clang).
|
Tool(cc_config.ClangPath(ctx, "bin/clang++")).
|
||||||
Flag("-o").
|
Flag("-o").
|
||||||
Output(linkerSboxOutputFile).
|
Output(linkerSboxOutputFile).
|
||||||
Inputs(deps.CrtBegin).
|
Inputs(deps.CrtBegin).
|
||||||
|
@ -416,6 +430,7 @@ func transformSrctoCrate(ctx ModuleContext, comp compiler, main android.Path, de
|
||||||
FlagWithInput("@", rustSboxOutputFile).
|
FlagWithInput("@", rustSboxOutputFile).
|
||||||
Flags(linkFlags).
|
Flags(linkFlags).
|
||||||
Inputs(deps.CrtEnd).
|
Inputs(deps.CrtEnd).
|
||||||
|
ImplicitTools(clangTools).
|
||||||
ImplicitTools(toolImplicits).
|
ImplicitTools(toolImplicits).
|
||||||
Implicits(rustcImplicitOutputs.Paths()).
|
Implicits(rustcImplicitOutputs.Paths()).
|
||||||
Implicits(implicits).
|
Implicits(implicits).
|
||||||
|
@ -441,7 +456,7 @@ func transformSrctoCrate(ctx ModuleContext, comp compiler, main android.Path, de
|
||||||
Flag("KYTHE_CANONICALIZE_VNAME_PATHS=prefer-relative").
|
Flag("KYTHE_CANONICALIZE_VNAME_PATHS=prefer-relative").
|
||||||
Tool(ctx.Config().PrebuiltBuildTool(ctx, "rust_extractor")).
|
Tool(ctx.Config().PrebuiltBuildTool(ctx, "rust_extractor")).
|
||||||
Flags(rustEnvVars(ctx, deps, kytheCmd)).
|
Flags(rustEnvVars(ctx, deps, kytheCmd)).
|
||||||
Tool(deps.Rustc).
|
Tool(config.RustPath(ctx, "bin/rustc")).
|
||||||
Flag("-C linker=true").
|
Flag("-C linker=true").
|
||||||
Inputs(inputs).
|
Inputs(inputs).
|
||||||
Flags(makeLibFlags(deps, kytheCmd)).
|
Flags(makeLibFlags(deps, kytheCmd)).
|
||||||
|
@ -455,11 +470,6 @@ func transformSrctoCrate(ctx ModuleContext, comp compiler, main android.Path, de
|
||||||
}
|
}
|
||||||
|
|
||||||
func Rustdoc(ctx ModuleContext, main android.Path, deps PathDeps, flags Flags) android.ModuleOutPath {
|
func Rustdoc(ctx ModuleContext, main android.Path, deps PathDeps, flags Flags) android.ModuleOutPath {
|
||||||
// TODO(b/298461712) remove this hack to let slim manifest branches build
|
|
||||||
if deps.Rustdoc == nil {
|
|
||||||
deps.Rustdoc = config.RustPath(ctx, "bin/rustdoc")
|
|
||||||
}
|
|
||||||
|
|
||||||
rustdocRule := getRuleBuilder(ctx, pctx, false, "rustdoc")
|
rustdocRule := getRuleBuilder(ctx, pctx, false, "rustdoc")
|
||||||
rustdocCmd := rustdocRule.Command()
|
rustdocCmd := rustdocRule.Command()
|
||||||
|
|
||||||
|
@ -498,7 +508,7 @@ func Rustdoc(ctx ModuleContext, main android.Path, deps PathDeps, flags Flags) a
|
||||||
|
|
||||||
rustdocCmd.
|
rustdocCmd.
|
||||||
Flags(rustEnvVars(ctx, deps, rustdocCmd)).
|
Flags(rustEnvVars(ctx, deps, rustdocCmd)).
|
||||||
Tool(deps.Rustdoc).
|
Tool(config.RustPath(ctx, "bin/rustdoc")).
|
||||||
Flags(rustdocFlags).
|
Flags(rustdocFlags).
|
||||||
Input(main).
|
Input(main).
|
||||||
Flag("-o "+docDir.String()).
|
Flag("-o "+docDir.String()).
|
||||||
|
|
|
@ -147,6 +147,6 @@ func rustPath(ctx android.PathContext) android.SourcePath {
|
||||||
if override := ctx.Config().Getenv("RUST_DEFAULT_VERSION"); override != "" {
|
if override := ctx.Config().Getenv("RUST_DEFAULT_VERSION"); override != "" {
|
||||||
rustVersion = override
|
rustVersion = override
|
||||||
}
|
}
|
||||||
return android.PathForSource(ctx, rustBase, ctx.Config().PrebuiltOS(), rustVersion)
|
return android.PathForSource(ctx, rustBase, HostPrebuiltTag(ctx.Config()), rustVersion)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
23
rust/rust.go
23
rust/rust.go
|
@ -472,13 +472,6 @@ type PathDeps struct {
|
||||||
// Paths to generated source files
|
// Paths to generated source files
|
||||||
SrcDeps android.Paths
|
SrcDeps android.Paths
|
||||||
srcProviderFiles android.Paths
|
srcProviderFiles android.Paths
|
||||||
|
|
||||||
// Paths to specific build tools
|
|
||||||
Rustc android.Path
|
|
||||||
Clang android.Path
|
|
||||||
Llvm_ar android.Path
|
|
||||||
Clippy_driver android.Path
|
|
||||||
Rustdoc android.Path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RustLibraries []RustLibrary
|
type RustLibraries []RustLibrary
|
||||||
|
@ -1480,18 +1473,9 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
depPaths.BuildToolDeps = append(depPaths.BuildToolDeps, buildTool.Deps...)
|
depPaths.BuildToolDeps = append(depPaths.BuildToolDeps, buildTool.Deps...)
|
||||||
switch android.RemoveOptionalPrebuiltPrefix(dep.Name()) {
|
switch android.RemoveOptionalPrebuiltPrefix(dep.Name()) {
|
||||||
case "rustc":
|
case "rustc":
|
||||||
depPaths.Rustc = buildTool.Src
|
|
||||||
// rustc expects the standard cc toolchain libraries (libdl, libm, libc, etc.)
|
// rustc expects the standard cc toolchain libraries (libdl, libm, libc, etc.)
|
||||||
// not to be under the __SBOX_SANDBOX_DIR__/ directory
|
// not to be under the __SBOX_SANDBOX_DIR__/ directory
|
||||||
depPaths.BuildToolSrcDeps = append(depPaths.BuildToolSrcDeps, buildTool.Deps...)
|
depPaths.BuildToolSrcDeps = append(depPaths.BuildToolSrcDeps, buildTool.Deps...)
|
||||||
case "clang++":
|
|
||||||
depPaths.Clang = buildTool.Src
|
|
||||||
case "llvm-ar":
|
|
||||||
depPaths.Llvm_ar = buildTool.Src
|
|
||||||
case "clippy-driver":
|
|
||||||
depPaths.Clippy_driver = buildTool.Src
|
|
||||||
case "rustdoc":
|
|
||||||
depPaths.Rustdoc = buildTool.Src
|
|
||||||
}
|
}
|
||||||
case depTag == cc.CrtBeginDepTag:
|
case depTag == cc.CrtBeginDepTag:
|
||||||
depPaths.CrtBegin = append(depPaths.CrtBegin, android.OutputFileForModule(ctx, dep, ""))
|
depPaths.CrtBegin = append(depPaths.CrtBegin, android.OutputFileForModule(ctx, dep, ""))
|
||||||
|
@ -1612,13 +1596,6 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "rustc")
|
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "rustc")
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "clippy-driver")
|
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "rustdoc")
|
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "clang++")
|
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "clang++.real")
|
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "lld")
|
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "ld.lld")
|
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "llvm-ar")
|
|
||||||
|
|
||||||
// rlibs
|
// rlibs
|
||||||
rlibDepVariations = append(rlibDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: rlibVariation})
|
rlibDepVariations = append(rlibDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: rlibVariation})
|
||||||
|
|
|
@ -89,7 +89,7 @@ func initToolchainLibrary(module *Module, library *libraryDecorator) android.Mod
|
||||||
|
|
||||||
func rustSetToolchainSource(ctx android.LoadHookContext) {
|
func rustSetToolchainSource(ctx android.LoadHookContext) {
|
||||||
if toolchainLib, ok := ctx.Module().(*Module).compiler.(*toolchainLibraryDecorator); ok {
|
if toolchainLib, ok := ctx.Module().(*Module).compiler.(*toolchainLibraryDecorator); ok {
|
||||||
prefix := filepath.Join(config.HostPrebuiltTag(ctx.Config()), GetRustPrebuiltVersion(ctx))
|
prefix := filepath.Join("linux-x86", GetRustPrebuiltVersion(ctx))
|
||||||
versionedCrateRoot := path.Join(prefix, android.String(toolchainLib.Properties.Toolchain_crate_root))
|
versionedCrateRoot := path.Join(prefix, android.String(toolchainLib.Properties.Toolchain_crate_root))
|
||||||
versionedSrcs := make([]string, len(toolchainLib.Properties.Toolchain_srcs))
|
versionedSrcs := make([]string, len(toolchainLib.Properties.Toolchain_srcs))
|
||||||
for i, src := range toolchainLib.Properties.Toolchain_srcs {
|
for i, src := range toolchainLib.Properties.Toolchain_srcs {
|
||||||
|
|
Loading…
Reference in a new issue