summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2022-08-22 09:18:43 +0200
committerDavid Lönnhager <david.l@mullvad.net>2022-08-23 13:38:31 +0200
commitaa39b4f5fed12445351b3e3c760f57b416529296 (patch)
tree2d4199cfda99e117d5b99c1ba3fc43feb823fb35
parent5af7326f9fd4fc0a482e8f87eda1eef4f9a9c117 (diff)
downloadmullvadvpn-aa39b4f5fed12445351b3e3c760f57b416529296.tar.xz
mullvadvpn-aa39b4f5fed12445351b3e3c760f57b416529296.zip
Update libwg script for cross compilation
-rwxr-xr-xwireguard/build-wireguard-go.sh30
1 files changed, 20 insertions, 10 deletions
diff --git a/wireguard/build-wireguard-go.sh b/wireguard/build-wireguard-go.sh
index af7774c359..0374a82892 100755
--- a/wireguard/build-wireguard-go.sh
+++ b/wireguard/build-wireguard-go.sh
@@ -88,16 +88,26 @@ function unix_target_triple {
function build_unix {
echo "Building wireguard-go for $1"
- # Flags for cross compiling for M1 macs
- if [[ "$(unix_target_triple)" != "$1" && "$1" == "aarch64-apple-darwin" ]]; then
- export CGO_ENABLED=1
- export GOOS=darwin
- export GOARCH=arm64
- export CC="$(xcrun -sdk $SDKROOT --find clang) -arch $GOARCH -isysroot $SDKROOT"
- export CFLAGS="-isysroot $SDKROOT -arch $GOARCH -I$SDKROOT/usr/include"
- export LD_LIBRARY_PATH="$SDKROOT/usr/lib"
- export CGO_CFLAGS="-isysroot $SDKROOT -arch $GOARCH"
- export CGO_LDFLAGS="-isysroot $SDKROOT -arch $GOARCH"
+ # Flags for cross compiling
+ if [[ "$(unix_target_triple)" != "$1" ]]; then
+ # Linux arm
+ if [[ "$1" == "aarch64-unknown-linux-gnu" ]]; then
+ export CGO_ENABLED=1
+ export GOARCH=arm64
+ export CC=aarch64-linux-gnu-gcc
+ fi
+
+ # Apple silicon
+ if [[ "$1" == "aarch64-apple-darwin" ]]; then
+ export CGO_ENABLED=1
+ export GOOS=darwin
+ export GOARCH=arm64
+ export CC="$(xcrun -sdk $SDKROOT --find clang) -arch $GOARCH -isysroot $SDKROOT"
+ export CFLAGS="-isysroot $SDKROOT -arch $GOARCH -I$SDKROOT/usr/include"
+ export LD_LIBRARY_PATH="$SDKROOT/usr/lib"
+ export CGO_CFLAGS="-isysroot $SDKROOT -arch $GOARCH"
+ export CGO_LDFLAGS="-isysroot $SDKROOT -arch $GOARCH"
+ fi
fi
pushd libwg