From ccc7c82df582979f964a4c9d6fa0296fa7821aef Mon Sep 17 00:00:00 2001 From: Christopher Schwan Date: Thu, 28 Mar 2024 17:09:19 +0100 Subject: [PATCH] Compile zlib manually with PIC in the container --- .github/workflows/rust.yml | 4 ---- maintainer/pineappl-ci/Containerfile | 1 + maintainer/pineappl-ci/script.sh | 20 +++++++++++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 75d487b3..7f3da98e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -59,10 +59,6 @@ jobs: # relative paths sometimes don't work, so use an absolute path echo "RUSTDOCFLAGS=-Cinstrument-coverage -Z unstable-options --persist-doctests $(pwd)/target/debug/doctestbins" >> "$GITHUB_ENV" - - name: Print some compiler information - run: | - echo "int main() {}" > test.c - cc -Q -v test.c - name: Build CLI run: | diff --git a/maintainer/pineappl-ci/Containerfile b/maintainer/pineappl-ci/Containerfile index cf66cae8..71da5db7 100644 --- a/maintainer/pineappl-ci/Containerfile +++ b/maintainer/pineappl-ci/Containerfile @@ -5,6 +5,7 @@ ARG APPLGRID_V=1.6.27 ARG CARGOC_V=0.9.24+cargo-0.73.0 ARG FASTNLO_V=2.5.0-2826 ARG LHAPDF_V=6.4.0 +ARG ZLIB_V=1.3.1 # the last version is the default Rust version used in the container # as long as we're using `persist-doctests` in the `Rust` workflow we need nightly as default diff --git a/maintainer/pineappl-ci/script.sh b/maintainer/pineappl-ci/script.sh index 1723d6d3..c5b61312 100755 --- a/maintainer/pineappl-ci/script.sh +++ b/maintainer/pineappl-ci/script.sh @@ -2,6 +2,13 @@ set -euo pipefail +# print this so we can see whether the compiler/linker has `--enable-default-pie` enabled; if it's +# not enabled we need to build our dependencies with `--with-pic=yes` (see below) +echo "--- COMPILER/LINKER INFORMATION" +echo "int main() {}" > test.c +cc -Q -v test.c +echo "---" + # install rustup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y @@ -34,11 +41,11 @@ rm -r /usr/local/cargo/registry curl "https://web.archive.org/web/20211018095814/https://lhapdf.hepforge.org/downloads/?f=LHAPDF-6.4.0.tar.gz" ) | tar xzf - cd LHAPDF-${LHAPDF_V} # compile static libraries with PIC to make statically linking PineAPPL's CLI work +# see also https://users.rust-lang.org/t/why-does-crelocation-model-dynamic-no-pic-help-although-it-shouldnt/109012 ./configure --disable-python --with-pic=yes make -j V=1 make install ldconfig - cd .. # install PDF sets @@ -46,6 +53,15 @@ for pdf in NNPDF31_nlo_as_0118_luxqed NNPDF40_nnlo_as_01180 NNPDF40_nlo_as_01180 curl "https://lhapdfsets.web.cern.ch/current/${pdf}.tar.gz" | tar xzf - -C /usr/local/share/LHAPDF done +# install zlib compiled with `-fPIC` +curl "https://www.zlib.net/zlib-${ZLIB_V}.tar.gz" | tar xzf - +cd zlib-${ZLIB_V} +CFLAGS=-fPIC ./configure --prefix=/usr/local +make -j +make install +ldconfig +cd .. + # install APPLgrid curl "https://applgrid.hepforge.org/downloads?f=applgrid-${APPLGRID_V}.tgz" | tar xzf - cd applgrid-${APPLGRID_V} @@ -56,7 +72,6 @@ make install ldconfig mkdir -p ${APPL_IGRID_DIR} cp src/*.h ${APPL_IGRID_DIR} - cd .. # install fastNLO @@ -67,5 +82,4 @@ cd fastnlo_toolkit-${FASTNLO_V} make -j V=1 make install ldconfig - cd ..