Add 'openmp' compiler property
Bug: http://b/70692399
If a module has 'openmp: true', add '-fopenmp' to CFlags during any
compile step and pass the libomp runtime to the linker during any link
step.
Test: Build samples in http://aosp/572924
Change-Id: Ic2a6410ec69aae548edaf582ee41659b0058561e
diff --git a/cc/compiler.go b/cc/compiler.go
index c9dcf95..7e8e8b8 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -148,6 +148,9 @@
// Stores the original list of source files before being cleared by library reuse
OriginalSrcs []string `blueprint:"mutated"`
+
+ // Build and link with OpenMP
+ Openmp *bool `android:"arch_variant"`
}
func NewBaseCompiler() *baseCompiler {
@@ -204,6 +207,10 @@
deps = protoDeps(ctx, deps, &compiler.Proto, Bool(compiler.Properties.Proto.Static))
}
+ if Bool(compiler.Properties.Openmp) {
+ deps.StaticLibs = append(deps.StaticLibs, "libomp")
+ }
+
return deps
}
@@ -494,6 +501,10 @@
}
}
+ if Bool(compiler.Properties.Openmp) {
+ flags.CFlags = append(flags.CFlags, "-fopenmp")
+ }
+
return flags
}