pkg/libintl: fix missing symbols

This commit is contained in:
Mitchell Hashimoto
2025-03-06 10:10:21 -08:00
parent cb8085ab72
commit e8c20b5501
2 changed files with 2398 additions and 337 deletions

View File

@ -1,3 +1,21 @@
//! Provides libintl for macOS.
//!
//! IMPORTANT: This is only for macOS. We could support other platforms
//! if/when we need to but generally Linux provides libintl in libc.
//! Windows we'll have to figure out when we get there.
//!
//! Since this is only for macOS, there's a lot of hardcoded stuff
//! here that assumes macOS. For example, I generated the config.h
//! on my own machine (a Mac) and then copied it here. This isn't
//! ideal since we should do the same detection that gettext's configure
//! script does, but its quite a bit of work to do that.
//!
//! UPGRADING: If you need to upgrade gettext, then the only thing to
//! really watch out for is the xlocale.h include we added manually
//! at the end of config.h. The comment there notes why. When we upgrade
//! we should audit our config.h and make sure we add that back (if we
//! have to).
const std = @import("std"); const std = @import("std");
pub fn build(b: *std.Build) !void { pub fn build(b: *std.Build) !void {
@ -6,342 +24,6 @@ pub fn build(b: *std.Build) !void {
const upstream = b.dependency("gettext", .{}); const upstream = b.dependency("gettext", .{});
const config = b.addConfigHeader(
.{ .style = .{
.autoconf = upstream.path("gettext-runtime/intl/config.h.in"),
} },
.{
// I mostly figured all of this out by actually running
// `./configure` on my Apple M3 MBP since that's the main
// target I'm interested in (macOS). We should adjust this as
// needed for other platforms.
.AC_APPLE_UNIVERSAL_BUILD = null,
.AVOID_ANY_THREADS = null,
.BITSIZEOF_PTRDIFF_T = null,
.BITSIZEOF_SIZE_T = null,
.BITSIZEOF_SIG_ATOMIC_T = null,
.BITSIZEOF_WCHAR_T = null,
.BITSIZEOF_WINT_T = null,
.CHECK_PRINTF_SAFE = 1,
.C_ALLOCA = null,
.DBL_EXPBIT0_BIT = 20,
.DBL_EXPBIT0_WORD = 1,
.DBL_SIGNBIT_BIT = null,
.DBL_SIGNBIT_WORD = null,
.ENABLE_NLS = 1,
.FLEXIBLE_ARRAY_MEMBER = {},
.FLT_EXPBIT0_BIT = 23,
.FLT_EXPBIT0_WORD = 0,
.FLT_SIGNBIT_BIT = null,
.FLT_SIGNBIT_WORD = null,
.GNULIB_FSCANF = 1,
.GNULIB_LOCK = 1,
.GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU = null,
.GNULIB_SCANF = 1,
.GNULIB_TEST_FGETC = 1,
.GNULIB_TEST_FGETS = 1,
.GNULIB_TEST_FPRINTF = 1,
.GNULIB_TEST_FPUTC = 1,
.GNULIB_TEST_FPUTS = 1,
.GNULIB_TEST_FREAD = 1,
.GNULIB_TEST_FREE_POSIX = 1,
.GNULIB_TEST_FREXP = 1,
.GNULIB_TEST_FREXPL = 1,
.GNULIB_TEST_FSCANF = 1,
.GNULIB_TEST_FWRITE = 1,
.GNULIB_TEST_GETC = 1,
.GNULIB_TEST_GETCHAR = 1,
.GNULIB_TEST_GETCWD = 1,
.GNULIB_TEST_GETLOCALENAME_L_UNSAFE = 1,
.GNULIB_TEST_LOCALENAME_ENVIRON = 1,
.GNULIB_TEST_LOCALENAME_UNSAFE = 1,
.GNULIB_TEST_MBRTOWC = 1,
.GNULIB_TEST_MBSINIT = 1,
.GNULIB_TEST_MBSZERO = 1,
.GNULIB_TEST_MEMCHR = 1,
.GNULIB_TEST_PRINTF = 1,
.GNULIB_TEST_PTHREAD_ONCE = 1,
.GNULIB_TEST_PUTC = 1,
.GNULIB_TEST_PUTCHAR = 1,
.GNULIB_TEST_PUTS = 1,
.GNULIB_TEST_SCANF = 1,
.GNULIB_TEST_SETLOCALE_NULL = 1,
.GNULIB_TEST_SIGNBIT = 1,
.GNULIB_TEST_TSEARCH = 1,
.GNULIB_TEST_VFPRINTF = 1,
.GNULIB_TEST_VPRINTF = 1,
.GNULIB_TEST_WGETCWD = 1,
.GNULIB_TEST_WMEMCPY = 1,
.GNULIB_TEST_WMEMSET = 1,
.HAVE_AIX72_LOCALES = null,
.HAVE_ALLOCA = 1,
.HAVE_ALLOCA_H = 1,
.HAVE_ASPRINTF = 1,
.HAVE_BP_SYM_H = null,
.HAVE_BUILTIN_EXPECT = 1,
.HAVE_CFLOCALECOPYPREFERREDLANGUAGES = 1,
.HAVE_CFPREFERENCESCOPYAPPVALUE = 1,
.HAVE_COPYSIGNF_IN_LIBC = null,
.HAVE_COPYSIGNL_IN_LIBC = null,
.HAVE_COPYSIGN_IN_LIBC = null,
.HAVE_CRTDEFS_H = null,
.HAVE_C_BOOL = null,
.HAVE_C_STATIC_ASSERT = null,
.HAVE_DCGETTEXT = null,
.HAVE_DECL_ALARM = 1,
.HAVE_DECL_COPYSIGN = null,
.HAVE_DECL_COPYSIGNF = null,
.HAVE_DECL_COPYSIGNL = null,
.HAVE_DECL_ECVT = 1,
.HAVE_DECL_EXECVPE = 0,
.HAVE_DECL_FCLOSEALL = 0,
.HAVE_DECL_FCVT = 1,
.HAVE_DECL_FEOF_UNLOCKED = 1,
.HAVE_DECL_FGETS_UNLOCKED = 0,
.HAVE_DECL_GCVT = 1,
.HAVE_DECL_GETW = 1,
.HAVE_DECL_MBRTOWC = null,
.HAVE_DECL_MBSINIT = null,
.HAVE_DECL_PUTW = 1,
.HAVE_DECL_WCSDUP = 1,
.HAVE_DECL_WCSNLEN = 1,
.HAVE_DECL__SNPRINTF = 0,
.HAVE_DECL__SNWPRINTF = 0,
.HAVE_DLFCN_H = 1,
.HAVE_DUPLOCALE = 1,
.HAVE_FAKE_LOCALES = null,
.HAVE_FEATURES_H = null,
.HAVE_FREELOCALE = 1,
.HAVE_FREE_POSIX = null,
.HAVE_FREXPL_IN_LIBC = 1,
.HAVE_FREXP_IN_LIBC = 1,
.HAVE_GETCWD = 1,
.HAVE_GETEGID = 1,
.HAVE_GETEUID = 1,
.HAVE_GETGID = 1,
.HAVE_GETLOCALENAME_L = null,
.HAVE_GETPAGESIZE = 1,
.HAVE_GETTEXT = null,
.HAVE_GETUID = 1,
.HAVE_GOOD_USELOCALE = 1,
.HAVE_ICONV = null,
.HAVE_INTMAX_T = 1,
.HAVE_INTTYPES_H = 1,
.HAVE_INTTYPES_H_WITH_UINTMAX = 1,
.HAVE_ISNAND_IN_LIBC = 1,
.HAVE_ISNANF_IN_LIBC = 1,
.HAVE_ISNANL_IN_LIBC = 1,
.HAVE_LANGINFO_CODESET = 1,
.HAVE_LANGINFO_H = 1,
.HAVE_LC_MESSAGES = 1,
.HAVE_LDEXPL_IN_LIBC = 1,
.HAVE_LDEXP_IN_LIBC = 1,
.HAVE_LIMITS_H = 1,
.HAVE_LONG_LONG_INT = 1,
.HAVE_MAP_ANONYMOUS = 1,
.HAVE_MATH_H = 1,
.HAVE_MBRTOWC = 1,
.HAVE_MBSINIT = 1,
.HAVE_MBSTATE_T = 1,
.HAVE_MEMPCPY = null,
.HAVE_MINIX_CONFIG_H = null,
.HAVE_MMAP = 1,
.HAVE_MPROTECT = 1,
.HAVE_MUNMAP = 1,
.HAVE_NAMELESS_LOCALES = null,
.HAVE_NEWLOCALE = 1,
.HAVE_NL_LANGINFO = 1,
.HAVE_POSIX_PRINTF = 1,
.HAVE_PTHREAD_API = 1,
.HAVE_PTHREAD_H = 1,
.HAVE_PTHREAD_MUTEX_RECURSIVE = 1,
.HAVE_PTHREAD_RWLOCK = 1,
.HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER = 1,
.HAVE_PTHREAD_SPINLOCK_T = null,
.HAVE_PTHREAD_T = 1,
.HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1,
.HAVE_SCHED_H = 1,
.HAVE_SEARCH_H = 1,
.HAVE_SIGNED_SIG_ATOMIC_T = null,
.HAVE_SIGNED_WCHAR_T = null,
.HAVE_SIGNED_WINT_T = null,
.HAVE_SNPRINTF = 1,
.HAVE_SNPRINTF_RETVAL_C99 = 1,
.HAVE_SNPRINTF_TRUNCATION_C99 = 1,
.HAVE_SOLARIS114_LOCALES = null,
.HAVE_STDBOOL_H = 1,
.HAVE_STDINT_H = 1,
.HAVE_STDINT_H_WITH_UINTMAX = 1,
.HAVE_STDIO_H = 1,
.HAVE_STDLIB_H = 1,
.HAVE_STPCPY = 1,
.HAVE_STRCASECMP = 1,
.HAVE_STRINGS_H = 1,
.HAVE_STRING_H = 1,
.HAVE_STRNLEN = 1,
.HAVE_SWPRINTF = 1,
.HAVE_SYMLINK = 1,
.HAVE_SYS_BITYPES_H = null,
.HAVE_SYS_INTTYPES_H = null,
.HAVE_SYS_MMAN_H = 1,
.HAVE_SYS_PARAM_H = 1,
.HAVE_SYS_SINGLE_THREADED_H = null,
.HAVE_SYS_STAT_H = 1,
.HAVE_SYS_TIME_H = 1,
.HAVE_SYS_TYPES_H = 1,
.HAVE_THRD_CREATE = null,
.HAVE_THREADS_H = null,
.HAVE_TSEARCH = 1,
.HAVE_TWALK = 1,
.HAVE_UNISTD_H = 1,
.HAVE_UNSIGNED_LONG_LONG_INT = 1,
.HAVE_USELOCALE = 1,
.HAVE_VASNPRINTF = null,
.HAVE_VISIBILITY = 1,
.HAVE_WCHAR_H = 1,
.HAVE_WCRTOMB = 1,
.HAVE_WCSLEN = 1,
.HAVE_WCSNLEN = 1,
.HAVE_WEAK_SYMBOLS = null,
.HAVE_WINDOWS_LOCALE_T = null,
.HAVE_WINT_T = 1,
.HAVE_WORKING_O_NOATIME = 1,
.HAVE_WORKING_O_NOFOLLOW = 1,
.HAVE_WORKING_SWPRINTF = null,
.HAVE_WORKING_USELOCALE = 1,
.HAVE_WPRINTF = 1,
.HAVE_XLOCALE_H = 1,
.HAVE___FSETLOCKING = null,
.HAVE___HEADER_INLINE = 1,
.ICONV_CONST = {},
.LDBL_EXPBIT0_BIT = 20,
.LDBL_EXPBIT0_WORD = 1,
.LDBL_SIGNBIT_BIT = null,
.LDBL_SIGNBIT_WORD = null,
.LOCALENAME_ENHANCE_LOCALE_FUNCS = null,
.LT_OBJDIR = ".libs/",
.MAP_ANONYMOUS = null,
.MBRTOWC_EMPTY_INPUT_BUG = null,
.MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ = null,
.MBRTOWC_NULL_ARG1_BUG = null,
.MBRTOWC_NULL_ARG2_BUG = null,
.MBRTOWC_NUL_RETVAL_BUG = null,
.MBRTOWC_RETVAL_BUG = null,
.MBRTOWC_STORES_INCOMPLETE_BUG = null,
.__USE_MINGW_ANSI_STDIO = 1,
.MUSL_LIBC = null,
.NEED_PRINTF_DIRECTIVE_A = 1,
.NEED_PRINTF_DIRECTIVE_B = 1,
.NEED_PRINTF_DIRECTIVE_F = null,
.NEED_PRINTF_DIRECTIVE_LC = null,
.NEED_PRINTF_DIRECTIVE_LS = null,
.NEED_PRINTF_DOUBLE = 1,
.NEED_PRINTF_ENOMEM = 1,
.NEED_PRINTF_FLAG_ALT_PRECISION_ZERO = null,
.NEED_PRINTF_FLAG_GROUPING = null,
.NEED_PRINTF_FLAG_LEFTADJUST = null,
.NEED_PRINTF_FLAG_ZERO = null,
.NEED_PRINTF_INFINITE_DOUBLE = null,
.NEED_PRINTF_INFINITE_LONG_DOUBLE = null,
.NEED_PRINTF_LONG_DOUBLE = 1,
.NEED_PRINTF_UNBOUNDED_PRECISION = null,
.NEED_WPRINTF_DIRECTIVE_C = 1,
.NEED_WPRINTF_DIRECTIVE_LA = null,
.NEED_WPRINTF_DIRECTIVE_LC = 1,
.PACKAGE = "libintl",
.PACKAGE_BUGREPORT = "bug-gettext@gnu.org",
.PACKAGE_NAME = "libintl",
.PACKAGE_STRING = "libintl 0.24",
.PACKAGE_TARNAME = "libintl",
.PACKAGE_URL = "",
.PACKAGE_VERSION = "0.24",
.PTHREAD_IN_USE_DETECTION_HARD = null,
.PTRDIFF_T_SUFFIX = null,
.REPLACE_VASNPRINTF = null,
.SETLOCALE_NULL_ALL_MTSAFE = 0,
.SETLOCALE_NULL_ONE_MTSAFE = 1,
.SIG_ATOMIC_T_SUFFIX = null,
.SIZE_MAX = null,
.SIZE_T_SUFFIX = null,
.STACK_DIRECTION = null,
.STDC_HEADERS = 1,
.USE_ISOC_AND_POSIX_THREADS = null,
.USE_ISOC_THREADS = null,
.USE_POSIX_THREADS = 1,
.USE_POSIX_THREADS_FROM_LIBC = null,
.USE_POSIX_THREADS_WEAK = null,
._ALL_SOURCE = 1,
._DARWIN_C_SOURCE = 1,
.__EXTENSIONS__ = 1,
._GNU_SOURCE = 1,
._HPUX_ALT_XOPEN_SOCKET_API = 1,
._MINIX = null,
._NETBSD_SOURCE = 1,
._OPENBSD_SOURCE = 1,
._POSIX_SOURCE = null,
._POSIX_1_SOURCE = null,
._POSIX_PTHREAD_SEMANTICS = 1,
.__STDC_WANT_IEC_60559_ATTRIBS_EXT__ = 1,
.__STDC_WANT_IEC_60559_BFP_EXT__ = 1,
.__STDC_WANT_IEC_60559_DFP_EXT__ = 1,
.__STDC_WANT_IEC_60559_EXT__ = 1,
.__STDC_WANT_IEC_60559_FUNCS_EXT__ = 1,
.__STDC_WANT_IEC_60559_TYPES_EXT__ = 1,
.__STDC_WANT_LIB_EXT2__ = 1,
.__STDC_WANT_MATH_SPEC_FUNCS__ = 1,
._TANDEM_SOURCE = 1,
._XOPEN_SOURCE = null,
.USE_WINDOWS_THREADS = null,
.VERSION = "0.24",
.WCHAR_T_SUFFIX = null,
.WINT_T_SUFFIX = null,
.WORDS_BIGENDIAN = null,
._ISOC11_SOURCE = null,
._LCONV_C99 = null,
._LINUX_SOURCE_COMPAT = 1,
._USE_STD_STAT = 1,
.__STDC_CONSTANT_MACROS = null,
.__STDC_LIMIT_MACROS = null,
.frexp = null,
.frexpl = null,
.@"inline" = null,
.intmax_t = null,
.mbrtowc = null,
.mbsinit = null,
.mbstate_t = null,
.memchr = null,
.mode_t = null,
.pid_t = null,
.ptrdiff_t = null,
.restrict = null,
//.restrict = "__restrict__",
.rpl_fgetc = null,
.rpl_fgets = null,
.rpl_fprintf = null,
.rpl_fputc = null,
.rpl_fputs = null,
.rpl_fread = null,
.rpl_frexp = null,
.rpl_frexpl = null,
.rpl_fscanf = null,
.rpl_fwrite = null,
.rpl_mbrtowc = null,
.rpl_mbsinit = null,
.rpl_memchr = null,
.rpl_tdelete = null,
.rpl_tfind = null,
.rpl_tsearch = null,
.rpl_twalk = null,
.rpl_vfprintf = null,
.size_t = null,
.ssize_t = null,
.tdelete = null,
.tfind = null,
.tsearch = null,
.twalk = null,
},
);
var flags = std.ArrayList([]const u8).init(b.allocator); var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit(); defer flags.deinit();
try flags.appendSlice(&.{ try flags.appendSlice(&.{
@ -365,7 +47,6 @@ pub fn build(b: *std.Build) !void {
try apple_sdk.addPaths(b, &lib.root_module); try apple_sdk.addPaths(b, &lib.root_module);
} }
lib.addConfigHeader(config);
lib.addCSourceFiles(.{ lib.addCSourceFiles(.{
.root = upstream.path("gettext-runtime/intl"), .root = upstream.path("gettext-runtime/intl"),
.files = srcs, .files = srcs,
@ -402,6 +83,16 @@ const srcs: []const []const u8 = &.{
"version.c", "version.c",
"compat.c", "compat.c",
// There's probably a better way to detect that we need these, but
// these are hardcoded for now for macOS.
"gnulib-lib/getlocalename_l-unsafe.c",
"gnulib-lib/localename.c",
"gnulib-lib/localename-environ.c",
"gnulib-lib/localename-unsafe.c",
"gnulib-lib/setlocale-lock.c",
"gnulib-lib/setlocale_null.c",
"gnulib-lib/setlocale_null-unlocked.c",
// Not needed for macOS, but we might need them for other platforms. // Not needed for macOS, but we might need them for other platforms.
// If we expand this to support other platforms, we should uncomment // If we expand this to support other platforms, we should uncomment
// these. // these.

2370
pkg/libintl/config.h Normal file

File diff suppressed because it is too large Load Diff