Fix build for Raspberry Pi 1 B+ and Zero
parent
93f101abcb
commit
f3d3284e35
|
@ -0,0 +1 @@
|
|||
/bin/ubxtool.*
|
|
@ -11,7 +11,9 @@ testrunner
|
|||
tlecatch
|
||||
ubxtool
|
||||
ubxtool.nodeps
|
||||
ubxtool.nodeps.*
|
||||
ubxtool.static
|
||||
# - created by build-ubxtool
|
||||
/bin/ubxtool.*
|
||||
# - created by update-tles
|
||||
active.txt
|
||||
beidou.txt
|
||||
|
|
|
@ -14,6 +14,7 @@ RUN set -ex && \
|
|||
apt-get install -y \
|
||||
build-essential \
|
||||
g++ \
|
||||
git \
|
||||
libprotobuf-dev \
|
||||
make \
|
||||
protobuf-compiler \
|
|
@ -0,0 +1,33 @@
|
|||
# See `build-ubxtool` script for cross-compilation options.
|
||||
|
||||
# 1. GCC has issues with exception unwinding with static build of libmusl.
|
||||
# The bug is fixed for gcc-10, but alpine:3.11 has 9.2.0-r3 and alpine:3.10 has 8.3.0-r0.
|
||||
# Both are affected per test and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91737
|
||||
#
|
||||
# 2. clang-9.0.0-r1 from alpine:3.11 generates wrong FPU instructions for Raspberry Pi 1 B+ and Zero.
|
||||
# It uses d{16..31} registers for a VFPv2 FPU and that leads to SIGILL.
|
||||
# The bug is described at https://reviews.llvm.org/D67375
|
||||
# The bug is fixed in clang-10: https://reviews.llvm.org/rGddf5e86c222c6b5226be53e1250421fe608bb4d0
|
||||
#
|
||||
# 3. clang-8.0.0-r0 from alpine:3.10 is not affected by the bug, so we use it.
|
||||
FROM alpine:3.10 AS build-env
|
||||
|
||||
# g++ is still installed to bring C++ headers like <string>, <map>, etc.
|
||||
# See https://pkgs.alpinelinux.org/contents?file=iostream&branch=v3.10&arch=armhf
|
||||
RUN set -ex && \
|
||||
apk add --no-cache \
|
||||
clang \
|
||||
g++ \
|
||||
git \
|
||||
make \
|
||||
protobuf-dev \
|
||||
&& \
|
||||
:
|
||||
|
||||
ADD . /galmon/
|
||||
WORKDIR /galmon/
|
||||
RUN CXX=clang make ubxtool.static
|
||||
|
||||
FROM scratch
|
||||
COPY --from=build-env /galmon/ubxtool.static /opt/ubxtool
|
||||
ENTRYPOINT ["/opt/ubxtool"]
|
5
Makefile
5
Makefile
|
@ -30,7 +30,7 @@ H2OPP=ext/powerblog/h2o-pp.o
|
|||
SIMPLESOCKETS=ext/powerblog/ext/simplesocket/swrappers.o ext/powerblog/ext/simplesocket/sclasses.o ext/powerblog/ext/simplesocket/comboaddress.o
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o *.d ext/*/*.o $(PROGRAMS) ubxtool.nodeps* navmon.pb.h navmon.pb.cc $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) $(H2OPP) $(SIMPLESOCKETS)
|
||||
rm -f *~ *.o *.d ext/*/*.o $(PROGRAMS) ubxtool.nodeps ubxtool.static navmon.pb.h navmon.pb.cc $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) $(H2OPP) $(SIMPLESOCKETS)
|
||||
rm -f ext/fmt-5.2.1/src/format.o
|
||||
|
||||
decrypt: decrypt.o bits.o ext/fmt-5.2.1/src/format.o
|
||||
|
@ -73,6 +73,9 @@ UBXTOOL_DEPS = navmon.pb.o ubxtool.o ubx.o bits.o ext/fmt-5.2.1/src/format.o gal
|
|||
|
||||
ubxtool: $(UBXTOOL_DEPS)
|
||||
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -lprotobuf -pthread
|
||||
# Static build with musl on alpine and clang
|
||||
ubxtool.static: $(UBXTOOL_DEPS)
|
||||
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -lprotobuf -pthread -lstdc++ -static
|
||||
# Static linking of `glibc` is non-trivial, so glibc is kept dynamically linked
|
||||
ubxtool.nodeps: $(UBXTOOL_DEPS)
|
||||
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib /usr/lib/*-linux-*/libprotobuf.a -pthread -static-libgcc -static-libstdc++
|
||||
|
|
|
@ -115,7 +115,7 @@ To build a minimal `ubxtool` docker image:
|
|||
|
||||
```
|
||||
git clone https://github.com/ahupowerdns/galmon.git --recursive
|
||||
./build-ubxtool native
|
||||
./build-ubxtool
|
||||
```
|
||||
|
||||
It may also cross-compile a binary and an image for a Raspberry Pi:
|
||||
|
@ -123,7 +123,7 @@ It may also cross-compile a binary and an image for a Raspberry Pi:
|
|||
```
|
||||
git clone https://github.com/ahupowerdns/galmon.git --recursive
|
||||
docker run -it --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
./build-ubxtool armhf
|
||||
./build-ubxtool armv6l
|
||||
```
|
||||
|
||||
Running
|
||||
|
|
|
@ -3,31 +3,87 @@
|
|||
# The script relies on the following project:
|
||||
# - https://github.com/multiarch/qemu-user-static
|
||||
# - https://github.com/multiarch/ubuntu-core
|
||||
# - https://github.com/multiarch/alpine
|
||||
#
|
||||
# Another easy cross-compilation option is to use https://github.com/docker/binfmt
|
||||
# It's also probably possible to use more official {i386,amd64,arm32v6,arm32v7,arm64v8}/alpine
|
||||
# images adding qemu binary from multiarch/qemu-user-static:{arm,arm64} to them.
|
||||
#
|
||||
# Register qemu-user-static before building
|
||||
# $ docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
|
||||
set -e
|
||||
|
||||
arch=${1:-native}
|
||||
this_mach=$(uname --machine)
|
||||
|
||||
case "$arch" in
|
||||
native)
|
||||
tag=latest
|
||||
from=ubuntu:bionic
|
||||
;;
|
||||
x86|x86_64|arm64|armhf)
|
||||
tag=${arch}
|
||||
from=multiarch/ubuntu-core:${arch}-bionic
|
||||
;;
|
||||
if [ "$this_mach" != "x86_64" ]; then
|
||||
echo "$0: build was tested on x86_64, not on this <$this_mach>" 1>&2
|
||||
fi
|
||||
|
||||
mach=${1:-${this_mach}}
|
||||
libc=${2:-static}
|
||||
|
||||
case "$mach" in
|
||||
i686)
|
||||
alpine=x86 # official: i386/alpine
|
||||
ubuntu=x86
|
||||
busybox=i386
|
||||
;;
|
||||
x86_64)
|
||||
alpine=x86_64 # official: amd64/alpine
|
||||
ubuntu=x86_64
|
||||
busybox=amd64
|
||||
;;
|
||||
armv6l)
|
||||
# For Raspberry 1 and Zero.
|
||||
# Tested on Raspberry 1 B+ (BCM2835 rev. 0010).
|
||||
alpine=armhf # official: arm32v6/alpine
|
||||
ubuntu=*
|
||||
busybox=arm32v6
|
||||
;;
|
||||
armv7l)
|
||||
# For Raspberry 2 and 3.
|
||||
# Tested on Raspberry 3 Model B (BCM2835 revision a02082).
|
||||
# Tested on Raspberry 3 Model B+ (BCM2835 revision a020d3).
|
||||
alpine=armv7 # official: arm32v7/alpine
|
||||
ubuntu=armhf
|
||||
busybox=arm32v7
|
||||
;;
|
||||
aarch64)
|
||||
# For Raspberry 4?
|
||||
alpine=arm64 # official: arm64v8/alpine
|
||||
ubuntu=arm64 # or aarch64? See https://wiki.ubuntu.com/ARM/RaspberryPi#Ubuntu_arm64.2FAArch64
|
||||
busybox=arm64v8
|
||||
;;
|
||||
*)
|
||||
echo "$0: unknown arch <$arch>, known are: (native|x86|x86_64|arm64|armhf)" 1>&2
|
||||
echo "$0: unknown machine hardware name <$mach>, known are: {i686,x86_64,armv6l,armv7l,aarch64}" 1>&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
sed "s,^FROM ubuntu:bionic AS,FROM ${from} AS," Dockerfile.ubxtool | docker build -f - --tag ubxtool:${tag} .
|
||||
case "$libc" in
|
||||
static)
|
||||
from="alpine:3.10"
|
||||
to="multiarch/alpine:${alpine}-v3.10"
|
||||
;;
|
||||
glibc)
|
||||
if [ "$ubuntu" = "*" ]; then
|
||||
echo "$0: unsupported combination of machine <$mach> and libc <$libc>" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
from="ubuntu:bionic"
|
||||
to="multiarch/ubuntu-core:${ubuntu}-bionic"
|
||||
;;
|
||||
*)
|
||||
echo "$0: unknown libc <$libc>, known are: {static,glibc}" 1>&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
tag="${mach}-${libc}"
|
||||
|
||||
sed -e "s,^FROM ${from} AS ,FROM ${to} AS ," \
|
||||
-e "s,^FROM busybox:glibc,FROM ${busybox}/busybox:glibc," \
|
||||
Dockerfile.ubxtool.${libc} \
|
||||
| docker build -f - --tag ubxtool:${tag} .
|
||||
|
||||
cntr=$(docker create ubxtool:${tag})
|
||||
docker cp ${cntr}:/opt/ubxtool ./ubxtool.nodeps.${tag}
|
||||
docker cp ${cntr}:/opt/ubxtool bin/ubxtool.${tag}
|
||||
docker rm ${cntr}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "fmt/format.h"
|
||||
#include "fmt/printf.h"
|
||||
#include "bits.hh"
|
||||
|
|
Loading…
Reference in New Issue