diff options
author | Tobias Bosch <tbosch@google.com> | 2019-07-17 04:22:34 -0700 |
---|---|---|
committer | Tobias Bosch <tbosch@google.com> | 2019-07-18 09:08:50 +0000 |
commit | 198a3c9519e5d93ffeb8f5e1b6694c34b178c5c4 (patch) | |
tree | 770bbd6c63184a1dbcdbcee01bf551815d062bee /compiler_wrapper/compiler_wrapper.go | |
parent | 22c32b40be54a9e4062655f90908f98b11e73966 (diff) | |
download | toolchain-utils-198a3c9519e5d93ffeb8f5e1b6694c34b178c5c4.tar.gz |
Fix minor bugs
These bugs were detected while creating golden tests
and comparing them to the old wrapper (see next commit).
Also makes flag order in old wrapper deterministic by
replacing sets with a SetList class that is based
on a list.
BUG=chromium:773875
TEST=unit test
Change-Id: I8e2680f732577f1f590042f1ccd589dfedadd6ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1706791
Tested-by: Tobias Bosch <tbosch@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper/compiler_wrapper.go')
-rw-r--r-- | compiler_wrapper/compiler_wrapper.go | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/compiler_wrapper/compiler_wrapper.go b/compiler_wrapper/compiler_wrapper.go index 314a8a71..8bee238d 100644 --- a/compiler_wrapper/compiler_wrapper.go +++ b/compiler_wrapper/compiler_wrapper.go @@ -50,19 +50,24 @@ func callCompilerInternal(env env, cfg *config, inputCmd *command) (exitCode int clangSyntax := processClangSyntaxFlag(mainBuilder) if mainBuilder.target.compilerType == clangType { cSrcFile, useClangTidy := processClangTidyFlags(mainBuilder) - compilerCmd, err = calcClangCommand(useClangTidy, mainBuilder) + sysroot, err := prepareClangCommand(mainBuilder) if err != nil { return 0, err } + allowCCache := true if useClangTidy { - if err := runClangTidy(env, compilerCmd, cSrcFile); err != nil { + allowCCache = false + clangCmdWithoutGomaAndCCache := mainBuilder.build() + if err := runClangTidy(env, clangCmdWithoutGomaAndCCache, cSrcFile); err != nil { return 0, err } } + processGomaCCacheFlags(sysroot, allowCCache, mainBuilder) + compilerCmd = mainBuilder.build() } else { if clangSyntax { - forceLocal := false - clangCmd, err := calcClangCommand(forceLocal, mainBuilder.clone()) + allowCCache := false + clangCmd, err := calcClangCommand(allowCCache, mainBuilder.clone()) if err != nil { return 0, err } @@ -98,16 +103,22 @@ func callCompilerInternal(env env, cfg *config, inputCmd *command) (exitCode int return wrapSubprocessErrorWithSourceLoc(compilerCmd, env.exec(compilerCmd)) } -func calcClangCommand(forceLocal bool, builder *commandBuilder) (*command, error) { - sysroot := processSysrootFlag(builder) +func prepareClangCommand(builder *commandBuilder) (sysroot string, err error) { + sysroot = processSysrootFlag(builder) builder.addPreUserArgs(builder.cfg.clangFlags...) calcCommonPreUserArgs(builder) if err := processClangFlags(builder); err != nil { - return nil, err + return "", err } - if !forceLocal { - processGomaCCacheFlags(sysroot, builder) + return sysroot, nil +} + +func calcClangCommand(allowCCache bool, builder *commandBuilder) (*command, error) { + sysroot, err := prepareClangCommand(builder) + if err != nil { + return nil, err } + processGomaCCacheFlags(sysroot, allowCCache, builder) return builder.build(), nil } @@ -116,7 +127,8 @@ func calcGccCommand(builder *commandBuilder) *command { builder.addPreUserArgs(builder.cfg.gccFlags...) calcCommonPreUserArgs(builder) processGccFlags(builder) - processGomaCCacheFlags(sysroot, builder) + allowCCache := true + processGomaCCacheFlags(sysroot, allowCCache, builder) return builder.build() } @@ -129,9 +141,9 @@ func calcCommonPreUserArgs(builder *commandBuilder) { processSanitizerFlags(builder) } -func processGomaCCacheFlags(sysroot string, builder *commandBuilder) { +func processGomaCCacheFlags(sysroot string, allowCCache bool, builder *commandBuilder) { gomaccUsed := processGomaCccFlags(builder) - if !gomaccUsed { + if !gomaccUsed && allowCCache { processCCacheFlag(sysroot, builder) } } |