Page MenuHomeFreeBSD

localedef: Fix bootstrapping on Ubuntu 16.04

Authored by jrtc27 on Jan 23 2021, 10:57 PM.



Glibc's stdlib.h defines various prototypes for GNU extensions that take
a locale_t. Newer versions use locale_t directly and include an internal
bits/types/locale_t.h in order to get its definition, but older versions
include xlocale.h for that, for which our bootstrap version is empty.
Moreover it expects to use the glibc-specific __locale_t type. Thus,
provide dummy definitions of both types in order to ensure the
prototypes don't give any errors, and guard against the header being
inadvertently included between the bootstrapping namespace.h and
un-namespace.h, where locale_t is #define'd.

Diff Detail

R10 FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

This revision is now accepted and ready to land.Jan 23 2021, 11:39 PM

I was able to compile this on a 12.2 system with -DBUILD_WITH_STRICT_TMPPATH -DBOOTSTRAP_ALL_TOOLS and the following patch applied:

diff --git a/usr.bin/localedef/bootstrap/xlocale.h b/usr.bin/localedef/bootstrap/xlocale.h
index 05629a32f4e3..d4b8d75de55c 100644
--- a/usr.bin/localedef/bootstrap/xlocale.h
+++ b/usr.bin/localedef/bootstrap/xlocale.h
@@ -51,5 +51,6 @@
 #error "Dummy xlocale.h included inside bootstrapping namespace context"

+#error "Linux only?"
 typedef        struct __dummy_host_locale      *__locale_t;
 typedef        __locale_t                      locale_t;

So it seems like I did remember correctly that this only affects Linux bootstrap. Therefore this is unlikely to break anything important and should be fine to commit. CheriBSD CI is also happy so it seems like both Ubuntu 18.04 and 20.04 still work.