Add -print-cmdline and -print-config

BUG=chromium:773875
TEST=unit test

Change-Id: Ib25e582257694f3a3457795873a249735e3aaf82
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1697931
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 b0269ab..314a8a7 100644
--- a/compiler_wrapper/compiler_wrapper.go
+++ b/compiler_wrapper/compiler_wrapper.go
@@ -43,6 +43,9 @@
 	if err != nil {
 		return 0, err
 	}
+	processPrintConfigFlag(mainBuilder)
+	processPrintCmdlineFlag(mainBuilder)
+	env = mainBuilder.env
 	var compilerCmd *command
 	clangSyntax := processClangSyntaxFlag(mainBuilder)
 	if mainBuilder.target.compilerType == clangType {
@@ -133,10 +136,8 @@
 	}
 }
 
-func getAbsWrapperDir(env env, wrapperPath string) (string, error) {
-	if !filepath.IsAbs(wrapperPath) {
-		wrapperPath = filepath.Join(env.getwd(), wrapperPath)
-	}
+func getAbsWrapperDir(env env, wrapperCmd *command) (string, error) {
+	wrapperPath := getAbsCmdPath(env, wrapperCmd)
 	evaledCmdPath, err := filepath.EvalSymlinks(wrapperPath)
 	if err != nil {
 		return "", wrapErrorwithSourceLocf(err, "failed to evaluate symlinks for %s", wrapperPath)