Aurelien Jarno: > On 2020-01-04 12:37, Ximin Luo wrote: >> Aurelien Jarno: >>> On 2020-01-04 01:56, Ximin Luo wrote: >>>> [..] >> >> Mirroring our IRC discussion on #debian-ports for the record: >> >> - I disabled java on riscv64 because I couldn't make it work when >> cross-building from amd64 to riscv64, but it was during an early part of my >> experimentation and perhaps you are right and it doesn't have to be disabled. > > I have actually found that while the dependencies are there, the > java packages are not built. I have verified they build fine on riscv64. > Please find the patch attached. >
Cross-compiling still doesn't work for the java bindings, but I've managed to fix that separately. Please see my new patch, attached. This should be applied together with Aurelien's 2 patches, in any order. My old patches from the original post can be dropped. (For the ocaml bindings, the entire toolchain doesn't support cross-compiling, so it is still disabled in the <cross> Build-Profile, same as my original patch.) X -- GPG: ed25519/56034877E1F87C35 GPG: rsa4096/1318EFAC5FBBDBCE https://github.com/infinity0/pubkeys.git
>From 75a25ca3b28ddeea54e211525953cac7b04d2631 Mon Sep 17 00:00:00 2001 From: Ximin Luo <infini...@debian.org> Date: Sat, 4 Jan 2020 01:07:50 +0000 Subject: [PATCH] support cross-compiling --- debian/control | 9 +++++---- debian/rules | 50 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/debian/control b/debian/control index 4394446..dce1815 100644 --- a/debian/control +++ b/debian/control @@ -5,10 +5,10 @@ Maintainer: LLVM Packaging Team <pkg-llvm-t...@lists.alioth.debian.org> Uploaders: Fabian Wolff <fabi.wo...@arcor.de>, Michael Tautschnig <m...@debian.org> Build-Depends: debhelper-compat (= 12), - dh-python, python3, - javahelper [!hppa !hurd-i386 !m68k !sh4], - default-jdk [!hppa !hurd-i386 !m68k !sh4], - ocaml-nox, dh-ocaml, ocaml-findlib, libzarith-ocaml-dev + dh-python:all, python3:native, + javahelper:all [!hppa !hurd-i386 !m68k !sh4], + default-jdk-headless:native [!hppa !hurd-i386 !m68k !sh4], + ocaml-nox <!cross>, dh-ocaml <!cross>, ocaml-findlib <!cross>, libzarith-ocaml-dev <!cross>, Standards-Version: 4.4.1 Homepage: https://github.com/Z3Prover/z3 Vcs-Git: https://salsa.debian.org/pkg-llvm-team/z3.git @@ -78,6 +78,7 @@ Package: libz3-ocaml-dev Section: ocaml Architecture: any Depends: libz3-dev (= ${binary:Version}), ${misc:Depends}, ${ocaml:Depends}, ${shlibs:Depends} +Build-Profiles: <!cross> Recommends: ocaml-findlib Description: theorem prover from Microsoft Research - OCaml bindings Z3 is a state-of-the art theorem prover from Microsoft Research. See the z3 diff --git a/debian/rules b/debian/rules index 31167b0..65f52d2 100755 --- a/debian/rules +++ b/debian/rules @@ -8,26 +8,38 @@ export DEB_CXXFLAGS_MAINT_APPEND = -fPIC DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) +# Support cross-compiling. This wouldn't be necessary with cmake which already +# has cross-compiling integration in Debian, but we're using upstream's custom +# Makefiles, so have to set these things ourselves. +export CXX=$(DEB_HOST_GNU_TYPE)-g++ +export CC=$(DEB_HOST_GNU_TYPE)-gcc +export AR=$(DEB_HOST_GNU_TYPE)-ar + +WITH_DH = python3 +MK_MAKE = --python --pypkgdir=$(CURDIR)/debian/tmp/usr/lib/python3/dist-packages + ifneq (,$(shell dh_listpackages -a | grep libz3-jni)) - WITH_JAVA ?= yes + WITH_JAVA := yes + WITH_DH := $(WITH_DH),javahelper + MK_MAKE += --java else - WITH_JAVA ?= no + WITH_JAVA := no +endif + +ifeq (,$(filter cross,$(DEB_BUILD_PROFILES))) + WITH_OCAML := yes + WITH_DH := $(WITH_DH),ocaml + MK_MAKE += --ml +else + WITH_OCAML := no endif %: - if [ $(WITH_JAVA) = yes ]; then \ - dh $@ --parallel --with python3,javahelper,ocaml; \ - else \ - dh $@ --parallel --with python3,ocaml; \ - fi + dh $@ --parallel --with $(WITH_DH); override_dh_auto_configure: sed -i 's/^DOTNET_ENABLED=.*/DOTNET_ENABLED=False/' scripts/mk_util.py; \ - if [ $(WITH_JAVA) = yes ]; then \ - python3 scripts/mk_make.py --python --pypkgdir=$(CURDIR)/debian/tmp/usr/lib/python3/dist-packages --java --ml --prefix=$(CURDIR)/debian/tmp/usr; \ - else \ - python3 scripts/mk_make.py --python --pypkgdir=$(CURDIR)/debian/tmp/usr/lib/python3/dist-packages --ml --prefix=$(CURDIR)/debian/tmp/usr; \ - fi + python3 scripts/mk_make.py --prefix=$(CURDIR)/debian/tmp/usr $(MK_MAKE) sed -i 's/^SLINK_FLAGS=/SLINK_FLAGS=$$(LDFLAGS) -fPIC /' build/config.mk echo 'libz3$$(SO_EXT): SLINK_FLAGS += -Wl,-soname,libz3.so.4' >> build/Makefile printf '%%:\n\t$$(MAKE) -C build $$@\n' > Makefile @@ -42,7 +54,7 @@ override_dh_clean: $(RM) Makefile scripts/*.pyc $(RM) -r build $(RM) src/api/python/*.pyc - $(RM) \ + $(RM) -f \ src/api/api_commands.cpp \ src/api/api_log_macros.cpp \ src/api/api_log_macros.h \ @@ -130,16 +142,20 @@ override_dh_auto_install: mv debian/tmp/usr/lib/libz3.so debian/tmp/usr/lib/libz3.so.4 ln -s libz3.so.4 debian/tmp/usr/lib/libz3.so mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/jni - -mv debian/tmp/usr/lib/libz3java.so* \ +ifeq (yes,$(WITH_JAVA)) + mv debian/tmp/usr/lib/libz3java.so* \ debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/jni/ +endif mv debian/tmp/usr/lib/libz3.so* \ debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/ override_dh_install: dh_install - -cp build/api/ml/*.cmxa debian/libz3-ocaml-dev/usr/lib/ocaml/z3/ - -cp build/api/ml/*.cmx debian/libz3-ocaml-dev/usr/lib/ocaml/z3/ - -sed -i 's/^linkopts =.*/linkopts = "-cclib -L\/usr\/lib"/' debian/libz3-ocaml-dev/usr/lib/ocaml/z3/META +ifeq (yes,$(WITH_OCAML)) + cp build/api/ml/*.cmxa debian/libz3-ocaml-dev/usr/lib/ocaml/z3/ + cp build/api/ml/*.cmx debian/libz3-ocaml-dev/usr/lib/ocaml/z3/ + sed -i 's/^linkopts =.*/linkopts = "-cclib -L\/usr\/lib"/' debian/libz3-ocaml-dev/usr/lib/ocaml/z3/META +endif override_dh_installchangelogs: dh_installchangelogs RELEASE_NOTES -- 2.24.1