pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/60713: lang/libLLVM: does not build on musl ('::lseek64' has not been declared)



>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




Home | Main Index | Thread Index | Old Index