Hi,

2016-08-26 1:52 GMT+02:00 Bryan Drewery <bdrew...@freebsd.org>:
> Libc wouldn't build, it complained quite loudly with a lot of these:

Got it. Thinking ahead, if it's just basename() giving the problems,
maybe it's easier to just go ahead and bump the symver of basename()
as well? I'm planning on replacing it anyway to be in sync with the
new basename() anyway. Attached is a new patch. Be sure to let me know
whether that works for you.

-- 
Ed Schouten <e...@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
Index: include/libgen.h
===================================================================
--- include/libgen.h    (revision 304750)
+++ include/libgen.h    (working copy)
@@ -39,4 +39,26 @@
 char   *dirname(char *);
 __END_DECLS
 
+/*
+ * In FreeBSD 12, the prototype of basename() and dirname() was modified
+ * to comply to POSIX. These functions may now modify their input.
+ * Unfortunately, our copy of xinstall(8) shipped with previous versions
+ * of FreeBSD is built using the host headers and libc during the
+ * bootstrapping phase and depends on the old behavior.
+ *
+ * Apply a workaround where we explicitly link against basename@FBSD_1.0
+ * and dirname@FBSD_1.0 in case these functions are called on constant
+ * strings, instead of making the build fail.
+ */
+#if defined(__generic) && !defined(__cplusplus)
+__BEGIN_DECLS
+char   *__old_basename(const char *);
+char   *__old_dirname(const char *);
+__END_DECLS
+__sym_compat(basename, __old_basename, FBSD_1.0);
+__sym_compat(dirname, __old_dirname, FBSD_1.0);
+#define        basename(x)     __generic(x, const char *, __old_basename, 
basename)(x)
+#define        dirname(x)      __generic(x, const char *, __old_dirname, 
dirname)(x)
+#endif
+
 #endif /* !_LIBGEN_H_ */
Index: lib/libc/gen/Symbol.map
===================================================================
--- lib/libc/gen/Symbol.map     (revision 304750)
+++ lib/libc/gen/Symbol.map     (working copy)
@@ -68,7 +68,6 @@
        arc4random_addrandom;
        arc4random_stir;
        __assert;
-       basename;
        check_utility_compat;
        clock;
        closedir;
@@ -418,6 +417,7 @@
 };
 
 FBSD_1.5 {
+       basename;
        dirname;
 };
 
Index: lib/libc/gen/basename.c
===================================================================
--- lib/libc/gen/basename.c     (revision 304750)
+++ lib/libc/gen/basename.c     (working copy)
@@ -66,7 +66,7 @@
 }
 
 char *
-basename(char *path)
+__freebsd11_basename(char *path)
 {
        static char *bname = NULL;
 
@@ -77,3 +77,13 @@
        }
        return (basename_r(path, bname));
 }
+
+__sym_compat(basename, __freebsd11_basename, FBSD_1.0);
+
+char *
+(basename)(char *path)
+{
+
+       /* TODO(ed): Replace this by a thread-safe version, like dirname(3). */
+       return (__freebsd11_basename(path));
+}
Index: lib/libc/gen/dirname.c
===================================================================
--- lib/libc/gen/dirname.c      (revision 304750)
+++ lib/libc/gen/dirname.c      (working copy)
@@ -31,7 +31,7 @@
 #include <string.h>
 
 char *
-dirname(char *path)
+(dirname)(char *path)
 {
        const char *in, *prev, *begin, *end;
        char *out;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to