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

freeswitch: fix build error for undeclared identifier 'NSIG' #77004

Merged
merged 1 commit into from
May 31, 2021

Conversation

cho-m
Copy link
Member

@cho-m cho-m commented May 11, 2021

  • Have you followed the guidelines for contributing?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install <formula>)?

Try to fix the freeswitch error seen in PR #76780.

I confirmed error on local --build-from-source:

In file included from ./include/apr_general.h:33:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:69:42: error: use of undeclared identifier 'NSIG'
extern __const char *__const sys_signame[NSIG];
                                         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:70:42: error: use of undeclared identifier 'NSIG'
extern __const char *__const sys_siglist[NSIG];
                                         ^
2 errors generated.

The condition to define NSIG is:

#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define NSIG	__DARWIN_NSIG
#endif

@BrewTestBot BrewTestBot added the lua Lua use is a significant feature of the PR or issue label May 11, 2021
@cho-m cho-m mentioned this pull request May 11, 2021
@SMillerDev
Copy link
Member

ARM says:

 ==> Installing freeswitch dependency: libevent
Error: SystemCommand::ProcessTerminatedInterrupt
/opt/homebrew/Library/Homebrew/system_command.rb:211:in `block in each_output_line'

I'll just re-run it

@cho-m
Copy link
Member Author

cho-m commented May 11, 2021

May need someone to take a deeper look into why the existing Formula ends up failing in #76780 (and #75728, which is for next version, but is probably due to same reason).

The condition that is causing the failure is also the same condition that is used to define NSIG, which should have been processed due to #include <sys/signal.h>.

This PR essentially forcefully set the value _DARWIN_C_SOURCE to guarantee NSIG is defined, but it would be a good idea to see if there is a nicer alternative (and perhaps check if the failures are due to Apple or Homebrew given that the Formula hasn't changed since originally bottled).


Related headers...

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h

...
#include <sys/signal.h>

#include <sys/_pthread/_pthread_types.h>
#include <sys/_pthread/_pthread_t.h>

#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
extern __const char *__const sys_signame[NSIG];
extern __const char *__const sys_siglist[NSIG];
#endif

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/signal.h

...
#define __DARWIN_NSIG   32      /* counting 0; could be 33 (mask is 1-32) */

#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define NSIG    __DARWIN_NSIG
#endif

@@ -151,6 +151,10 @@ class Freeswitch < Formula
end

def install
on_macos do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a comment here explaining what this is for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something like the headline message along with related upstream issue (signalwire/freeswitch#1145) be sufficient?


I'm actually not sure of exact reason why this is required yet.

If I had to guess, I think it is due to _XOPEN_SOURCE being set by freeswitch in certain places, which changes value of _POSIX_C_SOURCE.

Perhaps due to order of includes, we hit the odd behavior where the same condition to set NSIG and access NSIG are not equal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, macro voodoo. very nice. I guess at minimum a comment should give some indication of when a workaround can be removed, so a link to the upstream issue would help.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay for the comment.

For actual fix, another alternative may be to set _XOPEN_SOURCE, which would do the opposite of _DARWIN_C_SOURCE, i.e. darwin macro would probably allow platform-specific behavior while open-source macro would use portable functions instead.

@cho-m cho-m force-pushed the freeswitch-fix-build branch from d57f8b6 to f54214e Compare May 20, 2021 03:22
@carlocab carlocab merged commit 2516a2d into Homebrew:master May 31, 2021
@cho-m cho-m deleted the freeswitch-fix-build branch May 31, 2021 14:21
@github-actions github-actions bot added the outdated PR was locked due to age label Jul 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lua Lua use is a significant feature of the PR or issue outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants