Skip to content

Instantly share code, notes, and snippets.

@liusheng
Last active December 19, 2019 08:11
Show Gist options
  • Save liusheng/58c39f4f4c84a5a238e49a086eaea664 to your computer and use it in GitHub Desktop.
Save liusheng/58c39f4f4c84a5a238e49a086eaea664 to your computer and use it in GitHub Desktop.
builds kudu on ubuntu of aarch64 platform
#!/bin/bash -ex
# print g++ version
gcc --version
g++ --version
apt-get -y install autoconf automake curl flex gdb git \
libsasl2-dev libsasl2-modules libsasl2-modules-gssapi-mit libssl-dev libtool \
lsb-release make ntp openjdk-8-jdk openssl patch pkg-config python rsync unzip vim-common cmake
DEBIAN_FRONTEND=noninteractive apt-get -y install krb5-admin-server krb5-kdc krb5-user libkrb5-dev
# install crcutil from ubuntu repository
apt-get install -y libcrcutil-dev
# building docs required
apt-get install -y doxygen gem graphviz ruby-dev xsltproc zlib1g-dev
apt-get install openjdk-11-jdk -y
export JAVA_HOME=`dirname $(dirname $(update-alternatives --list javac |grep java-11))`
git clone https://github.com/apache/kudu
cd kudu
# thirdparty/build-if-necessary.sh
mkdir -p build/debug
cd build/debug
cmake ../..
make -j4
--- thirdparty/download-thirdparty.sh
+++ thirdparty/download-thirdparty.sh
@@ -297,12 +297,13 @@ fetch_and_patch \
$CURL_PATCHLEVEL \
"autoreconf -fvi"
-CRCUTIL_PATCHLEVEL=1
+CRCUTIL_PATCHLEVEL=2
fetch_and_patch \
crcutil-${CRCUTIL_VERSION}.tar.gz \
$CRCUTIL_SOURCE \
$CRCUTIL_PATCHLEVEL \
- "patch -p0 < $TP_DIR/patches/crcutil-fix-libtoolize-on-osx.patch"
+ "patch -p0 < $TP_DIR/patches/crcutil-fix-libtoolize-on-osx.patch" \
+ "patch -p0 < $TP_DIR/patches/crcutil-support-on-aarch64.patch"
LIBUNWIND_PATCHLEVEL=1
fetch_and_patch \
--- thirdparty/patches/crcutil-support-on-aarch64.patch
+++ thirdparty/patches/crcutil-support-on-aarch64.patch
@@ -0,0 +1,112 @@
+--- autogen.sh
++++ autogen.sh
+@@ -83,12 +83,14 @@
+ echo>${target} "ACLOCAL_AMFLAGS=-I m4"
+
+ # --pedantic -std=c99?
+-crcutil_flags="-DCRCUTIL_USE_MM_CRC32=1 -Wall -msse2 -Icode -Iexamples -Itests"
++crcutil_flags="-DCRCUTIL_USE_MM_CRC32=1 -Wall -Icode -Iexamples -Itests"
+ crcutil_flags="${crcutil_flags} -O3"
+-if [[ "$IS_CLANG" = "0" && "$(${CXX} -dumpversion)" > "4.4.9" ]]; then
+- crcutil_flags="${crcutil_flags} -mcrc32"
++if [[ "$(uname -p)" == "aarch64" ]]; then
++ crcutil_flags="${crcutil_flags} -march=armv8-a"
++elif [[ "$IS_CLANG" = "0" && "$(${CXX} -dumpversion)" > "4.4.9" ]]; then
++ crcutil_flags="${crcutil_flags} -msse2 -mcrc32"
+ elif [[ "$IS_CLANG" = "1" ]]; then
+- crcutil_flags="${crcutil_flags} -msse4.2"
++ crcutil_flags="${crcutil_flags} -msse2 -msse4.2"
+ fi
+
+ echo>>${target} "AM_CXXFLAGS=${crcutil_flags}"
+--- code/crc32c_sse4.h
++++ code/crc32c_sse4.h
+@@ -22,7 +22,7 @@
+ #include "gf_util.h" // base types, gf_util class, etc.
+ #include "crc32c_sse4_intrin.h" // _mm_crc32_u* intrinsics
+
+-#if HAVE_I386 || HAVE_AMD64
++#if HAVE_I386 || HAVE_AMD64 || HAVE_AARCH64
+
+ #if CRCUTIL_USE_MM_CRC32
+
+@@ -247,6 +247,6 @@ class RollingCrc32cSSE4 {
+
+ } // namespace crcutil
+
+-#endif // HAVE_I386 || HAVE_AMD64
++#endif // HAVE_I386 || HAVE_AMD64 || HAVE_AARCH64
+
+ #endif // CRCUTIL_CRC32C_SSE4_H_
+--- code/platform.h
++++ code/platform.h
+@@ -45,6 +45,13 @@
+ #endif // defined(__amd64__) || defined(_M_AMD64)
+ #endif // defined(HAVE_AMD64)
+
++#if !defined(HAVE_AARCH64)
++#if defined(__aarch64__)
++#define HAVE_AARCH64 1
++#else
++#define HAVE_AARCH64 0
++#endif // defined(__aarch64__)
++#endif // defined(HAVE_AARCH64)
+
+ #if HAVE_AMD64 || HAVE_I386
+ #if defined(_MSC_VER)
+--- code/crc32c_sse4.cc
++++ code/crc32c_sse4.cc
+@@ -18,7 +18,7 @@
+
+ #include "crc32c_sse4.h"
+
+-#if HAVE_I386 || HAVE_AMD64
++#if HAVE_I386 || HAVE_AMD64 || HAVE_AARCH64
+
+ namespace crcutil {
+
+@@ -363,4 +363,4 @@ void RollingCrc32cSSE4::Init(const Crc32cSSE4 &crc,
+
+ } // namespace crcutil
+
+-#endif // HAVE_I386 || HAVE_AMD64
++#endif // HAVE_I386 || HAVE_AMD64 || HAVE_AARCH64
+--- code/crc32c_sse4_intrin.h
++++ code/crc32c_sse4_intrin.h
+@@ -20,7 +20,7 @@
+ #include "platform.h"
+ #include "base_types.h"
+
+-#if CRCUTIL_USE_MM_CRC32 && (HAVE_I386 || HAVE_AMD64)
++#if CRCUTIL_USE_MM_CRC32 && (HAVE_I386 || HAVE_AMD64 || HAVE_AARCH64)
+
+ #if defined(_MSC_VER) || defined(__SSE4_2__)
+
+@@ -94,6 +94,6 @@ __forceinline uint32 _mm_crc32_u8(uint32 crc, uint8 value) {
+
+ #endif
+
+-#endif // CRCUTIL_USE_MM_CRC32 && (HAVE_I386 || HAVE_AMD64)
++#endif // CRCUTIL_USE_MM_CRC32 && (HAVE_I386 || HAVE_AMD64 || HAVE_AARCH64)
+
+ #endif // CRCUTIL_CRC32C_SSE4_INTRIN_H_
+--- examples/interface2.cc
++++ examples/interface.cc
+@@ -268,7 +268,7 @@
+ #endif // !HAVE_SSE2
+ }
+
+-#if CRCUTIL_USE_MM_CRC32 && (HAVE_I386 || HAVE_AMD64)
++#if CRCUTIL_USE_MM_CRC32 && (HAVE_I386 || HAVE_AMD64 || HAVE_AARCH64)
+ if (use_sse4_2 &&
+ degree == Crc32cSSE4::FixedDegree() &&
+ poly_lo == Crc32cSSE4::FixedGeneratingPolynomial() &&
+@@ -284,7 +284,7 @@
+ static_cast<size_t>(roll_length),
+ allocated_memory);
+ }
+-#endif // CRCUTIL_USE_MM_CRC32 && (HAVE_I386 || HAVE_AMD64)
++#endif // CRCUTIL_USE_MM_CRC32 && (HAVE_I386 || HAVE_AMD64 || HAVE_AARCH64)
+
+ if (poly_hi != 0 || (degree != 64 && (poly_lo >> degree) != 0)) {
+ return NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment