Skip to content

Commit

Permalink
pkgcheck.sh: verify make and cmake install same bits; tests madler#497
Browse files Browse the repository at this point in the history
…and madler#499

Probably want to be careful about using same
compiler for both builds in general, but for
now, hide it behind the FreeBSD conditional,
since that's where I hit the problem.

Run cmake first and configure/make second, see
issue madler#499 (build breaks due to zconf.h missing)

Add to cirrus CI unixlike builds.
  • Loading branch information
dankegel committed May 24, 2020
1 parent d1365b1 commit 197919a
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 11 deletions.
13 changes: 4 additions & 9 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ check_ubu1804_task:
container:
dockerfile: tooling/cirrus/ubu1804/Dockerfile
test_script:
- cc --version
- mkdir btmp; cd btmp; cmake -G Ninja .. && ninja && ctest -V
- sh tooling/test-cmake.sh && sh tooling/pkgcheck.sh
always:
junit_artifacts:
path: "btmp/*-results.xml"
Expand All @@ -14,8 +13,7 @@ check_ubu2004_task:
container:
dockerfile: tooling/cirrus/ubu2004/Dockerfile
test_script:
- cc --version
- mkdir btmp; cd btmp; cmake -G Ninja .. && ninja && ctest -V
- sh tooling/test-cmake.sh && sh tooling/pkgcheck.sh
always:
junit_artifacts:
path: "btmp/*-results.xml"
Expand All @@ -28,9 +26,7 @@ check_mac_task:
install_script:
- brew install ninja
test_script:
- cc --version
- ninja --version
- mkdir btmp; cd btmp; cmake -G Ninja .. && cmake --build . && ctest -V
- sh tooling/test-cmake.sh && sh tooling/pkgcheck.sh
always:
junit_artifacts:
path: "btmp/*-results.xml"
Expand All @@ -43,8 +39,7 @@ check_bsd_task:
install_script:
- pkg install -y gcc cmake ninja
test_script:
- cc --version
- mkdir btmp; cd btmp; cmake -G Ninja .. && ninja && ctest -V
- sh tooling/test-cmake.sh && sh tooling/pkgcheck.sh
always:
junit_artifacts:
path: "btmp/*-results.xml"
Expand Down
2 changes: 1 addition & 1 deletion tooling/cirrus/ubu1804/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM ubuntu:18.04

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
2 changes: 1 addition & 1 deletion tooling/cirrus/ubu2004/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM ubuntu:20.04

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
88 changes: 88 additions & 0 deletions tooling/pkgcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/sh
# Verify that the various build systems produce identical results on a Unixlike system
set -ex

# Tell GNU's ld etc. to use Jan 1 1970 when embedding timestamps
export SOURCE_DATE_EPOCH=0
# Tell Apple's ar etc. to use zero timestamps
export ZERO_AR_DATE=1

# New build system
# Happens to delete top-level zconf.h
# (which itself is a bug, https://github.com/madler/zlib/issues/162 )
# which triggers another bug later in configure,
# https://github.com/madler/zlib/issues/499
rm -rf btmp2 pkgtmp2
mkdir btmp2 pkgtmp2
export DESTDIR=$(pwd)/pkgtmp2
cd btmp2
cmake -G Ninja ..
ninja -v
ninja install
cd ..

# Original build system
rm -rf btmp1 pkgtmp1
mkdir btmp1 pkgtmp1
export DESTDIR=$(pwd)/pkgtmp1
cd btmp1
case $(uname) in
Darwin)
# Tell configure which compiler etc. to use to match cmake
# Tell configure to pad the executable the same way cmake will
CC="$(xcrun --find gcc || echo gcc)" \
CFLAGS="-DNDEBUG -O3 -isysroot $(xcrun --show-sdk-path)" \
LDFLAGS="-Wl,-headerpad_max_install_names" \
../configure
;;
FreeBSD)
# 1) tell configure to tell ar to be deterministic (skipped, see below)
# 2) configure fails with cc, so use clang or gcc
# 3) Force same CC for configure and clang
#export ARFLAGS="Drc"
if clang --version
then
export CC=clang
../configure
elif gcc --version
then
export CC=gcc
../configure
else
# will probably fail
../configure
fi
;;
*)
../configure
;;
esac
make
make install
cd ..

case $(uname) in
Darwin)
# Alas, dylibs still have an embedded hash or something,
# so nuke it.
# FIXME: find a less fragile way to deal with this.
dylib1=$(find pkgtmp1 -name '*.dylib*' -type f)
dylib2=$(find pkgtmp2 -name '*.dylib*' -type f)
dd conv=notrunc if=/dev/zero of=$dylib1 skip=1337 count=16
dd conv=notrunc if=/dev/zero of=$dylib2 skip=1337 count=16
;;
FreeBSD)
# I had trouble passing -D to the ar inside CMakeLists.txt,
# so punt and unpack the archive before comparing.
cd pkgtmp1; ar x usr/local/lib/libz.a; rm usr/local/lib/libz.a; cd ..
cd pkgtmp2; ar x usr/local/lib/libz.a; rm usr/local/lib/libz.a; cd ..
;;
esac

if diff -Nur pkgtmp1 pkgtmp2
then
echo pkgcheck-cmake-bits-identical PASS
else
echo pkgcheck-cmake-bits-identical FAIL
exit 1
fi
11 changes: 11 additions & 0 deletions tooling/test-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# Build and test with CMake
set -ex

rm -rf btmp
mkdir btmp
cd btmp
cmake -G Ninja ..
ninja
ctest -V
cd ..
11 changes: 11 additions & 0 deletions tooling/test-make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# Build and test with Make
set -ex

rm -rf btmp
mkdir btmp
cd btmp1
../configure
make
make test
cd ..

0 comments on commit 197919a

Please sign in to comment.