Skip to content

Commit

Permalink
Added 64bit build
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicletz committed Sep 6, 2021
1 parent d02a3a8 commit 13aaea7
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/otp
/arm64-v8a
/armeabi-v7a
/erl_crash.dump
*.so
Expand Down
26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ CC=ccache gcc

EXCLUDE=--exclude "*/examples/*" --exclude "*.beam" --exclude "*.h" --exclude "*.erl" --exclude "*.c" --exclude "*.a" --exclude "*.hrl"

ANDROID_ARM=armeabi-v7a
ANDROID_ARM64=arm64-v8a

armeabi-v7a/liberlang.so:
docker build -t liberlang .
mkdir -p armeabi-v7a
docker run --rm --entrypoint tar liberlang c -C ./release/arm-unknown-linux-androideabi/erts-12.0/bin . | tar x -C armeabi-v7a
docker run --rm --entrypoint find liberlang ./release/arm-unknown-linux-androideabi/ -name "*.so" -exec tar c "{}" + | tar x -C armeabi-v7a
# OpenSSL is now statically linked
# docker run --rm --entrypoint find liberlang /usr/local/openssl/ -name "*.so*" -exec tar c "{}" + | tar x -C armeabi-v7a
mv armeabi-v7a/beam.smp armeabi-v7a/liberlang.so
# docker run --rm --entrypoint tar liberlang c $(EXCLUDE) -C /work/otp/release/arm-unknown-linux-androideabi/ . > armeabi-v7a/otp.tar
all: ${ANDROID_ARM}/liberlang.so ${ANDROID_ARM64}/liberlang.so

${ANDROID_ARM}/liberlang.so:
docker build -t liberlang -f xcomp/android-arm.dockerfile .
mkdir -p ${ANDROID_ARM}
docker run --rm --entrypoint tar liberlang c -C ./release/arm-unknown-linux-androideabi/erts-12.0/bin . | tar x -C ${ANDROID_ARM}
docker run --rm --entrypoint find liberlang ./release/arm-unknown-linux-androideabi/ -name "*.so" -exec tar c "{}" + | tar x -C ${ANDROID_ARM}
mv ${ANDROID_ARM}/beam.smp ${ANDROID_ARM}/liberlang.so

${ANDROID_ARM64}/liberlang.so:
docker build -t liberlang64 -f xcomp/android-arm64.dockerfile .
mkdir -p ${ANDROID_ARM64}
docker run --rm --entrypoint tar liberlang64 c -C ./release/aarch64-unknown-linux-android/erts-12.0/bin . | tar x -C ${ANDROID_ARM64}
docker run --rm --entrypoint find liberlang64 ./release/aarch64-unknown-linux-android/ -name "*.so" -exec tar c "{}" + | tar x -C ${ANDROID_ARM64}
mv ${ANDROID_ARM64}/beam.smp ${ANDROID_ARM64}/liberlang64.so

otp:
git clone --depth 1 -b diode/beta https://github.com/diodechain/otp.git
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile → xcomp/android-arm.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ FROM dockcross/android-arm
# ENV
ENV NDK_ROOT $CROSS_ROOT
ENV ANDROID_NDK_HOME $CROSS_ROOT
# ENV NDK_ABI_PLAT androideabi$ANDROID_NDK_API
ENV NDK_ABI_PLAT androideabi21
ENV PATH $NDK_ROOT/bin:$PATH
ENV FC= CPP= LD= CC=clang AR=ar

# CC=/usr/arm-linux-androideabi/bin/arm-linux-androideabi-clang

# Setting up openssl
COPY install_openssl.sh /work/
RUN ARCH="android-arm -D__ANDROID_API__=21" ./install_openssl.sh

# RUN git clone --depth 1 -b diode/beta https://github.com/diodechain/otp.git
# Fetching OTP
RUN git clone --depth 1 -b diode/beta https://github.com/diodechain/otp.git

# We need -z global for liberlang.so because:
Expand Down
40 changes: 40 additions & 0 deletions xcomp/android-arm64.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM dockcross/android-arm64

# ENV
ENV NDK_ROOT $CROSS_ROOT
ENV ANDROID_NDK_HOME $CROSS_ROOT
ENV NDK_ABI_PLAT android23
ENV PATH $NDK_ROOT/bin:$PATH
ENV FC= CPP= LD= CC=clang AR=ar

# Setting up openssl
COPY install_openssl.sh /work/
# OpenSSL arm64 fails to detect this:
RUN cp ${NDK_ROOT}/bin/llvm-ar ${NDK_ROOT}/bin/aarch64-linux-android-ar
RUN cp ${NDK_ROOT}/bin/llvm-ranlib ${NDK_ROOT}/bin/aarch64-linux-android-ranlib
RUN ARCH="-D__ANDROID_API__=23 android-arm64" ./install_openssl.sh

# Fetching OTP
RUN git clone --depth 1 -b diode/beta https://github.com/diodechain/otp.git

# We need -z global for liberlang.so because:
# https://android-ndk.narkive.com/iNWj05IV/weak-symbol-linking-when-loading-dynamic-libraries
# https://android.googlesource.com/platform/bionic/+/30b17e32f0b403a97cef7c4d1fcab471fa316340/linker/linker_namespaces.cpp#100
ENV CFLAGS="-Os -fPIC" CXXFLAGS="-Os -fPIC" LDFLAGS="-z global"
# ENV LIBS -L$NDK_ROOT/lib64/clang/11.0.5/lib/linux/ /usr/local/openssl/lib/libcrypto.a -lclang_rt.builtins-aarch64-android
ENV LIBS /usr/local/openssl/lib/libcrypto.a
# RUN env
WORKDIR /work/otp
RUN ./otp_build autoconf

# Build with debugger produces
# dbg_wx_filedialog_win.erl:22: behaviour wx_object undefined

# Build run #1, building the x86 based cross compiler which will generate the .beam files
RUN ./otp_build configure --with-ssl=/usr/local/openssl/ --disable-dynamic-ssl-lib --without-javac --without-odbc --without-wx --without-debugger --without-observer --without-cdv --without-et --xcomp-conf=xcomp/erl-xcomp-arm64-android.conf
RUN ./otp_build boot -a

# Build run #2, now creating the arm binaries, appliying the install flags only here...
ENV INSTALL_PROGRAM "/usr/bin/install -c -s --strip-program=llvm-strip"
RUN ./otp_build configure --with-ssl=/usr/local/openssl/ --disable-dynamic-ssl-lib --without-javac --without-odbc --without-wx --without-debugger --without-observer --without-cdv --without-et --xcomp-conf=xcomp/erl-xcomp-arm64-android.conf LDFLAGS="-z global"
RUN ./otp_build release -a

0 comments on commit 13aaea7

Please sign in to comment.