Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libevent build failures with -std=c99 #3812

Closed
PHHargrove opened this issue Jul 5, 2017 · 5 comments
Closed

libevent build failures with -std=c99 #3812

PHHargrove opened this issue Jul 5, 2017 · 5 comments

Comments

@PHHargrove
Copy link
Member

As was noted in issue #17, Linux does not define NSIG unless _USE_MISC is defined.
For this reason, configuration with CC="gcc -std=c99" fails when building libevent because NSIG is undefined in strict C99 mode:

[...]/openmpi-3.0.0rc1/opal/mca/event/libevent2022/libevent/signal.c: In function 'evsig_cb':
[...]/openmpi-3.0.0rc1/opal/mca/event/libevent2022/libevent/signal.c:135:14: error: 'NSIG' undeclared (first use in this function); did you mean '_NSIG'?
  int ncaught[NSIG];
              ^~~~
              _NSIG

Something as simple as the following somewhere in libevent (event-internal.h?) might be sufficient:

#if !defined(NSIG) && defined(_NSIG)
#  define NSIG _NSIG
#endif

However, that alone is not sufficient since there are other things that are outside of strict C99:

[...]/openmpi-3.0.0rc1/opal/mca/event/libevent2022/libevent/signal.c: In function 'opal_libevent2022__evsig_set_handler':
[...]/openmpi-3.0.0rc1/opal/mca/event/libevent2022/libevent/signal.c:214:19: error: storage size of 'sa' isn't known
  struct sigaction sa;
                   ^~

That, at least, is POSIX rather than "MISC".

So, it may be a good idea to document that the embedded libevent is not compatible with (at least) Linux glibc in strict C99 mode.

@rhc54
Copy link
Contributor

rhc54 commented Jul 5, 2017

Might be interesting to check their 2.1 release and see if it is fixed there

@rhc54
Copy link
Contributor

rhc54 commented Jul 6, 2017

Well, v2.1.8 certainly doesn't build by default:

sample/event-read-fifo.c: In function ‘main’:
sample/event-read-fifo.c:109:6: warning: implicit declaration of function ‘lstat’ [-Wimplicit-function-declaration]
  if (lstat(fifo, &st) == 0) {
      ^~~~~
sample/event-read-fifo.c:109:2: warning: nested extern declaration of ‘lstat’ [-Wnested-externs]
  if (lstat(fifo, &st) == 0) {
  ^~
sample/event-read-fifo.c:110:21: error: ‘S_IFMT’ undeclared (first use in this function)
   if ((st.st_mode & S_IFMT) == S_IFREG) {
                     ^~~~~~
sample/event-read-fifo.c:110:21: note: each undeclared identifier is reported only once for each function it appears in
sample/event-read-fifo.c:110:32: error: ‘S_IFREG’ undeclared (first use in this function)
   if ((st.st_mode & S_IFMT) == S_IFREG) {
                                ^~~~~~~

Turns out the definition of lstat is covered by:

#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K

@jsquyres
Copy link
Member

jsquyres commented Aug 8, 2017

We're not going to make libevent C99 compliant. Closing as "wontfix".

@jsquyres jsquyres closed this as completed Aug 8, 2017
@abeltre1
Copy link

We're not going to make libevent C99 compliant. Closing as "wontfix".

I am getting the same problem with version 4.0.0 after I upgraded to the latest gcc. Do you have any immediate solutions?

@jsquyres
Copy link
Member

If this is happening to you in v4.0.x, please open a new issue with all the relevant details (logs, etc.). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants