libselinux: fix build for musl

Fixes: 05494899af53 ("libselinux: fix build on 32-bit LFS platforms")

+13 -42
+10 -41
pkgs/by-name/li/libselinux/fix-build-32bit-lfs.patch
··· 1 - From 86211534862622124d26e8570034efc1f5d78823 Mon Sep 17 00:00:00 2001 2 - From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz> 3 - Date: Sat, 22 Feb 2025 23:09:30 +0100 4 - Subject: [PATCH] Inject matchpathcon_filespec_add64() if 5 - !defined(__INO_T_MATCHES_INO64_T) instead of using __BITS_PER_LONG < 64 as 6 - proxy 7 - MIME-Version: 1.0 8 - Content-Type: text/plain; charset=UTF-8 9 - Content-Transfer-Encoding: 8bit 10 - 11 - The __INO_T_MATCHES_INO64_T is defined 12 - if ino_t would be the same size as ino64_t 13 - if -D_FILE_OFFSET_BITS=64 were not defined. 14 - 15 - This is /exactly/ what 16 - /* ABI backwards-compatible shim for non-LFS 32-bit systems */ 17 - #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 18 - is trying to get at, but currently fails because x32/RV32 are "LFS" 19 - with 32-bit longs and 64-bit time_ts natively. 20 - 21 - Thus, the 22 - static_assert(sizeof(unsigned long) == sizeof(__ino_t), "inode size mismatch"); 23 - assertion fails (__ino_t is the "kernel ino_t" type, 24 - which generally corresponds to the kernel's ulong, which is u64 on x32). 25 - 26 - glibc headers allow us to check the condition we care about directly. 27 - 28 - Fixes: commit 9395cc0322 ("Always build for LFS mode on 32-bit archs.") 29 - Closes: #463 30 - Closes: Debian#1098481 31 - Signed-off-by: наб <nabijaczleweli@nabijaczleweli.xyz> 32 - Cc: Alba Mendez <me@alba.sh> 33 - --- 34 - libselinux/include/selinux/selinux.h | 2 +- 35 - libselinux/src/matchpathcon.c | 4 ++-- 36 - 2 files changed, 3 insertions(+), 3 deletions(-) 37 - 38 diff --git libselinux/include/selinux/selinux.h libselinux/include/selinux/selinux.h 39 index f3cf5a209..f64896b7a 100644 40 --- libselinux/include/selinux/selinux.h ··· 44 use the latter of the two specifications based on their order in the 45 file contexts configuration. Return the used specification index. */ 46 -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 47 - +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && !defined(__INO_T_MATCHES_INO64_T) 48 #define matchpathcon_filespec_add matchpathcon_filespec_add64 49 #endif 50 extern int matchpathcon_filespec_add(ino_t ino, int specind, const char *file); ··· 57 } 58 59 -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 60 - +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && !defined(__INO_T_MATCHES_INO64_T) 61 /* alias defined in the public header but we undefine it here */ 62 #undef matchpathcon_filespec_add 63 64 - @@ -282,7 +282,7 @@ int matchpathcon_filespec_add(unsigned long ino, int specind, 65 } 66 #else 67 68 -static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch"); 69 - +static_assert(sizeof(uint64_t) == sizeof(ino_t), "inode size mismatch"); 70 71 #endif 72
··· 1 diff --git libselinux/include/selinux/selinux.h libselinux/include/selinux/selinux.h 2 index f3cf5a209..f64896b7a 100644 3 --- libselinux/include/selinux/selinux.h ··· 7 use the latter of the two specifications based on their order in the 8 file contexts configuration. Return the used specification index. */ 9 -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 10 + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T) 11 #define matchpathcon_filespec_add matchpathcon_filespec_add64 12 #endif 13 extern int matchpathcon_filespec_add(ino_t ino, int specind, const char *file); ··· 20 } 21 22 -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 23 + +#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T) 24 /* alias defined in the public header but we undefine it here */ 25 #undef matchpathcon_filespec_add 26 27 + @@ -280,9 +280,13 @@ int matchpathcon_filespec_add(unsigned long ino, int specind, 28 + { 29 + return matchpathcon_filespec_add64(ino, specind, file); 30 } 31 + +#elif (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || defined(__INO_T_MATCHES_INO64_T) 32 + + 33 + +static_assert(sizeof(uint64_t) == sizeof(ino_t), "inode size mismatch"); 34 + + 35 #else 36 37 -static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch"); 38 + +static_assert(sizeof(uint32_t) == sizeof(ino_t), "inode size mismatch"); 39 40 #endif 41
+3 -1
pkgs/by-name/li/libselinux/package.nix
··· 57 hash = "sha256-RiEUibLVzfiRU6N/J187Cs1iPAih87gCZrlyRVI2abU="; 58 }) 59 60 - # PR: https://github.com/SELinuxProject/selinux/pull/464 61 # Fix build on 32-bit LFS platforms 62 ./fix-build-32bit-lfs.patch 63 ];
··· 57 hash = "sha256-RiEUibLVzfiRU6N/J187Cs1iPAih87gCZrlyRVI2abU="; 58 }) 59 60 + # commit 5c3fcbd931b7f9752b5ce29cec3b6813991d61c0 plus an additional 61 + # fix for a musl build regression caused by that commit: 62 + # https://lore.kernel.org/selinux/20250426151356.7116-2-hi@alyssa.is/ 63 # Fix build on 32-bit LFS platforms 64 ./fix-build-32bit-lfs.patch 65 ];