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

Module ITKKWsys can't be built without compiler specific extensions #1505

Open
Nekto89 opened this issue Dec 20, 2019 · 5 comments
Open

Module ITKKWsys can't be built without compiler specific extensions #1505

Nekto89 opened this issue Dec 20, 2019 · 5 comments
Labels

Comments

@Nekto89
Copy link
Contributor

@Nekto89 Nekto89 commented Dec 20, 2019

Description

ITKKWsys can't be built with CMAKE_C_EXTENSIONS=OFF.

Steps to Reproduce

On Linux:

  1. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_STANDARD=11 -DCMAKE_C_EXTENSIONS=OFF -DITK_BUILD_DEFAULT_MODULES=OFF -DITKGroup_Core=OFF -DModule_ITKKWSys=ON ../src
  2. cmake --build .

Expected behavior

There should be no errors.

Actual behavior

[ 25%] Built target ClangFormat
[ 51%] Built target KWStyle
[ 54%] Building C object Modules/ThirdParty/KWSys/src/KWSys/CMakeFiles/itksys.dir/ProcessUNIX.c.o
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessCreate’:
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1726:19: error: ‘SIG_BLOCK’ undeclared (first use in this function)
   if (sigprocmask(SIG_BLOCK, &mask, &old_mask) < 0) {
                   ^~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1726:19: note: each undeclared identifier is reported only once for each function it appears in
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1745:17: error: ‘SIG_SETMASK’ undeclared (first use in this function); did you mean ‘SIGRTMAX’?
     sigprocmask(SIG_SETMASK, &old_mask, 0);
                 ^~~~~~~~~~~
                 SIGRTMAX
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessDestroy’:
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1879:19: error: ‘SIG_BLOCK’ undeclared (first use in this function)
   if (sigprocmask(SIG_BLOCK, &mask, &old_mask) < 0) {
                   ^~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1913:15: error: ‘SIG_SETMASK’ undeclared (first use in this function); did you mean ‘SIGRTMAX’?
   sigprocmask(SIG_SETMASK, &old_mask, 0);
               ^~~~~~~~~~~
               SIGRTMAX
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessTimeGetCurrent’:
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2031:17: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)
   clock_gettime(CLOCK_MONOTONIC, &current_timespec);
                 ^~~~~~~~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessRestoreDefaultSignalHandlers’:
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2307:20: error: storage size of ‘act’ isn’t known
   struct sigaction act;
                    ^~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2308:26: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigaction’
   memset(&act, 0, sizeof(struct sigaction));
                          ^~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessesUpdate’:
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2634:15: error: ‘SIG_BLOCK’ undeclared (first use in this function)
   sigprocmask(SIG_BLOCK, &newset, &oldset);
               ^~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2640:15: error: ‘SIG_SETMASK’ undeclared (first use in this function); did you mean ‘SIGRTMAX’?
   sigprocmask(SIG_SETMASK, &oldset, 0);
               ^~~~~~~~~~~
               SIGRTMAX
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessesAdd’:
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2713:24: error: storage size of ‘newSigAction’ isn’t known
       struct sigaction newSigAction;
                        ^~~~~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2714:39: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigaction’
       memset(&newSigAction, 0, sizeof(struct sigaction));
                                       ^~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2723:31: error: ‘SA_NOCLDSTOP’ undeclared (first use in this function)
       newSigAction.sa_flags = SA_NOCLDSTOP;
                               ^~~~~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessesSignalHandler’:
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2861:26: error: storage size of ‘defSigAction’ isn’t known
         struct sigaction defSigAction;
                          ^~~~~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2871:21: error: ‘SIG_UNBLOCK’ undeclared (first use in this function); did you mean ‘O_NONBLOCK’?
         sigprocmask(SIG_UNBLOCK, &unblockSet, 0);
                     ^~~~~~~~~~~
                     O_NONBLOCK
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2883:22: error: storage size of ‘newSigAction’ isn’t known
     struct sigaction newSigAction;
                      ^~~~~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2884:21: error: expected identifier or ‘(’ before ‘&’ token
     struct sigaction& oldSigAction;
                     ^
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2885:37: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigaction’
     memset(&newSigAction, 0, sizeof(struct sigaction));
                                     ^~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2886:5: error: ‘newSigChldAction’ undeclared (first use in this function); did you mean ‘newSigAction’?
     newSigChldAction.sa_handler = kwsysProcessesSignalHandler;
     ^~~~~~~~~~~~~~~~
     newSigAction
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2887:33: error: ‘SA_NOCLDSTOP’ undeclared (first use in this function)
     newSigChldAction.sa_flags = SA_NOCLDSTOP;
                                 ^~~~~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2891:9: error: ‘oldSigAction’ undeclared (first use in this function); did you mean ‘newSigAction’?
         oldSigAction = &kwsysProcessesOldSigChldAction;
         ^~~~~~~~~~~~
         newSigAction
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: At top level:
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2619:25: error: storage size of ‘kwsysProcessesOldSigChldAction’ isn’t known
 static struct sigaction kwsysProcessesOldSigChldAction;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2620:25: error: storage size of ‘kwsysProcessesOldSigIntAction’ isn’t known
 static struct sigaction kwsysProcessesOldSigIntAction;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/c/TestITK/src/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2621:25: error: storage size of ‘kwsysProcessesOldSigTermAction’ isn’t known
 static struct sigaction kwsysProcessesOldSigTermAction;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [Modules/ThirdParty/KWSys/src/KWSys/CMakeFiles/itksys.dir/build.make:63: Modules/ThirdParty/KWSys/src/KWSys/CMakeFiles/itksys.dir/ProcessUNIX.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1255: Modules/ThirdParty/KWSys/src/KWSys/CMakeFiles/itksys.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Reproducibility

Versions

v5.1rc01

Environment

Checked on Debian (gcc 8.3.0) using WSL

Additional Information

@dzenanz

This comment has been minimized.

Copy link
Member

@dzenanz dzenanz commented Dec 20, 2019

Confirmed with Ubuntu 18.04, with current master 9433960:

[ 54%] Building C object Modules/ThirdParty/KWSys/src/KWSys/CMakeFiles/itksys.dir/ProcessUNIX.c.o
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessCreate’:
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1726:19: error: ‘SIG_BLOCK’ undeclared (first use in this function)
   if (sigprocmask(SIG_BLOCK, &mask, &old_mask) < 0) {
                   ^~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1726:19: note: each undeclared identifier is reported only once for each function it appears in
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1745:17: error: ‘SIG_SETMASK’ undeclared (first use in this function); did you mean ‘SIGRTMAX’?
     sigprocmask(SIG_SETMASK, &old_mask, 0);
                 ^~~~~~~~~~~
                 SIGRTMAX
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessDestroy’:
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1879:19: error: ‘SIG_BLOCK’ undeclared (first use in this function)
   if (sigprocmask(SIG_BLOCK, &mask, &old_mask) < 0) {
                   ^~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:1913:15: error: ‘SIG_SETMASK’ undeclared (first use in this function); did you mean ‘SIGRTMAX’?
   sigprocmask(SIG_SETMASK, &old_mask, 0);
               ^~~~~~~~~~~
               SIGRTMAX
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessRestoreDefaultSignalHandlers’:
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2307:20: error: storage size of ‘act’ isn’t known
   struct sigaction act;
                    ^~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2308:26: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigaction’
   memset(&act, 0, sizeof(struct sigaction));
                          ^~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessesUpdate’:
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2634:15: error: ‘SIG_BLOCK’ undeclared (first use in this function)
   sigprocmask(SIG_BLOCK, &newset, &oldset);
               ^~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2640:15: error: ‘SIG_SETMASK’ undeclared (first use in this function); did you mean ‘SIGRTMAX’?
   sigprocmask(SIG_SETMASK, &oldset, 0);
               ^~~~~~~~~~~
               SIGRTMAX
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessesAdd’:
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2713:24: error: storage size of ‘newSigAction’ isn’t known
       struct sigaction newSigAction;
                        ^~~~~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2714:39: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigaction’
       memset(&newSigAction, 0, sizeof(struct sigaction));
                                       ^~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2723:31: error: ‘SA_NOCLDSTOP’ undeclared (first use in this function)
       newSigAction.sa_flags = SA_NOCLDSTOP;
                               ^~~~~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: In function ‘kwsysProcessesSignalHandler’:
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2861:26: error: storage size of ‘defSigAction’ isn’t known
         struct sigaction defSigAction;
                          ^~~~~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2871:21: error: ‘SIG_UNBLOCK’ undeclared (first use in this function); did you mean ‘O_NONBLOCK’?
         sigprocmask(SIG_UNBLOCK, &unblockSet, 0);
                     ^~~~~~~~~~~
                     O_NONBLOCK
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2883:22: error: storage size of ‘newSigAction’ isn’t known
     struct sigaction newSigAction;
                      ^~~~~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2884:21: error: expected identifier or ‘(’ before ‘&’ token
     struct sigaction& oldSigAction;
                     ^
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2885:37: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigaction’
     memset(&newSigAction, 0, sizeof(struct sigaction));
                                     ^~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2886:5: error: ‘newSigChldAction’ undeclared (first use in this function); did you mean ‘newSigAction’?
     newSigChldAction.sa_handler = kwsysProcessesSignalHandler;
     ^~~~~~~~~~~~~~~~
     newSigAction
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2887:33: error: ‘SA_NOCLDSTOP’ undeclared (first use in this function)
     newSigChldAction.sa_flags = SA_NOCLDSTOP;
                                 ^~~~~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2891:9: error: ‘oldSigAction’ undeclared (first use in this function); did you mean ‘newSigAction’?
         oldSigAction = &kwsysProcessesOldSigChldAction;
         ^~~~~~~~~~~~
         newSigAction
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c: At top level:
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2619:25: error: storage size of ‘kwsysProcessesOldSigChldAction’ isn’t known
 static struct sigaction kwsysProcessesOldSigChldAction;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2620:25: error: storage size of ‘kwsysProcessesOldSigIntAction’ isn’t known
 static struct sigaction kwsysProcessesOldSigIntAction;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dzenan/ITK-git/Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c:2621:25: error: storage size of ‘kwsysProcessesOldSigTermAction’ isn’t known
 static struct sigaction kwsysProcessesOldSigTermAction;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modules/ThirdParty/KWSys/src/KWSys/CMakeFiles/itksys.dir/build.make:62: recipe for target 'Modules/ThirdParty/KWSys/src/KWSys/CMakeFiles/itksys.dir/ProcessUNIX.c.o' failed
@dzenanz

This comment has been minimized.

Copy link
Member

@dzenanz dzenanz commented Dec 20, 2019

We turn off compiler extensions by default, but only for C++

set(CMAKE_CXX_EXTENSIONS OFF)

@Nekto89 why do you want to disable C compiler extensions?
@bradking how much work would it be to build KWStyle without compiler extensions?

@Nekto89

This comment has been minimized.

Copy link
Contributor Author

@Nekto89 Nekto89 commented Dec 20, 2019

No specific reason. I've found this after trying to use -std=c11 in CMAKE_C_FLAGS. But it can be built only with -std=gnu11.

@bradking

This comment has been minimized.

Copy link
Member

@bradking bradking commented Jan 8, 2020

ProcessUNIX.c:1726:19: error: ‘SIG_BLOCK’ undeclared (first use in this function)

This looks like a case where the platform's header files are activating some interfaces (or not) based on the compiler's mode. Add -D_POSIX_C_SOURCE=199506L to the C flags to work around this. Meanwhile I'll look at fixing this in upstream KWSys when I get a chance.

@bradking

This comment has been minimized.

Copy link
Member

@bradking bradking commented Jan 8, 2020

See KWSys MR 162.

Another approach is to use --std=c11 -D_GNU_SOURCE so that one gets no GNU compiler extensions but still gets GNU (posix+other) interfaces from system headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.