cros_setup_toolchains: don't wrap symlinks to libraries
Our native ELF check catches target libraries when the target is x86_64,
and we end up wrapping libs with shell scripts that makes no sense. The
point of this wrapping logic is to add shell scripts for symlinks to any
programs that we wrapped, not to add shell scripts for any symlink.
Nest the symlink check under the interp wrapper check so it only happens
when it makes sense.
BUG=chromium:766827
TEST=`cros_setup_toolchains --create-packages -t x86_64-cros-linux-gnu` doesn't wrap anymore
Change-Id: I90485f3cf6ebeb2be94701124e383aeb9d702021
Reviewed-on: https://chromium-review.googlesource.com/691342
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
diff --git a/scripts/cros_setup_toolchains.py b/scripts/cros_setup_toolchains.py
index dad8f5f..3ced25e 100644
--- a/scripts/cros_setup_toolchains.py
+++ b/scripts/cros_setup_toolchains.py
@@ -904,7 +904,7 @@
root: The root path to pull all packages/files from
"""
# Link in all the files.
- sym_paths = []
+ sym_paths = {}
for path in paths:
new_path = path_rewrite_func(path)
dst = output_dir + new_path
@@ -916,7 +916,7 @@
if os.path.islink(src):
tgt = os.readlink(src)
if os.path.sep in tgt:
- sym_paths.append((new_path, lddtree.normpath(ReadlinkRoot(src, root))))
+ sym_paths[lddtree.normpath(ReadlinkRoot(src, root))] = new_path
# Rewrite absolute links to relative and then generate the symlink
# ourselves. All other symlinks can be hardlinked below.
@@ -927,11 +927,6 @@
os.link(src, dst)
- # Now see if any of the symlinks need to be wrapped.
- for sym, tgt in sym_paths:
- if tgt in elfs:
- GeneratePathWrapper(output_dir, sym, tgt)
-
# Locate all the dependencies for all the ELFs. Stick them all in the
# top level "lib" dir to make the wrapper simpler. This exact path does
# not matter since we execute ldso directly, and we tell the ldso the
@@ -951,6 +946,11 @@
libpaths=e['rpath'] + e['runpath'])
FixClangXXWrapper(output_dir, path_rewrite_func(elf))
+ # Wrap any symlinks to the wrapper.
+ if elf in sym_paths:
+ link = sym_paths[elf]
+ GeneratePathWrapper(output_dir, link, elf)
+
for lib, lib_data in e['libs'].iteritems():
if lib in donelibs:
continue
@@ -1158,7 +1158,9 @@
ldpaths = lddtree.LoadLdpaths(root)
targets = ExpandTargets(targets_wanted)
- with osutils.TempDir() as tempdir:
+ with osutils.TempDir(prefix='create-packages') as tempdir:
+ logging.debug('Using tempdir: %s', tempdir)
+
# We have to split the root generation from the compression stages. This is
# because we hardlink in all the files (to avoid overhead of reading/writing
# the copies multiple times). But tar gets angry if a file's hardlink count