aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoj Gupta <manojgupta@google.com>2020-01-23 14:13:11 -0800
committerManoj Gupta <manojgupta@chromium.org>2020-01-24 15:04:33 +0000
commit39a1c992ee085cac78f64b36b66daa1e1c8747ad (patch)
treebb5f5b889c365357f484e19cc638d75bc95cb9ff
parent0ee6a5701bedfa6b67b33f8b47cd705d713b1777 (diff)
downloadtoolchain-utils-39a1c992ee085cac78f64b36b66daa1e1c8747ad.tar.gz
compiler_wrapper: strip newline char from resource dir.
The resource dir value returned by calling clang has a new line character. This breaks running clang with "-Xclang-path=/path/to/<clang_dir>" functionality as the resource directory with this new line does not exist. BUG=chromium:1044790 TEST=compilation with "-Xclang-path=/path/to/<clang_dir>" works. Change-Id: I0ef31108719aed02a433aff3e751e961892dd15a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2017844 Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: George Burgess <gbiv@chromium.org>
-rw-r--r--compiler_wrapper/clang_flags.go3
-rw-r--r--compiler_wrapper/clang_flags_test.go2
2 files changed, 3 insertions, 2 deletions
diff --git a/compiler_wrapper/clang_flags.go b/compiler_wrapper/clang_flags.go
index 8b76e965..1f0e2231 100644
--- a/compiler_wrapper/clang_flags.go
+++ b/compiler_wrapper/clang_flags.go
@@ -172,7 +172,8 @@ func getClangResourceDir(env env, clangPath string) (string, error) {
"failed to call clang to read the resouce-dir: %#v",
readResourceCmd)
}
- return stdoutBuffer.String(), nil
+ resourceDir := strings.TrimRight(stdoutBuffer.String(), "\n")
+ return resourceDir, nil
}
// Return the a directory which contains an 'ld' that gcc is using.
diff --git a/compiler_wrapper/clang_flags_test.go b/compiler_wrapper/clang_flags_test.go
index 0c0f1fdd..2a7fbd15 100644
--- a/compiler_wrapper/clang_flags_test.go
+++ b/compiler_wrapper/clang_flags_test.go
@@ -139,7 +139,7 @@ func TestUseXclangPathAndCalcResourceDirByNestedClangCall(t *testing.T) {
if err := verifyArgOrder(cmd, "--print-resource-dir"); err != nil {
t.Error(err)
}
- fmt.Fprint(stdout, "someResourcePath")
+ fmt.Fprint(stdout, "someResourcePath\n")
return nil
}
cmd := ctx.must(callCompiler(ctx, ctx.cfg,