Bug 321 - configure does not work when cross compiling
Summary: configure does not work when cross compiling
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: -current
Hardware: MIPS Linux
: P2 enhancement
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-29 10:59 AEST by Bryan Chua
Modified: 2006-10-07 11:35 AEST (History)
3 users (show)

See Also:


Attachments
configure.ac diff (3.33 KB, patch)
2002-06-29 11:00 AEST, Bryan Chua
no flags Details | Diff
sftp-glob.c diff (616 bytes, patch)
2002-06-29 11:00 AEST, Bryan Chua
no flags Details | Diff
Patch to configure.ac (3.7p1) (3.91 KB, patch)
2004-06-22 20:45 AEST, Peter Ãstrand
no flags Details | Diff
Update to -current (6.40 KB, patch)
2004-06-22 22:35 AEST, Darren Tucker
no flags Details | Diff
Updated patch for -current, which handles the zlib test (6.24 KB, patch)
2004-06-22 23:58 AEST, Peter Ãstrand
dtucker: ok+
Details | Diff
Add cross-compile support to the setres[ug]id test (1.36 KB, patch)
2004-09-07 21:37 AEST, Darren Tucker
djm: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Chua 2002-06-29 10:59:19 AEST
configure does not work when cross compiling because of the AC_TRY_RUN macro
without cross-compilation parameters.  Most of these can be resolved by
relatively safe guesses, changing them to AC_TRY_LINK, or runtime detection.

Attached is a patch that allows Openssh 3.4p1 to cross-compile.

--- openssh-3.4p1/configure.ac	Tue Jun 25 15:35:16 2002
+++ openssh-3.4p1.ayr/configure.ac	Fri Jun 28 14:21:34 2002
@@ -463,20 +463,6 @@
         ]
 )
 
-AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
-AC_TRY_RUN(
-
[
-#include <sys/types.h>
-#include <dirent.h>
-int main(void){struct dirent d;return(sizeof(d.d_name)<=sizeof(char));}
-
],
-
[AC_MSG_RESULT(yes)], 
-
[
-
	AC_MSG_RESULT(no)
-
	AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
-
]
-)
-
 # Check whether user wants S/Key support
 SKEY_MSG="no" 
 AC_ARG_WITH(skey,
@@ -505,6 +491,10 @@
 
			[
 
				AC_MSG_RESULT(no)
 
				AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
+
			]
+
			[
+
				AC_MSG_RESULT(no)
+
				AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
 
			])
 
	fi
 	]
@@ -597,6 +587,7 @@
 
	AC_MSG_RESULT(yes)
 
	AC_DEFINE(HAVE_MMAP_ANON_SHARED)
 	],
+
[ AC_MSG_RESULT(no) ],
 	[ AC_MSG_RESULT(no) ] 
 )
 fi
@@ -626,6 +617,7 @@
 }
 
			],
 
			[ ac_cv_have_broken_dirname="no" ],
+
			[ ac_cv_have_broken_dirname="yes" ],
 
			[ ac_cv_have_broken_dirname="yes" ]
 
		)
 
		LIBS="$save_LIBS"
@@ -670,6 +662,10 @@
 
		AC_MSG_RESULT(no)
 
		AC_DEFINE(BROKEN_SNPRINTF)
 
		AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
+
	],
+
	[
+
		AC_MSG_RESULT(assuming no)
+
		AC_DEFINE(BROKEN_SNPRINTF)
 
	]
 	)
 fi
@@ -784,6 +780,10 @@
 	[
 
	AC_MSG_RESULT(no)
 
	AC_MSG_ERROR(Your OpenSSL headers do not match your library)
+
],
+
[
+
	AC_MSG_RESULT(yes)
+
	AC_MSG_WARN(Not sure, hoping so)
 	]
 )
 
@@ -813,6 +813,13 @@
 
	# Default to use of the rand helper if OpenSSL doesn't
 
	# seed itself
 
	USE_RAND_HELPER=yes
+
],
+
[
+
	AC_MSG_RESULT(no)
+
	# Default to use of the rand helper if OpenSSL doesn't
+
	# seed itself
+
	USE_RAND_HELPER=yes
+
	AC_MSG_WARN(Not sure, assuming no)
 	]
 )
 
@@ -1417,7 +1424,8 @@
 #else
 main() { exit(0); }
 #endif
-
	], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ]
+
	], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ],
+
	[ AC_DEFINE(BROKEN_SNPRINTF) ]
 	)
 fi
 AC_SUBST(NO_SFTP)
@@ -1523,13 +1531,16 @@
 dnl make sure we're using the real structure members and not defines
 AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
 
	ac_cv_have_accrights_in_msghdr, [
-
AC_TRY_RUN(
+
AC_TRY_COMPILE(
 
	[
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
+
	],
+
	[
 int main() {
 #ifdef msg_accrights
+#error "msg_accrights is a macro"
 exit(1);
 #endif
 struct msghdr m;
@@ -1547,13 +1558,16 @@
 
 AC_CACHE_CHECK([for msg_control field in struct msghdr],
 
	ac_cv_have_control_in_msghdr, [
-
AC_TRY_RUN(
+
AC_TRY_COMPILE(
 
	[
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
+
	],
+
	[
 int main() {
 #ifdef msg_control
+#error "msg_control is a macro"
 exit(1);
 #endif
 struct msghdr m;
@@ -1860,20 +1874,17 @@
 
 if test -z "$no_dev_ptmx" ; then
 	if test "x$disable_ptmx_check" != "xyes" ; then
-
	AC_CHECK_FILE("/dev/ptmx", 
-
		[
-
			AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX)
-
			have_dev_ptmx=1
-
		]
-
	)
+
	if test -f "/dev/ptc" ; then
+
		AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX)
+
		have_dev_ptmx=1
+
	fi
 	fi
 fi
-AC_CHECK_FILE("/dev/ptc", 
-
[
-
	AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC)
-
	have_dev_ptc=1
-
]
-)
+
+if test -f "/dev/ptc" ; then
+
AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC)
+
have_dev_ptc=1
+fi
 
 # Options from here on. Some of these are preset by platform above
 AC_ARG_WITH(mantype,


--- openssh-3.4p1/sftp-glob.c	Tue Feb 12 19:10:33 2002
+++ openssh-3.4p1.ayr/sftp-glob.c	Fri Jun 28 14:02:44 2002
@@ -78,12 +78,9 @@
 	 * Solaris defines dirent->d_name as a one byte array and expects
 	 * you to hack around it.
 	 */
-#ifdef BROKEN_ONE_BYTE_DIRENT_D_NAME
-
strlcpy(ret->d_name, od->dir[od->offset++]->filename, MAXPATHLEN);
-#else
 	strlcpy(ret->d_name, od->dir[od->offset++]->filename,
-
    sizeof(ret->d_name));
-#endif
+
	(sizeof(ret->d_name) <= sizeof(char))?
+
	MAXPATHLEN: sizeof(ret->d_name));
 #ifdef __GNU_LIBRARY__
 	/*
 	 * Idiot glibc uses extensions to struct dirent for readdir with
Comment 1 Bryan Chua 2002-06-29 11:00:08 AEST
Created attachment 123 [details]
configure.ac diff
Comment 2 Bryan Chua 2002-06-29 11:00:40 AEST
Created attachment 124 [details]
sftp-glob.c diff
Comment 3 Peter Ãstrand 2004-06-22 20:45:26 AEST
Created attachment 655 [details]
Patch to configure.ac (3.7p1)

This new patch is for 3.7p1. It only modifies configure.ac; no C source. 

Can someone *please* apply?
Comment 4 Darren Tucker 2004-06-22 22:10:40 AEST
Comment on attachment 655 [details]
Patch to configure.ac (3.7p1)

>+if test "$cross_compiling"; then
I don't think that's portable, should probably be:
    if test ! -z "$cross_compiling";then

>+	echo cross compiling: Disabling /etc/default/login test
I think that should be AC_MSG_WARN().

I updated the patch to -current, will attach shortly.
Comment 5 Darren Tucker 2004-06-22 22:35:13 AEST
Created attachment 656 [details]
Update to -current

Update to current.  AC_TRY_COMPILE is marked obsolete so if we're making
changes we should use the modern equivalent AC_COMPILE_IFELSE.

Ditto for AC_TRY_RUN -> AC_RUN_IFELSE, especially since the manual says
AC_TRY_RUN doesn't have "action-if-cross-compiling" blocks.

Please test it (I don't cross-compile, so I haven't tested those bits).
Comment 6 Peter Ãstrand 2004-06-22 23:56:14 AEST
Patch 656 works, except that the zlib detection stuff needs some modification as
well. I'll submit a new patch. 
Comment 7 Peter Ãstrand 2004-06-22 23:58:41 AEST
Created attachment 657 [details]
Updated patch for -current, which handles the zlib test

This patch works for me. I'm configuring with:

./configure --with-ssl-dir=/usr/local/cross-solaris --host=sparc-sun-solaris2.8
--disable-etc-default-login

I've only tested the ssh client binary though; not sshd.
Comment 8 Darren Tucker 2004-07-02 13:24:06 AEST
Comment on attachment 657 [details]
Updated patch for -current, which handles the zlib test

This looks mostly OK, but I'd rather avoid messing with the /etc/default/login
tests.	Is reasonable to just expect people cross compiling to add
--without-etc-default-login?

Any other suggestions/opinions?
Comment 9 Peter Ãstrand 2004-07-02 17:35:25 AEST
>Is reasonable to just expect people cross compiling to add
>--without-etc-default-login?

Yes, I think this is reasonable. 
Comment 10 Michael Geiger 2004-09-07 18:39:28 AEST
I try to compile openssh-3.8.1p1 on a i386 linux system for s390-unknown-linux, 
but configure is still complaining about cross-compiling:

"checking if setresuid seems to work... configure: error: cannot run test 
program while cross compiling"

I tried to change configure.ac the way you did (although I'm not really sure 
what I am doing here  :-) and also the test for setresgid. Fixed it, but now I 
am stuck at

"checking if openpty correctly handles controlling tty... configure: error: 
cannot run test program while cross compiling"

How can I solve this?
Comment 11 Darren Tucker 2004-09-07 20:14:33 AEST
Micheal: You probably just need to run "autoreconf" to rebuild configure after
apply the patch(s).   Autoconf v2.59 is what we currently use, other versions
might work too.
Comment 12 Michael Geiger 2004-09-07 21:21:37 AEST
Daren: I ran autoconf after modifying configure.ac, of course. But I only 
applied the latest patch from here (...which handles the zlib test) ...
Comment 13 Darren Tucker 2004-09-07 21:37:59 AEST
Created attachment 710 [details]
Add cross-compile support to the setres[ug]id test

Ah, OK.  That check is only run if the setresuid is found, so I guess the other
folks doing cross-compiling are building for platforms that don't have it. 
Please try this patch in addition to #657.
Comment 14 Darren Tucker 2004-09-07 21:40:15 AEST
Comment on attachment 657 [details]
Updated patch for -current, which handles the zlib test

BTW, patch looks OK to me.  Should probably commit this (and the setresuid one
if it tests OK).
Comment 15 Damien Miller 2004-09-11 18:56:19 AEST
Comment on attachment 710 [details]
Add cross-compile support to the setres[ug]id test

this looks ok
Comment 16 Darren Tucker 2004-09-11 23:23:32 AEST
Comment on attachment 710 [details]
Add cross-compile support to the setres[ug]id test

>-	AC_TRY_RUN([
>+	AC_TRY_IFELSE([

Correction: make that "AC_RUN_IFELSE".
Comment 17 Darren Tucker 2004-09-11 23:27:28 AEST
Patches #657 and #710 applied.  Thanks to all.
Comment 18 Darren Tucker 2006-10-07 11:35:27 AEST
Change all RESOLVED bug to CLOSED with the exception of the ones fixed post-4.4.