Compare commits
5 commits
main
...
ryansquare
Author | SHA1 | Date | |
---|---|---|---|
d2e1c42115 | |||
c1c40c22b5 | |||
0231a5079a | |||
442fe50d3d | |||
e6673fa187 |
3 changed files with 204 additions and 0 deletions
80
packages/glibc/Containerfile
Normal file
80
packages/glibc/Containerfile
Normal file
|
@ -0,0 +1,80 @@
|
|||
FROM scratch AS base
|
||||
ARG ARCH=x86_64
|
||||
ENV VERSION=2.40
|
||||
ENV SRC_FILE=glibc-${VERSION}.tar.gz
|
||||
ENV SRC_SITE=http://ftpmirror.gnu.org/gnu/glibc/${SRC_FILE}
|
||||
ENV SRC_HASH=2abc038f5022949cb67e996c3cae0e7764f99b009f0b9b7fd954dfc6577b599e
|
||||
ENV CFLAGS="-Os -fstack-clash-protection -Wformat -Werror=format-security"
|
||||
ENV CXXFLAGS="-Os -fstack-clash-protection -Wformat -Werror=format-security -D_GLIBCXX_ASSERTIONS=1 -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -D_LIBCPP_ENABLE_HARDENED_MODE=1"
|
||||
#ENV LDFLAGS="-Wl,--as-needed,-O1,--sort-common -Wl,-soname,libc.musl-${ARCH}.so.1"
|
||||
|
||||
FROM base AS fetch
|
||||
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .
|
||||
|
||||
FROM fetch AS build
|
||||
|
||||
COPY --from=stagex/busybox . /
|
||||
COPY --from=stagex/musl . /
|
||||
# RUN rm -rf /usr/include
|
||||
|
||||
COPY --from=stagex/binutils . /
|
||||
COPY --from=stagex/bison . /
|
||||
COPY --from=stagex/gawk . /
|
||||
COPY --from=stagex/grep . /
|
||||
COPY --from=stagex/gcc . /
|
||||
COPY --from=stagex/linux-headers . /
|
||||
COPY --from=stagex/m4 . /
|
||||
COPY --from=stagex/make . /
|
||||
COPY --from=stagex/python . /
|
||||
RUN tar -xzf ${SRC_FILE}
|
||||
WORKDIR glibc-${VERSION}
|
||||
COPY --from=stagex/linux-headers /usr/include /usr/include/x86_64-linux-gnu
|
||||
ENV _TRIPLE=x86_64-linux-gnu
|
||||
ENV _LIBDIR=/usr/lib/${_TRIPLE}
|
||||
ENV _INCDIR=/usr/include/${_TRIPLE}
|
||||
RUN --network=none <<-EOF
|
||||
set -eux
|
||||
|
||||
sed -i 's/--yacc //' intl/Makefile
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
echo "slibdir=${_LIBDIR}" >> configparams
|
||||
echo "rtlddir=${_LIBDIR}" >> configparams
|
||||
../configure \
|
||||
--build=${ARCH}-linux-musl \
|
||||
--host=${ARCH}-linux-musl \
|
||||
--prefix=/usr \
|
||||
--sysconfdir=/etc \
|
||||
--mandir=/usr/share/man \
|
||||
--infodir=/usr/share/info \
|
||||
--libdir=${_LIBDIR} \
|
||||
--libexecdir=${_LIBDIR} \
|
||||
--includedir=${_INCDIR} \
|
||||
--localstatedir=/var \
|
||||
--with-headers=${_INCDIR} \
|
||||
--disable-nls \
|
||||
--disable-werror \
|
||||
--enable-debug
|
||||
make -j "$(nproc)"
|
||||
EOF
|
||||
|
||||
FROM build AS install
|
||||
RUN --network=none <<-EOF
|
||||
set -eux
|
||||
cd build
|
||||
make DESTDIR=/rootfs install
|
||||
mv /rootfs/sbin/* /rootfs/usr/bin
|
||||
mv /rootfs/lib64 /rootfs/usr/lib64-pre-move
|
||||
rmdir /rootfs/sbin
|
||||
# mkdir -p /rootfs/usr/bin /rootfs/usr/lib
|
||||
# rm -rf /rootfs/lib
|
||||
# ln -sf /usr/lib/ld-musl-${ARCH}.so.1 /rootfs/usr/bin/ldd
|
||||
# mv -f /rootfs/usr/lib/libc.so /rootfs/usr/lib/ld-musl-${ARCH}.so.1
|
||||
# ln -sf ld-musl-${ARCH}.so.1 /rootfs/usr/lib/libc.musl-${ARCH}.so.1
|
||||
# ln -sf /usr/lib/ld-musl-${ARCH}.so.1 /rootfs/usr/lib/libc.so
|
||||
EOF
|
||||
|
||||
FROM scratch AS package
|
||||
COPY --from=stagex/filesystem . /
|
||||
COPY --from=install /rootfs/. /
|
105
packages/rust-target-x86_64-gnu/Containerfile
Normal file
105
packages/rust-target-x86_64-gnu/Containerfile
Normal file
|
@ -0,0 +1,105 @@
|
|||
FROM scratch AS base
|
||||
ARG VERSION=1.76.0
|
||||
ENV SRC_SITE=https://static.rust-lang.org/dist
|
||||
ENV SRC_HASH=9e5cff033a7f0d2266818982ad90e4d3e4ef8f8ee1715776c6e25073a136c021
|
||||
|
||||
FROM base AS fetch
|
||||
COPY --from=stagex/busybox . /
|
||||
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE}/rustc-${VERSION}-src.tar.gz .
|
||||
#ADD rust rustc-${VERSION}-src
|
||||
|
||||
FROM fetch AS build
|
||||
COPY --from=stagex/binutils . /
|
||||
COPY --from=stagex/bash . /
|
||||
COPY --from=stagex/make . /
|
||||
COPY --from=stagex/cmake . /
|
||||
COPY --from=stagex/python . /
|
||||
COPY --from=stagex/py-setuptools . /
|
||||
COPY --from=stagex/zlib . /
|
||||
COPY --from=stagex/pkgconf . /
|
||||
COPY --from=stagex/openssl . /
|
||||
COPY --from=stagex/perl . /
|
||||
COPY --from=stagex/gcc . /
|
||||
COPY --from=stagex/libunwind . /
|
||||
COPY --from=stagex/musl . /
|
||||
COPY --from=stagex/rust . /
|
||||
|
||||
COPY --from=stagex/glibc . /
|
||||
|
||||
COPY --from=stagex/curl . /
|
||||
COPY --from=stagex/ca-certificates . /
|
||||
|
||||
COPY --from=stagex/llvm16 . /
|
||||
RUN mkdir -p $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/
|
||||
|
||||
#ADD no-default-static.patch .
|
||||
ADD glibc.patch .
|
||||
RUN <<EOF
|
||||
set -eux
|
||||
#PATCHES=no-default-static
|
||||
PATCHES=glibc
|
||||
PREFIX=/rust-${VERSION}/usr
|
||||
tar -xzf rustc-${VERSION}-src.tar.gz
|
||||
cd rustc-${VERSION}-src
|
||||
[[ -z "$PATCHES" ]] || for name in ${PATCHES//,/ }; do
|
||||
patch -p1 < ../${name}.patch
|
||||
done
|
||||
./configure \
|
||||
--build="x86_64-unknown-linux-musl" \
|
||||
--host="x86_64-unknown-linux-musl" \
|
||||
--target="x86_64-unknown-linux-gnu" \
|
||||
--enable-local-rust \
|
||||
--llvm-root="/usr" \
|
||||
--disable-docs \
|
||||
--enable-llvm-link-shared \
|
||||
--enable-option-checking \
|
||||
--enable-locked-deps \
|
||||
--enable-vendor \
|
||||
--dist-compression-formats=gz \
|
||||
--python="python3" \
|
||||
--prefix="/rootfs/usr" \
|
||||
--libdir="/usr/lib/x86_64-linux-gnu" \
|
||||
--sysconfdir="/rootfs/etc" \
|
||||
--release-channel="stable" \
|
||||
--set="install.prefix=/rootfs" \
|
||||
--set="build.extended=true" \
|
||||
--set="rust.musl-root=/usr" \
|
||||
--set="rust.backtrace-on-ice=true" \
|
||||
--set="rust.codegen-units=1" \
|
||||
--set="rust.codegen-units-std=1" \
|
||||
--set="rust.deny-warnings=false" \
|
||||
--set="rust.parallel-compiler=false" \
|
||||
--set="rust.remap-debuginfo=true" \
|
||||
--set="rust.llvm-libunwind=system" \
|
||||
--set="build.full-bootstrap=true" \
|
||||
--set="target.x86_64-unknown-linux-gnu.llvm-config=/usr/bin/llvm-config" \
|
||||
--set="target.x86_64-unknown-linux-gnu.cc=cc" \
|
||||
--set="target.x86_64-unknown-linux-gnu.cxx=c++" \
|
||||
--set="target.x86_64-unknown-linux-gnu.ar=ar" \
|
||||
--set="target.x86_64-unknown-linux-gnu.linker=cc" \
|
||||
--set="target.x86_64-unknown-linux-gnu.musl-libdir=/usr/lib/x86_64-linux-gnu"
|
||||
# un-usrmerge glibc
|
||||
rm /lib64
|
||||
mv /usr/lib64-pre-move /lib64
|
||||
python3 x.py build --stage 0 --target x86_64-unknown-linux-gnu library
|
||||
# RUSTFLAGS from pcsc
|
||||
# export RUSTFLAGS="-L /rustc-1.76.0-src/build/x86_64-unknown-linux-musl/stage0-sysroot/lib64/rustlib/x86_64-unknown-linux-gnu/lib/ -L /rustc-1.76.0-src/build/x86_64-unknown-linux-musl/stage0-sysroot/lib64/rustlib/x86_64-unknown-linux-gnu/lib/self-contained/ -L /usr/lib/x86_64-linux-gnu -L /lib64 -C target-feature=+crt-static"
|
||||
EOF
|
||||
|
||||
FROM build AS test
|
||||
ENV RUSTFLAGS="-L /rustc-1.76.0-src/build/x86_64-unknown-linux-musl/stage0-sysroot/lib64/rustlib/x86_64-unknown-linux-gnu/lib/ -L /rustc-1.76.0-src/build/x86_64-unknown-linux-musl/stage0-sysroot/lib64/rustlib/x86_64-unknown-linux-gnu/lib/self-contained/ -L /usr/lib/x86_64-linux-gnu -L /lib64 -C target-feature=+crt-static"
|
||||
RUN <<EOF
|
||||
set -eux
|
||||
cargo new --bin hello_world
|
||||
cd hello_world
|
||||
cargo run --release --target x86_64-unknown-linux-gnu
|
||||
EOF
|
||||
|
||||
FROM build AS install
|
||||
RUN <<-EOF
|
||||
mkdir /rootfs
|
||||
cp -r /rustc-1.76.0-src/build/x86_64-unknown-linux-musl/stage0-sysroot/lib64/rustlib/x86_64-unknown-linux-gnu /usr/lib/rustlib/x86_64-unknown-linux-gnu
|
||||
EOF
|
||||
|
||||
FROM stagex/filesystem AS package
|
||||
COPY --from=install /rootfs/. /
|
19
packages/rust-target-x86_64-gnu/glibc.patch
Normal file
19
packages/rust-target-x86_64-gnu/glibc.patch
Normal file
|
@ -0,0 +1,19 @@
|
|||
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
|
||||
index df4d1a43dab..17bb8bf9659 100644
|
||||
--- a/src/bootstrap/src/core/build_steps/compile.rs
|
||||
+++ b/src/bootstrap/src/core/build_steps/compile.rs
|
||||
@@ -438,12 +438,12 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
|
||||
|
||||
// Help the libc crate compile by assisting it in finding various
|
||||
// sysroot native libraries.
|
||||
- if target.contains("musl") {
|
||||
+ //if target.contains("musl") {
|
||||
if let Some(p) = builder.musl_libdir(target) {
|
||||
let root = format!("native={}", p.to_str().unwrap());
|
||||
cargo.rustflag("-L").rustflag(&root);
|
||||
}
|
||||
- }
|
||||
+ //}
|
||||
|
||||
if target.contains("-wasi") {
|
||||
if let Some(p) = builder.wasi_root(target) {
|
Loading…
Reference in a new issue