From 1d771add169c7d106b3822301524b5cc29891fd2 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 16 Jul 2024 06:12:12 +0200 Subject: [PATCH] Allow LIEF to fail when using patchelf (#5176) Avoid unconditional failure when LIEF raises, even when not used. --------- Co-authored-by: Bianca Henderson --- conda_build/post.py | 16 +++++++++++++++- news/5176-lief-fail | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 news/5176-lief-fail diff --git a/conda_build/post.py b/conda_build/post.py index 28ff905314..6b10af2a78 100644 --- a/conda_build/post.py +++ b/conda_build/post.py @@ -9,6 +9,7 @@ import shutil import stat import sys +import traceback from collections import OrderedDict, defaultdict from copy import copy from fnmatch import filter as fnmatch_filter @@ -609,7 +610,20 @@ def mk_relative_linux(f, prefix, rpaths=("lib",), method=None): existing_pe = existing_pe.split(os.pathsep) existing = existing_pe if have_lief: - existing2, _, _ = get_rpaths_raw(elf) + existing2 = None + try: + existing2, _, _ = get_rpaths_raw(elf) + except Exception as e: + if method == "LIEF": + print( + f"ERROR :: get_rpaths_raw({elf!r}) with LIEF failed: {e}, but LIEF was specified" + ) + traceback.print_tb(e.__traceback__) + else: + print( + f"WARNING :: get_rpaths_raw({elf!r}) with LIEF failed: {e}, will proceed with patchelf" + ) + method = "patchelf" if existing_pe and existing_pe != existing2: print( f"WARNING :: get_rpaths_raw()={existing2} and patchelf={existing_pe} disagree for {elf} :: " diff --git a/news/5176-lief-fail b/news/5176-lief-fail new file mode 100644 index 0000000000..c120627163 --- /dev/null +++ b/news/5176-lief-fail @@ -0,0 +1,3 @@ +### Bug fixes + +* Error handling when `LIEF` fails is now consistent with `patchelf`. (#5176)