Skip to content

Commit 180b25c

Browse files
committed
compat.libarchive: macOS with musl builds without the Apple SDK (#434)
libarchive reads __APPLE__ as the Apple SDK being present (TargetConditionals.h, copyfile, quarantine) in four private units and in the generated configuration; in an openkal graph for macOS the SDK is not there. __APPLE__ is removed from libarchive's own units under cfg(all(macos, c-abi = "musl")); archive.h and archive_entry.h do not test it. Measured with mcpp 2026.9.17.3: the archive member cross-builds for aarch64-macos above openkal-macos 0.10.0. Windows with musl is not adapted, and the reason is recorded here rather than worked around: libarchive writes wide string literals, which the Windows target makes sixteen bits while musl's wchar_t is thirty-two, and openkal-musl refuses that mixture on purpose (musl/PATCHES.md). The measurement reports it.
1 parent d66232f commit 180b25c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎pkgs/c/compat.libarchive.lua‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ package = {
4747
"-DLIBARCHIVE_STATIC",
4848
"-DPLATFORM_CONFIG_H=\\\"mcpp_libarchive_config.h\\\"",
4949
},
50+
-- macOS with musl as the C library (an openkal graph). libarchive
51+
-- reads __APPLE__ as "the Apple SDK is present" (TargetConditionals.h,
52+
-- copyfile, quarantine) in four private translation units and in the
53+
-- generated configuration below; the SDK is not in that graph. The
54+
-- flag is confined to libarchive's own units, and archive.h and
55+
-- archive_entry.h do not test __APPLE__, so consumers read the same
56+
-- declarations. mcpp-index#434.
57+
target_cfg = {
58+
["cfg(all(macos, c-abi = \"musl\"))"] = {
59+
cflags = { "-U__APPLE__" },
60+
},
61+
},
5062
generated_files = {
5163
["mcpp_generated/include/localcharset.h"] = "#pragma once\nstatic inline const char* locale_charset(void) { return \"UTF-8\"; }\n",
5264
["mcpp_generated/include/mcpp_libarchive_config.h"] = "#pragma once\n#if defined(_WIN32) && !defined(__CYGWIN__)\n#include \"contrib/android/config/windows_host.h\"\n#else\n#include \"contrib/android/config/linux_host.h\"\n#endif\n#define __LIBARCHIVE_CONFIG_H_INCLUDED 1\n#if !defined(__linux__)\n#undef HAVE_LINUX_FIEMAP_H\n#undef HAVE_LINUX_FS_H\n#undef HAVE_LINUX_MAGIC_H\n#undef HAVE_LINUX_TYPES_H\n#undef HAVE_SYS_STATFS_H\n#undef HAVE_SYS_VFS_H\n#endif\n#if defined(__APPLE__)\n#undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC\n#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1\n#undef HAVE_FUTIMESAT\n#undef HAVE_ICONV\n#undef HAVE_ICONV_H\n#endif\n#if defined(_WIN32) && !defined(__CYGWIN__)\n#include <stddef.h>\n#pragma comment(lib, \"advapi32.lib\")\n#pragma comment(lib, \"xmllite.lib\")\n#undef HAVE_UNISTD_H\n#undef HAVE_DECL_SSIZE_MAX\n#define HAVE_DECL_SSIZE_MAX 0\n#define HAVE__GET_TIMEZONE 1\ntypedef ptrdiff_t ssize_t;\ntypedef int pid_t;\ntypedef unsigned short mode_t;\n#ifndef PROV_RSA_AES\n#define PROV_RSA_AES 24\n#endif\n#ifndef CALG_SHA_256\n#define CALG_SHA_256 0x0000800c\n#endif\n#ifndef CALG_SHA_384\n#define CALG_SHA_384 0x0000800d\n#endif\n#ifndef CALG_SHA_512\n#define CALG_SHA_512 0x0000800e\n#endif\n#endif\n#undef HAVE_BZLIB_H\n#define HAVE_BZLIB_H 1\n#undef HAVE_LIBBZ2\n#define HAVE_LIBBZ2 1\n#undef HAVE_LIBLZ4\n#define HAVE_LIBLZ4 1\n#undef HAVE_LIBLZMA\n#define HAVE_LIBLZMA 1\n#undef HAVE_LIBZ\n#define HAVE_LIBZ 1\n#undef HAVE_LIBZSTD\n#define HAVE_LIBZSTD 1\n#undef HAVE_LZ4_H\n#define HAVE_LZ4_H 1\n#undef HAVE_LZ4HC_H\n#define HAVE_LZ4HC_H 1\n#undef HAVE_LZMA_H\n#define HAVE_LZMA_H 1\n#undef HAVE_LZMA_STREAM_ENCODER_MT\n#undef HAVE_ZLIB_H\n#define HAVE_ZLIB_H 1\n#undef HAVE_ZSTD_H\n#define HAVE_ZSTD_H 1\n#undef HAVE_ZSTD_compressStream\n#define HAVE_ZSTD_compressStream 1\n#undef HAVE_ZSTD_minCLevel\n#define HAVE_ZSTD_minCLevel 1\n#undef HAVE_LOCALCHARSET_H\n#define HAVE_LOCALCHARSET_H 1\n#undef HAVE_LOCALE_CHARSET\n#define HAVE_LOCALE_CHARSET 1\n#undef HAVE_CLOSEFROM\n#define HAVE_CLOSEFROM 0\n#undef HAVE_CLOSE_RANGE\n#define HAVE_CLOSE_RANGE 0\n#ifndef HAVE_DECL_INT32_MAX\n#define HAVE_DECL_INT32_MAX 1\n#endif\n#ifndef HAVE_DECL_INT32_MIN\n#define HAVE_DECL_INT32_MIN 1\n#endif\n#ifndef HAVE_DECL_UINTMAX_MAX\n#define HAVE_DECL_UINTMAX_MAX 1\n#endif\n#ifndef HAVE_DECL_INTMAX_MAX\n#define HAVE_DECL_INTMAX_MAX 1\n#endif\n#ifndef HAVE_DECL_INTMAX_MIN\n#define HAVE_DECL_INTMAX_MIN 1\n#endif\n",

0 commit comments

Comments
 (0)