Add flag property checking
Some checks for common errors with user-provided compiler and linker
flags:
* Using -I instead of include_dirs
* Using -l<lib> in ldflags instead of host_ldlibs (or shared_libs)
* Using -L in ldflags
* Splitting a multi-word flag into two flags
* Combining two flags into one list entry
* Using a path that could search outside the source or output trees
* Using a non-whitelisted library in host_ldlibs
Maybe some of the flag checks should happen during a static analysis
pass, but we don't have one right now, and this only adds ~1/2 second to
our 73 second Mega_device runs (recompile the changed code, run
soong_build, then report unknown target).
Change-Id: Icea7436260f1caa62c0cec29817a1cfea27b3e7c
diff --git a/cc/x86_linux_host.go b/cc/x86_linux_host.go
index 6562e6a..a75de90 100644
--- a/cc/x86_linux_host.go
+++ b/cc/x86_linux_host.go
@@ -97,6 +97,20 @@
linuxX8664ClangCppflags = []string{
"-isystem ${linuxGccRoot}/${linuxGccTriple}/include/c++/${linuxGccVersion}/${linuxGccTriple}",
}
+
+ linuxAvailableLibraries = addPrefix([]string{
+ "c",
+ "dl",
+ "gcc",
+ "gcc_s",
+ "m",
+ "ncurses",
+ "pthread",
+ "resolv",
+ "rt",
+ "util",
+ "z",
+ }, "-l")
)
const (
@@ -224,6 +238,10 @@
return "${linuxClangLdflags} ${linuxX8664ClangLdflags}"
}
+func (t *toolchainLinux) AvailableLibraries() []string {
+ return linuxAvailableLibraries
+}
+
var toolchainLinuxX86Singleton Toolchain = &toolchainLinuxX86{}
var toolchainLinuxX8664Singleton Toolchain = &toolchainLinuxX8664{}