summaryrefslogtreecommitdiffstats
path: root/tools/ld_bfd
diff options
context:
space:
mode:
authorbradchen@google.com <bradchen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-07 22:03:33 +0000
committerbradchen@google.com <bradchen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-07 22:03:33 +0000
commit9ddb68283018679bcadbce2f4e2e7171883069da (patch)
tree6f975a38ffb4b24c7663dab47f975e5affe66ceb /tools/ld_bfd
parent1b62f9017e442d98474e0fc46bc40d31f4704167 (diff)
downloadchromium_src-9ddb68283018679bcadbce2f4e2e7171883069da.zip
chromium_src-9ddb68283018679bcadbce2f4e2e7171883069da.tar.gz
chromium_src-9ddb68283018679bcadbce2f4e2e7171883069da.tar.bz2
Modify the build recipe for nacl_helper_bootstrap to invoke the linker explicitly via an action rather than invoking via g++. This addresses build problems that occurred on certain developer machines.
Also, modified tools/ld_bfd/ld script to find the loader within the Chrome OS build chroot. Also re-enable the nacl_helper. BUG=92964,nativeclient:480 TEST=nacl_integration tests on bots Review URL: http://codereview.chromium.org/7841008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100031 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/ld_bfd')
-rwxr-xr-xtools/ld_bfd/ld60
1 files changed, 33 insertions, 27 deletions
diff --git a/tools/ld_bfd/ld b/tools/ld_bfd/ld
index 124f202..41a9776 100755
--- a/tools/ld_bfd/ld
+++ b/tools/ld_bfd/ld
@@ -5,39 +5,45 @@
"""Wrapper for invoking the BFD loader
-A simple script to invoke the bfd loader instead of gold, removing
-threading command line options that the bfd loader doesn't support.
-Because this script is invoked from gcc via the -B flag, it needs
-to be in a file named "ld".
+A simple script to invoke the bfd loader instead of gold.
+This script is in a filename "ld" so it can be invoked from gcc
+via the -B flag.
"""
-
+# TODO(bradchen): Delete this script when Gold supports linker scripts properly.
import os
import subprocess
import sys
-# TODO(bradchen): Delete this script when Gold supports -Ttext properly.
-# It should be fixed by this patch:
-# http://sourceware.org/ml/binutils/2011-07/msg00206.html
+def PathTo(fname):
+ if fname[0] == os.pathsep:
+ return fname
+ for p in os.environ["PATH"].split(os.pathsep):
+ fpath = os.path.join(p, fname)
+ if os.path.exists(fpath):
+ return fpath
+ return fname
+
+def FindLDBFD():
+ cxx = os.getenv("CXX")
+ if not cxx:
+ cxx = "gcc"
+ popen = subprocess.Popen(cxx + " -print-prog-name=ld",
+ shell=True,
+ stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE)
+ (ld, error) = popen.communicate()
+ if popen.wait() != 0:
+ print "Could not find ld:" + error
+ return "ld"
+ ld = ld.strip()
+ ld_bfd = PathTo(ld + ".bfd")
+ if os.access(ld_bfd, os.X_OK):
+ return ld_bfd
+ return ld
+
def main():
- LD_BFD = "/usr/bin/ld.bfd"
- if not (os.path.exists(LD_BFD) and os.access(LD_BFD, os.X_OK)):
- # Can't find the BFD loader, so invoke the unmodified argv
- args = sys.argv
- args[0] = "ld"
- print "ld_bfd/ld: using ld"
- sys.exit(subprocess.call(args))
- # found the BFD loader, so use it
- args = list()
- args.append("/usr/bin/ld.bfd")
- for arg in sys.argv[1:]:
- if arg == "-Wl,--threads" or arg == "--threads":
- continue
- if arg == "-Wl,--thread-count=4" or arg == "--thread-count=4":
- continue
- if arg == "--icf=none":
- continue
- args.append(arg)
- print("ld_bfd/ld: exec ", args)
+ args = [FindLDBFD()] + sys.argv[1:]
+ print("tools/ld_bfd/ld: exec " + ' '.join(args))
sys.exit(subprocess.call(args))
if __name__ == "__main__":