diff options
| author | 2021-07-29 17:06:09 +0000 | |
|---|---|---|
| committer | 2021-07-29 17:06:09 +0000 | |
| commit | c4dae8eb27c37466f8ca7217d9652db4c599f05c (patch) | |
| tree | f5967c39a1eb8f7cf1e51c5c3de12c6dc0760b47 /rust/compiler.go | |
| parent | 0d8c4975351cf3bc5372beef807652c0dd708571 (diff) | |
| parent | 45a9e3196caaf61e2dcf4faec608ec9e3e862dd7 (diff) | |
Merge "rust: Prevent manually defined lib link flags."
Diffstat (limited to 'rust/compiler.go')
| -rw-r--r-- | rust/compiler.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/rust/compiler.go b/rust/compiler.go index df77759d6..de59f39ac 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -17,6 +17,7 @@ package rust import ( "fmt" "path/filepath" + "strings" "github.com/google/blueprint/proptools" @@ -235,6 +236,25 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag if err != nil { ctx.PropertyErrorf("lints", err.Error()) } + + // linkage-related flags are disallowed. + for _, s := range compiler.Properties.Ld_flags { + if strings.HasPrefix(s, "-Wl,-l") || strings.HasPrefix(s, "-Wl,-L") { + ctx.PropertyErrorf("ld_flags", "'-Wl,-l' and '-Wl,-L' flags cannot be manually specified") + } + } + for _, s := range compiler.Properties.Flags { + if strings.HasPrefix(s, "-l") || strings.HasPrefix(s, "-L") { + ctx.PropertyErrorf("flags", "'-l' and '-L' flags cannot be manually specified") + } + if strings.HasPrefix(s, "--extern") { + ctx.PropertyErrorf("flags", "'--extern' flag cannot be manually specified") + } + if strings.HasPrefix(s, "-Clink-args=") || strings.HasPrefix(s, "-C link-args=") { + ctx.PropertyErrorf("flags", "'-C link-args' flag cannot be manually specified") + } + } + flags.RustFlags = append(flags.RustFlags, lintFlags) flags.RustFlags = append(flags.RustFlags, compiler.Properties.Flags...) flags.RustFlags = append(flags.RustFlags, compiler.cfgsToFlags()...) |