nh2 / static-haskell-nix

easily build most Haskell programs into fully static Linux executables
388 stars 36 forks source link

glibc build error with musl on nixpkgs master #56

Closed nh2 closed 4 years ago

nh2 commented 4 years ago

In my new nightly build against nixpkgs master

https://buildkite.com/nh2/static-haskell-nix/builds/85#8e61f177-7a78-4c39-935d-e721c593a150/6-2314

It's building glibc-2.27 with musl, getting error:

../sysdeps/unix/sysv/linux/x86/gettimeofday.c:42:41: error: ‘__gettimeofday’ alias between functions of incompatible types ‘int(struct timeval *, struct timezone *)’ and ‘int (*(void))(struct timeval *, struct timezone *)’ [-Werror=attribute-alias]
...

cc1: all warnings being treated as errors

@dtzWill or @matthewbauer Do you know this problem?

nh2 commented 4 years ago

On #61 I have bisected with git bisect run:

% git bisect log
git bisect start
# good: [07ce48cc3a1c6551a754ad487d2d9a90361530e5] Merge pull request #65924 from r-ryantm/auto-update/gitkraken
git bisect good 07ce48cc3a1c6551a754ad487d2d9a90361530e5
# bad: [2c3b2d19cd3844a7b7e02fc80448321aca622574] git: Don't depend `curl-config` when cross-compiling.
git bisect bad 2c3b2d19cd3844a7b7e02fc80448321aca622574
# bad: [83aa6f5d7f540a088e79941e103bd85a2f0114af] slack-theme-black: 2019-09-07 -> 2019-09-11
git bisect bad 83aa6f5d7f540a088e79941e103bd85a2f0114af
# good: [16c5acf313b4f45121f709e5ff5a221b894720b6] Merge pull request #67352 from symphorien/dogtail
git bisect good 16c5acf313b4f45121f709e5ff5a221b894720b6
# good: [320bcfeb24e4ba560f2d821ccdcb8c602555ebfd] Merge pull request #66635 from Gerschtli/docker-compose-zsh
git bisect good 320bcfeb24e4ba560f2d821ccdcb8c602555ebfd
# good: [5f48e89f37f3bf5dd30ea54d9f1f03e019ad595f] sundials: add lapack support
git bisect good 5f48e89f37f3bf5dd30ea54d9f1f03e019ad595f
# bad: [43d4d45d85c7ed968228ca285e29af4db77f7834] Merge pull request #68369 from tazjin/chore/kontemplate-1.8.0
git bisect bad 43d4d45d85c7ed968228ca285e29af4db77f7834
# bad: [5f4734b1dd8410d5287fe0f22b9c0f30850a2fc3] Merge remote-tracking branch 'upstream/gcc-8' into staging-next
git bisect bad 5f4734b1dd8410d5287fe0f22b9c0f30850a2fc3
# bad: [e68505e7355b0a76caac43783f59fae6474073dc] Merge remote-tracking branch 'upstream/gcc8' into staging-next
git bisect bad e68505e7355b0a76caac43783f59fae6474073dc
# good: [59ff3a08f847d35f274c65f63dd735bfd43c2097] pythonPackages.pystache: fix pname
git bisect good 59ff3a08f847d35f274c65f63dd735bfd43c2097
# bad: [a581c10acab775776b66285dee70ab8e9eddc9af] Revert "iasl: 20180313 -> 20180508"
git bisect bad a581c10acab775776b66285dee70ab8e9eddc9af
# bad: [da5a692fcd561f690fe46807de179c85e7f75263] Merge pull request #40519 from Synthetica9/gcc8-darwin-revert
git bisect bad da5a692fcd561f690fe46807de179c85e7f75263
# bad: [116cce8b5f868c18b91e67fb3b5ba0eed093e62e] libglvnd: set -Wno-error=array-bounds (#40432)
git bisect bad 116cce8b5f868c18b91e67fb3b5ba0eed093e62e
# bad: [3a395ccb57f3d918a361c646f0d7765be63f90a6] systemd: suppress certain warnings to compile under gcc8
git bisect bad 3a395ccb57f3d918a361c646f0d7765be63f90a6
# bad: [c10842fe0b27acb8809181a5eaa2da97ee5d3ce3] libomxil-bellagio: fix build on gcc8
git bisect bad c10842fe0b27acb8809181a5eaa2da97ee5d3ce3
# bad: [2da936e61fd3c943f10f5749c6f88b1eb70941fc] gcc: default to gcc8
git bisect bad 2da936e61fd3c943f10f5749c6f88b1eb70941fc
# first bad commit: [2da936e61fd3c943f10f5749c6f88b1eb70941fc] gcc: default to gcc8

However there were some evaluation failures at the end that may have misled it:

make[2]: *** [/build/build/sysd-rules:93: /build/build/time/gettimeofday.os] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[2]: *** [/build/build/sysd-rules:93: /build/build/time/time.os] Error 1
make[2]: Leaving directory '/build/glibc-2.27/time'
make[1]: *** [Makefile:215: time/subdir_lib] Error 2
make[1]: Leaving directory '/build/glibc-2.27'
make: *** [Makefile:9: all] Error 2
builder for '/nix/store/7ldkj08433a5fjmwln4k3ygg37s5jy4x-glibc-2.27.drv' failed with exit code 2
error: build of '/nix/store/7ldkj08433a5fjmwln4k3ygg37s5jy4x-glibc-2.27.drv' on 'ssh://root@46.4.89.8' failed: builder for '/nix/store/7ldkj08433a5fjmwln4k3ygg37s5jy4x-glibc-2.27.drv' failed with exit code 2
builder for '/nix/store/7ldkj08433a5fjmwln4k3ygg37s5jy4x-glibc-2.27.drv' failed with exit code 1
error: build of '/nix/store/7ldkj08433a5fjmwln4k3ygg37s5jy4x-glibc-2.27.drv' failed
Bisecting: 45 revisions left to test after this (roughly 6 steps)
[59ff3a08f847d35f274c65f63dd735bfd43c2097] pythonPackages.pystache: fix pname
running ./bisect-script.sh
/nix/store/35i7in07zfvl7lpd1y23naqaizcnvcm8-glibc-2.27
Bisecting: 22 revisions left to test after this (roughly 5 steps)
[a581c10acab775776b66285dee70ab8e9eddc9af] Revert "iasl: 20180313 -> 20180508"
running ./bisect-script.sh
error: attribute 'appendOverlays' missing, at /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:30:11
Bisecting: 10 revisions left to test after this (roughly 4 steps)
[da5a692fcd561f690fe46807de179c85e7f75263] Merge pull request #40519 from Synthetica9/gcc8-darwin-revert
running ./bisect-script.sh
error: attribute 'appendOverlays' missing, at /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:30:11
Bisecting: 5 revisions left to test after this (roughly 3 steps)
[116cce8b5f868c18b91e67fb3b5ba0eed093e62e] libglvnd: set -Wno-error=array-bounds (#40432)
running ./bisect-script.sh
error: attribute 'appendOverlays' missing, at /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:30:11
Bisecting: 2 revisions left to test after this (roughly 2 steps)
[3a395ccb57f3d918a361c646f0d7765be63f90a6] systemd: suppress certain warnings to compile under gcc8
running ./bisect-script.sh
error: attribute 'appendOverlays' missing, at /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:30:11
Bisecting: 0 revisions left to test after this (roughly 1 step)
[c10842fe0b27acb8809181a5eaa2da97ee5d3ce3] libomxil-bellagio: fix build on gcc8
running ./bisect-script.sh
error: attribute 'appendOverlays' missing, at /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:30:11
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[2da936e61fd3c943f10f5749c6f88b1eb70941fc] gcc: default to gcc8
running ./bisect-script.sh
error: attribute 'appendOverlays' missing, at /home/niklas/src/haskell/static-haskell-nix/survey/default.nix:30:11
2da936e61fd3c943f10f5749c6f88b1eb70941fc is the first bad commit
commit 2da936e61fd3c943f10f5749c6f88b1eb70941fc
Author: Robin Gloster <mail@glob.in>
Date:   Fri May 4 18:46:36 2018 +0200

    gcc: default to gcc8

:040000 040000 9cdea4cf2ec5eed911e947d2313f88713544bebf b751af924be0ee2b50240805ffaedc5916227c84 M  pkgs
bisect run success
nh2 commented 4 years ago

The problem in the above bisect is that it goes too far back (back to 2018, even though the upgrade I want to do is from mid-2019 master to current master), so far that appendOverlays doesn't exist.

This is likely because of some old branch having been merged into master from the side.

So I've tried the approach from https://blog.smart.ly/2015/02/03/git-bisect-debugging-with-feature-branches/ to restrict the bisection to find which merge into master (that is, typical nixpkgs pull request) introduced the error.

I ran (for rev in $(git rev-list 07ce48cc3a1c6551a754ad487d2d9a90361530e5..2c3b2d19cd3844a7b7e02fc80448321aca622574 --merges --first-parent); do git rev-list $rev^2 --not $rev^; done) | xargs git bisect skip and then git bisect run ./bisect-script.sh. My bisection script is (both here and in the previous bisection):

% cat ./bisect-script.sh
#!/usr/bin/env bash
cd ~/src/haskell/static-haskell-nix && NIX_PATH=nixpkgs=nixpkgs nix-build survey/default.nix --arg disableOptimization true -A pkgs.glibc

Bisection log: bisect-log-master-only.txt.gz

Important part near the end:

...
# good: [21f61dde0dcf436660224acdb7ee5bd6d72ee192] nemiver: clean up (#68333)
git bisect good 21f61dde0dcf436660224acdb7ee5bd6d72ee192
# bad: [731c82a447d916e78f31642ad757a3ce8911f1ea] Merge pull request #68244 from NixOS/staging-next
git bisect bad 731c82a447d916e78f31642ad757a3ce8911f1ea
# only skipped commits left to test
# possible first bad commit: [731c82a447d916e78f31642ad757a3ce8911f1ea] Merge pull request #68244 from NixOS/staging-next
# possible first bad commit: [b5284a56d9b2c0bace0e7d9acdb2003b47fe581e] asn2quickder: fix build
...

This shows that bad: [731c82a447d916e78f31642ad757a3ce8911f1ea] Merge pull request #68244 from NixOS/staging-next (https://github.com/NixOS/nixpkgs/pull/68244) is the PR that introduced the build failure.

nh2 commented 4 years ago

https://github.com/DynamoRIO/dynamorio/issues/3032 suggests that the [-Werror=attribute-alias] warnings are new in GCC 8, which would explain this failure.

Unclear is if we can just silence those warnings, and whether it's sensible that the build builds glibc with musl (it did that before the upgrade as well though).

nh2 commented 4 years ago

Possibly related:

nh2 commented 4 years ago

I commented at https://github.com/NixOS/nixpkgs/pull/68244#issuecomment-544307798

nh2 commented 4 years ago

PR to fix it in nixpkgs: https://github.com/NixOS/nixpkgs/pull/71480