llvm-tools

Source

FROM scratch AS build
COPY --from=stagex/bootstrap-stage3 . /

ARG VERSION
ARG CPORTS_VERSION
ARG TARGETARCH
COPY <<-'EOF' /etc/profile
	set -eux
	[[ "$TARGETARCH" == "amd64" ]] \
		&& ARCH="x86_64" \
		&& LLVM_TARGET_ARCH="X86"
	[[ "$TARGETARCH" == "arm64" ]] \
		&& ARCH="aarch64" \
		&& LLVM_TARGET_ARCH="AArch64"
	export ARCH
	export MAKEFLAGS="-j$(nproc)"
	export BUILD=${ARCH}-unknown-linux-musl
	export TARGET=${ARCH}-unknown-linux-musl
EOF
SHELL ["/bin/sh","-l","-c"]

ADD fetch/llvm-${VERSION}.tar.xz .
ADD fetch/cports-${CPORTS_VERSION}.tar.gz .
WORKDIR /llvm-project-${VERSION}.src
ADD patches/*.patch .

RUN --network=none <<-EOF
	cp /cports-${CPORTS_VERSION}/main/llvm/patches/*.patch .
	for file in $(find . -maxdepth 1 -name "*.patch" | sort); do
	  patch -p1 < "$file"
	done
EOF

RUN --network=none <<-EOF
	# CMake configuration arguments applicable to both of the following builds

	CMAKE_ARGS=""
	cmake_cache_set() {
	  CMAKE_ARGS="$CMAKE_ARGS -D$1=$2"
	}
	# The runtimes are built with nested `cmake` invocations which aren't proxied the variables
	# declared here. They need to have their variables set with a prefix of `RUNTIMES_${TARGET}_`.
	# This is hardcoded to a target of the host as it's the only target the runtimes are built for.
	cmake_runtime_cache_set() {
	  CMAKE_ARGS="$CMAKE_ARGS -DRUNTIMES_${ARCH}-linux-musl_$1=$2"
	}

	# Configure the build itself
	cmake_cache_set CMAKE_BUILD_TYPE Release
	cmake_cache_set CMAKE_INSTALL_PREFIX /usr/
	# If the following is set, LLVM should automatically set `CMAKE_INSTALL_LIBDIR`
	cmake_cache_set LLVM_LIBDIR_SUFFIX ""
	# We explicitly set this as there's discussions to standardize around it
	cmake_cache_set CMAKE_INSTALL_LIBDIR /usr/lib
	cmake_cache_set CMAKE_INSTALL_RPATH /usr/lib
	cmake_cache_set LLVM_INSTALL_UTILS ON
	cmake_cache_set LLVM_INSTALL_BINUTILS_SYMLINKS ON
	cmake_cache_set CLANG_CONFIG_FILE_SYSTEM_DIR /etc/clang

	# Configure for `musl`
	cmake_cache_set LLVM_HOST_TRIPLE "${ARCH}-linux-musl"
	cmake_cache_set LLVM_TARGET_ARCH "$LLVM_TARGET_ARCH"
	cmake_cache_set LLVM_RUNTIME_TARGETS "${ARCH}-linux-musl"
	cmake_cache_set LLVM_BUILTIN_TARGETS "${ARCH}-linux-musl"
	cmake_runtime_cache_set LIBCXX_HAS_MUSL_LIBC ON
	cmake_runtime_cache_set COMPILER_RT_DEFAULT_TARGET_ONLY ON

	# Configure which parts of LLVM are built
	cmake_cache_set LLVM_ENABLE_PROJECTS "clang;lld"
	cmake_cache_set LLVM_ENABLE_RUNTIMES "compiler-rt;libunwind;libcxx;libcxxabi"

	# Configure compiler-rt
	cmake_runtime_cache_set COMPILER_RT_BUILD_BUILTINS ON
	cmake_runtime_cache_set COMPILER_RT_USE_BUILTINS_LIBRARY ON
	cmake_runtime_cache_set COMPILER_RT_USE_LLVM_UNWINDER ON
	# This does not work out-of-the-box with a `musl` host
	cmake_runtime_cache_set COMPILER_RT_BUILD_GWP_ASAN OFF
	cmake_cache_set CLANG_DEFAULT_RTLIB compiler-rt

	# Configure libcxx(abi) (and libunwind)
	cmake_cache_set LLVM_ENABLE_LIBCXX ON
	cmake_runtime_cache_set LIBCXX_CXX_ABI libcxxabi
	cmake_runtime_cache_set LIBCXX_HARDENING_MODE fast
	cmake_runtime_cache_set LIBCXX_USE_COMPILER_RT ON
	cmake_runtime_cache_set LIBCXXABI_USE_COMPILER_RT ON
	cmake_runtime_cache_set LIBCXXABI_USE_LLVM_UNWINDER ON
	cmake_runtime_cache_set LIBUNWIND_USE_COMPILER_RT ON

	cmake_cache_set CLANG_DEFAULT_CXX_STDLIB libc++
	cmake_cache_set CLANG_DEFAULT_UNWINDLIB libunwind

	# Disable a variety of unused/uninstantiated features
	cmake_cache_set LLVM_ENABLE_LIBXML2 OFF
	cmake_cache_set LLVM_ENABLE_LIBEDIT OFF
	cmake_cache_set LLVM_ENABLE_LIBPFM OFF
	cmake_cache_set LLVM_ENABLE_ICU OFF
	cmake_cache_set LLVM_ENABLE_ICONV OFF

	cmake_runtime_cache_set COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED OFF

	echo "$CMAKE_ARGS" > ./cmake_args
EOF

RUN --network=none <<-EOF
	# We first build LLVM with GCC, before we will build LLVM with LLVM

	# As this build only has to compile LLVM itself, we disable a variety of unnecessary components
	CMAKE_ARGS="$(cat ./cmake_args)"
	cmake_cache_set() {
	  CMAKE_ARGS="$CMAKE_ARGS -D$1=$2"
	}
	cmake_runtime_cache_set() {
	  CMAKE_ARGS="$CMAKE_ARGS -DRUNTIMES_${ARCH}-linux-musl_$1=$2"
	}

	cmake_runtime_cache_set COMPILER_RT_ENABLE_PEDANTIC OFF
	cmake_runtime_cache_set COMPILER_RT_ENABLE_STATIC_UNWINDER OFF
	cmake_runtime_cache_set COMPILER_RT_BUILD_SANITIZERS OFF
	cmake_runtime_cache_set COMPILER_RT_BUILD_XRAY OFF
	cmake_runtime_cache_set COMPILER_RT_BUILD_LIBFUZZER OFF
	cmake_runtime_cache_set COMPILER_RT_BUILD_PROFILE OFF
	cmake_runtime_cache_set COMPILER_RT_BUILD_CTX_PROFILE OFF
	cmake_runtime_cache_set COMPILER_RT_BUILD_MEMPROF OFF
	cmake_runtime_cache_set COMPILER_RT_BUILD_ORC OFF
	cmake_runtime_cache_set COMPILER_RT_HWASAN_WITH_INTERCEPTORS OFF
	cmake_runtime_cache_set LIBCXX_ENABLE_PEDANTIC OFF
	cmake_runtime_cache_set LIBCXX_ENABLE_STATIC OFF
	cmake_runtime_cache_set LIBCXX_ENABLE_STATIC_ABI_LIBRARY OFF
	cmake_runtime_cache_set LIBCXXABI_ENABLE_PEDANTIC OFF
	cmake_runtime_cache_set LIBCXXABI_ENABLE_STATIC_UNWINDER OFF
	cmake_runtime_cache_set LIBUNWIND_ENABLE_PEDANTIC OFF
	cmake_runtime_cache_set LIBUNWIND_ENABLE_STATIC OFF

	cmake \
		-B build \
		-S llvm \
		-Wno-dev \
		-DLLVM_TARGETS_TO_BUILD="$LLVM_TARGET_ARCH" \
		-DLLVM_BUILD_LLVM_DYLIB=OFF \
		-DLLVM_ENABLE_BACKTRACES=OFF \
		-DLLVM_ENABLE_BINDINGS=OFF \
		-DLLVM_ENABLE_PEDANTIC=OFF \
		-DLLVM_ENABLE_PLUGINS=OFF \
		-DLLVM_ENABLE_TELEMETRY=OFF \
		-DLLVM_ENABLE_ZSTD=OFF \
		-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
		$CMAKE_ARGS
	cmake --build build -v --parallel $(nproc)

	# Remove all object files, static archives from the bootstrap to ensure they aren't further used
	for object_file in $(find /usr/lib -name "*.o"); do
		rm $object_file
	done
	for static_archive in $(find /usr/lib -name "*.a"); do
		rm $static_archive
	done

	# Install the LLVM toolchain we just built
	cmake --install build
	rm -rf build
EOF

# Install `musl` as we just erased all of our `*.a`, `*.o` files, including _our_ copy of `musl`
COPY --from=stagex/core-musl . /

RUN --network=none <<-EOF
	export LIBCC="/usr/lib/clang/21/lib/${TARGET}/libclang_rt.builtins.a"

	# Build LLVM's `atomic.c` into `libatomic.so`
	mkdir build-libatomic
	cd build-libatomic
	clang -std=c99 -fPIC -O2 -c -o atomic.o ../compiler-rt/lib/builtins/atomic.c
	rm -rf /usr/lib/libatomic*
	ar rcs /usr/lib/libatomic.a atomic.o
	ld.lld --shared -o /usr/lib/libatomic.so atomic.o
	cd ..

	export CFLAGS="-fPIC"
	export CXXFLAGS="$CFLAGS"

	#HACK: The only reason we are not using "all" here is because AMDGPU does not build deterministically
	# Zig hard requires "all" so this also forces a messy patch there as well to remove AMDGPU support as well
	export LLVM_TARGETS_TO_BUILD="AArch64;ARM;AVR;BPF;Hexagon;Lanai;LoongArch;Mips;MSP430;NVPTX;PowerPC;RISCV;Sparc;SPIRV;SystemZ;VE;WebAssembly;X86;XCore"

	CMAKE_ARGS="$(cat ./cmake_args)"
	cmake_cache_set() {
		CMAKE_ARGS="$CMAKE_ARGS -D$1=$2"
	}
	cmake_runtime_cache_set() {
		CMAKE_ARGS="$CMAKE_ARGS -DRUNTIMES_${ARCH}-linux-musl_$1=$2"
	}

	cmake_cache_set CMAKE_C_COMPILER /usr/bin/clang
	cmake_cache_set CMAKE_CXX_COMPILER /usr/bin/clang++
	cmake_cache_set CMAKE_AR /usr/bin/llvm-ar
	cmake_cache_set CMAKE_NM /usr/bin/llvm-nm
	cmake_cache_set CMAKE_RANLIB /usr/bin/llvm-ranlib
	cmake_cache_set LLVM_NATIVE_TOOL_DIR /usr/bin/
	cmake_cache_set LLVM_USE_LINKER lld
	cmake_cache_set LLVM_HEADERS_TABLEGEN /usr/bin/llvm-tblgen
	cmake_cache_set CLANG_TABLEGEN /usr/bin/clang-tblgen
	cmake_cache_set LLVM_TARGETS_TO_BUILD "$LLVM_TARGETS_TO_BUILD"
	cmake_cache_set LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON
	cmake_cache_set LLVM_BUILD_LLVM_DYLIB ON
	cmake_cache_set LLVM_LINK_LLVM_DYLIB ON

	echo "$CMAKE_ARGS" > ./cmake_args

	# We disable the sanitizers from this build because they kept hitting a race condition
	# https://codeberg.org/stagex/stagex/issues/778
	cmake_runtime_cache_set COMPILER_RT_BUILD_SANITIZERS OFF

	cmake \
		-B build \
		-S llvm \
		-Wno-dev \
		$CMAKE_ARGS
	cmake --build build -v
EOF

RUN --network=none <<-EOF
	export LIBCC="/usr/lib/clang/21/lib/${TARGET}/libclang_rt.builtins.a"

	export CFLAGS="-fPIC"
	export CXXFLAGS="$CFLAGS"

	CMAKE_ARGS="$(cat ./cmake_args)"
	cmake_cache_set() {
		CMAKE_ARGS="$CMAKE_ARGS -D$1=$2"
	}
	cmake_runtime_cache_set() {
		CMAKE_ARGS="$CMAKE_ARGS -DRUNTIMES_${ARCH}-linux-musl_$1=$2"
	}

	# Now that we've already built everything else, we additionally build the sanitizers
	cmake_runtime_cache_set COMPILER_RT_BUILD_SANITIZERS ON

	cmake \
		-B build \
		-S llvm \
		-Wno-dev \
		$CMAKE_ARGS
	cmake --build build -v
	DESTDIR="/rootfs" cmake --install build

	# NSan, for whatever reason, is not being reproducibly built. It's removed here as it
	# _should_ be unpopular and not a blocker, but ideally this would be solved (TODO).
	rm /rootfs/usr/lib/clang/21/lib/${TARGET}/libclang_rt.nsan*
EOF

RUN --network=none <<-EOF
	ln -sf /usr/bin/clang++ /rootfs/usr/bin/c++
	ln -sf /usr/bin/clang /rootfs/usr/bin/cc
	ln -sf /usr/bin/ld.lld /rootfs/usr/bin/ld
	ln -sf /usr/lib/clang/21/lib/${TARGET}/libclang_rt.builtins.a /rootfs/usr/lib/libclang_rt.builtins.a
	cp /usr/lib/libatomic.* /rootfs/usr/lib/
	strip /rootfs/usr/lib/libLLVM.so.21.1
EOF

FROM build AS build-llvm-libgcc
RUN --network=none <<-EOF
	# The following is allowed to directly use `-DCOMPILER_RT` as it's not building via `llvm`
	cmake \
		-B build-libgcc \
		-S runtimes \
		-Wno-dev \
		-DCMAKE_C_COMPILER=/usr/bin/clang \
		-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
		-DCMAKE_AR=/usr/bin/llvm-ar \
		-DCMAKE_NM=/usr/bin/llvm-nm \
		-DCMAKE_RANLIB=/usr/bin/llvm-ranlib \
		-DCMAKE_C_COMPILER_TARGET="${TARGET}" \
		-DCMAKE_CXX_COMPILER_TARGET="${TARGET}" \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
		-DLLVM_USE_LINKER=lld \
		$(cat ./cmake_args) \
		-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
		-DLLVM_ENABLE_RUNTIMES="llvm-libgcc" \
		-DLLVM_LIBGCC_EXPLICIT_OPT_IN=Yes \
		-DCOMPILER_RT_ENABLE_PEDANTIC=OFF \
		-DCOMPILER_RT_ENABLE_STATIC_UNWINDER=OFF \
		-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
		-DCOMPILER_RT_BUILD_XRAY=OFF \
		-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
		-DCOMPILER_RT_BUILD_PROFILE=OFF \
		-DCOMPILER_RT_BUILD_CTX_PROFILE=OFF \
		-DCOMPILER_RT_BUILD_MEMPROF=OFF \
		-DCOMPILER_RT_BUILD_ORC=OFF \
		-DCOMPILER_RT_HWASAN_WITH_INTERCEPTORS=OFF
	cmake --build build-libgcc -v

	# Install the libraries to a temporary location
	mkdir libgcc-libs
	DESTDIR="libgcc-libs" cmake --install build-libgcc

	# Before installing _solely_ `libgcc*`, not the just-built copies of any other libraries
	rm -rf /rootfs
	mkdir -p /rootfs/usr/lib
	for libgcc in $(find libgcc-libs ! -type d -name "libgcc*"); do
		cp -P $libgcc /rootfs/usr/lib/
	done
	# Also copy the expected `linux` subdirectory which symbolic links point to
	# This is justified as this subdirectory isn't built by default and is specific to the `libgcc` build
	cp -r libgcc-libs/usr/lib/linux /rootfs/usr/lib
EOF

FROM stagex/core-filesystem AS package-llvm
COPY --from=build /rootfs/ /

FROM stagex/core-filesystem AS package-llvm-libgcc
COPY --from=build-llvm-libgcc /rootfs/ /

#FROM stagex/core-filesystem AS package-clang-tools-extra
#COPY --from=build /rootfs/usr/include/clang-tidy /usr/include/
#COPY --from=build /rootfs/usr/share/clang/*tidy* /usr/share/clang/
#COPY --from=build /rootfs/usr/bin/clang-apply-replacements /usr/bin/
#COPY --from=build /rootfs/usr/bin/clang-query /usr/bin/
#COPY --from=build /rootfs/usr/bin/clang-tidy /usr/bin/
#COPY --from=build /rootfs/usr/bin/clang-tidy-confusable-chars-gen /usr/bin
#COPY --from=build /rootfs/usr/bin/diagtool /usr/bin
#COPY --from=build /rootfs/usr/bin/find-all-symbols /usr/bin
#COPY --from=build /rootfs/usr/bin/hmaptool /usr/bin
#COPY --from=build /rootfs/usr/bin/modularize /usr/bin
#COPY --from=build /rootfs/usr/bin/pp-trace /usr/bin
#COPY --from=build /rootfs/usr/bin/run-clang-tidy /usr/bin
#COPY --from=build /rootfs/usr/bin/sancov /usr/bin

#FROM stagex/core-filesystem AS package-clang-tools-extra-static
#COPY --from=build /rootfs/usr/lib/libclangApplyReplacements* /usr/lib/
#COPY --from=build /rootfs/usr/lib/libclangQuery* /usr/lib/
#COPY --from=build /rootfs/usr/lib/libclangTidy* /usr/lib/

FROM stagex/core-filesystem AS package-llvm-binutils
COPY --from=build /rootfs/usr/bin/addr2line /usr/bin/
COPY --from=build /rootfs/usr/bin/ar /usr/bin/
COPY --from=build /rootfs/usr/bin/c++filt /usr/bin/
COPY --from=build /rootfs/usr/bin/dlltool /usr/bin/
COPY --from=build /rootfs/usr/bin/dwp /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-addr2line /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-ar /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-bitcode-strip /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-cxxfilt /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-dlltool /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-dwp /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-install-name-tool /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-lib /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-nm /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-objcopy /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-objdump /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-ranlib /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-rc /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-readelf /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-readobj /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-size /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-strings /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-strip /usr/bin/
COPY --from=build /rootfs/usr/bin/llvm-symbolizer /usr/bin/
COPY --from=build /rootfs/usr/bin/nm /usr/bin/
COPY --from=build /rootfs/usr/bin/objcopy /usr/bin/
COPY --from=build /rootfs/usr/bin/objdump /usr/bin/
COPY --from=build /rootfs/usr/bin/ranlib /usr/bin/
COPY --from=build /rootfs/usr/bin/readelf /usr/bin/
COPY --from=build /rootfs/usr/bin/size /usr/bin/
COPY --from=build /rootfs/usr/bin/strings /usr/bin/
COPY --from=build /rootfs/usr/bin/strip /usr/bin/
COPY --from=build /rootfs/usr/bin/windres /usr/bin/

FROM stagex/core-filesystem AS package-clang
COPY --from=build /rootfs/usr/bin/*clang* /usr/bin/
COPY --from=build /rootfs/usr/bin/*-cc /usr/bin/
COPY --from=build /rootfs/usr/bin/*-c++ /usr/bin/
COPY --from=build /rootfs/usr/bin/c-index-test /usr/bin/
COPY --from=build /rootfs/usr/bin/cc /usr/bin/
#COPY --from=build /rootfs/usr/bin/c89 /usr/bin/
#COPY --from=build /rootfs/usr/bin/c99 /usr/bin/
COPY --from=build /rootfs/usr/bin/c++ /usr/bin/
COPY --from=build /rootfs/usr/lib/cmake/clang /usr/lib/cmake/
COPY --from=build /rootfs/usr/share/clang /usr/share/
#COPY --from=build /rootfs/usr/share/clang-docs /usr/share/

FROM stagex/core-filesystem AS package-clang-rt-devel
COPY --from=build /rootfs/usr/lib/clang/. /usr/lib/clang/

FROM stagex/core-filesystem AS package-clang-devel-static
COPY --from=build /rootfs/usr/lib/libclang*.a /usr/lib/

FROM stagex/core-filesystem AS package-clang-devel
COPY --from=build /rootfs/usr/include/clang /usr/include/
COPY --from=build /rootfs/usr/include/clang-c /usr/include/
COPY --from=build /rootfs/usr/lib/libclang*.so /usr/lib/

FROM stagex/core-filesystem AS package-clang-analyzer
COPY --from=build /rootfs/usr/bin/analyze-build /usr/bin/
COPY --from=build /rootfs/usr/bin/intercept-build /usr/bin/
COPY --from=build /rootfs/usr/bin/scan-* /usr/bin/
COPY --from=build /rootfs/usr/lib/libear /usr/lib/
COPY --from=build /rootfs/usr/lib/libscanbuild /usr/lib/
COPY --from=build /rootfs/usr/libexec/analyze-* /usr/libexec/
COPY --from=build /rootfs/usr/libexec/*analyzer /usr/libexec/
COPY --from=build /rootfs/usr/libexec/intercept-* /usr/libexec/
COPY --from=build /rootfs/usr/share/scan-* /usr/share/
COPY --from=build /rootfs/usr/share/man/man1/scan-build.1 /usr/share/man/man1/

FROM stagex/core-filesystem AS package-clang-libs
COPY --from=build /rootfs/usr/lib/libclang.so.* /usr/lib/

FROM stagex/core-filesystem AS package-clang-cpp-libs
COPY --from=build /rootfs/usr/lib/libclang-cpp.so.* /usr/lib/

FROM stagex/core-filesystem AS package-mlir
COPY --from=build /rootfs/usr/bin/mlir* /usr/bin/

FROM stagex/core-filesystem AS package-mlir-libs
COPY --from=build /rootfs/usr/lib/libMLIR*.so /usr/lib/
COPY --from=build /rootfs/usr/lib/libmlir*.so /usr/lib/

FROM stagex/core-filesystem AS package-mlir-devel
COPY --from=build /rootfs/usr/include/mlir* /usr/include/
COPY --from=build /rootfs/usr/lib/libMLIR*.so /usr/lib/
COPY --from=build /rootfs/usr/lib/libmlir*.so /usr/lib/
#COPY --from=build /rootfs/usr/lib/cmake/mlir /usr/lib/cmake/

FROM stagex/core-filesystem AS package-mlir-devel-static
COPY --from=build /rootfs/usr/lib/libMLIR*.a /usr/lib/

FROM stagex/core-filesystem AS package-libunwind
COPY --from=build /rootfs/usr/lib/libunwind.so.* /usr/lib/

FROM stagex/core-filesystem AS package-libunwind-devel
COPY --from=build /rootfs/usr/lib/libunwind.so /usr/lib/
COPY --from=build /rootfs/usr/include/*unwind* /usr/include/
COPY --from=build /rootfs/usr/include/mach-o /usr/include/

FROM stagex/core-filesystem AS package-libunwind-devel-static
COPY --from=build /rootfs/usr/lib/libunwind.a /usr/lib/

FROM stagex/core-filesystem AS package-libcxx
COPY --from=build /rootfs/usr/lib/libc++.so.* /usr/lib/

FROM stagex/core-filesystem AS package-libcxx-devel
COPY --from=build /rootfs/usr/lib/libc++.modules.json /usr/lib/
COPY --from=build /rootfs/usr/lib/libc++.so /usr/lib/
COPY --from=build /rootfs/usr/lib/libc++experimental.a /usr/lib/
COPY --from=build /rootfs/usr/include/c++ /usr/include/
COPY --from=build /rootfs/usr/share/libc++ /usr/share/

FROM stagex/core-filesystem AS package-libcxx-devel-static
COPY --from=build /rootfs/usr/lib/libc++.a /usr/lib/

FROM stagex/core-filesystem AS package-libcxxabi
COPY --from=build /rootfs/usr/lib/libc++abi.so.* /usr/lib/

FROM stagex/core-filesystem AS package-libcxxabi-devel
COPY --from=build /rootfs/usr/lib/libc++abi.so /usr/lib/
COPY --from=build /rootfs/usr/include/c++/v1/cxxabi.h /usr/include/c++/v1/
COPY --from=build /rootfs/usr/include/c++/v1/__cxxabi_config.h /usr/include/c++/v1/

FROM stagex/core-filesystem AS package-libcxxabi-devel-static
COPY --from=build /rootfs/usr/lib/libc++abi.a /usr/lib/

FROM stagex/core-filesystem AS package-llvm-libs
COPY --from=build /rootfs/usr/lib/libLLVM.so.* /usr/lib/
COPY --from=build /rootfs/usr/lib/libLLVM-*.so.* /usr/lib/

FROM stagex/core-filesystem AS package-lld
COPY --from=build /rootfs/usr/bin/*-ld* /usr/bin/
COPY --from=build /rootfs/usr/bin/ld /usr/bin/
COPY --from=build /rootfs/usr/bin/lld* /usr/bin/
COPY --from=build /rootfs/usr/bin/ld.lld* /usr/bin/
COPY --from=build /rootfs/usr/bin/ld64.lld* /usr/bin/

FROM stagex/core-filesystem AS package-lld-devel
COPY --from=build /rootfs/usr/include/lld /usr/include/
COPY --from=build /rootfs/usr/lib/cmake/lld /usr/lib/cmake/

FROM stagex/core-filesystem AS package-llvm-linker-tools
COPY --from=build /rootfs/usr/lib/libLTO.so.* /usr/lib/

FROM stagex/core-filesystem AS package-llvm-devel
COPY --from=build /rootfs/usr/include/ /usr/include/
COPY --from=build /rootfs/usr/lib/*.so /usr/lib/
COPY --from=build /rootfs/usr/lib/libRemarks.so.* /usr/lib/
COPY --from=build /rootfs/usr/lib/cmake /usr/lib/

FROM stagex/core-filesystem AS package-llvm-devel-static
COPY --from=build /rootfs/usr/lib/*.a /usr/lib/

FROM stagex/core-filesystem AS package-llvm-tools
COPY --from=build /rootfs/usr/bin/FileCheck /usr/bin/
COPY --from=build /rootfs/usr/bin/count /usr/bin/
COPY --from=build /rootfs/usr/bin/not /usr/bin/
COPY --from=build /rootfs/usr/bin/split-file /usr/bin/
COPY --from=build /rootfs/usr/bin/yaml-bench /usr/bin/
COPY --from=build /rootfs/usr/share/opt-viewer /usr/share/

FROM stagex/core-filesystem AS package-llvm-runtime
COPY --from=build /rootfs/usr/bin/lli /usr/bin/
Copied to clipboard!