Compile error in nPth's t-fork.c on Solaris 11.3 i86pc
Testing, NormalPublic

Description

Hi Everyone,

I'm on Solaris 11.3 i86pc. I'm trying to upgrade from 1.4.20 to the family based on GnuPG 2.2.15 from https://www.gnupg.org/download/. Npth is giving trouble on Solaris.

gcc -DHAVE_CONFIG_H -I. -I..  -I../src -D_POSIX_C_SOURCE=200112L -I/usr/local/include -DNDEBUG  -g2 -O2 -march=native -fPIC -pthread -MT t-fork.o -MD -MP -MF .deps/t-fork.Tpo -c -o t-fork.o t-fork.c
In file included from /usr/include/stdio.h:15:0,
                 from t-support.h:13,
                 from t-mutex.c:13:
/usr/include/sys/feature_tests.h:358:2: error: #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications       require the use of c99"
 #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
  ^
In file included from /usr/include/stdio.h:15:0,
                 from t-support.h:13,
                 from t-thread.c:13:
/usr/include/sys/feature_tests.h:358:2: error: #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications       require the use of c99"
 #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
  ^
In file included from /usr/include/sys/types.h:12:0,
                 from t-fork.c:13:
/usr/include/sys/feature_tests.h:358:2: error: #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications       require the use of c99"
 #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
  ^
gmake[2]: *** [t-mutex.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: *** [t-fork.o] Error 1

Here is config.log:

.

I can provide remote access to the machine, if needed. It is a lot better than trying to use Solaris in a VM.

Related Objects

JW created this task.May 10 2019, 8:01 AM
JW added a comment.May 10 2019, 9:05 AM

It looks like Solaris only needs CFLAGS+=-std=c99. It was added for all programs and libraries listed at https://www.gnupg.org/download/index.html.

werner renamed this task from Compile error in Nth t-fork.c on Solaris 11.3 i86pc to Compile error in nPth's t-fork.c on Solaris 11.3 i86pc.May 10 2019, 10:16 AM
werner triaged this task as Normal priority.
gniibe claimed this task.May 14 2019, 5:13 AM
gniibe added a subscriber: gniibe.

IIUC, -std=c99 won't solve this issue. It is Solaris specific C99 issue.

Please try a patch to configure.ac:

After applying the patch, run ./autogen.sh to update configure script (you need autoconf etc.).

It looks like somewhat complicated more. It seems that specifying _POSIX_C_SOURCE=200112L is not good on Solaris with old GCC. Perhaps, it would have no problem with newer gcc (or -std=gnu99 option).

For gcc 4.8, default is gnu90 (ISO C90 plus GNU features). Now, gcc 8 default is gnu99 (ISO C99 plus GNU features).

_POSIX_C_SOURCE=200112L was added to allow compiling c99 (with no GNU features). It is for pthread_rwlock* API, which is available under _XOPEN_SOURCE=500 or more (UNIX98).

In case of gcc 4.8 on Solaris, could you please try this patch (instead of configure patch) to see if it works?

JW added a comment.EditedMay 14 2019, 7:35 AM

In case of gcc 4.8 on Solaris, could you please try this patch (instead of configure patch) to see if it works?

I have a Solaris 11.3 machine available for testing. I need you authorized_keys. Send to noloader, gmail address.

The GCC Compile Farm also has Solaris 9, 10, 11 machines available for both i86pc and Sparc. The CFarm machines are slow, though.

One thing you should avoid... Don't try to install Solaris in a VM. It is awful slow.

Thanks for your offer. I have an account for GCC Compiler Farm. I'm trying with gcc211 machine. will back soon.

gniibe added a comment.EditedMay 14 2019, 8:05 AM

I figured out:

  • Removing -D_POSIX_C_SOURCE=200112L works both of gcc 4.9 and gcc 5.5 on Solaris 11.3 (even with -std=c99).
  • Then, adding -D_XOPEN_SOURCE=500, gcc 4.9 works, but gcc 5.5 failed by another error (Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications)
    • I confirmed gcc 5.5 defaults to -std=gnu99

So, I think that configure's adding -D_POSIX_C_SOURCE=200112L for non-Solaris machine will be a solution.

gniibe added a comment.EditedMay 14 2019, 8:08 AM

While original npth-1.6 can be compiled with newer gcc (>= 5), we'd say please use CFLAGS+=-std=gnu99 with older gcc, as workaround.

gniibe changed the task status from Open to Testing.May 15 2019, 3:12 AM

While I think that building with GCC 4 on Solaris 11/12 is minor issue, requirement of newer POSIX API (on GNU/Linux) would be a bit serious issue.
I pushed my change to fix this.