Resolve wrapper path against path env

BUG=chromium:773875
TEST=unit test

Change-Id: I150eb18a5d765d43ee7a2341767ff41f6641c6ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1757222
Tested-by: Tobias Bosch <tbosch@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
diff --git a/compiler_wrapper/compiler_wrapper.go b/compiler_wrapper/compiler_wrapper.go
index 521846c..4aa91c6 100644
--- a/compiler_wrapper/compiler_wrapper.go
+++ b/compiler_wrapper/compiler_wrapper.go
@@ -8,15 +8,29 @@
 	"fmt"
 	"io"
 	"path/filepath"
+	"strings"
 )
 
 func callCompiler(env env, cfg *config, inputCmd *command) int {
-	exitCode := 0
 	var compilerErr error
-	if cfg.oldWrapperPath != "" {
-		exitCode, compilerErr = callCompilerWithRunAndCompareToOldWrapper(env, cfg, inputCmd)
-	} else {
-		exitCode, compilerErr = callCompilerInternal(env, cfg, inputCmd)
+	if !filepath.IsAbs(inputCmd.Path) && !strings.HasPrefix(inputCmd.Path, ".") {
+		if resolvedPath, err := resolveAgainstPathEnv(env, inputCmd.Path); err == nil {
+			inputCmd = &command{
+				Path:       resolvedPath,
+				Args:       inputCmd.Args,
+				EnvUpdates: inputCmd.EnvUpdates,
+			}
+		} else {
+			compilerErr = err
+		}
+	}
+	exitCode := 0
+	if compilerErr == nil {
+		if cfg.oldWrapperPath != "" {
+			exitCode, compilerErr = callCompilerWithRunAndCompareToOldWrapper(env, cfg, inputCmd)
+		} else {
+			exitCode, compilerErr = callCompilerInternal(env, cfg, inputCmd)
+		}
 	}
 	if compilerErr != nil {
 		printCompilerError(env.stderr(), compilerErr)