A simple ./configure; make using IBM VisualAge C++ 5 under AIX 4.3.3 ML9 returns: xlC -O2 - qlanglvl=extended -I. -I. -I/usr/local/include -DSSHDIR=\"/usr/local/etc\" - D_PATH_SSH_PROGRAM=\"/usr/local/bin/ssh\" - D_PATH_SSH_ASKPASS_DEFAULT=\"/usr/local/libexec/ssh-askpass\" - D_PATH_SFTP_SERVER=\"/usr/local/libexec/sftp-server\" -D_PATH_SSH_PIDDIR=\"/var/run\" - DSSH_RAND_HELPER=\"/usr/local/libexec/ssh-rand-helper\" -DHAVE_CONFIG_H -c monitor_fdpass.c "monitor_fdpass.c", line 43.18: 1506-195 (S) Integral constant expression with a value greater than zero is required. "monitor_fdpass.c", line 87.18: 1506- 195 (S) Integral constant expression with a value greater than zero is required. make: 1254-004 The error code from the last command is 1. This appears to be a problem with the line: char tmp[CMSG_SPACE(sizeof(int))]; It would seem that the IBM compiler does not like array declarations that need to be computed in this way. Hard-coding 16 in place of CMSG_SPACE(sizeof(int)) allows compilation to succeed. Can someone help me to solve this problem?
can you provide cpp output from the file (e.g., cc -E) for the tmp[] definition? can someone with some AIX knowledge help with this?
Created attachment 71 [details] cpp output for monitor_fdpass.c
tmp[CMSG_SPACE(sizeof(int))]; evaluates to: char tmp[((ulong)((caddr_t)(sizeof(struct cmsghdr)) + sizeof (void *) - 1 - ((ulong)((caddr_t)(sizeof(struct cmsghdr)) + sizeof (void *) - 1) % sizeof (void *))) + (ulong)((caddr_t)(sizeof(int)) + sizeof (void *) - 1 - ((ulong)((caddr_t)(sizeof(int)) + sizeof (void *) - 1) % sizeof (void *))))];
It seems the IBM compiler will not do pointer arithmetic at compile time. For example, assuming pointers are compatible with unsigned longs, the following program will not compile using the IBM compiler xlc, but using gcc it will compile just fine (printing "6" when it runs, assuming ints are 4 bytes long): int main() { char tmp[(unsigned long)((int *)(10) - 1)]; printf ("size is %d\n", sizeof(tmp)); } Without the "- 1", the program will compile and run correctly (printing "10") using either xlc or gcc. The CMSG_SPACE macro used in monitor_fdpass.c uses the ALIGN macro, which AIX defines in sys/socket.h using pointer arithmetic. One fix is to undefine AIX's ALIGN macro in favour of openssh's which does not use pointer arithmetic and works just fine. A quick-and-dirty way of doing this is to apply the following patch to defines.h then run configure with CFLAGS="-DCOMPILER_CHOKES_ON_SYSTEM_ALIGN": --- defines.h.orig Sat Apr 6 18:52:05 2002 +++ defines.h Thu Apr 11 15:51:06 2002 @@ -447,6 +447,11 @@ #ifndef ALIGNBYTES #define ALIGNBYTES (sizeof(int) - 1) #endif +#ifdef COMPILER_CHOKES_ON_SYSTEM_ALIGN +#ifdef ALIGN +#undef ALIGN +#endif +#endif #ifndef ALIGN #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) #endif A better fix would be to have configure try to compile the following test program: #include <sys/socket.h> #ifndef ALIGN #define ALIGN(p) p #endif int main() { char tmp[ALIGN(1)]; } If sys/socket.h exists but this compilation fails, configure could set the COMPILER_CHOKES_ON_SYSTEM_ALIGN flag. However, since I have no experience with autoconf I'll let someone else suggest the appropriate patch. An alternative is to simply always use openssh's ALIGN macro (i.e., omit the #ifdef COMPILER_CHOKES_ON_SYSTEM_ALIGN from the defines.h patch) but I don't know if that would break anything on a system where the system's ALIGN macro has to be used because of something special it does. Two other changes are also needed to make this snapshot compile with the older version (4) of IBM's C compiler that I am using: It will not allow "enum {a,b,...,x,}" with nothing after the final comma -- this occurs twice in log.h and once in monitor.h, and if running in strict ANSI mode it will not allow the redefinition of TILDE in openbsd-compat/glob.c (the system header files already define it). These issues may apply to released versions of openssh also; I've never tried compiling it with IBM's compiler until I saw this bug report. If anyone wants me to I could open up a new bug report and attach a patch. I personally don't care about them too much since I use gcc, and presumably the current IBM compiler is okay since the reporter of this bug didn't mention any such problems.
Created attachment 77 [details] My first ever attempt at an autoconf/autoheader configuration based on the above recommendation! Can someone knowlegable review with a view to having this committed? Thanks.
Created attachment 78 [details] ...and the patch for defines.h to use COMPILER_CHOKES_ON_SYSTEM_ALIGN helps, too.
openssh-SNAP-20020421 still shows this error. Can anyone spare some time to look into the above attachments? Thanks.
Please try tommorrows snapshot (check that Bug #213 is mentioned in the Changelog). It should fix the problem.
openssh-SNAP-20020427 now compiles and runs with IBM xlc 5 under AIX 4.3.3 ML9. Thanks for the fix :-)
Mass change of RESOLVED bugs to CLOSED