Skip to content
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

CVC4: Add patches to ease building on AArch64 #54

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ build_boolector() {

build_cvc4() {
pushd repos/CVC4-archived
# Make the get-antlr script work on both x86-64 and AArch64
patch -p1 -i $PATCHES/cvc4-antlr-check-aarch64.patch
# Fix a pointer-to-integer cast in ANTLR
patch -p1 -i $PATCHES/cvc4-antlr-pointer-to-integer-cast.patch
# Add missing #include statements that macos-14's version of Clang++ requires.
patch -p1 -i $PATCHES/cvc4-fix-missing-includes.patch
./contrib/get-antlr-3.4
Expand Down
46 changes: 42 additions & 4 deletions patches/cvc4-antlr-check-aarch64.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,55 @@
diff --git a/contrib/get-antlr-3.4 b/contrib/get-antlr-3.4
index 45dc86583..ea69b4b7f 100755
index 45dc86583..685623f19 100755
--- a/contrib/get-antlr-3.4
+++ b/contrib/get-antlr-3.4
@@ -47,7 +47,7 @@ cd "$ANTLR_HOME_DIR/libantlr3c-3.4"
@@ -26,6 +26,22 @@ if [ -z "${MACHINE_TYPE}" ]; then
MACHINE_TYPE=$(${CONFIG_GUESS_SCRIPT} | sed 's,-.*,,')
fi

+# In addition to config.guess, we also download a more recent version of
+# config.sub. We aren't going to use it directly in this script, but we will
+# copy it into our ANTLR checkout later.
+CONFIG_SUB_SCRIPT="$ANTLR_HOME_DIR/config.sub"
+if ! [ -e "${CONFIG_SUB_SCRIPT}" ]; then
+ mkdir -p "$ANTLR_HOME_DIR"
+ # Attempt to download once
+ webget 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' $CONFIG_SUB_SCRIPT
+ if [ -e "$CONFIG_SUB_SCRIPT" ]; then
+ chmod +x "$CONFIG_SUB_SCRIPT"
+ else
+ echo "$(basename $0): I need an up-to-date version of config/config.sub." >&2
+ exit 1
+ fi
+fi
+
mkdir -p "$INSTALL_DIR/share/java"
webget \
"https://www.antlr3.org/download/antlr-3.4-complete.jar" \
@@ -43,11 +59,22 @@ install_bin "$ANTLR_HOME_DIR/bin/antlr3"
setup_dep \
"https://www.antlr3.org/download/C/libantlr3c-3.4.tar.gz" \
"$ANTLR_HOME_DIR/libantlr3c-3.4"
+# Use more up-to-date config.guess and config.sub scripts that are aware of
+# AArch64 Linux and Darwin.
+cp "${CONFIG_GUESS_SCRIPT}" "$ANTLR_HOME_DIR/libantlr3c-3.4/config.guess"
+cp "${CONFIG_SUB_SCRIPT}" "$ANTLR_HOME_DIR/libantlr3c-3.4/config.sub"
cd "$ANTLR_HOME_DIR/libantlr3c-3.4"

+# By default, ANTLR's configure script will attempt to pass x86-specific flags
+# such as -m64, which do not exist on other architectures (e.g., ARM). We can
+# override this default by passing --disable-abiflags to the configure script.
+if [[ "${MACHINE_TYPE}" != 'x86_64' ]]; then
+ ANTLR_CONFIGURE_ARGS="--disable-abiflags ${ANTLR_CONFIGURE_ARGS}"
+fi
+
# Make antlr3debughandlers.c empty to avoid unreferenced symbols
rm -rf src/antlr3debughandlers.c && touch src/antlr3debughandlers.c
-if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
+if [[ "${MACHINE_TYPE}" == 'x86_64' || "${MACHINE_TYPE}" == 'aarch64' ]]; then
# 64-bit stuff here
./configure --enable-64bit --disable-antlrdebug --prefix="$INSTALL_DIR" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE
else
@@ -67,7 +67,7 @@ fi
@@ -67,7 +94,7 @@ fi
mv "$INSTALL_LIB_DIR/libantlr3c.a" "$INSTALL_LIB_DIR/libantlr3c-static.a"
make clean

Expand All @@ -20,7 +58,7 @@ index 45dc86583..ea69b4b7f 100755
# 64-bit stuff here
./configure --enable-64bit --with-pic --disable-antlrdebug --prefix="$INSTALL_DIR" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE
else
@@ -84,7 +84,7 @@ mv "$INSTALL_LIB_DIR/libantlr3c.la" "$INSTALL_LIB_DIR/libantlr3c.la.orig"
@@ -84,7 +111,7 @@ mv "$INSTALL_LIB_DIR/libantlr3c.la" "$INSTALL_LIB_DIR/libantlr3c.la.orig"
awk '/^old_library=/ {print "old_library='\''libantlr3c-static.a'\''"} /^library_names=/ {print "library_names='\''libantlr3c.a'\''"} !/^old_library=/ && !/^library_names=/ {print}' < "$INSTALL_LIB_DIR/libantlr3c.la.orig" > "$INSTALL_LIB_DIR/libantlr3c.la"
rm "$INSTALL_LIB_DIR/libantlr3c.la.orig"

Expand Down
22 changes: 22 additions & 0 deletions patches/cvc4-antlr-pointer-to-integer-cast.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/src/parser/antlr_line_buffered_input.cpp b/src/parser/antlr_line_buffered_input.cpp
index cdf553880..ba0214dd4 100644
--- a/src/parser/antlr_line_buffered_input.cpp
+++ b/src/parser/antlr_line_buffered_input.cpp
@@ -31,6 +31,7 @@
#include "parser/antlr_line_buffered_input.h"

#include <antlr3.h>
+#include <stdint.h>
#include <iostream>
#include <string>
#include <cassert>
@@ -288,7 +289,7 @@ static void bufferedInputSeek(pANTLR3_INT_STREAM is, ANTLR3_MARKER seekPoint) {
->line_buffer->isPtrBefore(
(uint8_t*)seekPoint, input->line, input->charPositionInLine));

- while ((ANTLR3_MARKER)(input->nextChar) != seekPoint) {
+ while ((ANTLR3_MARKER)((intptr_t)input->nextChar) != seekPoint) {
is->consume(is);
}
}

Loading