Using WSL2 to cross-compile from Linux to Windows
Niels Möller
nisse at lysator.liu.se
Tue Jul 26 21:56:46 CEST 2022
johanneskauffmann at hotmail.com writes:
> A while back someone messaged about cross-compiling from Linux to Windows [1].
> That person had a problem with the GMP script detecting the wrong build
> compiler:
It looks like that particular message ([1]
https://gmplib.org/list-archives/gmp-bugs/2020-January/004715.html) was
mine.
> Below, I implemented the patch suggested in the referenced message, and it works
> wonderfully.
>
>
> diff -r 58bb9b017366 acinclude.m4
> --- a/acinclude.m4 Sun May 29 18:08:56 2022 +0200
> +++ b/acinclude.m4 Sun Jun 12 23:34:56 2022 +0200
> @@ -3794,11 +3794,15 @@
> [CC_FOR_BUILD=$HOST_CC],
> [AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])])
> else
> - for i in "$CC" "$CC $CFLAGS $CPPFLAGS" cc gcc c89 c99; do
> - GMP_PROG_CC_FOR_BUILD_WORKS($i,
> - [CC_FOR_BUILD=$i
> - break])
> - done
> + if test $cross_compiling = no ; then
> + CC_FOR_BUILD="$CC"
> + else
> + for i in cc gcc c89 c99; do
> + GMP_PROG_CC_FOR_BUILD_WORKS($i,
> + [CC_FOR_BUILD=$i
> + break])
> + done
> + fi
> if test -z "$CC_FOR_BUILD"; then
> AC_MSG_ERROR([Cannot find a build system compiler])
> fi
Still makes sense to me. Could perhaps keep $CC at the *end* of the list?
I'm a bit annoyed by the related problem, that it is not enough to pass
--host to get cross_compilation set properly. For some backwards
compatiblity reasons one has to explicitly pass --build as well, even
when config.guess figures out the build system type perfectly right.
Documented in some detail at
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/autoconf.html#Hosts-and-Cross_002dCompilation
Regards,
/Niels
--
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
More information about the gmp-bugs
mailing list