<div dir="auto">Hindi language please</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 20, 2022, 8:02 PM Andrew Clayton <<a href="mailto:andrew@digital-domain.net">andrew@digital-domain.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, 20 Jun 2022 13:36:00 +0100<br>
Andrew Clayton <<a href="mailto:andrew@digital-domain.net" target="_blank" rel="noreferrer">andrew@digital-domain.net</a>> wrote:<br>
<br>
> On Mon, 20 Jun 2022 13:28:41 +0100<br>
> Andrew Clayton <<a href="mailto:andrew@digital-domain.net" target="_blank" rel="noreferrer">andrew@digital-domain.net</a>> wrote:<br>
> <br>
> > But then I did a make clean and ./configure && make and all was good.  <br>
> <br>
> Hmm, so taking my own advice, _now_ I see a load of errors... will<br>
> investigate.<br>
<br>
Not got right to the bottom of it, but here's where we're at.<br>
<br>
The first error is<br>
<br>
cc -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g   -I src -I build   \<br>
                      \<br>
                     \<br>
-o build/src/nxt_socketpair.o \<br>
-MMD -MF build/src/nxt_socketpair.dep -MT build/src/nxt_socketpair.o \<br>
src/nxt_socketpair.c<br>
In file included from /usr/include/sys/socket.h:33,<br>
                 from /usr/include/netinet/in.h:23,<br>
                 from /usr/include/netdb.h:27,<br>
                 from src/nxt_unix.h:157,<br>
                 from src/nxt_main.h:31,<br>
                 from src/nxt_socketpair.c:7:<br>
src/nxt_socket_msg.h:32:54: error: invalid application of ‘sizeof’ to incomplete type ‘nxt_socket_cred_t’ {aka ‘struct ucred’}<br>
   32 |     (CMSG_SPACE(2 * sizeof(int)) + CMSG_SPACE(sizeof(nxt_socket_cred_t)))<br>
      |                                                      ^~~~~~~~~~~~~~~~~<br>
<br>
On Linux/glibc at least, struct ucred is defined in<br>
/usr/include/bits/socket.h as<br>
<br>
#ifdef __USE_GNU                                                                <br>
/* User visible structure for SCM_CREDENTIALS message */                        <br>
struct ucred                                                                    <br>
{                                                                               <br>
  pid_t pid;                    /* PID of sending process.  */                  <br>
  uid_t uid;                    /* UID of sending process.  */                  <br>
  gid_t gid;                    /* GID of sending process.  */                  <br>
};                                                                              <br>
#endif<br>
<br>
So it needs _GNU_SOURCE defined, as confirmed by this test case<br>
<br>
#define _GNU_SOURCE 1                                                           <br>
<br>
#include <sys/socket.h>                                                         <br>
<br>
int main(void)                                                                  <br>
{                                                                               <br>
        sizeof(struct ucred);                                                   <br>
        return 0;                                                               <br>
}<br>
<br>
Commenting out the #define makes it fail to compile.<br>
<br>
$ make m<br>
cc     m.c   -o m<br>
m.c: In function ‘main’:<br>
m.c:9:16: error: invalid application of ‘sizeof’ to incomplete type ‘struct ucred’<br>
    9 |         sizeof(struct ucred);<br>
      |                ^~~~~~<br>
make: *** [<builtin>: m] Error 1<br>
<br>
Now previously malloc.h was being included _after_ _GNU_SOURCE was being defined.<br>
malloc.h seems to somehow be interfering with that, as demonstrated by<br>
<br>
#include <malloc.h>                                                             <br>
<br>
#define _GNU_SOURCE 1                                                           <br>
<br>
#include <sys/socket.h>                                                         <br>
<br>
int main(void)                                                                  <br>
{                                                                               <br>
        sizeof(struct ucred);                                                   <br>
        return 0;                                                               <br>
}<br>
<br>
<br>
which fails to build.<br>
<br>
Indeed if in unit, I comment out the malloc.h include, it builds, or if<br>
I define _GNU_SOURCE before it, it builds.<br>
<br>
Hmm, actually, including any system (at least) header file before<br>
_GNU_SOURCE is defined breaks the test program.<br>
<br>
Arghhhh....<br>
<br>
Of course, all these header files include features.h which deals with<br>
all the standards macros.<br>
<br>
So if we include a header file before _GNU_SOURCE is defined, then<br>
_FEATURES_H is defined, then if we define _GNU_SOURCE and include more<br>
header files, then features.h won't do anything due to _FEATURES_H<br>
already being defined and _GNU_SOURCE will have no effect as in<br>
/usr/include/features.h<br>
<br>
#ifdef  _GNU_SOURCE<br>
# define __USE_GNU      1<br>
#endif<br>
<br>
won't happen. (__USE_GNU is what glibc seems to use internally for<br>
_GNU_SOURCE).<br>
<br>
OK, so not every header file includes features.h, for example<br>
sys/syscall.h which is why things worked before.<br>
<br>
So maybe we did get to the bottom of it...<br>
<br>
So it just remains to see how to solve this current issue. But<br>
basically you need to define _GNU_SOURCE before including any header<br>
file that includes features.h.<br>
<br>
Cheers,<br>
Andrew<br>
<br>
_______________________________________________<br>
unit mailing list -- <a href="mailto:unit@nginx.org" target="_blank" rel="noreferrer">unit@nginx.org</a><br>
To unsubscribe send an email to <a href="mailto:unit-leave@nginx.org" target="_blank" rel="noreferrer">unit-leave@nginx.org</a><br>
</blockquote></div>