aboutsummaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-02-10 01:44:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-02-10 01:44:23 +0000
commit2d3e445c3a41ee0f87cca0a7a7396024731fdea5 (patch)
treedd6e9d27f284b09f23df61f441af99e0a2c6a75b /cc
parenta3cd089ffaa6efdf2bfa6ace5cd4a0470fcfcdd6 (diff)
parent4917049f6efe2d08e67eb26ec77e21dcce5172c5 (diff)
downloadbuild_soong-2d3e445c3a41ee0f87cca0a7a7396024731fdea5.tar.gz
build_soong-2d3e445c3a41ee0f87cca0a7a7396024731fdea5.tar.bz2
build_soong-2d3e445c3a41ee0f87cca0a7a7396024731fdea5.zip
Merge "Fix llvm-ar error caused by using lto and sanitizer together"
Diffstat (limited to 'cc')
-rw-r--r--cc/builder.go4
-rw-r--r--cc/cc.go1
-rw-r--r--cc/lto.go2
-rw-r--r--cc/sanitize.go3
-rw-r--r--cc/util.go1
5 files changed, 8 insertions, 3 deletions
diff --git a/cc/builder.go b/cc/builder.go
index 06461324..279c1da7 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -256,6 +256,7 @@ type builderFlags struct {
systemIncludeFlags string
groupStaticLibs bool
+ arGoldPlugin bool
stripKeepSymbols bool
stripKeepMiniDebugInfo bool
@@ -512,6 +513,9 @@ func TransformObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths,
if !ctx.Darwin() {
arFlags += " -format=gnu"
}
+ if flags.arGoldPlugin {
+ arFlags += " --plugin ${config.LLVMGoldPlugin}"
+ }
if flags.arFlags != "" {
arFlags += " " + flags.arFlags
}
diff --git a/cc/cc.go b/cc/cc.go
index 9cc7dfa3..49fefe96 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -142,6 +142,7 @@ type Flags struct {
LdFlagsDeps android.Paths // Files depended on by linker flags
GroupStaticLibs bool
+ ArGoldPlugin bool // Whether LLVM gold plugin option is passed to llvm-ar
}
type ObjectLinkerProperties struct {
diff --git a/cc/lto.go b/cc/lto.go
index 91b11b53..4757fc7e 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -86,7 +86,7 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
// https://github.com/android-ndk/ndk/issues/498.
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-emulated-tls")
}
- flags.ArFlags = append(flags.ArFlags, " --plugin ${config.LLVMGoldPlugin}")
+ flags.ArGoldPlugin = true
}
return flags
}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index ac6cb778..c47c3194 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -38,7 +38,6 @@ var (
"-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blacklist.txt"}
cfiLdflags = []string{"-flto", "-fsanitize-cfi-cross-dso", "-fsanitize=cfi",
"-Wl,-plugin-opt,O1"}
- cfiArflags = []string{"--plugin ${config.ClangBin}/../lib64/LLVMgold.so"}
cfiExportsMapPath = "build/soong/cc/config/cfi_exports.map"
cfiExportsMap android.Path
cfiStaticLibsMutex sync.Mutex
@@ -407,7 +406,7 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
// See b/72706604 or https://github.com/android-ndk/ndk/issues/498.
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-emulated-tls")
}
- flags.ArFlags = append(flags.ArFlags, cfiArflags...)
+ flags.ArGoldPlugin = true
if Bool(sanitize.Properties.Sanitize.Diag.Cfi) {
diagSanitizers = append(diagSanitizers, "cfi")
}
diff --git a/cc/util.go b/cc/util.go
index 5131b09a..92a32bc9 100644
--- a/cc/util.go
+++ b/cc/util.go
@@ -84,6 +84,7 @@ func flagsToBuilderFlags(in Flags) builderFlags {
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
groupStaticLibs: in.GroupStaticLibs,
+ arGoldPlugin: in.ArGoldPlugin,
}
}