Skip to content

Commit 526ff57

Browse files
CVC5: Add multi-arch support
We compile for linux on x64 and arm64 and windows on x64 only. CVC5 is also available on MacOS, but there doesn't seem to be a simple way to cross compile. The same is true for windows on arm64.
1 parent 56088e0 commit 526ff57

File tree

7 files changed

+132
-33
lines changed

7 files changed

+132
-33
lines changed

build/build-maven-publish.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,15 @@ SPDX-License-Identifier: Apache-2.0
229229
<ivy:artifactproperty name="[artifact].revision" value="[revision]"/>
230230
<property name="stage.solver" value="cvc5"/>
231231
<property name="stage.revision" value="${cvc5.revision}"/>
232+
<property name="libDir.x64" value="lib/java/runtime-cvc5/x64"/>
233+
<property name="libDir.arm64" value="lib/java/runtime-cvc5/arm64"/>
232234
<!-- prepare the pom-file -->
233235
<generate-solver-pom-file/>
234236
<!-- then publish the files -->
235237
<stage-solver-file filename="cvc5" fileending="jar"/>
236-
<stage-solver-file filename="libcvc5j" classifier="libcvc5j" fileending="so"/>
238+
<stage-solver-file filename="libcvc5j" classifier="libcvc5j-x64" filedirectory="${libDir.x64}" fileending="so"/>
239+
<stage-solver-file filename="libcvc5j" classifier="libcvc5j-arm64" filedirectory="${libDir.arm64}" fileending="so"/>
240+
<stage-solver-file filename="libcvc5j" classifier="libcvc5j-x64" filedirectory="${libDir.x64}" fileending="dll"/>
237241
</target>
238242

239243
<!--

build/build-publish-solvers/solver-cvc5.xml

+92-24
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ SPDX-License-Identifier: Apache-2.0
1212

1313
<!-- vim: set tabstop=8 shiftwidth=4 expandtab sts=4 filetype=ant fdm=marker: -->
1414
<project name="publish-solvers-cvc5" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
15-
1615
<import file="macros.xml"/>
1716

17+
<property name="cvc5.distDir" value="${ivy.solver.dist.dir}/cvc5"/>
18+
1819
<!-- Build options for CVC5, Reasoning:
1920
- 'production' enable optimization, disables assertions and tracing,
2021
- 'static' build libcvc5 and all dependencies statically,
2122
- 'java-bindings' build the JNI bindings,
2223
- 'auto-download' load all dependencies automatically,
23-
- 'statistics' for the new statistics stuff,
2424
- 'prefix' because I don't want it to use system installed or install system-wide,
2525
Theoretically CVC5s performance should be improvable by using -best (uses the best
2626
known general performance/dependencies) but this can not be combined with auto-download.
@@ -41,6 +41,8 @@ SPDX-License-Identifier: Apache-2.0
4141
The custom revision has to be unique amongst the already known version
4242
numbers from the ivy repository. The script will append the git revision.
4343
</fail>
44+
<checkPathOption pathOption="jdk-linux-arm64.path" defaultPath="/path/to/jdk" targetName="JDK source folder (Linux arm64 version)"/>
45+
<checkPathOption pathOption="jdk-windows-x64.path" defaultPath="/path/to/jdk" targetName="JDK source folder (Windows x64 version)"/>
4446

4547
<!-- get the short commit hash of the cvc5 version used -->
4648
<exec executable="git" dir="${cvc5.path}" outputproperty="cvc5.revision" failonerror="true">
@@ -51,47 +53,113 @@ SPDX-License-Identifier: Apache-2.0
5153
<property name="cvc5.version" value="${cvc5.customRev}-g${cvc5.revision}"/>
5254
<echo message="Building CVC5 in version '${cvc5.version}'"/>
5355

54-
<!-- build CVC5 -->
55-
<echo message="Cleaning old build files"/>
56-
<exec executable="rm" dir="${cvc5.path}" failonerror="true">
56+
<!-- set a path to the build folder and make sure there are no previous build files -->
57+
<property name="cvc5.buildDir" location="${cvc5.path}/build"/>
58+
<fail message="Found `/build` directory in ${cvc5.path}. Please make sure that -Dcvc5.path points to a clean checkout of CVC5 without any build files.">
59+
<condition>
60+
<available file="${cvc5.buildDir}" type="dir"/>
61+
</condition>
62+
</fail>
63+
64+
<!-- build CVC5 for x64 linux -->
65+
<echo message="Building CVC5 for x64 linux"/>
66+
<property name="cvc5.installDir.x64-linux" location="${cvc5.path}/install/x64-linux"/>
67+
<exec executable="./configure.sh" dir="${cvc5.path}" failonerror="true">
68+
<arg value="production"/>
69+
<arg value="--static"/>
70+
<arg value="--java-bindings"/>
71+
<arg value="--auto-download"/>
72+
<arg value="--prefix=${cvc5.installDir.x64-linux}"/>
73+
</exec>
74+
<exec executable="make" dir="${cvc5.buildDir}" failonerror="true">
75+
<arg value="-j4"/>
76+
<arg value="install"/>
77+
</exec>
78+
<exec executable="rm" failonerror="true">
5779
<arg value="-rf"/>
58-
<arg value="build"/>
80+
<arg value="${cvc5.buildDir}"/>
81+
</exec>
82+
<exec executable="strip" dir="${cvc5.installDir.x64-linux}/lib" failonerror="true">
83+
<arg value="libcvc5jni.so"/>
5984
</exec>
6085

61-
<echo message="Configuring and building CVC5 in version '${cvc5.version}'"/>
86+
<!-- build CVC5 for arm64 linux -->
87+
<echo message="Building CVC5 for arm64 linux"/>
88+
<property name="cvc5.installDir.arm64-linux" location="${cvc5.path}/install/arm64-linux"/>
6289
<exec executable="./configure.sh" dir="${cvc5.path}" failonerror="true">
90+
<env key="JNI_HOME" value="${jdk-linux-arm64.path}"/>
6391
<arg value="production"/>
92+
<arg value="--arm64"/>
6493
<arg value="--static"/>
6594
<arg value="--java-bindings"/>
6695
<arg value="--auto-download"/>
67-
<arg value="--statistics"/>
68-
<arg value="--prefix=${cvc5.path}/build/install"/>
96+
<arg value="--prefix=${cvc5.installDir.arm64-linux}"/>
97+
</exec>
98+
<exec executable="make" dir="${cvc5.buildDir}" failonerror="true">
99+
<arg value="-j4"/>
100+
<arg value="install"/>
101+
</exec>
102+
<exec executable="rm" failonerror="true">
103+
<arg value="-rf"/>
104+
<arg value="${cvc5.buildDir}"/>
69105
</exec>
70-
<exec executable="make" dir="${cvc5.path}/build/" failonerror="true">
71-
<arg value="-j4" />
106+
<exec executable="aarch64-linux-gnu-strip" dir="${cvc5.installDir.arm64-linux}/lib" failonerror="true">
107+
<arg value="libcvc5jni.so"/>
108+
</exec>
109+
110+
<!-- build CVC5 for x64 windows -->
111+
<echo message="Building CVC5 for x64 windows"/>
112+
<property name="cvc5.installDir.x64-windows" location="${cvc5.path}/install/x64-windows"/>
113+
<exec executable="./configure.sh" dir="${cvc5.path}" failonerror="true">
114+
<env key="JNI_HOME" value="${jdk-windows-x64.path}"/>
115+
<arg value="production"/>
116+
<arg value="--win64"/>
117+
<arg value="--static"/>
118+
<arg value="--java-bindings"/>
119+
<arg value="--auto-download"/>
120+
<arg value="--prefix=${cvc5.installDir.x64-windows}"/>
121+
</exec>
122+
<exec executable="make" dir="${cvc5.buildDir}" failonerror="true">
123+
<arg value="-j4"/>
124+
<arg value="install"/>
125+
</exec>
126+
<exec executable="rm" failonerror="true">
127+
<arg value="-rf"/>
128+
<arg value="${cvc5.buildDir}"/>
129+
</exec>
130+
<exec executable="x86_64-w64-mingw32-strip" dir="${cvc5.installDir.x64-windows}/bin" failonerror="true">
131+
<arg value="cvc5jni.dll"/>
72132
</exec>
73133

74134
<!-- get the actual jar location as cvc5.jar is just a link -->
75-
<exec executable="readlink" dir="${cvc5.path}/build/src/api/java" outputproperty="cvc5.jar" failonerror="true">
135+
<exec executable="readlink" dir="${cvc5.installDir.x64-linux}/share/java" outputproperty="cvc5.jar" failonerror="true">
76136
<arg value="-f"/>
77137
<arg value="cvc5.jar"/>
78138
</exec>
79139

80140
<!-- copy library files into directory to be published for IVY -->
81-
<echo message="Copying artifact files into current directory"/>
82-
<copy file="${cvc5.path}/build/src/api/java/libcvc5jni.so" tofile="libcvc5j-${cvc5.version}.so"/>
83-
<copy file="${cvc5.jar}" tofile="cvc5-${cvc5.version}.jar"/>
84-
85-
<!-- remove unneeded symbols -->
86-
<echo message="Strip unneeded symbols"/>
87-
<exec executable="strip" dir="./" failonerror="true">
88-
<arg value="libcvc5j-${cvc5.version}.so"/>
89-
</exec>
141+
<echo message="Copying artifact for Ivy release"/>
142+
<copy file="${cvc5.jar}" tofile="${cvc5.distDir}/cvc5-${cvc5.version}.jar"/>
143+
<copy file="${cvc5.installDir.x64-linux}/lib/libcvc5jni.so" tofile="${cvc5.distDir}/x64/libcvc5j-${cvc5.version}.so"/>
144+
<copy file="${cvc5.installDir.arm64-linux}/lib/libcvc5jni.so" tofile="${cvc5.distDir}/arm64/libcvc5j-${cvc5.version}.so"/>
145+
<copy file="${cvc5.installDir.x64-windows}/bin/cvc5jni.dll" tofile="${cvc5.distDir}/x64/libcvc5j-${cvc5.version}.dll"/>
90146
</target>
91147

92148
<target name="publish-cvc5" depends="package-cvc5, load-ivy"
93-
description="Publish CVC5 binaries to Ivy repository.">
94-
<ivy:resolve conf="solver-cvc5" file="solvers_ivy_conf/ivy_cvc5.xml" />
95-
<publishToRepository solverName="CVC5" solverVersion="${cvc5.version}"/>
149+
description="Publish CVC5 binaries to Ivy repository.">
150+
<ivy:resolve conf="solver-cvc5" file="solvers_ivy_conf/ivy_cvc5.xml"/>
151+
<publishToRepository solverName="CVC5" solverVersion="${cvc5.version}" distDir="${cvc5.distDir}"/>
152+
153+
<!--
154+
We additionally provide x64-files without arch-attribute for backwards compatibility,
155+
such that applications can load dependencies without changing their Ivy configuration.
156+
Those files are not part of any direct configuration, but will be resolved if the
157+
arch-attribute is not used.
158+
-->
159+
<copy todir="repository/${ivy.organisation}/${ivy.module}/">
160+
<fileset dir="repository/${ivy.organisation}/${ivy.module}/x64/">
161+
<include name="*-${cvc5.version}.*"/>
162+
</fileset>
163+
</copy>
96164
</target>
97165
</project>

lib/ivy.xml

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ SPDX-License-Identifier: Apache-2.0
4545
<conf name="runtime-z3-x64" extends="core" description="only one solver included"/>
4646
<conf name="runtime-z3-arm64" extends="core" description="only one solver included"/>
4747
<conf name="runtime-cvc4" extends="core" description="only one solver included"/>
48-
<conf name="runtime-cvc5" extends="core" description="only one solver included"/>
48+
<conf name="runtime-cvc5" extends="runtime-cvc5-x64,runtime-cvc5-arm64" description="only one solver included"/>
49+
<conf name="runtime-cvc5-x64" extends="core" description="only one solver included"/>
50+
<conf name="runtime-cvc5-arm64" extends="core" description="only one solver included"/>
4951
<conf name="runtime-boolector" extends="core" description="only one solver included"/>
5052
<conf name="runtime-yices2" extends="core" description="only one solver included"/>
5153
<conf name="runtime-bitwuzla" extends="runtime-bitwuzla-x64,runtime-bitwuzla-arm64" description="only one solver included"/>
@@ -66,10 +68,10 @@ SPDX-License-Identifier: Apache-2.0
6668

6769
<!-- The normal dependencies with all solvers included, except those unter GPL. -->
6870
<conf name="runtime-x64-without-gpl"
69-
extends="runtime-mathsat-x64,runtime-opensmt-x64,runtime-optimathsat,runtime-smtinterpol,runtime-princess,runtime-z3-x64,runtime-cvc4,runtime-cvc5,runtime-boolector,runtime-bitwuzla-x64"
71+
extends="runtime-mathsat-x64,runtime-opensmt-x64,runtime-optimathsat,runtime-smtinterpol,runtime-princess,runtime-z3-x64,runtime-cvc4,runtime-cvc5-x64,runtime-boolector,runtime-bitwuzla-x64"
7072
description="all solvers for x64 architecture included, except those under GPL"/>
7173
<conf name="runtime-arm64-without-gpl"
72-
extends="runtime-mathsat-arm64,runtime-opensmt-arm64,runtime-smtinterpol,runtime-princess,runtime-z3-arm64,runtime-bitwuzla-arm64"
74+
extends="runtime-mathsat-arm64,runtime-opensmt-arm64,runtime-smtinterpol,runtime-princess,runtime-cvc5-arm64,runtime-z3-arm64,runtime-bitwuzla-arm64"
7375
description="all solvers for arm64 architecture included, except those under GPL"/>
7476

7577
<!-- Dependencies needed for building or running tests. -->
@@ -191,7 +193,7 @@ SPDX-License-Identifier: Apache-2.0
191193
<dependency org="org.sosy_lab" name="javasmt-solver-opensmt" rev="2.8.0-sosy0-ge831bf23" conf="runtime-opensmt-x64->solver-opensmt-x64; runtime-opensmt-arm64->solver-opensmt-arm64; contrib->sources,javadoc"/>
192194
<dependency org="org.sosy_lab" name="javasmt-solver-optimathsat" rev="1.7.1-sosy0" conf="runtime-optimathsat->solver-optimathsat" />
193195
<dependency org="org.sosy_lab" name="javasmt-solver-cvc4" rev="1.8-prerelease-2020-06-24-g7825d8f28" conf="runtime-cvc4->solver-cvc4" />
194-
<dependency org="org.sosy_lab" name="javasmt-solver-cvc5" rev="1.2.1-gdc565d916" conf="runtime-cvc5->solver-cvc5"/>
196+
<dependency org="org.sosy_lab" name="javasmt-solver-cvc5" rev="latest-g4c241968d" conf="runtime-cvc5-x64->solver-cvc5-x64; runtime-cvc5-arm64->solver-cvc5-arm64"/>
195197
<dependency org="org.sosy_lab" name="javasmt-solver-boolector" rev="3.2.2-g1a89c229" conf="runtime-boolector->solver-boolector" />
196198
<dependency org="org.sosy_lab" name="javasmt-solver-bitwuzla" rev="0.7.0-13.1-g595512ae" conf="runtime-bitwuzla-x64->solver-bitwuzla-x64; runtime-bitwuzla-arm64->solver-bitwuzla-arm64; contrib->sources,javadoc"/>
197199

lib/native/arm64-linux/libcvc5j.so

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../java/runtime-cvc5/arm64/libcvc5j.so

lib/native/x86_64-linux/libcvc5j.so

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../java/runtime-cvc5/libcvc5j.so
1+
../../java/runtime-cvc5/x64/libcvc5j.so

lib/native/x86_64-windows/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ For MathSAT5:
3939
For Bitwuzla:
4040
- mklink libbitwuzlaj.dll ..\..\java\runtime-bitwuzla\libbitwuzlaj.dll
4141

42+
For CVC5:
43+
44+
- mlink libcvc5j.dll ..\..\java\runtime-cvc5\x64\libcvcj.so
45+
4246
### With a direct copy of the library:
4347

4448
An alternative simple solution (without the need of administrator rights) is to copy over
@@ -57,6 +61,10 @@ For MathSAT5:
5761
For Bitwuzla:
5862
- copy ..\..\java\runtime-bitwuzla\libbitwuzlaj.dll libbitwuzlaj.dll
5963

64+
For CVC5:
65+
66+
- copy ..\..\java\runtime-cvc5\x64\libcvc5j.dll libcvc5j.dll
67+
6068
Or simply use a wildcard:
6169
- copy ..\..\java\runtime-*\*dll .\
6270
- copy ..\..\java\runtime-*\x64\*dll .\

solvers_ivy_conf/ivy_cvc5.xml

+19-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SPDX-License-Identifier: Apache-2.0
1111
-->
1212

1313
<ivy-module version="2.0"
14+
xmlns:e="http://ant.apache.org/ivy/extra"
1415
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1516
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
1617
<info organisation="org.sosy_lab" module="javasmt-solver-cvc5">
@@ -22,12 +23,27 @@ SPDX-License-Identifier: Apache-2.0
2223
</info>
2324

2425
<configurations>
25-
<conf name="solver-cvc5" />
26+
<!-- default config, provides only x64 for backwards-compatibility -->
27+
<conf name="solver-cvc5" extends="solver-cvc5-x64"/>
28+
29+
<!-- main configurations -->
30+
<conf name="solver-cvc5-x64" extends="solver-cvc5-linux-x64, solver-cvc5-windows-x64"/>
31+
<conf name="solver-cvc5-arm64" extends="solver-cvc5-linux-arm64"/>
32+
33+
<!-- basic configurations -->
34+
<conf name="solver-cvc5-linux-x64" extends="solver-cvc5-common"/>
35+
<conf name="solver-cvc5-linux-arm64" extends="solver-cvc5-common"/>
36+
<conf name="solver-cvc5-windows-x64" extends="solver-cvc5-common"/>
37+
38+
<conf name="solver-cvc5-common" visibility="private"/>
2639
</configurations>
2740

2841
<publications defaultconf="solver-cvc5">
29-
<artifact name="libcvc5j" conf="solver-cvc5" type="shared-object" ext="so"/>
30-
<artifact name="cvc5" conf="solver-cvc5"/>
42+
<artifact name="libcvc5j" conf="solver-cvc5-linux-x64" e:arch="x64" type="shared-object" ext="so"/>
43+
<artifact name="libcvc5j" conf="solver-cvc5-linux-arm64" e:arch="arm64" type="shared-object" ext="so"/>
44+
<artifact name="libcvc5j" conf="solver-cvc5-windows-x64" e:arch="x64" type="shared-object" ext="dll"/>
45+
<!-- Java code -->
46+
<artifact name="cvc5" conf="solver-cvc5-common" ext="jar"/>
3147
</publications>
3248

3349
<dependencies></dependencies>

0 commit comments

Comments
 (0)