Skip to content

Commit 3a5a61b

Browse files
authored
Merge pull request #8889 from FirebirdSQL/work/out-of-tree-build-linux
Out-of-tree builds on Linux and ARM build performance improvements
2 parents 9864ec0 + 7f3b18a commit 3a5a61b

44 files changed

Lines changed: 653 additions & 379 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
build-linux-docker:
4141
name: build-linux-docker-${{ matrix.arch }}
42-
runs-on: ubuntu-24.04
42+
runs-on: ${{ (startsWith(matrix.arch, 'arm') && 'ubuntu-24.04-arm') || 'ubuntu-24.04' }}
4343
env:
4444
FB_DOCKER_PATH: ${{ (startsWith(matrix.arch, 'arm') && 'arm32-arm64') || 'x86-x64' }}
4545

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ extern/ttmath/release/
2828
/src/include/gen/parse.h
2929
/src/include/gen/autoconfig.auto
3030
/src/include/gen/autoconfig.h
31-
extern/libcds/lib/
3231
/vcpkg_installed/

autogen.sh

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55

66
PKG_NAME=Firebird6
77
SRCDIR=`dirname $0`
8+
SRCDIR=`(cd "$SRCDIR" && pwd)`
9+
OBJDIR=`pwd`
10+
11+
if [ "$OBJDIR" = "$SRCDIR" ]
12+
then
13+
BUILD_MODE=in-tree
14+
else
15+
BUILD_MODE=out-of-tree
16+
fi
817

918
if [ -z "$AUTORECONF" ]
1019
then
@@ -17,8 +26,11 @@ echo "AUTORECONF="$AUTORECONF
1726
AUTOMAKE=true
1827
export AUTOMAKE
1928

20-
# This helps some old aclocal versions find binreloc.m4 in current directory
21-
ACLOCAL='aclocal -I .'
29+
# This helps some old aclocal versions find local and source m4 macros
30+
ACLOCAL="aclocal -I $OBJDIR -I $OBJDIR/m4 -I $SRCDIR"
31+
if [ -d "$SRCDIR/m4" ]; then
32+
ACLOCAL="$ACLOCAL -I $SRCDIR/m4"
33+
fi
2234
export ACLOCAL
2335

2436
# Give a warning if no arguments to 'configure' have been supplied.
@@ -30,9 +42,9 @@ if test -z "$*" -a x$NOCONFIGURE = x; then
3042
fi
3143

3244
# Some versions of autotools need it
33-
if [ ! -d m4 ]; then
34-
rm -rf m4
35-
mkdir m4
45+
if [ ! -d "$OBJDIR/m4" ]; then
46+
rm -rf "$OBJDIR/m4"
47+
mkdir -p "$OBJDIR/m4"
3648
fi
3749

3850
# Ensure correct utilities are called by AUTORECONF
@@ -42,28 +54,49 @@ if [ "x$autopath" != "x" ]; then
4254
export PATH
4355
fi
4456

45-
echo "Running autoreconf ..."
46-
$AUTORECONF --install --force --verbose || exit 1
57+
if [ "$BUILD_MODE" = "out-of-tree" ]
58+
then
59+
mkdir -p "$OBJDIR/builds/make.new"
60+
ln -sf "$SRCDIR/configure.ac" "$OBJDIR/configure.ac"
61+
ln -sf "$SRCDIR/acx_pthread.m4" "$OBJDIR/acx_pthread.m4"
62+
ln -sf "$SRCDIR/binreloc.m4" "$OBJDIR/binreloc.m4"
63+
fi
64+
65+
echo "Running autoreconf in $OBJDIR ($BUILD_MODE) ..."
66+
(cd "$OBJDIR" && $AUTORECONF --install --force --verbose) || exit 1
67+
68+
if [ "$BUILD_MODE" = "out-of-tree" ]
69+
then
70+
# Prefer auxiliary files generated in the build directory when running configure
71+
sed -i 's#ac_aux_dir_candidates="${srcdir}/builds/make.new/config"#ac_aux_dir_candidates="$ac_pwd/builds/make.new/config${PATH_SEPARATOR}${srcdir}/builds/make.new/config"#' "$OBJDIR/configure"
72+
fi
4773

4874
# Hack to bypass bug in autoreconf - --install switch not passed to libtoolize,
4975
# therefore missing config.sub and confg.guess files
50-
CONFIG_AUX_DIR=builds/make.new/config
51-
if [ ! -f $CONFIG_AUX_DIR/config.sub -o ! -f $CONFIG_AUX_DIR/config.guess ]; then
76+
CONFIG_AUX_DIR="$OBJDIR/builds/make.new/config"
77+
if [ ! -f "$CONFIG_AUX_DIR/config.sub" -o ! -f "$CONFIG_AUX_DIR/config.guess" ]; then
5278
# re-run libtoolize with --install switch, if it does not understand that switch
5379
# and there are no config.sub/guess files in CONFIG_AUX_DIR, we will anyway fail
5480
echo "Re-running libtoolize ..."
5581
if [ -z "$LIBTOOLIZE" ]; then
5682
LIBTOOLIZE=libtoolize
5783
fi
58-
$LIBTOOLIZE --install --copy --force || exit 1
84+
(cd "$OBJDIR" && $LIBTOOLIZE --install --copy --force) || exit 1
5985
fi
6086

6187
# If NOCONFIGURE is set, skip the call to configure
6288
if test "x$NOCONFIGURE" = "x"; then
63-
echo Running $SRCDIR/configure $conf_flags "$@" ...
89+
if [ "$BUILD_MODE" = "out-of-tree" ]
90+
then
91+
CONFIGURE_CMD="$OBJDIR/configure --srcdir=$SRCDIR"
92+
else
93+
CONFIGURE_CMD="$OBJDIR/configure"
94+
fi
95+
96+
echo Running $CONFIGURE_CMD $conf_flags "$@" ...
6497
rm -f config.cache config.log
65-
chmod a+x $SRCDIR/configure
66-
$SRCDIR/configure $conf_flags "$@" \
98+
chmod a+x "$OBJDIR/configure"
99+
$CONFIGURE_CMD $conf_flags "$@" \
67100
&& echo Now type \`make\' to compile $PKG_NAME
68101
else
69102
echo Autogen skipping configure process.

builds/docker/linux/arm32-arm64/Dockerfile

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ ARG ARG_LIBTOOL_VERSION=2.4.6
77
ARG ARG_NCURSES_VERSION=6.3
88
ARG ARG_LTM_VERSION=1.2.0
99
ARG ARG_ZLIB_VERSION=1.3.1
10-
ARG ARG_ICU_VERSION=70-1
10+
ARG ARG_ICU_VERSION=77-1
1111

1212
ARG ARG_CPUCOUNT=24
1313

1414
ARG ARG_CTNG_UID=1000
1515
ARG ARG_CTNG_GID=1000
1616

1717

18-
FROM debian:bookworm as builder
18+
FROM $ARG_BASE AS builder
1919

2020
ARG ARG_TARGET_ARCH
2121
ARG ARG_CTNF_CONFIG
@@ -25,7 +25,6 @@ ARG ARG_LIBTOOL_VERSION
2525
ARG ARG_NCURSES_VERSION
2626
ARG ARG_LTM_VERSION
2727
ARG ARG_ZLIB_VERSION
28-
ARG ARG_ICU_VERSION
2928

3029
ARG ARG_CPUCOUNT
3130

@@ -71,10 +70,9 @@ RUN groupadd -g $ARG_CTNG_GID ctng && \
7170

7271
USER ctng
7372

74-
COPY --from=asfernandes/firebird-builder:fb6-x64-ng-v1 --chown=ctng:ctng /home/ctng/x-tools /home/ctng/x-tools
73+
COPY --from=firebirdsql/firebird-builder-linux:fb6-x64-ng-v2 --chown=ctng:ctng /home/ctng/x-tools /home/ctng/x-tools
7574

7675
RUN mkdir ~/build && \
77-
curl -SL --output ~/build/icu4c-${ARG_ICU_VERSION}-src.tgz https://github.com/unicode-org/icu/releases/download/release-${ARG_ICU_VERSION}/icu4c-`echo ${ARG_ICU_VERSION} | tr - _`-src.tgz && \
7876
curl -SL --output ~/build/ncurses-${ARG_NCURSES_VERSION}.tar.gz https://ftp.gnu.org/pub/gnu/ncurses/ncurses-${ARG_NCURSES_VERSION}.tar.gz && \
7977
curl -SL --output ~/build/libtool-${ARG_LIBTOOL_VERSION}.tar.gz https://ftpmirror.gnu.org/libtool/libtool-${ARG_LIBTOOL_VERSION}.tar.gz && \
8078
curl -SL --output ~/build/ltm-${ARG_LTM_VERSION}.tar.xz https://github.com/libtom/libtommath/releases/download/v${ARG_LTM_VERSION}/ltm-${ARG_LTM_VERSION}.tar.xz && \
@@ -110,8 +108,8 @@ RUN sudo apt-get -y remove \
110108
libtomcrypt-dev && \
111109
sudo rm -rf /var/lib/apt/lists/*
112110

113-
ENV PATH "/home/ctng/x-tools/x86_64-pc-linux-gnu/bin:/home/ctng/x-tools/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sysroot/usr/local/bin:${PATH}"
114-
ENV PATH "/home/ctng/x-tools/${ARG_TARGET_ARCH}/bin:/home/ctng/x-tools/${ARG_TARGET_ARCH}/${ARG_TARGET_ARCH}/sysroot/usr/local/bin:${PATH}"
111+
ENV PATH="/home/ctng/x-tools/x86_64-pc-linux-gnu/bin:/home/ctng/x-tools/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sysroot/usr/local/bin:${PATH}"
112+
ENV PATH="/home/ctng/x-tools/${ARG_TARGET_ARCH}/bin:/home/ctng/x-tools/${ARG_TARGET_ARCH}/${ARG_TARGET_ARCH}/sysroot/usr/local/bin:${PATH}"
115113

116114
RUN cd ~/build && \
117115
mkdir -p libtool-${ARG_LIBTOOL_VERSION}-src && \
@@ -180,38 +178,20 @@ RUN cd ~/build && \
180178
make -j${ARG_CPUCOUNT} && \
181179
make install
182180

183-
RUN cd ~/build && \
184-
mkdir icu4c-${ARG_ICU_VERSION}-src && \
185-
tar xvf icu4c-${ARG_ICU_VERSION}-src.tgz --strip 1 -C icu4c-${ARG_ICU_VERSION}-src && \
186-
mkdir icu4c-${ARG_ICU_VERSION}-build-x86_64 && \
187-
cd icu4c-${ARG_ICU_VERSION}-build-x86_64 && \
188-
CXXFLAGS='-std=c++20 -static-libstdc++' ../icu4c-${ARG_ICU_VERSION}-src/source/runConfigureICU \
189-
Linux \
190-
--host=x86_64-pc-linux-gnu && \
191-
make -j${ARG_CPUCOUNT}
192-
193-
RUN cd ~/build && \
194-
mkdir icu4c-${ARG_ICU_VERSION}-build && \
195-
cd icu4c-${ARG_ICU_VERSION}-build && \
196-
CXXFLAGS='-std=c++20 -static-libstdc++' ../icu4c-${ARG_ICU_VERSION}-src/source/runConfigureICU \
197-
Linux \
198-
--host=${ARG_TARGET_ARCH} \
199-
--with-cross-build=/home/ctng/build/icu4c-${ARG_ICU_VERSION}-build-x86_64 \
200-
--prefix=/home/ctng/x-tools/${ARG_TARGET_ARCH}/${ARG_TARGET_ARCH}/sysroot/usr/local \
201-
--includedir=/home/ctng/x-tools/${ARG_TARGET_ARCH}/${ARG_TARGET_ARCH}/sysroot/usr/include && \
202-
make -j${ARG_CPUCOUNT} && \
203-
make install
204-
205181

206182
FROM $ARG_BASE
207183

208184
ARG ARG_TARGET_ARCH
209185
ARG ARG_CTNG_UID
210186
ARG ARG_CTNG_GID
187+
ARG ARG_ICU_VERSION
188+
ARG ARG_CPUCOUNT
211189

212190
RUN apt-get update && \
213191
apt-get -y install \
214192
cmake \
193+
gosu \
194+
curl \
215195
libc6-amd64-cross \
216196
libfile-copy-recursive-perl \
217197
unzip && \
@@ -221,20 +201,36 @@ RUN ln -s /usr/x86_64-linux-gnu/lib64 /lib64 && \
221201
groupadd -g $ARG_CTNG_GID ctng && \
222202
useradd -d /home/ctng -m -g $ARG_CTNG_GID -u $ARG_CTNG_UID -s /bin/bash ctng
223203

224-
USER ctng
225-
226-
RUN chmod o=u /home/ctng
204+
RUN mkdir /home/ctng/firebird-build && \
205+
chown ctng:ctng /home/ctng/firebird-build && \
206+
chmod o=u /home/ctng
227207

228208
COPY --from=builder --chown=ctng:ctng /home/ctng/x-tools /home/ctng/x-tools
229209
COPY --chown=ctng:ctng scripts/* /
230210

231211
# Let non-emulated x86_64-linux-gnu make run.
232212
RUN rm /home/ctng/x-tools/${ARG_TARGET_ARCH}/bin/make
233213

234-
ENV PATH "/home/ctng/x-tools/${ARG_TARGET_ARCH}/bin:/home/ctng/x-tools/${ARG_TARGET_ARCH}/${ARG_TARGET_ARCH}/sysroot/usr/local/bin:/home/ctng/x-tools/x86_64-pc-linux-gnu/bin:${PATH}"
214+
ENV PATH="/home/ctng/x-tools/${ARG_TARGET_ARCH}/bin:/home/ctng/x-tools/${ARG_TARGET_ARCH}/${ARG_TARGET_ARCH}/sysroot/usr/local/bin:/home/ctng/x-tools/x86_64-pc-linux-gnu/bin:${PATH}"
235215
ENV LIBRARY_PATH "/home/ctng/x-tools/${ARG_TARGET_ARCH}/${ARG_TARGET_ARCH}/sysroot/usr/local/lib"
236216
ENV LD_LIBRARY_PATH "/usr/x86_64-linux-gnu/lib:/home/ctng/x-tools/${ARG_TARGET_ARCH}/${ARG_TARGET_ARCH}/sysroot/usr/local/lib"
237217

218+
RUN mkdir ~/build && \
219+
cd ~/build && \
220+
curl -SL --output icu4c-${ARG_ICU_VERSION}-src.tgz https://github.com/unicode-org/icu/releases/download/release-${ARG_ICU_VERSION}/icu4c-`echo ${ARG_ICU_VERSION} | tr - _`-src.tgz && \
221+
mkdir icu4c-${ARG_ICU_VERSION}-src && \
222+
tar xvf icu4c-${ARG_ICU_VERSION}-src.tgz --strip 1 -C icu4c-${ARG_ICU_VERSION}-src && \
223+
mkdir icu4c-${ARG_ICU_VERSION}-build && \
224+
cd icu4c-${ARG_ICU_VERSION}-build && \
225+
CXXFLAGS='-std=c++20 -static-libstdc++' ../icu4c-${ARG_ICU_VERSION}-src/source/runConfigureICU \
226+
Linux \
227+
--host=${ARG_TARGET_ARCH} \
228+
--prefix=/home/ctng/x-tools/${ARG_TARGET_ARCH}/${ARG_TARGET_ARCH}/sysroot/usr && \
229+
make -j${ARG_CPUCOUNT} && \
230+
make install && \
231+
cd / && \
232+
rm -rf ~/build
233+
238234
ENV BUILD_ARCH=$ARG_TARGET_ARCH
239235

240236
WORKDIR /firebird
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/bin/sh
2+
ARG_NATIVE_ARCH=linux/arm
23
docker buildx build \
4+
--progress=plain \
5+
--platform $ARG_NATIVE_ARCH \
36
--pull \
7+
--build-arg ARG_NATIVE_ARCH=$ARG_NATIVE_ARCH \
48
--build-arg ARG_BASE=arm32v7/debian:bookworm \
59
--build-arg ARG_TARGET_ARCH=arm-pc-linux-gnueabihf \
610
--build-arg ARG_CTNF_CONFIG=crosstool-ng-config-arm32 \
7-
-t asfernandes/firebird-builder:fb6-arm32-ng-v1 .
11+
-t firebirdsql/firebird-builder-linux:fb6-arm32-ng-v2 .
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/bin/sh
2+
ARG_NATIVE_ARCH=linux/arm64
23
docker buildx build \
4+
--progress=plain \
5+
--platform $ARG_NATIVE_ARCH \
36
--pull \
7+
--build-arg ARG_NATIVE_ARCH=$ARG_NATIVE_ARCH \
48
--build-arg ARG_BASE=arm64v8/debian:bookworm \
59
--build-arg ARG_TARGET_ARCH=aarch64-pc-linux-gnu \
610
--build-arg ARG_CTNF_CONFIG=crosstool-ng-config-arm64 \
7-
-t asfernandes/firebird-builder:fb6-arm64-ng-v1 .
11+
-t firebirdsql/firebird-builder-linux:fb6-arm64-ng-v2 .
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
22
set -e
33

4-
docker push asfernandes/firebird-builder:fb6-arm32-ng-v1
5-
docker push asfernandes/firebird-builder:fb6-arm64-ng-v1
4+
docker push firebirdsql/firebird-builder-linux:fb6-arm32-ng-v2
5+
docker push firebirdsql/firebird-builder-linux:fb6-arm64-ng-v2
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
#!/bin/sh
2-
docker run --platform arm --rm --user `id -u`:`id -g` -v `pwd`/../../../..:/firebird -t asfernandes/firebird-builder:fb6-arm32-ng-v1
2+
mkdir -p `pwd`/../../../../gen
3+
docker run --platform arm --rm \
4+
-e CTNG_UID=${CTNG_UID:-$(id -u)} \
5+
-e CTNG_GID=${CTNG_GID:-$(id -g)} \
6+
-v `pwd`/../../../..:/firebird \
7+
-v `pwd`/../../../../gen:/home/ctng/firebird-build/gen \
8+
-t firebirdsql/firebird-builder-linux:fb6-arm32-ng-v2
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
#!/bin/sh
2-
docker run --platform arm64 --rm --user `id -u`:`id -g` -v `pwd`/../../../..:/firebird -t asfernandes/firebird-builder:fb6-arm64-ng-v1
2+
mkdir -p `pwd`/../../../../gen
3+
docker run --platform arm64 --rm \
4+
-e CTNG_UID=${CTNG_UID:-$(id -u)} \
5+
-e CTNG_GID=${CTNG_GID:-$(id -g)} \
6+
-v `pwd`/../../../..:/firebird \
7+
-v `pwd`/../../../../gen:/home/ctng/firebird-build/gen \
8+
-t firebirdsql/firebird-builder-linux:fb6-arm64-ng-v2

builds/docker/linux/arm32-arm64/scripts/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ gcc -v
55
ld -v
66
make -v
77

8-
./autogen.sh \
8+
cd /home/ctng/firebird-build
9+
10+
/firebird/autogen.sh \
911
--host=$BUILD_ARCH \
1012
--prefix=/opt/firebird \
1113
--enable-binreloc \

0 commit comments

Comments
 (0)