-
Notifications
You must be signed in to change notification settings - Fork 56
Add the SMT solver Bitwuzla to JavaSMT #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 113 commits
93fd470
68c9b64
b3e6ea3
24a072a
573b6d2
3671f10
5f485ba
44d4996
0a2431d
72772bb
992cbe4
bebae05
bd3c009
33a328a
b5d65f4
9fbbacd
a3146e4
8f0ab73
67043df
7945be0
aac0ffb
126109c
e848771
e7c09f6
0eac793
de2258e
9d3508b
93cc3c0
624a4f0
334ba39
eb326fc
3303561
0b3ce9b
813128d
edf2ad5
2df6010
74b0e3f
f9be507
4c6cc93
93956e7
3121a58
7b311bd
31ae390
528f067
9e36ffb
ee94c0e
fc85356
ce8fe23
a7fdfd7
e290497
edf94e5
01e8224
dd9ee48
b9809f9
860a731
a10b1b3
bd7b287
5916a2e
bdf0313
4f063cb
59865e0
2c85acc
6b98093
89420eb
472891b
dc51ce2
680e75b
6deda76
4087901
14a6dc8
af60de3
3e5d5df
0244742
f39d450
e6d705d
b4a347e
dbe1dce
f71a7be
77781cc
4c223cb
e0a70f6
6137a95
658a3de
4b2f4e1
cbe27b6
3ba8af9
4bf6a71
53cf8c9
9acfed2
b0feace
4066a3e
8a50a25
49f26aa
c3d65dd
c9ea122
49c6bc6
54e90b9
c32a817
1516d6e
5d1d85a
5023509
3ae7860
566363d
10c62f8
961a4ef
0df9aca
c1a256e
6449569
1d86ad2
71a6808
52e09ae
a569f47
807da40
2cd624d
698c73c
371e786
3ef4a9e
b242838
181d750
b979f74
78ee2ea
bfeae7f
37bf4f7
f176424
15505d6
0920e6d
7ff2598
263e60c
35e731e
e948746
b9a81c2
1fdc1eb
048f636
58e73e6
140ba93
6063862
01bacf6
2259126
5b7fb54
18f406c
c2b7709
1ad1d6a
45691bc
b11228b
28c8469
ada557c
7e3499e
454833d
ba8be95
a0b02d3
fb8376b
4c9622f
dd009bd
b2479c6
18372ac
0d9a64b
3d9a1dd
9e8d756
261eb52
1036d43
161d319
09d0690
8a653de
0097668
7162b64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,230 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
|
|
||
| <!-- | ||
| This file is part of JavaSMT, | ||
| an API wrapper for a collection of SMT solvers: | ||
| https://github.com/sosy-lab/java-smt | ||
|
|
||
| SPDX-FileCopyrightText: 2024 Dirk Beyer <https://www.sosy-lab.org> | ||
|
|
||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| <!-- vim: set tabstop=8 shiftwidth=4 expandtab sts=4 filetype=ant fdm=marker: --> | ||
| <project name="publish-solvers-bitwuzla" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant"> | ||
|
|
||
| <import file="macros.xml"/> | ||
|
|
||
| <!-- Determine version and build the Bitwuzla binaries --> | ||
| <target name="build-bitwuzla"> | ||
| <fail unless="bitwuzla.path"> | ||
| Please specify the path to Bitwuzla with the flag -Dbitwuzla.path=/path/to/bitwuzla. | ||
| The path has to point to the root Bitwuzla folder, i.e., | ||
| a checkout of the official git repositoy from 'https://github.com/bitwuzla/bitwuzla'. | ||
| Note that shell substitutions do not work and a full absolute path has to be specified. | ||
| </fail> | ||
| <fail unless="bitwuzla.customRev"> | ||
| Please specify a custom revision with the flag -Dbitwuzla.customRev=XXX. | ||
| The custom revision has to be unique amongst the already known version | ||
| numbers from the ivy repository. The script will append the git revision. | ||
| </fail> | ||
| <fail unless="gmp.path"> | ||
| Please specify the path to GMP with the flag -Dgmp.path=/path/to/gmp. | ||
| The path has to point to the root GMP folder with version equal to or larger than 6.1. | ||
| Note that shell substitutions do not work and a full absolute path has to be specified. | ||
| </fail> | ||
|
|
||
| <!-- get a naive version --> | ||
| <exec executable="git" dir="${bitwuzla.path}" outputproperty="bitwuzla.revision" | ||
| failonerror="true"> | ||
| <arg value="show"/> | ||
| <arg value="-s"/> | ||
| <arg value="--format=%h"/> | ||
| </exec> | ||
| <property name="bitwuzla.version" value="${bitwuzla.customRev}-g${bitwuzla.revision}"/> | ||
| <echo message="Building Bitwuzla in version '${bitwuzla.version}'"/> | ||
|
|
||
| <!-- path to our local directory in lib/native --> | ||
| <property name="source.path" value="${user.dir}/lib/native/source/libbitwuzla"/> | ||
|
|
||
| <!-- build bitwuzla --> | ||
| <exec executable="./configure.py" dir="${bitwuzla.path}" failonerror="true"> | ||
| <arg value="--shared"/> | ||
| <arg value="--wipe"/> | ||
| <arg value="--prefix"/> | ||
| <arg value="${bitwuzla.path}/install"/> | ||
| </exec> | ||
| <exec executable="meson" dir="${bitwuzla.path}/build/" failonerror="true"> | ||
| <arg value="compile"/> | ||
| </exec> | ||
| <exec executable="meson" dir="${bitwuzla.path}/build/" failonerror="true"> | ||
| <arg value="install"/> | ||
| </exec> | ||
|
|
||
| <!-- copy bitwuzla include files to the source tree --> | ||
| <delete dir="${source.path}/include" quiet="true"/> | ||
| <copy todir="${source.path}"> | ||
| <fileset dir="${bitwuzla.path}/install" includes="include/**"/> | ||
| </copy> | ||
|
|
||
| <!-- check if -Dbitwuzla.rebuildWrapper=on was used--> | ||
| <condition property="rebuild"> | ||
| <istrue value="${bitwuzla.rebuildWrapper}"/> | ||
| </condition> | ||
| </target> | ||
|
|
||
| <!-- Run swig to generate a new wrapper. Only executed if rebuildWrapper was specified. --> | ||
| <target name="build-wrapper" if="rebuild" depends="build-bitwuzla"> | ||
| <!-- create ouput directory for the swig proxies --> | ||
| <delete dir="$source.path}/src" quiet="true"/> | ||
| <mkdir dir="${source.path}/src/org/sosy_lab/java_smt/solvers/bitwuzla/api"/> | ||
|
|
||
| <!-- run swig to generate java files and the c wrapper --> | ||
| <exec executable="swig" dir="${source.path}" failonerror="true"> | ||
| <arg value="-java"/> | ||
| <arg value="-c++"/> | ||
| <arg value="-package"/> | ||
| <arg value="org.sosy_lab.java_smt.solvers.bitwuzla.api"/> | ||
| <arg value="-outdir"/> | ||
| <arg value="src/org/sosy_lab/java_smt/solvers/bitwuzla/api"/> | ||
| <arg value="-o"/> | ||
| <arg value="bitwuzla_wrap.cpp"/> | ||
| <arg value="bitwuzla.i"/> | ||
| </exec> | ||
|
|
||
| <!-- apply patch for the phantom reference issue --> | ||
| <!-- FIXME: This will lead to memory leaks. We should look for a proper fix. --> | ||
|
baierd marked this conversation as resolved.
|
||
| <exec executable="patch" failonerror="true"> | ||
| <arg value="-p0"/> | ||
| <arg value="-i"/> | ||
| <arg value="lib/native/source/libbitwuzla/phantomReferences.patch"/> | ||
| </exec> | ||
| </target> | ||
|
|
||
| <!-- Skip rebuilding the swig header if rebuildWrapper was not specified --> | ||
| <target name="skip-wrapper" unless="rebuild" depends="build-bitwuzla"> | ||
| <echo>WARNING: Skipping the build step for the SWIG wrapper. | ||
| If the Bitwuzla API has changed since the last release the wrapper should be updated. Use | ||
| option -Dbitwuzla.rebuildWrapper to run SWIG and automatically generate a new wrapper.</echo> | ||
| </target> | ||
|
|
||
| <!-- Continue with the build and package everything --> | ||
| <target name="package-bitwuzla" depends="build-wrapper, skip-wrapper"> | ||
| <!-- compile java proxies and create jar file --> | ||
| <mkdir dir="${source.path}/build"/> | ||
| <javac release="11" srcdir="${source.path}/src/" destdir="${source.path}/build" includeantruntime="false" | ||
| failonerror="true"> | ||
| <include name="org/sosy_lab/java_smt/solvers/bitwuzla/api/*.java"/> | ||
| </javac> | ||
| <jar destfile="bitwuzla-${bitwuzla.version}.jar" basedir="${source.path}/build"/> | ||
| <delete dir="${source.path}/build"/> | ||
|
|
||
| <!-- generate and package javadoc documentation --> | ||
| <delete dir="${source.path}/doc"/> | ||
| <mkdir dir="${source.path}/doc"/> | ||
| <javadoc sourcepath="${source.path}/src" destdir="${source.path}/doc"/> | ||
| <jar destfile="bitwuzla-${bitwuzla.version}-javadoc.jar" basedir="${source.path}/doc"/> | ||
| <delete dir="${source.path}/doc"/> | ||
|
|
||
| <!-- package swig generated source code --> | ||
| <jar destfile="bitwuzla-${bitwuzla.version}-sources.jar" basedir="${source.path}/src"/> | ||
|
|
||
| <!-- compile the swig wrapper --> | ||
| <exec executable="g++" dir="${source.path}" failonerror="true"> | ||
| <arg value="-fPIC"/> | ||
| <arg value="-c"/> | ||
| <arg value="bitwuzla_wrap.cpp"/> | ||
| <arg value="-I${source.path}/include"/> | ||
| <arg value="-I${gmp.path}"/> | ||
| <arg value="-I${java.home}/include"/> | ||
| <arg value="-I${java.home}/include/linux"/> | ||
| </exec> | ||
|
|
||
| <!-- link the wrapper to create libbitwuzlaJNI.so --> | ||
| <exec executable="g++" dir="${source.path}" failonerror="true"> | ||
| <arg value="-shared"/> | ||
| <arg value="-o"/> | ||
| <arg value="libbitwuzlaJNI.so"/> | ||
| <arg value="bitwuzla_wrap.o"/> | ||
| <arg value="-L${bitwuzla.path}/install/lib/x86_64-linux-gnu"/> | ||
| <arg value="-lbitwuzla"/> | ||
| <arg value="-Wl,-z,defs"/> | ||
| </exec> | ||
|
|
||
| <!-- patch JNI library as it fails to do later for some reason --> | ||
| <exec executable="patchelf" failonerror="true"> | ||
| <arg value="--set-rpath"/> | ||
| <arg value="$ORIGIN"/> | ||
| <arg value="--replace-needed"/><arg value="libbitwuzla.so.0"/><arg value="libbitwuzla.so"/> | ||
| <arg value="${source.path}/libbitwuzlaJNI.so"/> | ||
| </exec> | ||
| <exec executable="patchelf" failonerror="true"> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kfriedberger we currently execute
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no concrete idea about it, just a guess: it is possible that there are multiple entries in the library and patchelf only changes the first one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I wouldn't trust For actually inspecting the binary, try using different tools. Maybe |
||
| <arg value="--set-rpath"/> | ||
| <arg value="$ORIGIN"/> | ||
| <arg value="--replace-needed"/><arg value="libbitwuzla.so.0"/><arg value="libbitwuzla.so"/> | ||
| <arg value="${source.path}/libbitwuzlaJNI.so"/> | ||
| </exec> | ||
|
|
||
| <!-- copy library files into directory to be published for Ivy --> | ||
| <move file="${source.path}/libbitwuzlaJNI.so" | ||
| tofile="libbitwuzlaJNI-${bitwuzla.version}.so" | ||
| failonerror="true"/> | ||
| <copy file="${bitwuzla.path}/build/src/libbitwuzla.so.0" | ||
| tofile="libbitwuzla-${bitwuzla.version}.so" | ||
| failonerror="true"/> | ||
| <copy file="${bitwuzla.path}/build/src/lib/libbitwuzlals.so" | ||
| tofile="libbitwuzlals-${bitwuzla.version}.so" | ||
| failonerror="true"/> | ||
| <copy file="${bitwuzla.path}/build/src/lib/libbitwuzlabv.so" | ||
| tofile="libbitwuzlabv-${bitwuzla.version}.so" | ||
| failonerror="true"/> | ||
| <copy file="${bitwuzla.path}/build/src/lib/libbitwuzlabb.so" | ||
| tofile="libbitwuzlabb-${bitwuzla.version}.so" | ||
| failonerror="true"/> | ||
| <copy file="${gmp.path}/.libs/libgmp.so.10.5.0" | ||
| tofile="libgmp-${bitwuzla.version}.so" | ||
| failonerror="true"/> | ||
|
|
||
| <!-- patch all other libraries --> | ||
| <exec executable="patchelf" failonerror="true"> | ||
| <arg value="--set-rpath"/> | ||
| <arg value="$ORIGIN"/> | ||
| <arg value="libgmp-${bitwuzla.version}.so"/> | ||
| </exec> | ||
| <exec executable="patchelf" failonerror="true"> | ||
| <arg value="--set-rpath"/> | ||
| <arg value="$ORIGIN"/> | ||
| <arg value="libbitwuzlabb-${bitwuzla.version}.so"/> | ||
| </exec> | ||
| <exec executable="patchelf" failonerror="true"> | ||
| <arg value="--set-rpath"/> | ||
| <arg value="$ORIGIN"/> | ||
| <arg value="--replace-needed"/> | ||
| <arg value="libgmp.so.10"/> | ||
| <arg value="libgmp.so"/> | ||
| <arg value="libbitwuzlabv-${bitwuzla.version}.so"/> | ||
| </exec> | ||
| <exec executable="patchelf" failonerror="true"> | ||
| <arg value="--set-rpath"/> | ||
| <arg value="$ORIGIN"/> | ||
| <arg value="--replace-needed"/> | ||
| <arg value="libgmp.so.10"/> | ||
| <arg value="libgmp.so"/> | ||
| <arg value="libbitwuzlals-${bitwuzla.version}.so"/> | ||
| </exec> | ||
| <exec executable="patchelf" failonerror="true"> | ||
| <arg value="--set-rpath"/> | ||
| <arg value="$ORIGIN"/> | ||
| <arg value="--replace-needed"/> | ||
| <arg value="libgmp.so.10"/> | ||
| <arg value="libgmp.so"/> | ||
| <arg value="libbitwuzla-${bitwuzla.version}.so"/> | ||
| </exec> | ||
| </target> | ||
|
|
||
| <target name="publish-bitwuzla" depends="package-bitwuzla, load-ivy" | ||
| description="Publish Bitwuzla binaries to Ivy repository."> | ||
| <ivy:resolve conf="solver-bitwuzla" file="solvers_ivy_conf/ivy_bitwuzla.xml"/> | ||
| <publishToRepository solverName="Bitwuzla" solverVersion="${bitwuzla.version}"/> | ||
| </target> | ||
| </project> | ||
Uh oh!
There was an error while loading. Please reload this page.