From b79fc584c7e6a9e60c9dac5dd01fab2e8523bcec Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Wed, 13 Jul 2022 14:50:33 +0800 Subject: [PATCH 1/2] Add extra cflags for LLVM_NEXT The staging compiler update sometimes needs additional cflags to build, but those flags may not be recognised by the current compiler. Add a new `llvmNextExtraCommonGlobalCflags` section and only append those flags when LLVM_NEXT is set. Test: LLVM_NEXT=true m Bug: 236798112 Change-Id: Icc4687950acd44798b2cf09131a425ddfd919214 --- cc/config/global.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cc/config/global.go b/cc/config/global.go index c5fde5560..69990896b 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -280,6 +280,11 @@ var ( "-Wno-string-concatenation", } + llvmNextExtraCommonGlobalCflags = []string{ + "-Wno-unqualified-std-cast-call", + "-Wno-deprecated-non-prototype", + } + IllegalFlags = []string{ "-w", } @@ -361,6 +366,11 @@ func init() { if ctx.Config().IsEnvTrue("USE_CCACHE") { flags = append(flags, "-Wno-unused-command-line-argument") } + + if ctx.Config().IsEnvTrue("LLVM_NEXT") { + flags = append(flags, llvmNextExtraCommonGlobalCflags...) + } + return strings.Join(flags, " ") }) From 4f664e91288790d4ae83836504bc8d1fb146199f Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Thu, 14 Jul 2022 20:36:15 +0800 Subject: [PATCH 2/2] [bindgen] Allow unrecognised -Wno-* flags on LLVM_NEXT Test: LLVM_NEXT=true m Bug: 236798112 Change-Id: I5d1625a30d7271c94cba71347f17fbcb0b87f4ae --- rust/bindgen.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/bindgen.go b/rust/bindgen.go index 4d723d6a6..72cc894cc 100644 --- a/rust/bindgen.go +++ b/rust/bindgen.go @@ -239,6 +239,11 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr cflags = append(cflags, "-x c") } + // 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") + } + outputFile := android.PathForModuleOut(ctx, b.BaseSourceProvider.getStem(ctx)+".rs") var cmd, cmdDesc string