Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: build GCC 14, build nowallet depends and source with it, stage built packages in /opt, allowlist LLVM libc++ #6387

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
Draft
64 changes: 61 additions & 3 deletions contrib/containers/ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN set -ex; \
apt-get update && \
apt-get install $APT_ARGS \
g++-multilib \
linux-libc-dev:i386 \
wine32; \
fi; \
apt-get install $APT_ARGS \
Expand All @@ -25,9 +26,11 @@ RUN set -ex; \
bison \
build-essential \
bsdmainutils \
curl \
ca-certificates \
ccache \
cmake \
curl \
flex \
g++ \
gettext \
git \
Expand All @@ -44,15 +47,71 @@ RUN set -ex; \
libxcb-xinerama0 \
libxcb-xkb1 \
libxkbcommon-x11-0 \
linux-libc-dev \
lsb-release \
software-properties-common \
tzdata \
unzip \
wget \
m4 \
pkg-config \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

# Compile and install GCC
ARG GCC_VERSION=14.2.0
ARG GCC_COMPILE_ARGS=""
RUN set -ex; \
curl -fL https://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz -o /tmp/gcc.tar.xz; \
mkdir -p /tmp/gcc; \
tar -xf /tmp/gcc.tar.xz -C /tmp/gcc --strip-components=1; \
rm /tmp/gcc.tar.xz; \
cd /tmp/gcc; \
./contrib/download_prerequisites; \
(rm *.tar.* || true); \
dpkgArch="$(dpkg --print-architecture)"; GCC_PLATFORM_ARGS=""; \
case "${dpkgArch##*-}" in \
armel) GCC_PLATFORM_ARGS="--with-arch=armv4t --with-float=soft";; \
armhf) GCC_PLATFORM_ARGS="--with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16 --with-mode=thumb";; \
i386|i686) GCC_PLATFORM_ARGS="--with-arch=i686";; \
amd64) GCC_PLATFORM_ARGS="--enable-multilib --with-abi=m64 --with-arch-32=i686 --with-multilib-list=m32,m64,mx32";; \
esac; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
ln -s "/usr/include/${gnuArch}/asm" "/usr/include/asm"; \
majorVersion="${GCC_VERSION%%.*}"; \
./configure \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am against of building gcc everytime. It's heavy process, it make things that supposed to be close to instant to be "1 hour long".

If you really need custom gcc build - let's build it, put somewhere as a binary, and only download it and verify hashes. It's not necessary should be a build that is done by gcc's team, but it can be 3rd party repo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcc is default compiler in my ubuntu 24.10, I don't see a reason to build it from scratch. It's not a bleeding-edge-night-build which we need.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

@kwvg kwvg Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's heavy process, it make things that supposed to be close to instant to be "1 hour long".

It doesn't take an hour, it takes ~25 minutes (build) and efforts have been made to make it cacheable as possible (as mentioned in the PR description, see below, along with all the alternatives explored, see above). Builds without the GCC compile take ~5 minutes (build), so the slowdown impact relative to the current deployment in a worst-case scenario (cache-miss) is 20 minutes and the subsequent caching should should give us pull times comparable to regular cache hits.

  • Reducing the packages installed in first RUN layer to the minimum needed for GCC and LLVM installations and placing GCC build and install to the second RUN layer.

I'm not against building them separately and downloading binaries for them. What about baking in the first two steps into their own Docker container and FROM'ing it? It should bypass cache misses and the rebuilds that it would attract.


gcc is default compiler in my ubuntu 24.10, I don't see a reason to build it from scratch. It's not a bleeding-edge-night-build which we need.

This has been addressed in the PR description (see below)

  • Moving the development image base to noble as GCC 14 is available for it (source) (but means we aren't testing against the lowest supported LTS).

maybe their's? https://github.com/xpack-dev-tools/gcc-xpack

I had suggested this to Pasta and he seemed lukewarm towards the idea (@PastaPastaPasta, thoughts?)

--build="${gnuArch}" \
--host="${gnuArch}" \
--target="${gnuArch}" \
--disable-bootstrap \
--disable-vtable-verify \
--disable-werror \
--enable-checking=release \
--enable-clocale=gnu \
--enable-default-pie \
--enable-gnu-unique-object \
--enable-languages=c,c++,fortran,objc,obj-c++ \
--enable-libstdcxx-debug \
--enable-libstdcxx-time=yes \
--enable-libsanitizer \
--enable-linker-build-id \
--enable-nls \
--enable-threads=posix \
--prefix="/opt/gcc" \
--program-suffix="-${majorVersion}" \
--with-default-libstdcxx-abi=new \
--with-gcc-major-version-only \
--with-tune=generic \
--without-included-gettext \
${GCC_COMPILE_ARGS} \
${GCC_PLATFORM_ARGS}; \
make -j "$(( $(nproc) - 1 ))"; \
make install-strip; \
cd /tmp; \
rm -rf /tmp/gcc;
ENV LD_LIBRARY_PATH="/opt/gcc/lib:/opt/gcc/lib64:${LD_LIBRARY_PATH}"
ENV PATH="/opt/gcc/bin:${PATH}"

# Install Clang+LLVM and set it as default
# We don't need all packages but the default set doesn't include some
# packages we want so we will need to install some of them manually.
Expand Down Expand Up @@ -80,7 +139,6 @@ RUN set -ex; \
# PYTHON_VERSION should match the value in .python-version
ARG PYTHON_VERSION=3.9.18
RUN apt-get update && apt-get install $APT_ARGS \
ca-certificates \
libbz2-dev \
libffi-dev \
liblzma-dev \
Expand Down Expand Up @@ -158,7 +216,7 @@ ENV PATH="/tmp/shellcheck-${SHELLCHECK_VERSION}:${PATH}"
# due to gcc-multilib installing the following symbolic link, which is needed for -m32 support. However, this causes
# arm builds to also have the asm folder implicitly in the include search path. This is kind of ok, because the asm folder
# for arm has precedence.
RUN ln -s x86_64-linux-gnu/asm /usr/include/asm
RUN ln -s "/usr/include/$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)/asm" "/usr/include/asm"

# Make sure std::thread and friends is available
RUN \
Expand Down