Last active
January 24, 2023 02:47
-
-
Save patterns/6780b43c5db8071ab02b91725874c565 to your computer and use it in GitHub Desktop.
gollvm build on rpi and target wasm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To make sense, see the mailinglist archive item | |
# https://www.mail-archive.com/golang-nuts@googlegroups.com/msg47286.html | |
# Also, manage the mono repo fetch separately and avoid docker repeating the step | |
FROM ll0 | |
WORKDIR /opt | |
RUN tar -xzf git-09629215c272f09e3ebde6cc7eac9625d28910ff.tgz | |
RUN rm git-09629215c272f09e3ebde6cc7eac9625d28910ff.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ll1 | |
RUN apt -qq update && \ | |
apt -qq install --no-install-recommends -y git ninja-build cmake build-essential \ | |
clang autoconf ca-certificates python3 | |
WORKDIR /opt | |
RUN cd llvm-project/llvm/tools \ | |
&& git clone https://go.googlesource.com/gollvm | |
RUN cd llvm-project/llvm/tools/gollvm \ | |
&& git checkout 0e34e09fc15cde73f1b9974f2a657360abb94b4f \ | |
&& git clone https://go.googlesource.com/gofrontend | |
RUN cd llvm-project/llvm/tools/gollvm/gofrontend \ | |
&& git checkout 7f33baa09a8172bb2c5f1ca0435d9efe3e194c9b | |
RUN cd llvm-project/llvm/tools/gollvm/libgo \ | |
&& git clone https://github.com/libffi/libffi.git | |
RUN cd llvm-project/llvm/tools/gollvm/libgo/libffi \ | |
&& git checkout ab1677106605aba1c27665964ff90bea59612ce3 | |
RUN cd llvm-project/llvm/tools/gollvm/libgo \ | |
&& git clone https://github.com/ianlancetaylor/libbacktrace.git | |
RUN cd llvm-project/llvm/tools/gollvm/libgo/libbacktrace \ | |
&& git checkout 2446c66076480ce07a6bd868badcbceb3eeecc2e | |
RUN mkdir /opt/build-debug && cd /opt/build-debug \ | |
&& cmake -DCMAKE_BUILD_TYPE=Debug \ | |
-DCMAKE_C_COMPILER=clang \ | |
-DCMAKE_CXX_COMPILER=clang++ \ | |
-DLLVM_USE_LINKER=gold \ | |
-DLLVM_TARGETS_TO_BUILD="WebAssembly" \ | |
-DGOLLVM_USE_SPLIT_STACK=OFF \ | |
-DCMAKE_INSTALL_PREFIX=/opt/dist \ | |
-G Ninja ../llvm-project/llvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snap info lxd | |
sudo usermod -a -G lxd username | |
sudo reboot | |
sudo lxd init | |
lxc launch ubuntu:22.04 gollvm | |
lxc exec gollvm -- apt update && apt upgrade -y | |
lxc exec gollvm -- sudo --user ubuntu --login | |
mkdir workarea && cd workarea | |
git clone https://github.com/llvm/llvm-project.git | |
cd llvm-project && git checkout 09629215c272f09e3ebde6cc7eac9625d28910ff | |
cd llvm/tools && git clone https://go.googlesource.com/gollvm | |
cd gollvm && git checkout 0e34e09fc15cde73f1b9974f2a657360abb94b4f | |
git clone https://go.googlesource.com/gofrontend | |
cd gofrontend && git checkout 7f33baa09a8172bb2c5f1ca0435d9efe3e194c9b | |
cd ../libgo && git clone https://github.com/libffi/libffi.git | |
cd libffi && git checkout ab1677106605aba1c27665964ff90bea59612ce3 | |
cd .. && git clone https://github.com/ianlancetaylor/libbacktrace.git | |
cd libbacktrace && git checkout 2446c66076480ce07a6bd868badcbceb3eeecc2e | |
exit | |
# back to host | |
# take snapshot | |
lxc copy gollvm gollvm-09629215c272f09e3ebde6cc7eac9625d28910ff | |
lxc exec gollvm-02 -- apt -qq install --no-install-recommends -y \ | |
ninja-build build-essential cmake clang autoconf python3 ca-certificates | |
# take snapshot | |
lxc copy gollvm-02 gollvm-03 | |
lxc exec gollvm-03 -- sudo --user ubuntu --login | |
cd workarea && mkdir build.rel && cd build.rel | |
cmake -DCMAKE_INSTALL_PREFIX=/opt/test -DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \ | |
-DLLVM_USE_LINKER=gold -DGOLLVM_USE_SPLIT_STACK=OFF \ | |
-G Ninja ../llvm-project/llvm | |
ninja gollvm | |
ninja install-gollvm | |
exit | |
# back to host | |
lxc file pull gollvm-03 /opt/test . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The dockerfiles are more as documentation because LXC is a better fit for dealing with the 4K objects of the LLVM monorepo. Attaching a shell script, not to be run as-is rather to list out the steps that allowed gollvm to finally actually complete.