Source: libselinux
Version: 3.8.1-1
Tags: patch ftbfs
User: helm...@debian.org
Usertags: rebootstrap

libselinux fails to build from source for 64bit musl architectures.

aarch64-linux-musl-gcc -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 
-Werror=implicit-function-declaration 
-ffile-prefix-map=/tmp/buildd/libselinux_1/libselinux-3.8.1=. 
-specs=/usr/share/dpkg/pie-compile.specs -fstack-protector-strong -Wformat 
-Werror=format-security -mbranch-protection=standard 
-fno-semantic-interposition -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Wextra 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I../include -D_GNU_SOURCE 
-DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -DHAVE_STRLCPY 
-DHAVE_REALLOCARRAY  -c -o selinux_restorecon.o selinux_restorecon.c
selinux_restorecon.c: In function ‘filespec_add’:
selinux_restorecon.c:441:23: error: storage size of ‘sb’ isn’t known
  441 |         struct stat64 sb;
      |                       ^~
selinux_restorecon.c:455:31: error: implicit declaration of function ‘lstat64’; 
did you mean ‘lstat’? [-Wimplicit-function-declaration]
  455 |                         ret = lstat64(fl->file, &sb);
      |                               ^~~~~~~
      |                               lstat
selinux_restorecon.c:441:23: warning: unused variable ‘sb’ [-Wunused-variable]
  441 |         struct stat64 sb;
      |                       ^~

In order to use lstat64, -D_LARGEFILE64_SOURCE must be defined.
debian/rules defines this for 32bit, but it really is always required.
On 64bit, it would be ok to use lstat directly, but the use of the
lstat64 name requires the macro to be set.

Attaching a patch for your convenience.

Helmut
diff --minimal -Nru libselinux-3.8.1/debian/changelog 
libselinux-3.8.1/debian/changelog
--- libselinux-3.8.1/debian/changelog   2025-03-16 08:02:09.000000000 +0100
+++ libselinux-3.8.1/debian/changelog   2025-05-09 13:54:17.000000000 +0200
@@ -1,3 +1,10 @@
+libselinux (3.8.1-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix musl FTBFS: Always define -D_LARGEFILE64_SOURCE. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Fri, 09 May 2025 13:54:17 +0200
+
 libselinux (3.8.1-1) unstable; urgency=medium
 
   * New upstream release, just change version number Closes: #1099888
diff --minimal -Nru libselinux-3.8.1/debian/rules libselinux-3.8.1/debian/rules
--- libselinux-3.8.1/debian/rules       2025-02-03 09:35:18.000000000 +0100
+++ libselinux-3.8.1/debian/rules       2025-05-09 13:54:15.000000000 +0200
@@ -28,10 +28,8 @@
 
 BUILT_USING=$(shell dpkg-query -f '$${source:Package} (= $${source:Version}), 
' -W "libsepol-dev")
 
-ifeq ($(DEB_HOST_ARCH_BITS),32)
 # Use of lstat64 requires this macro.
 export DEB_CPPFLAGS_MAINT_APPEND += -D_LARGEFILE64_SOURCE
-endif
 
 # Upstream recommends using this flag
 export DEB_CFLAGS_MAINT_APPEND = -fno-semantic-interposition

Reply via email to