Skip to content

Commit

Permalink
Merge 77eaee0 into 5a5ab1d
Browse files Browse the repository at this point in the history
  • Loading branch information
fanquake committed Apr 5, 2024
2 parents 5a5ab1d + 77eaee0 commit f782106
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -126,7 +126,7 @@ $(OSX_ZIP): deploydir
cd $(APP_DIST_DIR) && find . | sort | $(ZIP) -X@ $@

$(APP_DIST_DIR)/$(OSX_APP)/Contents/MacOS/Bitcoin-Qt: $(OSX_APP_BUILT) $(OSX_PACKAGING)
INSTALL_NAME_TOOL=$(INSTALL_NAME_TOOL) OTOOL=$(OTOOL) STRIP=$(STRIP) $(PYTHON) $(OSX_DEPLOY_SCRIPT) $(OSX_APP) $(OSX_VOLNAME) -translations-dir=$(QT_TRANSLATION_DIR)
INSTALL_NAME_TOOL=$(INSTALL_NAME_TOOL) OBJDUMP=$(OBJDUMP) STRIP=$(STRIP) $(PYTHON) $(OSX_DEPLOY_SCRIPT) $(OSX_APP) $(OSX_VOLNAME) -translations-dir=$(QT_TRANSLATION_DIR)

deploydir: $(APP_DIST_DIR)/$(OSX_APP)/Contents/MacOS/Bitcoin-Qt
endif !BUILD_DARWIN
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_mac_cross.sh
Expand Up @@ -11,7 +11,7 @@ export SDK_URL=${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}
export CONTAINER_NAME=ci_macos_cross
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:22.04"
export HOST=x86_64-apple-darwin
export PACKAGES="zip"
export PACKAGES="llvm zip"
export XCODE_VERSION=15.0
export XCODE_BUILD_ID=15A240d
export RUN_UNIT_TESTS=false
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Expand Up @@ -759,8 +759,8 @@ case $host in
;;
*)
AC_PATH_TOOL([DSYMUTIL], [dsymutil], [dsymutil])
AC_PATH_TOOL([INSTALL_NAME_TOOL], [install_name_tool], [install_name_tool])
AC_PATH_TOOL([OTOOL], [otool], [otool])
AC_PATH_TOOL([INSTALL_NAME_TOOL], [llvm-install-name-tool], [llvm-install-name-tool])
AC_PATH_TOOL([OBJDUMP], [llvm-objdump], [llvm-objdump])
AC_PATH_PROG([ZIP], [zip], [zip])

dnl libtool will try to strip the static lib, which is a problem for
Expand Down
28 changes: 14 additions & 14 deletions contrib/macdeploy/macdeployqtplus
Expand Up @@ -77,7 +77,7 @@ class FrameworkInfo(object):
bundleBinaryDirectory = "Contents/MacOS"

@classmethod
def fromOtoolLibraryLine(cls, line: str) -> Optional['FrameworkInfo']:
def fromLibraryLine(cls, line: str) -> Optional['FrameworkInfo']:
# Note: line must be trimmed
if line == "":
return None
Expand All @@ -88,7 +88,7 @@ class FrameworkInfo(object):

m = cls.reOLine.match(line)
if m is None:
raise RuntimeError(f"otool line could not be parsed: {line}")
raise RuntimeError(f"llvm-objdump line could not be parsed: {line}")

path = m.group(1)

Expand Down Expand Up @@ -120,7 +120,7 @@ class FrameworkInfo(object):
break
i += 1
if i == len(parts):
raise RuntimeError(f"Could not find .framework or .dylib in otool line: {line}")
raise RuntimeError(f"Could not find .framework or .dylib in llvm-objdump line: {line}")

info.frameworkName = parts[i]
info.frameworkDirectory = "/".join(parts[:i])
Expand Down Expand Up @@ -183,23 +183,23 @@ class DeploymentInfo(object):

def getFrameworks(binaryPath: str, verbose: int) -> list[FrameworkInfo]:
if verbose:
print(f"Inspecting with otool: {binaryPath}")
otoolbin=os.getenv("OTOOL", "otool")
otool = run([otoolbin, "-L", binaryPath], stdout=PIPE, stderr=PIPE, text=True)
if otool.returncode != 0:
sys.stderr.write(otool.stderr)
print(f"Inspecting with llvm-objdump: {binaryPath}")
objdump = os.getenv("OBJDUMP", "objdump")
output = run([objdump, "--macho", "--dylibs-used", binaryPath], stdout=PIPE, stderr=PIPE, text=True)
if output.returncode != 0:
sys.stderr.write(output.stderr)
sys.stderr.flush()
raise RuntimeError(f"otool failed with return code {otool.returncode}")
raise RuntimeError(f"llvm-objdump failed with return code {output.returncode}")

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

libraries = []
for line in otoolLines:
for line in lines:
line = line.replace("@loader_path", os.path.dirname(binaryPath))
info = FrameworkInfo.fromOtoolLibraryLine(line.strip())
info = FrameworkInfo.fromLibraryLine(line.strip())
if info is not None:
if verbose:
print("Found framework:")
Expand Down
2 changes: 1 addition & 1 deletion depends/Makefile
Expand Up @@ -233,7 +233,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_
-e 's|@RANLIB@|$(host_RANLIB)|' \
-e 's|@NM@|$(host_NM)|' \
-e 's|@STRIP@|$(host_STRIP)|' \
-e 's|@OTOOL@|$(host_OTOOL)|' \
-e 's|@OBJDUMP@|$(host_OBJDUMP)|' \
-e 's|@INSTALL_NAME_TOOL@|$(host_INSTALL_NAME_TOOL)|' \
-e 's|@DSYMUTIL@|$(host_DSYMUTIL)|' \
-e 's|@build_os@|$(build_os)|' \
Expand Down
2 changes: 1 addition & 1 deletion depends/README.md
Expand Up @@ -48,7 +48,7 @@ The paths are automatically configured and no other options are needed unless ta

#### For macOS cross compilation

sudo apt-get install curl bsdmainutils cmake zip
sudo apt-get install bsdmainutils cmake curl llvm zip

Note: You must obtain the macOS SDK before proceeding with a cross-compile.
Under the depends directory, create a subdirectory named `SDKs`.
Expand Down
4 changes: 2 additions & 2 deletions depends/builders/darwin.mk
Expand Up @@ -3,7 +3,7 @@ build_darwin_CXX:=$(shell xcrun -f clang++) -isysroot$(shell xcrun --show-sdk-pa
build_darwin_AR:=$(shell xcrun -f ar)
build_darwin_RANLIB:=$(shell xcrun -f ranlib)
build_darwin_STRIP:=$(shell xcrun -f strip)
build_darwin_OTOOL:=$(shell xcrun -f otool)
build_darwin_OBJDUMP:=$(shell xcrun -f objdump)
build_darwin_NM:=$(shell xcrun -f nm)
build_darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool)
build_darwin_DSYMUTIL:=$(shell xcrun -f dsymutil)
Expand All @@ -16,7 +16,7 @@ darwin_CXX:=$(shell xcrun -f clang++) -stdlib=libc++ -isysroot$(shell xcrun --sh
darwin_AR:=$(shell xcrun -f ar)
darwin_RANLIB:=$(shell xcrun -f ranlib)
darwin_STRIP:=$(shell xcrun -f strip)
darwin_OTOOL:=$(shell xcrun -f otool)
darwin_OBJDUMP:=$(shell xcrun -f objdump)
darwin_NM:=$(shell xcrun -f nm)
darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool)
darwin_DSYMUTIL:=$(shell xcrun -f dsymutil)
Expand Down
3 changes: 2 additions & 1 deletion depends/builders/default.mk
@@ -1,6 +1,7 @@
default_build_CC = gcc
default_build_CXX = g++
default_build_AR = ar
default_build_OBJDUMP = objdump
default_build_TAR = tar
default_build_RANLIB = ranlib
default_build_STRIP = strip
Expand All @@ -12,7 +13,7 @@ build_$(build_os)_$1 ?= $$(default_build_$1)
build_$(build_arch)_$(build_os)_$1 ?= $$(build_$(build_os)_$1)
build_$1=$$(build_$(build_arch)_$(build_os)_$1)
endef
$(foreach var,CC CXX AR TAR RANLIB NM STRIP SHA256SUM DOWNLOAD OTOOL INSTALL_NAME_TOOL DSYMUTIL TOUCH,$(eval $(call add_build_tool_func,$(var))))
$(foreach var,CC CXX AR TAR RANLIB NM STRIP SHA256SUM DOWNLOAD OBJDUMP INSTALL_NAME_TOOL DSYMUTIL TOUCH,$(eval $(call add_build_tool_func,$(var))))
define add_build_flags_func
build_$(build_arch)_$(build_os)_$1 += $(build_$(build_os)_$1)
build_$1=$$(build_$(build_arch)_$(build_os)_$1)
Expand Down
6 changes: 3 additions & 3 deletions depends/config.site.in
Expand Up @@ -118,9 +118,9 @@ if test -n "@STRIP@"; then
fi

if test "@host_os@" = darwin; then
if test -n "@OTOOL@"; then
OTOOL="@OTOOL@"
ac_cv_path_OTOOL="${OTOOL}"
if test -n "@OBJDUMP@"; then
OBJDUMP="@OBJDUMP@"
ac_cv_path_OBJDUMP="${OBJDUMP}"
fi

if test -n "@INSTALL_NAME_TOOL@"; then
Expand Down
6 changes: 5 additions & 1 deletion depends/hosts/darwin.mk
Expand Up @@ -37,9 +37,13 @@ clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
llvm_config_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-config")

llvm_lib_dir=$(shell $(llvm_config_prog) --libdir)

darwin_OBJDUMP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-objdump")
darwin_INSTALL_NAME_TOOL=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-install-name-tool")
darwin_DSYMUTIL=$(shell $(SHELL) $(.SHELLFLAGS) "command -v dsymutil")
endif

cctools_TOOLS=AR RANLIB STRIP NM OTOOL INSTALL_NAME_TOOL DSYMUTIL
cctools_TOOLS=AR RANLIB STRIP NM

# Make-only lowercase function
lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
Expand Down
2 changes: 1 addition & 1 deletion depends/hosts/default.mk
Expand Up @@ -38,5 +38,5 @@ host_$1 = $$($(host_arch)_$(host_os)_$1)
host_$(release_type)_$1 = $$($(host_arch)_$(host_os)_$(release_type)_$1)
endef

$(foreach tool,CC CXX AR RANLIB STRIP NM OBJCOPY OTOOL INSTALL_NAME_TOOL DSYMUTIL,$(eval $(call add_host_tool_func,$(tool))))
$(foreach tool,CC CXX AR RANLIB STRIP NM OBJCOPY OBJDUMP INSTALL_NAME_TOOL DSYMUTIL,$(eval $(call add_host_tool_func,$(tool))))
$(foreach flags,CFLAGS CXXFLAGS CPPFLAGS LDFLAGS, $(eval $(call add_host_flags_func,$(flags))))
2 changes: 2 additions & 0 deletions depends/packages/native_llvm.mk
Expand Up @@ -18,6 +18,8 @@ define $(package)_stage_cmds
cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin/ && \
cp bin/dsymutil $($(package)_staging_prefix_dir)/bin/$(host)-dsymutil && \
cp bin/llvm-config $($(package)_staging_prefix_dir)/bin/ && \
cp bin/llvm-objdump $($(package)_staging_prefix_dir)/bin/$(host)-objdump && \
cp bin/llvm-install-name-tool $($(package)_staging_prefix_dir)/bin/ && \
cp include/llvm-c/ExternC.h $($(package)_staging_prefix_dir)/include/llvm-c && \
cp include/llvm-c/lto.h $($(package)_staging_prefix_dir)/include/llvm-c && \
cp lib/libLTO.so $($(package)_staging_prefix_dir)/lib/ && \
Expand Down

0 comments on commit f782106

Please sign in to comment.