Merge pull request #235501 from reckenrode/libelf-clang-darwin

libelf: fix build with clang 16 on Darwin

authored by toonn and committed by GitHub c11f7232 b7ed52e2

+21 -1
+9 -1
pkgs/development/libraries/libelf/default.nix
··· 21 21 # Fix warnings from preprocessor instructions. 22 22 # https://github.com/NixOS/nixpkgs/issues/59929 23 23 ./preprocessor-warnings.patch 24 + # `configure` defines a test `main` with an implicit `int` return, which clang 16 disallows. 25 + ./fix-configure-main.patch 24 26 ]; 25 27 26 28 enableParallelBuilding = true; ··· 55 57 # cross-compiling, but `autoreconfHook` brings in `makeWrapper` which 56 58 # doesn't work with the bootstrapTools bash, so can only do this for 57 59 # cross builds when `stdenv.shell` is a newer bash. 58 - ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) autoreconfHook; 60 + ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform 61 + # The provided `configure` script fails on clang 16 because some tests have a `main` 62 + # returning an implicit `int`, which clang 16 treats as an error. Running `autoreconf` fixes 63 + # the test and allows `configure` to detect clang properly. 64 + # This is done only for clang on Darwin because the Darwin stdenv bootstrap does not use 65 + # libelf, so should be safe because it will always be run with a compatible version of bash. 66 + || (stdenv.cc.isClang && stdenv.isDarwin)) autoreconfHook; 59 67 60 68 meta = { 61 69 description = "ELF object file access library";
+12
pkgs/development/libraries/libelf/fix-configure-main.patch
··· 1 + diff -ur a/configure.in b/configure.in 2 + --- a/configure.in 2008-05-23 04:17:56.000000000 -0400 3 + +++ b/configure.in 2023-06-01 19:16:04.801921924 -0400 4 + @@ -282,7 +282,7 @@ 5 + #define memmove(d,s,n) bcopy((s),(d),(n)) 6 + #endif 7 + extern int strcmp(); 8 + -main() { 9 + +int main() { 10 + char buf[] = "0123456789"; 11 + memmove(buf + 1, buf, 9); 12 + if (strcmp(buf, "0012345678")) exit(1);