aboutsummaryrefslogtreecommitdiffhomepage
path: root/Dockerfile
diff options
context:
space:
mode:
authordeadprogram <[email protected]>2021-12-01 00:59:44 +0100
committerRon Evans <[email protected]>2021-12-15 19:26:32 +0100
commit0f9d2ac0e437a0b80ffb72cb7ab2e6d898d46f3e (patch)
tree9cbe281205f19d3bb24915be2895ed17483a49a3 /Dockerfile
parent5264469cbd837b59cdf50493e7eea2b96bb621cb (diff)
downloadtinygo-0f9d2ac0e437a0b80ffb72cb7ab2e6d898d46f3e.tar.gz
tinygo-0f9d2ac0e437a0b80ffb72cb7ab2e6d898d46f3e.zip
docker: update Dockerfile for dev build for LLVM 12 changes
Signed-off-by: deadprogram <[email protected]>
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile84
1 files changed, 22 insertions, 62 deletions
diff --git a/Dockerfile b/Dockerfile
index e21b29ade..f6a65515a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,80 +1,40 @@
-# TinyGo base stage installs the most recent Go 1.17.x, LLVM 11 and the TinyGo compiler itself.
-FROM golang:1.17 AS tinygo-base
+# tinygo-llvm stage obtains the llvm source for TinyGo
+FROM golang:1.17 AS tinygo-llvm
-RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \
- echo "deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-11 main" >> /etc/apt/sources.list && \
- apt-get update && \
- apt-get install -y llvm-11-dev libclang-11-dev lld-11 git
+RUN apt-get update && \
+ apt-get install -y apt-utils make cmake clang-11 binutils-avr gcc-avr avr-libc ninja-build
-COPY . /tinygo
-
-# remove submodules directories and re-init them to fix any hard-coded paths
-# after copying the tinygo directory in the previous step.
-RUN cd /tinygo/ && \
- rm -rf ./lib/* && \
- git submodule sync && \
- git submodule update --init --recursive --force
-
-COPY ./lib/picolibc-stdio.c /tinygo/lib/picolibc-stdio.c
+COPY ./Makefile /tinygo/Makefile
RUN cd /tinygo/ && \
- go install /tinygo/
-
-# tinygo-wasm stage installs the needed dependencies to compile TinyGo programs for WASM.
-FROM tinygo-base AS tinygo-wasm
+ make llvm-source
-COPY --from=tinygo-base /go/bin/tinygo /go/bin/tinygo
-COPY --from=tinygo-base /tinygo/src /tinygo/src
-COPY --from=tinygo-base /tinygo/targets /tinygo/targets
+# tinygo-llvm-build stage build the custom llvm with xtensa support
+FROM tinygo-llvm AS tinygo-llvm-build
RUN cd /tinygo/ && \
- apt-get update && \
- apt-get install -y make clang-11 libllvm11 lld-11 cmake ninja-build && \
- mkdir build && \
- make wasi-libc binaryen
+ make llvm-build
-# tinygo-avr stage installs the needed dependencies to compile TinyGo programs for AVR microcontrollers.
-FROM tinygo-base AS tinygo-avr
+# tinygo-compiler stage builds the compiler itself
+FROM tinygo-llvm-build AS tinygo-compiler
-COPY --from=tinygo-base /go/bin/tinygo /go/bin/tinygo
-COPY --from=tinygo-base /tinygo/src /tinygo/src
-COPY --from=tinygo-base /tinygo/targets /tinygo/targets
-COPY --from=tinygo-base /tinygo/Makefile /tinygo/
-COPY --from=tinygo-base /tinygo/tools /tinygo/tools
-COPY --from=tinygo-base /tinygo/lib /tinygo/lib
+COPY . /tinygo
+# remove submodules directories and re-init them to fix any hard-coded paths
+# after copying the tinygo directory in the previous step.
RUN cd /tinygo/ && \
- apt-get update && \
- apt-get install -y apt-utils make binutils-avr gcc-avr avr-libc && \
- make gen-device-avr && \
- apt-get autoremove -y && \
- apt-get clean
-
-# tinygo-arm stage installs the needed dependencies to compile TinyGo programs for ARM microcontrollers.
-FROM tinygo-base AS tinygo-arm
-
-COPY --from=tinygo-base /go/bin/tinygo /go/bin/tinygo
-COPY --from=tinygo-base /tinygo/src /tinygo/src
-COPY --from=tinygo-base /tinygo/targets /tinygo/targets
-COPY --from=tinygo-base /tinygo/Makefile /tinygo/
-COPY --from=tinygo-base /tinygo/tools /tinygo/tools
-COPY --from=tinygo-base /tinygo/lib /tinygo/lib
+ rm -rf ./lib/* && \
+ git submodule sync && \
+ git submodule update --init --recursive --force
RUN cd /tinygo/ && \
- apt-get update && \
- apt-get install -y apt-utils make clang-11 && \
- make gen-device-nrf && make gen-device-stm32
-
-# tinygo-all stage installs the needed dependencies to compile TinyGo programs for all platforms.
-FROM tinygo-wasm AS tinygo-all
+ make
-COPY --from=tinygo-base /tinygo/Makefile /tinygo/
-COPY --from=tinygo-base /tinygo/tools /tinygo/tools
-COPY --from=tinygo-base /tinygo/lib /tinygo/lib
+# tinygo-tools stage installs the needed dependencies to compile TinyGo programs for all platforms.
+FROM tinygo-compiler AS tinygo-tools
RUN cd /tinygo/ && \
- apt-get update && \
- apt-get install -y apt-utils make clang-11 binutils-avr gcc-avr avr-libc && \
- make gen-device
+ make wasi-libc binaryen && \
+ make gen-device -j4
CMD ["tinygo"]