compiler_wrapper: Use ld.bfd to detect binutils path

Use ld.bfd instead of ld to detect binutils path. This is to assist
in finding packages that use GCC/Binutils ignoring portage
enviroment.

BUG=b:193847062
TEST=go test

Change-Id: I0fd8c5c13ad2227f03ec3193c58c9bdfca4e4dc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3365636
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Auto-Submit: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: George Burgess <gbiv@chromium.org>
Commit-Queue: George Burgess <gbiv@chromium.org>
diff --git a/compiler_wrapper/clang_flags.go b/compiler_wrapper/clang_flags.go
index 84149bf..e25ed74 100644
--- a/compiler_wrapper/clang_flags.go
+++ b/compiler_wrapper/clang_flags.go
@@ -126,7 +126,7 @@
 
 	// Specify the target for clang.
 	if !builder.cfg.isHostWrapper {
-		linkerPath := getLinkerPath(env, builder.target.target+"-ld", builder.rootPath)
+		linkerPath := getLinkerPath(env, builder.target.target+"-ld.bfd", builder.rootPath)
 		relLinkerPath, err := filepath.Rel(env.getwd(), linkerPath)
 		if err != nil {
 			return wrapErrorwithSourceLocf(err, "failed to make linker path %s relative to %s",
diff --git a/compiler_wrapper/clang_flags_test.go b/compiler_wrapper/clang_flags_test.go
index 25c13c7..23aed7e 100644
--- a/compiler_wrapper/clang_flags_test.go
+++ b/compiler_wrapper/clang_flags_test.go
@@ -248,7 +248,7 @@
 func TestClangLinkerPathProbesBinariesOnPath(t *testing.T) {
 	withTestContext(t, func(ctx *testContext) {
 		linkerPath := filepath.Join(ctx.tempDir, "a/b/c")
-		ctx.writeFile(filepath.Join(linkerPath, "x86_64-cros-linux-gnu-ld"), "")
+		ctx.writeFile(filepath.Join(linkerPath, "x86_64-cros-linux-gnu-ld.bfd"), "")
 		ctx.env = []string{"PATH=nonExistantPath:" + linkerPath}
 		cmd := ctx.must(callCompiler(ctx, ctx.cfg,
 			ctx.newCommand("./x86_64-cros-linux-gnu-clang", mainCc)))
@@ -268,7 +268,7 @@
 		ctx.writeFile(realLinkerPath, "")
 		firstLinkLinkerPath := filepath.Join(ctx.tempDir, "a/first/somelinker")
 		ctx.symlink(realLinkerPath, firstLinkLinkerPath)
-		secondLinkLinkerPath := filepath.Join(ctx.tempDir, "a/second/x86_64-cros-linux-gnu-ld")
+		secondLinkLinkerPath := filepath.Join(ctx.tempDir, "a/second/x86_64-cros-linux-gnu-ld.bfd")
 		ctx.symlink(firstLinkLinkerPath, secondLinkLinkerPath)
 
 		ctx.env = []string{"PATH=nonExistantPath:" + filepath.Dir(secondLinkLinkerPath)}