Skip to content

Commit 86e2290

Browse files
committed
build: use objdump instead of otool
See bitcoin/bitcoin#7f5ac4520d1553170b1053a9ffcd58179386a6d2.
1 parent 7b6007f commit 86e2290

File tree

8 files changed

+40
-22
lines changed

8 files changed

+40
-22
lines changed

Diff for: Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ $(APP_DIST_DIR)/.background/$(OSX_BACKGROUND_IMAGE): $(OSX_BACKGROUND_IMAGE_DPIF
150150
$(TIFFCP) -c none $(OSX_BACKGROUND_IMAGE_DPIFILES) $@
151151

152152
$(APP_DIST_DIR)/$(OSX_APP)/Contents/MacOS/gridcoinresearch: $(OSX_APP_BUILT) $(OSX_PACKAGING)
153-
INSTALLNAMETOOL=$(INSTALLNAMETOOL) OTOOL=$(OTOOL) STRIP=$(STRIP) $(PYTHON) $(OSX_DEPLOY_SCRIPT) $(OSX_APP) $(OSX_VOLNAME) -translations-dir=$(QT_TRANSLATION_DIR) -verbose 2
153+
OBJDUMP=$(OBJDUMP) STRIP=$(STRIP) $(PYTHON) $(OSX_DEPLOY_SCRIPT) $(OSX_APP) $(OSX_VOLNAME) -translations-dir=$(QT_TRANSLATION_DIR) -verbose 2
154154

155155
deploydir: $(APP_DIST_EXTRAS)
156156
endif

Diff for: configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ AC_PATH_PROG([GIT], [git])
9090
AC_PATH_PROG(CCACHE,ccache)
9191
AC_PATH_PROG(XGETTEXT,xgettext)
9292
AC_PATH_PROG(HEXDUMP,hexdump)
93+
AC_PATH_TOOL([OBJDUMP], [objdump])
9394
AC_PATH_TOOL(READELF, readelf)
9495
AC_PATH_TOOL(CPPFILT, c++filt)
9596
AC_PATH_TOOL(OBJCOPY, objcopy)
@@ -559,7 +560,6 @@ case $host in
559560
*)
560561
AC_PATH_TOOL([DSYMUTIL], [dsymutil], dsymutil)
561562
AC_PATH_TOOL([INSTALLNAMETOOL], [install_name_tool], install_name_tool)
562-
AC_PATH_TOOL([OTOOL], [otool], otool)
563563
AC_PATH_PROGS([XORRISOFS], [xorrisofs], xorrisofs)
564564
AC_PATH_PROGS([DMG], [dmg], dmg)
565565
AC_PATH_PROGS([RSVG_CONVERT], [rsvg-convert rsvg],rsvg-convert)

Diff for: contrib/macdeploy/macdeployqtplus

+14-14
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class FrameworkInfo(object):
7979
bundleBinaryDirectory = "Contents/MacOS"
8080

8181
@classmethod
82-
def fromOtoolLibraryLine(cls, line: str) -> Optional['FrameworkInfo']:
82+
def fromLibraryLine(cls, line: str) -> Optional['FrameworkInfo']:
8383
# Note: line must be trimmed
8484
if line == "":
8585
return None
@@ -90,7 +90,7 @@ class FrameworkInfo(object):
9090

9191
m = cls.reOLine.match(line)
9292
if m is None:
93-
raise RuntimeError(f"otool line could not be parsed: {line}")
93+
raise RuntimeError(f"Line could not be parsed: {line}")
9494

9595
path = m.group(1)
9696

@@ -122,7 +122,7 @@ class FrameworkInfo(object):
122122
break
123123
i += 1
124124
if i == len(parts):
125-
raise RuntimeError(f"Could not find .framework or .dylib in otool line: {line}")
125+
raise RuntimeError(f"Could not find .framework or .dylib in line: {line}")
126126

127127
info.frameworkName = parts[i]
128128
info.frameworkDirectory = "/".join(parts[:i])
@@ -184,24 +184,24 @@ class DeploymentInfo(object):
184184
return False
185185

186186
def getFrameworks(binaryPath: str, verbose: int) -> List[FrameworkInfo]:
187+
objdump = os.getenv("OBJDUMP", "objdump")
187188
if verbose:
188-
print(f"Inspecting with otool: {binaryPath}")
189-
otoolbin=os.getenv("OTOOL", "otool")
190-
otool = run([otoolbin, "-L", binaryPath], stdout=PIPE, stderr=PIPE, universal_newlines=True)
191-
if otool.returncode != 0:
192-
sys.stderr.write(otool.stderr)
189+
print(f"Inspecting with {objdump}: {binaryPath}")
190+
output = run([objdump, "--macho", "--dylibs-used", binaryPath], stdout=PIPE, stderr=PIPE, text=True)
191+
if output.returncode != 0:
192+
sys.stderr.write(output.stderr)
193193
sys.stderr.flush()
194-
raise RuntimeError(f"otool failed with return code {otool.returncode}")
194+
raise RuntimeError(f"{objdump} failed with return code {output.returncode}")
195195

196-
otoolLines = otool.stdout.split("\n")
197-
otoolLines.pop(0) # First line is the inspected binary
196+
lines = output.stdout.split("\n")
197+
lines.pop(0) # First line is the inspected binary
198198
if ".framework" in binaryPath or binaryPath.endswith(".dylib"):
199-
otoolLines.pop(0) # Frameworks and dylibs list themselves as a dependency.
199+
lines.pop(0) # Frameworks and dylibs list themselves as a dependency.
200200

201201
libraries = []
202-
for line in otoolLines:
202+
for line in lines:
203203
line = line.replace("@loader_path", os.path.dirname(binaryPath))
204-
info = FrameworkInfo.fromOtoolLibraryLine(line.strip())
204+
info = FrameworkInfo.fromLibraryLine(line.strip())
205205
if info is not None:
206206
if verbose:
207207
print("Found framework:")

Diff for: depends/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_
152152
-e 's|@RANLIB@|$(host_RANLIB)|' \
153153
-e 's|@NM@|$(host_NM)|' \
154154
-e 's|@STRIP@|$(host_STRIP)|' \
155+
-e 's|@OBJDUMP@|$(host_OBJDUMP)|' \
156+
-e 's|@DSYMUTIL@|$(host_DSYMUTIL)|' \
155157
-e 's|@build_os@|$(build_os)|' \
156158
-e 's|@host_os@|$(host_os)|' \
157159
-e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \

Diff for: depends/builders/darwin.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ build_darwin_CXX:=$(shell xcrun -f clang++) -isysroot$(shell xcrun --show-sdk-pa
33
build_darwin_AR:=$(shell xcrun -f ar)
44
build_darwin_RANLIB:=$(shell xcrun -f ranlib)
55
build_darwin_STRIP:=$(shell xcrun -f strip)
6-
build_darwin_OTOOL:=$(shell xcrun -f otool)
6+
build_darwin_OBJDUMP:=$(shell xcrun -f objdump)
77
build_darwin_NM:=$(shell xcrun -f nm)
88
build_darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool)
99
build_darwin_SHA256SUM=shasum -a 256
@@ -16,7 +16,7 @@ darwin_AR:=$(shell xcrun -f ar)
1616
darwin_RANLIB:=$(shell xcrun -f ranlib)
1717
darwin_STRIP:=$(shell xcrun -f strip)
1818
darwin_LIBTOOL:=$(shell xcrun -f libtool)
19-
darwin_OTOOL:=$(shell xcrun -f otool)
19+
darwin_OBJDUMP:=$(shell xcrun -f objdump)
2020
darwin_NM:=$(shell xcrun -f nm)
2121
darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool)
2222
darwin_native_toolchain=

Diff for: depends/builders/default.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
default_build_CC = gcc
22
default_build_CXX = g++
33
default_build_AR = ar
4+
default_build_OBJDUMP = objdump
45
default_build_RANLIB = ranlib
56
default_build_STRIP = strip
67
default_build_NM = nm
7-
default_build_OTOOL = otool
88
default_build_INSTALL_NAME_TOOL = install_name_tool
99

1010
define add_build_tool_func
1111
build_$(build_os)_$1 ?= $$(default_build_$1)
1212
build_$(build_arch)_$(build_os)_$1 ?= $$(build_$(build_os)_$1)
1313
build_$1=$$(build_$(build_arch)_$(build_os)_$1)
1414
endef
15-
$(foreach var,CC CXX AR RANLIB NM STRIP SHA256SUM DOWNLOAD OTOOL INSTALL_NAME_TOOL,$(eval $(call add_build_tool_func,$(var))))
15+
$(foreach var,CC CXX AR RANLIB NM STRIP SHA256SUM DOWNLOAD OBJDUMP INSTALL_NAME_TOOL,$(eval $(call add_build_tool_func,$(var))))
1616
define add_build_flags_func
1717
build_$(build_arch)_$(build_os)_$1 += $(build_$(build_os)_$1)
1818
build_$1=$$(build_$(build_arch)_$(build_os)_$1)

Diff for: depends/config.site.in

+17
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ if test -n "@NM@"; then
8080
ac_cv_path_ac_pt_NM=${NM}
8181
fi
8282

83+
if test -n "@STRIP@"; then
84+
STRIP="@STRIP@"
85+
ac_cv_path_ac_pt_STRIP="${STRIP}"
86+
fi
87+
88+
if test "@host_os@" = darwin; then
89+
if test -n "@OBJDUMP@"; then
90+
OBJDUMP="@OBJDUMP@"
91+
ac_cv_path_OBJDUMP="${OBJDUMP}"
92+
fi
93+
94+
if test -n "@DSYMUTIL@"; then
95+
DSYMUTIL="@DSYMUTIL@"
96+
ac_cv_path_DSYMUTIL="${DSYMUTIL}"
97+
fi
98+
fi
99+
83100
if test -n "@debug@"; then
84101
enable_reduce_exports=no
85102
fi

Diff for: depends/hosts/default.mk

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ default_host_RANLIB = $(host_toolchain)ranlib
99
default_host_STRIP = $(host_toolchain)strip
1010
default_host_LIBTOOL = $(host_toolchain)libtool
1111
default_host_INSTALL_NAME_TOOL = $(host_toolchain)install_name_tool
12-
default_host_OTOOL = $(host_toolchain)otool
1312
default_host_NM = $(host_toolchain)nm
1413

1514
define add_host_tool_func
@@ -35,5 +34,5 @@ host_$1 = $$($(host_arch)_$(host_os)_$1)
3534
host_$(release_type)_$1 = $$($(host_arch)_$(host_os)_$(release_type)_$1)
3635
endef
3736

38-
$(foreach tool,CC CXX AR RANLIB STRIP NM LIBTOOL OTOOL INSTALL_NAME_TOOL,$(eval $(call add_host_tool_func,$(tool))))
37+
$(foreach tool,CC CXX AR RANLIB STRIP NM LIBTOOL OBJDUMP INSTALL_NAME_TOOL,$(eval $(call add_host_tool_func,$(tool))))
3938
$(foreach flags,CFLAGS CXXFLAGS CPPFLAGS LDFLAGS, $(eval $(call add_host_flags_func,$(flags))))

0 commit comments

Comments
 (0)