Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure: pkgsStatic.dnsperf #370498

Open
Azathothas opened this issue Jan 3, 2025 · 7 comments · May be fixed by #370881
Open

Build failure: pkgsStatic.dnsperf #370498

Azathothas opened this issue Jan 3, 2025 · 7 comments · May be fixed by #370881
Labels
0.kind: build failure A package fails to build

Comments

@Azathothas
Copy link

Steps To Reproduce

Steps to reproduce the behavior:

  1. build pkgsStatic.dnsperf

Build log

Build Log
$ nix-build '<nixpkgs>' --impure --attr "pkgsStatic.dnsperf" --cores "$(($(nproc)+1))" --max-jobs "$(($(nproc)+1))" --log-format bar-with-logs
these 4 derivations will be built:
  /nix/store/2i0z44a1r58y8bkkzxm89r13v7jli8q6-ck-static-x86_64-unknown-linux-musl-0.7.2.drv
  /nix/store/lgzydnl3kc5qz43062vf3c2grq8pl540-dns-root-data-static-x86_64-unknown-linux-musl-2024-06-20.drv
  /nix/store/sna0jd3ikxakyqvhvq4m2c0d5fdbn7bv-ldns-static-x86_64-unknown-linux-musl-1.8.4.drv
  /nix/store/ix6jwg29yh16d9abg9skwz3ccxpjmjcp-dnsperf-static-x86_64-unknown-linux-musl-2.14.0.drv
---snipped--
dnsperf-static-x86_64-unknown-linux-musl> x86_64-unknown-linux-musl-gcc -DHAVE_CONFIG_H -I.    -I. -I.. -pthread -I/nix/store/ykfg6sbazxq50frh5aigrwgxbv7cjvr9-openssl-static-x86_64-unknown-linux-musl-3.3.2-dev/include -I/nix/store/ykfg6sbazxq50frh5aigrwgxbv7cjvr9-openssl-static-x86_64-unknown-linux-musl-3.3.2-dev/include -I/nix/store/lh2yfp3lzdl1k40657pk5zfnnlv3hsy1-ldns-static-x86_64-unknown-linux-musl-1.8.4-dev/include -g -O2 -D__unknown__ -DCK_USE_CC_BUILTINS=1 -I/nix/store/84nmik09z723inm2ylb0d7bdp23pyzsp-ck-static-x86_64-unknown-linux-musl-0.7.2/include  -c -o strerror.o strerror.c
dnsperf-static-x86_64-unknown-linux-musl> strerror.c: In function 'perf_strerror_r':
dnsperf-static-x86_64-unknown-linux-musl> strerror.c:35:12: error: returning 'int' from a function with return type 'const char *' makes pointer from integer without a cast []
dnsperf-static-x86_64-unknown-linux-musl>    35 |     return strerror_r(errnum, str, len);
dnsperf-static-x86_64-unknown-linux-musl>       |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
dnsperf-static-x86_64-unknown-linux-musl> make[3]: *** [Makefile:669: strerror.o] Error 1
dnsperf-static-x86_64-unknown-linux-musl> make[3]: Leaving directory '/build/source/src'
dnsperf-static-x86_64-unknown-linux-musl> make[2]: *** [Makefile:741: all-recursive] Error 1
dnsperf-static-x86_64-unknown-linux-musl> make[2]: Leaving directory '/build/source/src'
dnsperf-static-x86_64-unknown-linux-musl> make[1]: *** [Makefile:481: all] Error 2
dnsperf-static-x86_64-unknown-linux-musl> make[1]: Leaving directory '/build/source/src'
dnsperf-static-x86_64-unknown-linux-musl> make: *** [Makefile:475: all-recursive] Error 1
error: builder for '/nix/store/ix6jwg29yh16d9abg9skwz3ccxpjmjcp-dnsperf-static-x86_64-unknown-linux-musl-2.14.0.drv' failed with exit code 2

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory
/nix/store/5mh7kaj2fyv8mk4sfq1brwxgc02884wi-bash-5.2p37/bin/bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.0-25-amd64, Ubuntu, 24.04.1 LTS (Noble Numbat), nobuild`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.25.3`
 - nixpkgs: `/nix/store/qx8njj2ikv1kizbf5pbfbza9f8k9vq50-source`

Notify maintainers

@jtojnar


Add a 👍 reaction to issues you find important.

@Azathothas Azathothas added the 0.kind: build failure A package fails to build label Jan 3, 2025
@jtojnar
Copy link
Member

jtojnar commented Jan 3, 2025

Looks like a warning turned error upon gcc bump. See https://discourse.nixos.org/t/error-builder-for-jack1-0-125-0-drv-failed-with-exit-code-2/58186

@poopsicles
Copy link
Contributor

is it better to a) allow the error with env.NIX_CFLAGS_COMPILE or, b) patch the source to fix the return type?

@FliegendeWurst
Copy link
Member

b) patch the source to fix the return type?

The source does use the correct return type in another ifdef, so the proper fix would be to activate that.

@poopsicles
Copy link
Contributor

poopsicles commented Jan 4, 2025

i'm not sure if i'm doing something wrong, but this doesn't happen when building regular dnsperf, so i don't think it's the gcc issue

pkgsStatic uses musl right? i found DNS-OARC/dnsperf#265, so i'm not sure it works with musl out of the box?

the bit that gets flagged about the return type, stderror_r, looks like it does return int on non GNU:

int strerror_r(int errnum, char buf[.buflen], size_t buflen);
                      /* XSI-compliant */

char *strerror_r(int errnum, char buf[.buflen], size_t buflen);
                      /* GNU-specific */

but even though the check is made with (_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE (amongst others), it still tries to pick the GNU version

anyways, alpine has a patch that takes away the conditional, so would it make sense to apply that if stdenv.hostPlatform.isStatic?

(of course, pkgsStatic shouldn't imply musl #196329, so maybe there's a better way of detecting that?)

EDIT: i think stdenv.hostPlatform.isMusl could work

@FliegendeWurst
Copy link
Member

I suppose you can do a conditional patch. Usually we try to avoid these.

Better would be to undefine _GNU_SOURCE if isMusl, I think.

@poopsicles
Copy link
Contributor

from what i can tell1 (not sure if this is the best way of sussing things out), _GNU_SOURCE isn't being set anywhere, it's the lack of _POSIX_C_SOURCE that's the problem...and i'm not sure what the reasonable value to set it to is

Footnotes

  1. regular dnsperf:

    $ nix-shell -A dnsperf
    [nix-shell:~/Downloads/nixpkgs]$ unpackPhase
    [nix-shell:~/Downloads/nixpkgs]$ cd source
    [nix-shell:~/Downloads/nixpkgs/source]$ $preConfigurePhases
    [nix-shell:~/Downloads/nixpkgs/source]$ configurePhase
    [nix-shell:~/Downloads/nixpkgs/source]$ echo | gcc -dM -E - | grep -i gnu
    #define __gnu_linux__ 1
    #define __GNUC__ 14
    #define __GNUC_WIDE_EXECUTION_CHARSET_NAME "UTF-32LE"
    #define __GNUC_EXECUTION_CHARSET_NAME "UTF-8"
    #define __GNUC_PATCHLEVEL__ 1
    #define __GNUC_STDC_INLINE__ 1
    #define __GNUC_MINOR__ 2
     
    [nix-shell:~/Downloads/nixpkgs/source]$ echo | gcc -dM -E - | grep -i posix
    

    pkgsStatic.dnsperf:

    $ nix-shell -A pkgsStatic.dnsperf
    [nix-shell:~/Downloads/nixpkgs]$ unpackPhase
    [nix-shell:~/Downloads/nixpkgs]$ cd source
    [nix-shell:~/Downloads/nixpkgs/source]$ $preConfigurePhases
    [nix-shell:~/Downloads/nixpkgs/source]$ configurePhase
    [nix-shell:~/Downloads/nixpkgs/source]$ echo | x86_64-unknown-linux-musl-gcc -dM -E - | grep -i gnu
    #define __GNUC__ 14
    #define __GNUC_WIDE_EXECUTION_CHARSET_NAME "UTF-32LE"
    #define __GNUC_EXECUTION_CHARSET_NAME "UTF-8"
    #define __GNUC_PATCHLEVEL__ 1
    #define __GNUC_STDC_INLINE__ 1
    #define __GNUC_MINOR__ 2
     
    [nix-shell:~/Downloads/nixpkgs/source]$ echo | x86_64-unknown-linux-musl-gcc -dM -E - | grep -i posix
    

@poopsicles
Copy link
Contributor

@Azathothas if you need an overlay to get this working:

# configuration.nix
nixpkgs.overlays = [
  # dnsperf doesn't have support for musl
  # remove when https://nixpk.gs/pr-tracker.html?pr=370881 is merged
  (final: prev: {
    dnsperf = prev.dnsperf.overrideAttrs {
      patches = lib.optional prev.stdenv.hostPlatform.isMusl [
        (prev.fetchpatch {
          url = "https://gitlab.alpinelinux.org/alpine/aports/-/raw/5bd92b8f86a0bf15dddf8fa180adf14344d6cc15/testing/dnsperf/musl-perf_strerror_r.patch";
          hash = "sha256-yTJHXkti/xSklmVfAV45lEsOiHy7oL1phImNTNtcPkM=";
        })
      ];
    };
  })
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure A package fails to build
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants