# syntax=docker/dockerfile:1 FROM rockylinux:8 AS builder SHELL ["/bin/bash", "-euo", "pipefail", "-c"] ENV LANG=C.UTF-8 ENV TOOLSET=gcc-toolset-15 ENV PATH=/opt/rh/$TOOLSET/root/usr/bin:$PATH ENV LIBRARY_PATH=/opt/rh/$TOOLSET/root/usr/lib64:/opt/rh/$TOOLSET/root/usr/lib:/usr/local/lib64:/usr/local/lib:/lib64:/lib:/usr/lib64:/usr/lib ENV LD_LIBRARY_PATH=$LIBRARY_PATH ENV PKG_CONFIG_PATH=/opt/rh/$TOOLSET/root/usr/lib64/pkgconfig:/opt/rh/$TOOLSET/root/usr/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig RUN --mount=type=cache,target=/var/cache/dnf < /usr/local/bin/pkg-config #!/bin/sh for i in "\$@"; do [ "\$i" = "--version" ] && exec /usr/bin/pkg-config "\$i" done exec /usr/bin/pkg-config --static "\$@" CAT chmod +x /usr/local/bin/pkg-config CMAKE_ROOT="$(cmake --system-information | sed -n 's/^CMAKE_ROOT "\([^"]*\)"$/\1/p')" test -n "$CMAKE_ROOT" sed -i '/CMAKE_${lang}_FLAGS_DEBUG_INIT/s/")/ -O0 {% if LTO %}-fno-lto -fno-use-linker-plugin{% endif %}")/' "$CMAKE_ROOT/Modules/Compiler/GNU.cmake" for i in EXE SHARED MODULE; do sed -i '1i string(APPEND CMAKE_'$i'_LINKER_FLAGS_DEBUG_INIT " -fuse-ld=lld")' "$CMAKE_ROOT/Modules/CMakeCommonLanguageInclude.cmake" done sed -i '/CMAKE_EXE_LINKER_FLAGS_INIT/s/")/ -Wl,--exclude-libs,ALL")/' "$CMAKE_ROOT/Modules/CMakeCommonLanguageInclude.cmake" sed -i '/__gcc_hints/d' "$CMAKE_ROOT/Modules/Compiler/GNU-FindBinUtils.cmake" sed -i '1i set(_CMAKE_TOOLCHAIN_LOCATION "")' "$CMAKE_ROOT/Modules/CMakeFindBinUtils.cmake" sed -i 's/NO_DEFAULT_PATH//g; s/PKG_CONFIG_ALLOW_SYSTEM_LIBS/PKG_CONFIG_IS_DUMB/g' "$CMAKE_ROOT/Modules/FindPkgConfig.cmake" sed -i '/Requires.private: valgrind/d' /usr/lib64/pkgconfig/libdrm.pc sed -i '/Requires.private: gl/s/gl/opengl glx/' /usr/lib64/pkgconfig/epoxy.pc sed -i 's/-lharfbuzz//' /usr/lib64/pkgconfig/harfbuzz.pc sed -i 's/-lpng16//' /usr/lib64/pkgconfig/libpng16.pc rm /etc/profile.d/ccache.* echo set debuginfod enabled on > /opt/rh/$TOOLSET/root/etc/gdbinit.d/00-debuginfod.gdb adduser user EOF WORKDIR /usr/src ENV CC="ccache gcc" ENV CXX="ccache g++" ENV AR=gcc-ar ENV RANLIB=gcc-ranlib ENV NM=gcc-nm ENV CFLAGS='{% if DEBUG %}-g -gdwarf64 -gz{% endif %} {% if MINSIZE %}-Os{% else %}-O3{% endif %} {% if LTO %}-flto=auto -ffat-lto-objects{% endif %} -pipe -fPIC -fno-strict-aliasing -fexceptions -fasynchronous-unwind-tables -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fhardened -Wno-hardened' ENV CXXFLAGS=$CFLAGS ENV LDFLAGS='-static-libstdc++ -static-libgcc -static-libasan -pthread -Wl,--push-state,--no-as-needed,-ldl,--pop-state -Wl,--as-needed -Wl,-z,muldefs' ENV CCACHE_DIR=/var/cache/ccache ENV CCACHE_UMASK=002 ENV CCACHE_COMPRESS=1 ENV CCACHE_MAXSIZE=20G ENV CMAKE_GENERATOR=Ninja ENV CMAKE_BUILD_TYPE=None ENV CMAKE_BUILD_PARALLEL_LEVEL='{{ JOBS }}' ENV SOURCE_DATE_EPOCH=1 RUN < libX11.locks.c <<'EOF2' #include typedef struct _LockInfoRec { pthread_mutex_t mutex; } LockInfoRec, *LockInfoPtr; static LockInfoRec GlobalLock = { PTHREAD_MUTEX_INITIALIZER }; static void LockMutex(LockInfoPtr lock) { pthread_mutex_lock(&lock->mutex); } static void UnlockMutex(LockInfoPtr lock) { pthread_mutex_unlock(&lock->mutex); } LockInfoPtr _Xglobal_lock = &GlobalLock; void (*_XLockMutex_fn)(LockInfoPtr) = LockMutex; void (*_XUnlockMutex_fn)(LockInfoPtr) = UnlockMutex; EOF2 gcc $CFLAGS -c -o libX11.locks.o libX11.locks.c ar rs /usr/local/lib64/libX11.a libX11.locks.o cd ../.. rm -rf Implib.so EOF FROM builder AS patches RUN < src/lib.rs cargo add --path ../tlottie --features c-api cargo add --path ../wallet-engine cargo rustc --lib --release \ --crate-type staticlib --crate-type cdylib \ --config "profile.release.opt-level={% if MINSIZE %}'z'{% else %}3{% endif %}" \ --config "profile.release.lto='{% if LTO %}thin{% else %}off{% endif %}'" \ --config "profile.release.codegen-units=1" \ --config "profile.release.panic='unwind'" \ -- --print native-static-libs mkdir -p $DESTDIR/usr/local/lib64 $DESTDIR/usr/local/include/tlottie $DESTDIR/usr/local/include/wallet_engine objcopy --strip-debug target/release/libtdesktop_rust.a $DESTDIR/usr/local/lib64/libtdesktop_rust.a cp ../tlottie/include/tlottie.h $DESTDIR/usr/local/include/tlottie/tlottie.h cargo run --manifest-path ../wallet-engine/bindgen/cpp/bindgen/Cargo.toml --locked -- \ --library --out-dir $DESTDIR/usr/local/include/wallet_engine \ target/release/libtdesktop_rust.so cd .. rm -rf tlottie wallet-engine tdesktop_rust rustup cargo EOF FROM builder COPY --link --from=zlib /usr/src/zlib-cache / COPY --link --from=xz /usr/src/xz-cache / COPY --link --from=lcms2 /usr/src/lcms2-cache / COPY --link --from=brotli /usr/src/brotli-cache / COPY --link --from=highway /usr/src/highway-cache / COPY --link --from=mozjpeg /usr/src/mozjpeg-cache / COPY --link --from=opus /usr/src/opus-cache / COPY --link --from=dav1d /usr/src/dav1d-cache / COPY --link --from=openh264 /usr/src/openh264-cache / COPY --link --from=vpx /usr/src/vpx-cache / COPY --link --from=webp /usr/src/webp-cache / COPY --link --from=avif /usr/src/avif-cache / COPY --link --from=heif /usr/src/heif-cache / COPY --link --from=jxl /usr/src/jxl-cache / COPY --link --from=rnnoise /usr/src/rnnoise-cache / COPY --link --from=xcb /usr/src/xcb-cache / COPY --link --from=xcb-wm /usr/src/xcb-wm-cache / COPY --link --from=xcb-util /usr/src/xcb-util-cache / COPY --link --from=xcb-image /usr/src/xcb-image-cache / COPY --link --from=xcb-keysyms /usr/src/xcb-keysyms-cache / COPY --link --from=xcb-render-util /usr/src/xcb-render-util-cache / COPY --link --from=xcb-cursor /usr/src/xcb-cursor-cache / COPY --link --from=xext /usr/src/xext-cache / COPY --link --from=xfixes /usr/src/xfixes-cache / COPY --link --from=xv /usr/src/xv-cache / COPY --link --from=xtst /usr/src/xtst-cache / COPY --link --from=xrandr /usr/src/xrandr-cache / COPY --link --from=xrender /usr/src/xrender-cache / COPY --link --from=xdamage /usr/src/xdamage-cache / COPY --link --from=xcomposite /usr/src/xcomposite-cache / COPY --link --from=ffmpeg /usr/src/ffmpeg-cache / COPY --link --from=openal /usr/src/openal-cache / COPY --link --from=openssl /usr/src/openssl-cache / COPY --link --from=xkbcommon /usr/src/xkbcommon-cache / COPY --link --from=qt /usr/src/qt-cache / COPY --link --from=boost /usr/src/boost-cache / COPY --link --from=breakpad /usr/src/breakpad-cache / COPY --link --from=webrtc /usr/src/webrtc-cache / COPY --link --from=ada /usr/src/ada-cache / COPY --link --from=tde2e /usr/src/tde2e-cache / COPY --link --from=tdesktop_rust /usr/src/tdesktop_rust-cache / COPY --link --from=patches /usr/src/patches patches RUN <