Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Jan 2021 21:00:07 GMT
From:      Jessica Clarke <jrtc27@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: d6327ae8c11b - main - Fix cross-build support for Ubuntu 16.04
Message-ID:  <202101232100.10NL07s8035929@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=d6327ae8c11b73765f100981baca49166b558b70

commit d6327ae8c11b73765f100981baca49166b558b70
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2021-01-23 20:59:15 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2021-01-23 20:59:15 +0000

    Fix cross-build support for Ubuntu 16.04
    
    Older glibc headers did some very nasty things that have since been
    sanitised. We could also fix this by adding a linux/getopt.h wrapper
    alongside the existing common/getopt.h that #undef's __need_getopt, but
    that seems a little more hacky and complicated.
    
    Reviewed by:    arichardson
---
 tools/build/cross-build/include/linux/unistd.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/build/cross-build/include/linux/unistd.h b/tools/build/cross-build/include/linux/unistd.h
index 9d1bd1bf4025..ea131f1ab732 100644
--- a/tools/build/cross-build/include/linux/unistd.h
+++ b/tools/build/cross-build/include/linux/unistd.h
@@ -41,9 +41,17 @@
 /* Ensure that unistd.h pulls in getopt */
 #define __USE_POSIX2
 #endif
+/*
+ * Before version 2.25, glibc's unistd.h would define the POSIX subset of
+ * getopt.h by defining __need_getopt,  including getopt.h (which would
+ * disable the header guard) and then undefining it so later including
+ * getopt.h explicitly would define the extensions. However, we wrap getopt,
+ * and so the wrapper's #pragma once breaks that. Thus getopt.h must be
+ * included before the real unistd.h to ensure we get all the extensions.
+ */
+#include <getopt.h>
 #include_next <unistd.h>
 #include <fcntl.h>
-#include <getopt.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/syscall.h>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101232100.10NL07s8035929>