NetBSD Problem Report #60713

From zakinko@snowrabbit.org  Thu Sep 10 23:20:11 2026
Return-Path: <zakinko@snowrabbit.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)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 62D7B1A923B
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 10 Sep 2026 23:20:11 +0000 (UTC)
Message-Id: <20260910232009.C3D09C8F25@bambi.snowrabbit.org>
Date: Fri, 11 Sep 2026 08:20:09 +0900 (JST)
From: zakinko@snowrabbit.org
Reply-To: zakinko@snowrabbit.org
To: gnats-bugs@NetBSD.org
Cc: zakinko@snowrabbit.org
Subject: lang/libLLVM: does not build on musl ('::lseek64' has not been declared)
X-Send-Pr-Version: 3.95
X-From4GNATS: "zakinko@snowrabbit.org via gnats" <gnats-admin@NetBSD.org>

>Number:         60713
>Category:       pkg
>Synopsis:       lang/libLLVM: does not build on musl ('::lseek64' has not been declared)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 10 23:25:00 +0000 2026
>Originator:     Showta Ishizaki
>Release:        NetBSD 11.0, pkgsrc CVS as of 2026-09-01
>Organization:
>Environment:
System: NetBSD 11.0 amd64
Architecture: x86_64
Machine: amd64
>Description:
	lang/libLLVM (llvm-13.0.1) fails to compile on musl-based Linux.  On
	Alpine 3.21 (musl):

	  llvm/lib/Support/raw_ostream.cpp:807:11: error: no member named
	  'lseek64' in the global namespace; did you mean 'lseek'?

	raw_fd_ostream::seek() uses ::lseek64 when HAVE_LSEEK64 is defined:

	  #elif defined(HAVE_LSEEK64)
	    pos = ::lseek64(FD, off, SEEK_SET);

	musl exports the lseek64 symbol, so cmake's check_symbol_exists sets
	HAVE_LSEEK64, but musl's <unistd.h> does not declare lseek64 unless
	_LARGEFILE64_SOURCE is defined, so the use is undeclared.  glibc
	declares it unconditionally, which is why only musl is affected.

	I reproduced it by cmake-configuring llvm-13.0.1 on Alpine 3.21 --
	the generated config.h has "#define HAVE_LSEEK64 1" -- and compiling
	the real raw_ostream.cpp with the build's own flags: it fails with the
	error above, and after removing the lseek64 branch it compiles.

	off_t is 64-bit on every platform pkgsrc targets, so plain ::lseek is
	correct; llvm-project removed this branch after the 13 release (it is
	gone in 18.x).

	NetBSD is not affected: on NetBSD 11 the same configure leaves
	HAVE_LSEEK64 undefined (there is no lseek64 in libc), so the file
	already takes the ::lseek branch.  I compiled the patched raw_ostream.cpp
	on NetBSD 11 as well; the patch changes nothing there.

>How-To-Repeat:
	Build lang/libLLVM on a musl-based Linux (e.g. Alpine).  The build
	stops in raw_ostream.cpp with the error above.

>Fix:
	Add the patch below and regenerate distinfo (cvs add the patch).

	  cvs add patches/patch-lib_Support_raw__ostream.cpp

--- distinfo
+SHA1 (patch-lib_Support_raw__ostream.cpp) = d97808c2723a8e4bd035bf7add76c585ad81fea3

$NetBSD$

raw_fd_ostream::seek() uses ::lseek64 when HAVE_LSEEK64 is defined.  musl
libc exports the lseek64 symbol (so cmake defines HAVE_LSEEK64), but does
not declare it in <unistd.h> unless _LARGEFILE64_SOURCE is set, so the
build fails with "'::lseek64' has not been declared".  off_t is already
64-bit on every platform pkgsrc targets, so plain ::lseek is correct.
Drop the lseek64 branch, matching the upstream fix (llvm-project removed
it after the 13 release).

--- lib/Support/raw_ostream.cpp.orig	2022-01-25 00:00:00.000000000 +0000
+++ lib/Support/raw_ostream.cpp
@@ -803,8 +803,6 @@ uint64_t raw_fd_ostream::seek(uint64_t o
   flush();
 #ifdef _WIN32
   pos = ::_lseeki64(FD, off, SEEK_SET);
-#elif defined(HAVE_LSEEK64)
-  pos = ::lseek64(FD, off, SEEK_SET);
 #else
   pos = ::lseek(FD, off, SEEK_SET);
 #endif

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.