Bug 1596656 - Move OBJCOPY to python configure. r=firefox-build-system-reviewers,andi

As a bonus, we also check and prefer llvm-objcopy when it's suitable.

Differential Revision: https://phabricator.services.mozilla.com/D136975
This commit is contained in:
Mike Hommey 2022-01-26 23:53:37 +00:00
parent a6f796c8ac
commit c45108f00b
3 changed files with 27 additions and 12 deletions

View File

@ -85,7 +85,6 @@ AC_CHECK_PROGS(LIPO, "${TOOLCHAIN_PREFIX}lipo", :)
AC_CHECK_PROGS(STRIP, "${TOOLCHAIN_PREFIX}strip", :)
AC_CHECK_PROGS(OTOOL, "${TOOLCHAIN_PREFIX}otool", :)
AC_CHECK_PROGS(INSTALL_NAME_TOOL, "${TOOLCHAIN_PREFIX}install_name_tool", :)
AC_CHECK_PROGS(OBJCOPY, "${TOOLCHAIN_PREFIX}objcopy", :)
PATH=$_SAVE_PATH
])

View File

@ -827,12 +827,38 @@ def readelf_when(compile_env, target, host):
check_prog(
"READELF",
readelf,
what="readelf",
when=readelf_when,
paths=clang_search_path,
validate=validate_readelf,
)
@depends(llvm_tool("llvm-objcopy"), toolchain_prefix)
def objcopy(llvm_objcopy, toolchain_prefix):
commands = [llvm_objcopy[0], "objcopy"]
for prefix in toolchain_prefix or ():
commands.insert(1, "%sreadelf" % prefix)
return tuple(commands)
def validate_objcopy(path):
if "llvm-objcopy" not in path:
return True
# llvm-objcopy doesn't support --only-keep-debug before llvm 9.0.
retcode, stdout, stderr = get_cmd_output(path, "--help")
return retcode == 0 and any(
l.startswith(" --only-keep-debug ") for l in stdout.splitlines()
)
check_prog(
"OBJCOPY",
objcopy,
when=readelf_when,
paths=clang_search_path,
validate=validate_objcopy,
)
option("--enable-dtrace", help="Build with dtrace support")
dtrace = check_header(

View File

@ -63,16 +63,6 @@ if test "$COMPILE_ENVIRONMENT"; then
MOZ_ANDROID_NDK
fi # COMPILE_ENVIRONMENT
case "$target" in
*-android*|*-linuxandroid*)
;;
*-linux*)
AC_PATH_PROG(OBJCOPY,objcopy)
;;
esac
AC_SUBST(OBJCOPY)
dnl ========================================================
dnl Checks for compilers.
dnl ========================================================