NetBSD Problem Report #59413

From www@netbsd.org  Fri May  9 19:59:15 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 0848F1A9242
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  9 May 2025 19:59:15 +0000 (UTC)
Message-Id: <20250509195913.F04AB1A9243@mollari.NetBSD.org>
Date: Fri,  9 May 2025 19:59:13 +0000 (UTC)
From: bad@bsd.de
Reply-To: bad@bsd.de
To: gnats-bugs@NetBSD.org
Subject: tools build blows up in zutil.h on macOS 15.4.1/Xcode 16.3
X-Send-Pr-Version: www-1.0

>Number:         59413
>Category:       toolchain
>Synopsis:       tools build blows up in zutil.h on macOS 15.4.1/Xcode 16.3
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    bad
>State:          needs-pullups
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 09 20:00:00 +0000 2025
>Closed-Date:    
>Last-Modified:  Thu May 22 11:24:32 +0000 2025
>Originator:     Christoph Badura
>Release:        netbsd-current
>Organization:
The MAZE OF TWISTY LITTLE ZLIB VERSIONS, ALL DIFFERENT Foundation
>Environment:
Darwin inspiral-coalescence-ringdown 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:28:23 PDT 2025; root:xnu-11417.101.15~117/RELEASE_X86_64 x86_64
Apple clang version 17.0.0 (clang-1700.0.13.3)
Target: x86_64-apple-darwin24.4.0

>Description:
clang aborts with: 
In file included from /Users/bad/work/netbsd/src-current/tools/gdb/../../external/gpl3/gdb/dist/zlib/zutil.c:10:
In file included from /Users/bad/work/netbsd/src-current/tools/gdb/../../external/gpl3/gdb/dist/zlib/gzguts.h:21:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:61:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:318:7: error: expected identifier or '('
  318 | FILE    *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fdopen));
      |          ^
/Users/bad/work/netbsd/src-current/tools/gdb/../../external/gpl3/gdb/dist/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
  147 | #        define fdopen(fd,mode) NULL /* No fdopen() */

The same happens for binutils and gcc.

Also:

In file included from /Users/bad/work/netbsd/src-current/tools/gdb/../../external/gpl3/gdb/dist/zlib/zutil.c:8:
/Users/bad/work/netbsd/src-current/tools/gdb/../../external/gpl3/gdb/dist/zlib/zutil.h:170:11: warning: 'OS_CODE' macro redefined [-Wmacro-redefined]
  170 | #  define OS_CODE 19
      |           ^
/Users/bad/work/netbsd/src-current/tools/gdb/../../external/gpl3/gdb/dist/zlib/zutil.h:141:11: note: previous definition is here
  141 | #  define OS_CODE  7
      |           ^

First report (with out details, though) by Greg Woods:
https://mail-index.netbsd.org/current-users/2025/04/04/msg046361.html

Both problems fixed upstream in zlib in commit
https://github.com/madler/zlib/commit/4bd9a71f3539b5ce47f0c67ab5e01f3196dc8ef9
which removed the #define for fdopen as that isn't used by the zlib code anymore.

Our tree includes 6 copies of zlib:
common/dist/zlib/zutil.h
external/cddl/osnet/dist/uts/common/zmod/zutil.h

external/gpl3/gdb/dist/zlib/zutil.h
external/gpl3/gdb.old/dist/zlib/zutil.h
external/gpl3/binutils.old/dist/zlib/zutil.h
external/gpl3/binutils/dist/zlib/zutil.h

The first one is at version 1.3.1 and not affected.
The second one is not used in the tools build.

The last 4 need to be patched.

martin@ remarked that it would be desirable to not have 6 copies of zlib in the tree.

This is probably worth pulling up.  But that very likely needs to be done with a patch.

>How-To-Repeat:
"build.sh -m amd64 tools build" on macOS 15.4.1 with Xcode 16.3 installed.

>Fix:
Liberally apply the above upstream commit.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: toolchain-manager->bad
Responsible-Changed-By: bad@NetBSD.org
Responsible-Changed-When: Fri, 09 May 2025 20:02:01 +0000
Responsible-Changed-Why:
take


From: "Christoph Badura" <bad@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59413 CVS commit: src/external/gpl3
Date: Fri, 9 May 2025 20:18:10 +0000

 Module Name:	src
 Committed By:	bad
 Date:		Fri May  9 20:18:10 UTC 2025

 Modified Files:
 	src/external/gpl3/binutils.old/dist/zlib: zutil.h
 	src/external/gpl3/binutils/dist/zlib: zutil.h
 	src/external/gpl3/gdb.old/dist/zlib: zutil.h
 	src/external/gpl3/gdb/dist/zlib: zutil.h

 Log Message:
 binutils, gdb: fix build und Xcode 16.3

 Apply https://github.com/madler/zlib/commit/4bd9a71f3539b5ce47f0c67ab5e01f3196dc8ef9
 This removes the #defines for fdopen which isn't used by the zlib code anymore.
 It also removes a bogus use of "|| defined(TARGET_OS_MAC)" (now defined by
 default by the Xcode compiler) which caused a redefinition of OS_CODE.

 First reported by Greg Woods:
 https://mail-index.netbsd.org/current-users/2025/04/04/msg046361.html

 Probably worth pulling up to -10 and -9 but very likely needs to be done via
 a patch.

 Only tested by a full amd64 build.  So the {binutils,gdb}.old change is
 untested, but the diff looks good to me and I don't expect any failures.

 We probably should have 6 copies of zlib in the tree, all of slightly
 different version.

 Fixes PR toolchain/59413.


 To generate a diff of this commit:
 cvs rdiff -u -r1.6 -r1.7 src/external/gpl3/binutils.old/dist/zlib/zutil.h
 cvs rdiff -u -r1.1.1.5 -r1.2 src/external/gpl3/binutils/dist/zlib/zutil.h
 cvs rdiff -u -r1.1.1.5 -r1.2 src/external/gpl3/gdb.old/dist/zlib/zutil.h
 cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gdb/dist/zlib/zutil.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Christoph Badura <bad@bsd.de>
To: gnats-bugs@netbsd.org
Cc: jiaxun.yang@flygoat.com
Subject: Re: toolchain/59413: tools build blows up in zutil.h on macOS
 15.4.1/Xcode 16.3
Date: Sat, 10 May 2025 17:25:12 +0200

 Duplicate of PR toolchain/59383: build.sh failed to build binutils on MacOS 15.4
 https://gnats.netbsd.org/59383

 Sorry, I wasn't aware of that and I forgot to search the bug database.

 --chris

State-Changed-From-To: open->needs-pullups
State-Changed-By: bad@NetBSD.org
State-Changed-When: Thu, 22 May 2025 11:24:32 +0000
State-Changed-Why:
Worth pulling up to -10 and probably -9.
I don't currently have the resources to test, though.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.