Skip to content

Commit

Permalink
Compile zlib manually with PIC in the container
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Mar 28, 2024
1 parent 1ffc524 commit ccc7c82
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
1 change: 1 addition & 0 deletions maintainer/pineappl-ci/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions maintainer/pineappl-ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -34,18 +41,27 @@ 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
for pdf in NNPDF31_nlo_as_0118_luxqed NNPDF40_nnlo_as_01180 NNPDF40_nlo_as_01180; do
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}
Expand All @@ -56,7 +72,6 @@ make install
ldconfig
mkdir -p ${APPL_IGRID_DIR}
cp src/*.h ${APPL_IGRID_DIR}

cd ..

# install fastNLO
Expand All @@ -67,5 +82,4 @@ cd fastnlo_toolkit-${FASTNLO_V}
make -j V=1
make install
ldconfig

cd ..

0 comments on commit ccc7c82

Please sign in to comment.