diff options
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/binary.go | 2 | ||||
| -rw-r--r-- | rust/bindgen.go | 8 | ||||
| -rw-r--r-- | rust/compiler.go | 2 | ||||
| -rw-r--r-- | rust/config/Android.bp | 1 | ||||
| -rw-r--r-- | rust/config/global.go | 2 | ||||
| -rw-r--r-- | rust/config/riscv64_device.go | 91 | ||||
| -rw-r--r-- | rust/fuzz.go | 15 | ||||
| -rw-r--r-- | rust/rust.go | 6 | ||||
| -rw-r--r-- | rust/sanitize.go | 14 |
9 files changed, 120 insertions, 21 deletions
diff --git a/rust/binary.go b/rust/binary.go index 41110f92f..056888ef2 100644 --- a/rust/binary.go +++ b/rust/binary.go @@ -106,7 +106,7 @@ func (binary *binaryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps { if static { deps.CrtBegin = []string{"libc_musl_crtbegin_static"} } else { - deps.CrtBegin = []string{"libc_musl_crtbegin_dynamic", "musl_linker_script"} + deps.CrtBegin = []string{"libc_musl_crtbegin_dynamic"} } deps.CrtEnd = []string{"libc_musl_crtend"} } diff --git a/rust/bindgen.go b/rust/bindgen.go index 0199d3a37..17d80ddee 100644 --- a/rust/bindgen.go +++ b/rust/bindgen.go @@ -30,7 +30,7 @@ var ( defaultBindgenFlags = []string{""} // bindgen should specify its own Clang revision so updating Clang isn't potentially blocked on bindgen failures. - bindgenClangVersion = "clang-r450784d" + bindgenClangVersion = "clang-r468909b" _ = pctx.VariableFunc("bindgenClangVersion", func(ctx android.PackageVarContext) string { if override := ctx.Config().Getenv("LLVM_BINDGEN_PREBUILTS_VERSION"); override != "" { @@ -51,7 +51,7 @@ var ( }) _ = pctx.VariableFunc("bindgenClangLibdir", func(ctx android.PackageVarContext) string { if ctx.Config().UseHostMusl() { - return "musl/lib64/" + return "musl/lib/" } else { return "lib64/" } @@ -239,6 +239,10 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr cflags = append(cflags, "-x c") } + // clang-r468909b complains about the -x c in the flags in clang-sys parse_search_paths: + // clang: error: '-x c' after last input file has no effect [-Werror,-Wunused-command-line-argument] + cflags = append(cflags, "-Wno-unused-command-line-argument") + // LLVM_NEXT may contain flags that bindgen doesn't recognise. Turn off unknown flags warning. if ctx.Config().IsEnvTrue("LLVM_NEXT") { cflags = append(cflags, "-Wno-unknown-warning-option") diff --git a/rust/compiler.go b/rust/compiler.go index bf6a48844..6055158ec 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -161,7 +161,7 @@ type BaseCompilerProperties struct { // This is primarily meant for rust_binary and rust_ffi modules where the default // linkage of libstd might need to be overridden in some use cases. This should // generally be avoided with other module types since it may cause collisions at - // linkage if all dependencies of the root binary module do not link against libstd\ + // linkage if all dependencies of the root binary module do not link against libstd // the same way. Prefer_rlib *bool `android:"arch_variant"` diff --git a/rust/config/Android.bp b/rust/config/Android.bp index be73d69eb..79ea7a174 100644 --- a/rust/config/Android.bp +++ b/rust/config/Android.bp @@ -15,6 +15,7 @@ bootstrap_go_package { "arm64_device.go", "global.go", "lints.go", + "riscv64_device.go", "toolchain.go", "darwin_host.go", "x86_linux_bionic_host.go", diff --git a/rust/config/global.go b/rust/config/global.go index e67683786..81aec7e73 100644 --- a/rust/config/global.go +++ b/rust/config/global.go @@ -24,7 +24,7 @@ import ( var pctx = android.NewPackageContext("android/soong/rust/config") var ( - RustDefaultVersion = "1.63.0" + RustDefaultVersion = "1.64.0" RustDefaultBase = "prebuilts/rust/" DefaultEdition = "2021" Stdlibs = []string{ diff --git a/rust/config/riscv64_device.go b/rust/config/riscv64_device.go new file mode 100644 index 000000000..d014dbf8b --- /dev/null +++ b/rust/config/riscv64_device.go @@ -0,0 +1,91 @@ +// Copyright 2022 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config + +import ( + "strings" + + "android/soong/android" +) + +var ( + Riscv64RustFlags = []string{} + Riscv64ArchFeatureRustFlags = map[string][]string{"": {}} + Riscv64LinkFlags = []string{} + + Riscv64ArchVariantRustFlags = map[string][]string{"": {}} +) + +func init() { + registerToolchainFactory(android.Android, android.Riscv64, Riscv64ToolchainFactory) + + pctx.StaticVariable("Riscv64ToolchainRustFlags", strings.Join(Riscv64RustFlags, " ")) + pctx.StaticVariable("Riscv64ToolchainLinkFlags", strings.Join(Riscv64LinkFlags, " ")) + + for variant, rustFlags := range Riscv64ArchVariantRustFlags { + pctx.StaticVariable("Riscv64"+variant+"VariantRustFlags", + strings.Join(rustFlags, " ")) + } + +} + +type toolchainRiscv64 struct { + toolchain64Bit + toolchainRustFlags string +} + +func (t *toolchainRiscv64) RustTriple() string { + return "riscv64-linux-android" +} + +func (t *toolchainRiscv64) ToolchainLinkFlags() string { + // Prepend the lld flags from cc_config so we stay in sync with cc + return "${config.DeviceGlobalLinkFlags} ${cc_config.Riscv64Lldflags} ${config.Riscv64ToolchainLinkFlags}" +} + +func (t *toolchainRiscv64) ToolchainRustFlags() string { + return t.toolchainRustFlags +} + +func (t *toolchainRiscv64) RustFlags() string { + return "${config.Riscv64ToolchainRustFlags}" +} + +func (t *toolchainRiscv64) Supported() bool { + return true +} + +func (toolchainRiscv64) LibclangRuntimeLibraryArch() string { + return "riscv64" +} + +func Riscv64ToolchainFactory(arch android.Arch) Toolchain { + archVariant := arch.ArchVariant + + toolchainRustFlags := []string{ + "${config.Riscv64ToolchainRustFlags}", + "${config.Riscv64" + archVariant + "VariantRustFlags}", + } + + toolchainRustFlags = append(toolchainRustFlags, deviceGlobalRustFlags...) + + for _, feature := range arch.ArchFeatures { + toolchainRustFlags = append(toolchainRustFlags, Riscv64ArchFeatureRustFlags[feature]...) + } + + return &toolchainRiscv64{ + toolchainRustFlags: strings.Join(toolchainRustFlags, " "), + } +} diff --git a/rust/fuzz.go b/rust/fuzz.go index 586095c49..6faf55cf6 100644 --- a/rust/fuzz.go +++ b/rust/fuzz.go @@ -34,6 +34,7 @@ type fuzzDecorator struct { *binaryDecorator fuzzPackagedModule fuzz.FuzzPackagedModule + sharedLibraries android.Paths } var _ compiler = (*fuzzDecorator)(nil) @@ -86,6 +87,15 @@ func (fuzzer *fuzzDecorator) compilerProps() []interface{} { &fuzzer.fuzzPackagedModule.FuzzProperties) } +func (fuzzer *fuzzDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) buildOutput { + out := fuzzer.binaryDecorator.compile(ctx, flags, deps) + + // Grab the list of required shared libraries. + fuzzer.sharedLibraries, _ = cc.CollectAllSharedDependencies(ctx) + + return out +} + func (fuzzer *fuzzDecorator) stdLinkage(ctx *depsContext) RustLinkage { return RlibLinkage } @@ -149,11 +159,8 @@ func (s *rustFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) { // The executable. files = append(files, fuzz.FileToZip{rustModule.UnstrippedOutputFile(), ""}) - // Grab the list of required shared libraries. - sharedLibraries := fuzz.CollectAllSharedDependencies(ctx, module, cc.UnstrippedOutputFile, cc.IsValidSharedDependency) - // Package shared libraries - files = append(files, cc.GetSharedLibsToZip(sharedLibraries, rustModule, &s.FuzzPackager, archString, "lib", &sharedLibraryInstalled)...) + files = append(files, cc.GetSharedLibsToZip(fuzzModule.sharedLibraries, rustModule, &s.FuzzPackager, archString, "lib", &sharedLibraryInstalled)...) archDirs[archOs], ok = s.BuildZipFile(ctx, module, fuzzModule.fuzzPackagedModule, files, builder, archDir, archString, hostOrTargetString, archOs, archDirs) if !ok { diff --git a/rust/rust.go b/rust/rust.go index 1517e6263..28a300bc6 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -1615,7 +1615,7 @@ func (mod *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Mo } } - if depTag == procMacroDepTag { + if depTag == procMacroDepTag || depTag == customBindgenDepTag { return false } @@ -1664,6 +1664,10 @@ func (k kytheExtractRustSingleton) GenerateBuildActions(ctx android.SingletonCon } } +func (c *Module) Partition() string { + return "" +} + var Bool = proptools.Bool var BoolDefault = proptools.BoolDefault var String = proptools.String diff --git a/rust/sanitize.go b/rust/sanitize.go index a3c5cb583..c68137ecd 100644 --- a/rust/sanitize.go +++ b/rust/sanitize.go @@ -189,16 +189,6 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { } } - // TODO:(b/178369775) - // For now sanitizing is only supported on devices - if ctx.Os() == android.Android && Bool(s.Fuzzer) { - sanitize.Properties.SanitizerEnabled = true - } - - if ctx.Os() == android.Android && Bool(s.Address) { - sanitize.Properties.SanitizerEnabled = true - } - // HWASan requires AArch64 hardware feature (top-byte-ignore). if ctx.Arch().ArchType != android.Arm64 || !ctx.Os().Bionic() { s.Hwaddress = nil @@ -219,7 +209,9 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { s.Memtag_heap = nil } - if ctx.Os() == android.Android && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap)) { + // TODO:(b/178369775) + // For now sanitizing is only supported on devices + if ctx.Os() == android.Android && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap) || Bool(s.Fuzzer)) { sanitize.Properties.SanitizerEnabled = true } } |