diff options
author | Tobias Bosch <tbosch@google.com> | 2019-08-21 16:42:53 -0700 |
---|---|---|
committer | Tobias Bosch <tbosch@google.com> | 2019-08-22 14:32:57 +0000 |
commit | 3e482f294ed90e3569274bad10aba4000fc6376c (patch) | |
tree | 9ef51950886579b2baa5a847cf9681137ca23fea /compiler_wrapper | |
parent | 6a6b52504d18b06f7ca871eff8cdad4e966c01e0 (diff) | |
download | toolchain-utils-3e482f294ed90e3569274bad10aba4000fc6376c.tar.gz |
Only resolve symlinks for wd for /proc/self/cwd
This is important as we are calculating the path to clang
sometimes relative, and resolving regular symlinked directories
makes this calculation invalid.
BUG=chromium:773875
TEST=executed the clang wrapper in a symlinked directory
Change-Id: I695db983861dea9fd047fb0bdf265a732a184963
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1764505
Reviewed-by: George Burgess <gbiv@chromium.org>
Tested-by: Tobias Bosch <tbosch@google.com>
Diffstat (limited to 'compiler_wrapper')
-rw-r--r-- | compiler_wrapper/env.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler_wrapper/env.go b/compiler_wrapper/env.go index f888f4a4..cde8b8fa 100644 --- a/compiler_wrapper/env.go +++ b/compiler_wrapper/env.go @@ -33,13 +33,11 @@ func newProcessEnv() (env, error) { if err != nil { return nil, wrapErrorwithSourceLocf(err, "failed to read working directory") } - // E.g. for "/proc/self/cwd" - // Don't use filepath.EvalSymlinks as that uses os.Getwd again... - fi, err := os.Lstat(wd) - if err != nil { - return nil, wrapErrorwithSourceLocf(err, "failed to stat working directory") - } - if fi.Mode()&os.ModeSymlink != 0 { + // Special case for linux when setting PWD=/proc/self/cwd. + // Don't do this for regular symlinked directories, as we are calculating + // the path to clang, and following a symlinked cwd first would make + // this calculation invalid. + if wd == "/proc/self/cwd" { if wd, err = os.Readlink(wd); err != nil { return nil, wrapErrorwithSourceLocf(err, "failed to read wd symlink %s", wd) } |