Project

General

Profile

Bug #2806

Strongswan 5.6.3+ on mips32r2 and uClibc

Added by Alexander Ostapchuk about 2 months ago. Updated 19 days ago.

Status:
Closed
Priority:
Normal
Category:
build
Target version:
Start date:
Due date:
Estimated time:
Affected version:
5.6.3
Resolution:
Fixed

Description

Hello!

Strongswan 5.6.3+ do not build for mips32r2 with uClibc 0.9.33.2

This is error in src/libstrongswan/settings/settings_lexer.c at string

"#include <unistd.h>" - error expected ';', ',' or ')' before numeric constant

The referenced line in unistd.h is:

extern void __exit_thread (int val) __attribute__ ((__noreturn__));

As I can see in the src/libstrongswan/settings/settings_lexer.c is defined variable "val"

line 716 "settings/settings_lexer.c" 

#define INITIAL 0
#define ref 1
#define val 2
#define inc 3
#define str 4

#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
 * down here because we want the user's section 1 to have been scanned first.
 * The user has a chance to override it with an option.
 */
/* %if-c-only */
#include <unistd.h>
/* %endif */
/* %if-c++-only */
/* %endif */
#endif

and after preprocessing we have in the unistd.h:

extern void __exit_thread (int 1) __attribute__ ((__noreturn__));

After I move include above the define - everything compiled without errors

line 716 "settings/settings_lexer.c" 

#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
 * down here because we want the user's section 1 to have been scanned first.
 * The user has a chance to override it with an option.
 */
/* %if-c-only */
#include <unistd.h>
/* %endif */
/* %if-c++-only */
/* %endif */
#endif

#define INITIAL 0
#define ref 1
#define val 2
#define inc 3
#define str 4

Associated revisions

Revision 97c4551e (diff)
Added by Tobias Brunner 19 days ago

Avoid inclusion of unistd.h in generated lexers

Because the file is not available on all platforms the inclusion comes
after the user options in order to disable including it. But that means
the inclusion also follows after the defined scanner states, which are
generated as simple #defines to numbers. If the included unistd.h e.g.
uses variables in function definitions with the same names this could
result in compilation errors.

Interactive mode has to be disabled too as it relies on isatty() from
unistd.h. Since we don't use the scanners interactively, this is not a
problem and might even make the scanners a bit faster.

Fixes #2806.

History

#1 Updated by Tobias Brunner about 2 months ago

  • Tracker changed from Issue to Bug
  • Status changed from New to Feedback
  • Assignee set to Tobias Brunner
  • Target version set to 5.7.2

This is error in src/libstrongswan/settings/settings_lexer.c at string

If you read the first comment in that file, you know that it is generated by flex. So we have no direct way to influence the placement of these defines.

I can see three ways to fix this. Either use %option nounistd to avoid the inclusion (this requires %option never-interactive too to disable interactive mode, which uses isatty() from uinstd.h), or include the file ourselves in the header so the include guard in the header file should prevent these conflicts, or rename the state variables (but that might cause conflicts with other versions of unistd.h or later changes to that file). I'm leaning towards the first option as we don't use the scanners interactively, so that's what I pushed to the 2806-flex-unistd branch.

Anyway, to fix this you either have to do what you already did (modify the distributed and generated file), apply a patch to the .l files and regenerate them, or build everything directly from the repository with the pushed patch applied (which requires other tools like bison and gperf, see source:HACKING).

#2 Updated by Tobias Brunner 19 days ago

  • Status changed from Feedback to Closed
  • Resolution set to Fixed

Also available in: Atom PDF