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

libelf: fix build with clang 16 on Darwin #235501

Merged
merged 1 commit into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkgs/development/libraries/libelf/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ stdenv.mkDerivation rec {
# Fix warnings from preprocessor instructions.
# https://github.com/NixOS/nixpkgs/issues/59929
./preprocessor-warnings.patch
# `configure` defines a test `main` with an implicit `int` return, which clang 16 disallows.
./fix-configure-main.patch
];

enableParallelBuilding = true;
Expand Down Expand Up @@ -55,7 +57,13 @@ stdenv.mkDerivation rec {
# cross-compiling, but `autoreconfHook` brings in `makeWrapper` which
# doesn't work with the bootstrapTools bash, so can only do this for
# cross builds when `stdenv.shell` is a newer bash.
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) autoreconfHook;
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform
# The provided `configure` script fails on clang 16 because some tests have a `main`
# returning an implicit `int`, which clang 16 treats as an error. Running `autoreconf` fixes
# the test and allows `configure` to detect clang properly.
# This is done only for clang on Darwin because the Darwin stdenv bootstrap does not use
# libelf, so should be safe because it will always be run with a compatible version of bash.
|| (stdenv.cc.isClang && stdenv.isDarwin)) autoreconfHook;

meta = {
description = "ELF object file access library";
Expand Down
12 changes: 12 additions & 0 deletions pkgs/development/libraries/libelf/fix-configure-main.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -ur a/configure.in b/configure.in
--- a/configure.in 2008-05-23 04:17:56.000000000 -0400
+++ b/configure.in 2023-06-01 19:16:04.801921924 -0400
@@ -282,7 +282,7 @@
#define memmove(d,s,n) bcopy((s),(d),(n))
#endif
extern int strcmp();
-main() {
+int main() {
char buf[] = "0123456789";
memmove(buf + 1, buf, 9);
if (strcmp(buf, "0012345678")) exit(1);