1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-14 16:31:42 +03:00
mold/build-static.sh
Rui Ueyama 3e3d58b6f1 Static-link oneTBB by default
oneTBB API is changing rapidly, so even if a oneTBB is installed
into a system already, it is likely that that is not a compatible
version with mold. This makes program building unnecessarily hard.

This change intends to solve the problem once and for all by
including oneTBB as a subdirectory and static-link against it at
build-time.

oneTBB is released under the Apache License 2.0, which is compatible
with AGPL. Therefore, we can still distribute the binary of mold
under AGPL.

If you do not want to static-link oneTBB, pass `SYSTEM_TBB=1`
to `make`.

This change also ports mold from oneTBB v2020.3 to v2021.3.0.

Fixes https://github.com/rui314/mold/issues/66
2021-07-03 00:08:33 +09:00

28 lines
897 B
Bash
Executable File

#!/bin/bash -x
# This is a shell script to build a statically-linked mold
# executable using Docker, so that it is easy to build mold
# on non-Ubuntu 20.04 machines.
#
# A docker image used for building mold is persistent.
# Run `docker image rm mold-build-ubuntu20` to remove the image
# from disk.
set -e
# If the existing file is not statically-linked, remove it.
[ -f mold ] && ! ldd mold 2>&1 | grep -q 'not a dynamic executable' && \
rm mold
cat <<EOF | docker build -t mold-build-ubuntu20 -
FROM ubuntu:20.04
RUN apt-get update && \
TZ=Europe/London apt-get install -y tzdata && \
apt-get install -y build-essential git clang lld cmake \
libstdc++-10-dev libxxhash-dev zlib1g-dev libssl-dev && \
rm -rf /var/lib/apt/lists/*
EOF
docker run -it --rm -v `pwd`:/mold -u $(id -u):$(id -g) \
mold-build-ubuntu20 \
make -C /mold -j$(nproc) EXTRA_LDFLAGS='-fuse-ld=lld -static'