From 4ce80b8838b5bcb4b434fef4c50bb55ff4dddadb Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Tue, 21 Nov 2023 15:57:26 -0800 Subject: [PATCH] llvm and dependencies --- Makefile | 39 +++ packages/binutils/Dockerfile | 8 +- packages/llvm/Dockerfile | 80 +++++++ packages/llvm/rust-feature-tables.patch | 305 ++++++++++++++++++++++++ packages/perl/Dockerfile | 2 +- packages/py-setuptools/Dockerfile | 19 ++ 6 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 packages/llvm/Dockerfile create mode 100644 packages/llvm/rust-feature-tables.patch create mode 100644 packages/py-setuptools/Dockerfile diff --git a/Makefile b/Makefile index a862ad6..fe12f0c 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ out/openssl.oci.tgz: \ out/gcc.oci.tgz \ out/binutils.oci.tgz \ out/busybox.oci.tgz \ + out/linux-headers.oci.tgz \ out/musl.oci.tgz docker build -t imgrep/openssl --output type=oci,dest=$@ packages/openssl @@ -55,6 +56,7 @@ out/perl.oci.tgz: \ out/gcc.oci.tgz \ out/binutils.oci.tgz \ out/busybox.oci.tgz \ + out/make.oci.tgz \ out/musl.oci.tgz docker build -t imgrep/perl --output type=oci,dest=$@ packages/perl @@ -78,6 +80,43 @@ out/python.oci.tgz: \ out/musl.oci.tgz docker build -t imgrep/python --output type=oci,dest=$@ packages/python +out/ninja.oci.tgz: \ + out/busybox.oci.tgz \ + out/gcc.oci.tgz \ + out/binutils.oci.tgz \ + out/musl.oci.tgz \ + out/make.oci.tgz \ + out/openssl.oci.tgz \ + out/python.oci.tgz + docker build -t imgrep/ninja --output type=oci,dest=$@ packages/ninja + +out/cmake.oci.tgz: \ + out/busybox.oci.tgz \ + out/gcc.oci.tgz \ + out/binutils.oci.tgz \ + out/ninja.oci.tgz \ + out/musl.oci.tgz \ + out/make.oci.tgz \ + out/linux-headers.oci.tgz + docker build -t imgrep/cmake --output type=oci,dest=$@ packages/cmake + +out/py-setuptools.oci.tgz: \ + out/busybox.oci.tgz \ + out/python.oci.tgz + docker build -t imgrep/py-setuptools --output type=oci,dest=$@ packages/py-setuptools + +out/llvm.oci.tgz: \ + out/gcc.oci.tgz \ + out/python.oci.tgz \ + out/py-setuptools.oci.tgz \ + out/perl.oci.tgz \ + out/binutils.oci.tgz \ + out/cmake.oci.tgz \ + out/ninja.oci.tgz \ + out/busybox.oci.tgz \ + out/musl.oci.tgz + docker build -t imgrep/llvm --output type=oci,dest=$@ packages/llvm + test: docker build -t imgrep/test-c tests/c docker build -t imgrep/test-go tests/go diff --git a/packages/binutils/Dockerfile b/packages/binutils/Dockerfile index c3ced30..5e3b635 100644 --- a/packages/binutils/Dockerfile +++ b/packages/binutils/Dockerfile @@ -18,20 +18,20 @@ RUN set -ex; \ --target=x86_64-linux-musl \ --with-build-sysroot= \ --with-sysroot=/ \ - --prefix=/ \ + --prefix=/usr \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --sysconfdir=/etc \ --enable-plugins \ --without-zstd \ --disable-shared \ - --disable-gold \ --disable-jansson \ --disable-gdb \ --disable-gprofng \ --disable-multilib \ --disable-nls \ --disable-werror \ + --enable-gold \ --enable-64-bit-bfd \ --enable-default-execstack=no \ --enable-default-hash-style=gnu \ @@ -43,10 +43,10 @@ RUN set -ex; \ --with-mmap \ --with-pic; \ make -j "$(nproc)"; \ - make DESTDIR="/rootfs" install; + make DESTDIR="/home/user/rootfs" install; COPY --from=musl /usr/lib/libc.so /rootfs/lib/ld-musl-x86_64.so.1 FROM scratch -COPY --from=build /rootfs / +COPY --from=build /home/user/rootfs / ENTRYPOINT ["/bin/ld"] CMD ["--version"] diff --git a/packages/llvm/Dockerfile b/packages/llvm/Dockerfile new file mode 100644 index 0000000..b6fe7f1 --- /dev/null +++ b/packages/llvm/Dockerfile @@ -0,0 +1,80 @@ +FROM imgrep/busybox:latest as busybox +FROM imgrep/gcc:latest as gcc +FROM imgrep/binutils:latest as binutils +FROM imgrep/musl:latest as musl +FROM imgrep/openssl:latest as openssl +FROM imgrep/python:latest as python +FROM imgrep/py-setuptools:latest as py-setuptools +FROM imgrep/cmake:latest as cmake +FROM imgrep/ninja:latest as ninja + +FROM busybox as build +ENV SRC_SITE=https://github.com/llvm/llvm-project/releases/download +ENV SRC_VERSION=16.0.6 +ENV SRC_HASH=ce5e71081d17ce9e86d7cbcfa28c4b04b9300f8fb7e78422b1feb6bc52c3028e +RUN wget ${SRC_SITE}/llvmorg-${SRC_VERSION}/llvm-project-${SRC_VERSION}.src.tar.xz +RUN echo "${SRC_HASH} llvm-project-${SRC_VERSION}.src.tar.xz" | sha256sum -c +RUN tar -xf llvm-project-${SRC_VERSION}.src.tar.xz +WORKDIR llvm-project-${SRC_VERSION}.src +RUN ls -lah . +ADD . . +RUN patch -p1 < rust-feature-tables.patch +COPY --from=binutils . / +COPY --from=cmake . / +COPY --from=ninja . / +COPY --from=musl . / +COPY --from=gcc . / +COPY --from=python . / +COPY --from=py-setuptools . / + +RUN set -eux; \ + python -c "import setuptools; print(setuptools.__version__)"; \ + cmake \ + -B build \ + -G Ninja \ + -Wno-dev -S llvm \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr/ \ + -DCMAKE_INSTALL_RPATH=/usr/ \ + -DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-linux-musl" \ + -DLLVM_HOST_TRIPLE="x86_64-linux-musl" \ + -DLLVM_APPEND_VC_REV=OFF \ + -DLLVM_BINUTILS_INCDIR=/usr/include \ + -DLLVM_BUILD_DOCS=OFF \ + -DLLVM_BUILD_EXAMPLES=OFF \ + -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_BUILD_TESTS=ON \ + -DLLVM_ENABLE_ASSERTIONS=OFF \ + -DLLVM_ENABLE_DUMP=ON \ + -DLLVM_ENABLE_EH=ON \ + -DLLVM_ENABLE_FFI=ON \ + -DLLVM_ENABLE_LIBCXX=OFF \ + -DLLVM_ENABLE_LIBEDIT=OFF \ + -DLLVM_ENABLE_PIC=ON \ + -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_SPHINX=OFF \ + -DLLVM_ENABLE_TERMINFO=ON \ + -DLLVM_ENABLE_ZLIB=OFF \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_INCLUDE_BENCHMARKS=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_LINK_LLVM_DYLIB=ON \ + -DLLVM_USE_PERF=ON; \ + cmake --build build + +RUN python3 llvm/utils/lit/setup.py build + +RUN set -eux; \ + export DESTDIR="/home/user/rootfs/"; \ + cmake --install build; \ + python3 llvm/utils/lit/setup.py install --root="$DESTDIR" + +COPY --from=musl /lib* /home/user/rootfs/lib/ + +FROM scratch +COPY --from=build /home/user/rootfs / +USER 100:100 +ENTRYPOINT ["/usr/bin/llc"] +CMD ["--version"] diff --git a/packages/llvm/rust-feature-tables.patch b/packages/llvm/rust-feature-tables.patch new file mode 100644 index 0000000..42fa8f4 --- /dev/null +++ b/packages/llvm/rust-feature-tables.patch @@ -0,0 +1,305 @@ + + + +rust-feature-tables.patch « llvm16 « main - aports - Alpine packages build scripts + + + + + + + + + + +
+ + + + +
+aboutsummaryrefslogtreecommitdiffstats
+ + + +
+
+
blob: 2068d51f2b9aae67132d65eb83489b22c9d227c4 (plain) + + +
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+
Patch-Source: https://github.com/rust-lang/llvm-project/commit/0a157fd7a5f61973ffddf96b3d445a718193eb1a
+From 0a157fd7a5f61973ffddf96b3d445a718193eb1a Mon Sep 17 00:00:00 2001
+From: Cameron Hart <cameron.hart@gmail.com>
+Date: Sun, 10 Jul 2016 23:55:53 +1000
+Subject: [PATCH] [rust] Add accessors for MCSubtargetInfo CPU and Feature
+ tables
+
+This is needed for `-C target-cpu=help` and `-C target-feature=help` in rustc
+---
+ llvm/include/llvm/MC/MCSubtargetInfo.h | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/llvm/include/llvm/MC/MCSubtargetInfo.h b/llvm/include/llvm/MC/MCSubtargetInfo.h
+index e1f0a86141e36..1e529bf4fb31e 100644
+--- a/llvm/include/llvm/MC/MCSubtargetInfo.h
++++ b/llvm/include/llvm/MC/MCSubtargetInfo.h
+@@ -230,6 +230,14 @@ class MCSubtargetInfo {
+     return Found != ProcDesc.end() && StringRef(Found->Key) == CPU;
+   }
+ 
++  ArrayRef<SubtargetSubTypeKV> getCPUTable() const {
++    return ProcDesc;
++  }
++
++  ArrayRef<SubtargetFeatureKV> getFeatureTable() const {
++    return ProcFeatures;
++  }
++
+   virtual unsigned getHwMode() const { return 0; }
+ 
+   /// Return the cache size in bytes for the given level of cache.
+
+
+
+ +
+ + diff --git a/packages/perl/Dockerfile b/packages/perl/Dockerfile index 60d128e..ce1832e 100644 --- a/packages/perl/Dockerfile +++ b/packages/perl/Dockerfile @@ -46,7 +46,7 @@ RUN set -eux; \ -Dusenm; \ make; \ make DESTDIR=/home/user/rootfs install -COPY --from=musl /lib/libc.so /home/user/rootfs/lib/ld-musl-x86_64.so.1 +COPY --from=musl /usr/lib/libc.so /home/user/rootfs/lib/ld-musl-x86_64.so.1 FROM scratch COPY --from=build /home/user/rootfs / diff --git a/packages/py-setuptools/Dockerfile b/packages/py-setuptools/Dockerfile new file mode 100644 index 0000000..a7d70f8 --- /dev/null +++ b/packages/py-setuptools/Dockerfile @@ -0,0 +1,19 @@ +FROM imgrep/busybox:latest as busybox +FROM imgrep/python:latest as python + +FROM busybox as build +ENV SRC_SITE=https://pypi.io/packages/source/s/setuptools +ENV SRC_VERSION=68.2.2 +ENV SRC_HASH=4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87 +RUN wget ${SRC_SITE}/setuptools-${SRC_VERSION}.tar.gz +RUN echo "${SRC_HASH} setuptools-${SRC_VERSION}.tar.gz" | sha256sum -c +RUN tar -xzf setuptools-${SRC_VERSION}.tar.gz +WORKDIR setuptools-${SRC_VERSION} +COPY --from=python . / +RUN set -eux; \ + python3 setup.py build; \ + python3 setup.py install --root=/home/user/rootfs; \ + ls -Rlah /home/user/rootfs + +FROM scratch +COPY --from=build /home/user/rootfs /