Bug 213 - -SNAP-20020410 fails to compile under AIX 4.3.3
Summary: -SNAP-20020410 fails to compile under AIX 4.3.3
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: -current
Hardware: PPC AIX
: P2 normal
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-11 06:19 AEST by Doug Manton
Modified: 2004-04-14 12:24 AEST (History)
0 users

See Also:


Attachments
cpp output for monitor_fdpass.c (80.81 KB, text/plain)
2002-04-11 18:07 AEST, Doug Manton
no flags 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. (1.10 KB, patch)
2002-04-17 00:54 AEST, Doug Manton
no flags Details | Diff
...and the patch for defines.h to use COMPILER_CHOKES_ON_SYSTEM_ALIGN helps, too. (408 bytes, patch)
2002-04-17 01:05 AEST, Doug Manton
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Manton 2002-04-11 06:19:28 AEST
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?
Comment 1 Kevin Steves 2002-04-11 08:57:47 AEST
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?
Comment 2 Doug Manton 2002-04-11 18:07:26 AEST
Created attachment 71 [details]
cpp output for monitor_fdpass.c
Comment 3 Doug Manton 2002-04-11 18:09:00 AEST
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 *))))];
Comment 4 Philip Spencer 2002-04-12 06:51:53 AEST
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.

Comment 5 Doug Manton 2002-04-17 00:54:11 AEST
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.
Comment 6 Doug Manton 2002-04-17 01:05:27 AEST
Created attachment 78 [details]
...and the patch for defines.h to use COMPILER_CHOKES_ON_SYSTEM_ALIGN helps, too.
Comment 7 Doug Manton 2002-04-23 00:34:29 AEST
openssh-SNAP-20020421 still shows this error.  Can anyone spare some time to look into the above 
attachments?

Thanks.
Comment 8 Damien Miller 2002-04-23 23:01:16 AEST
Please try tommorrows snapshot (check that Bug #213 is mentioned in the
Changelog). It should fix the problem.
Comment 9 Doug Manton 2002-04-28 02:53:39 AEST
openssh-SNAP-20020427 now compiles and runs with IBM xlc 5 under 
AIX 4.3.3 ML9.  

Thanks for the fix :-)
Comment 10 Damien Miller 2004-04-14 12:24:18 AEST
Mass change of RESOLVED bugs to CLOSED