Revert "Fix cross-build support for Ubuntu 16.04"

This reverts commit d6327ae8c1.

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 was
included before the real unistd.h to ensure we get all the extensions.

However, with clang 12 that causes problems where we get a function
mismatch (since getopt can throw exceptions). If we include it after
unistd.h, it will get the full definitions since glibc no longer does
the subsetting thing. This will result in matching definitions and fix
clang 12.

Reviewed by: imp, jrtc27 (OK'd on irc)
Pull Request: https://github.com/freebsd/freebsd-src/pull/668
This commit is contained in:
Jose Luis Duran 2023-03-02 08:31:31 -07:00 committed by Warner Losh
parent 0eabe33087
commit 320e7e0003

View File

@ -41,17 +41,9 @@
/* 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>