From d5930a18c634a8e82269cfe471e1ba3c225b101c Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 9 Jan 2020 06:56:20 -0700 Subject: [PATCH] configure: fix `--disable-mac64` mode as cross-compile mode --- racket/src/ac/iconv.m4 | 36 ++++++++++++++++++ racket/src/ac/sdk_mac.m4 | 7 +++- racket/src/ac/valid_sizeof.m4 | 6 +++ racket/src/cfg-racket | 68 ++++++++++++++++++++-------------- racket/src/cs/c/configure | 61 ++++++++++++++++-------------- racket/src/cs/c/configure.ac | 46 +---------------------- racket/src/racket/configure.ac | 41 ++------------------ 7 files changed, 128 insertions(+), 137 deletions(-) create mode 100644 racket/src/ac/iconv.m4 create mode 100644 racket/src/ac/valid_sizeof.m4 diff --git a/racket/src/ac/iconv.m4 b/racket/src/ac/iconv.m4 new file mode 100644 index 0000000000..d1983737d9 --- /dev/null +++ b/racket/src/ac/iconv.m4 @@ -0,0 +1,36 @@ +iconv_lib_flag="" +if test "${skip_iconv_check}" = "no" ; then + if test "${enable_iconv}" = "yes" ; then + AC_CHECK_HEADER(iconv.h, enable_iconv=yes, enable_iconv=no) + if test "${enable_iconv}" = "yes" ; then + # Does it all work, now? + AC_TRY_LINK( + [#include ] + [#include ], +[ iconv_open("UTF-8", "UTF-8");] + return 0; + , enable_iconv=yes, enable_iconv=no) + if test "${enable_iconv}" = "no" ; then + # Try adding -liconv ? + # We did not use AC_CHECK_LIB because iconv is sometimes macro-renamed + ORIG_LIBS="$LIBS" + LIBS="$LIBS -liconv" + AC_TRY_LINK( + [#include ] + [#include ], +[ iconv_open("UTF-8", "UTF-8");] + return 0; + , enable_iconv=yes, enable_iconv=no) + if test "${enable_iconv}" = "no" ; then + LIBS="$ORIG_LIBS" + else + iconv_lib_flag=" -liconv" + fi + fi + fi + fi + [ msg="iconv is usable" ] + AC_MSG_CHECKING($msg) + iconv_usage_result="$enable_iconv$iconv_lib_flag" + AC_MSG_RESULT($iconv_usage_result) +fi diff --git a/racket/src/ac/sdk_mac.m4 b/racket/src/ac/sdk_mac.m4 index 69acbcf3e0..3b0a327b74 100644 --- a/racket/src/ac/sdk_mac.m4 +++ b/racket/src/ac/sdk_mac.m4 @@ -66,7 +66,12 @@ SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} CC="'"'"${CC}"' -m32"' fi need_cc_in_extras=no + if test "$build_cpu" = "x86_64" ; then + # AG_PROC_CC has already decided that we weren't + # cross compiling, so change that decision + cross_compiling=yes + echo may be cross compiling after all + fi fi fi fi - diff --git a/racket/src/ac/valid_sizeof.m4 b/racket/src/ac/valid_sizeof.m4 new file mode 100644 index 0000000000..1de172f429 --- /dev/null +++ b/racket/src/ac/valid_sizeof.m4 @@ -0,0 +1,6 @@ +if test "${ac_cv_sizeof_void_p}" != "4" ; then + if test "${ac_cv_sizeof_void_p}" != "8" ; then + echo "Something has gone wrong getting the pointer size; see config.log" + exit 1 + fi +fi diff --git a/racket/src/cfg-racket b/racket/src/cfg-racket index c1f618fbfc..8df78936f9 100755 --- a/racket/src/cfg-racket +++ b/racket/src/cfg-racket @@ -5025,12 +5025,17 @@ $as_echo "#define HAVE_STDINT_H 1" >>confdefs.h SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} CC="'"'"${CC}"' -m32"' fi need_cc_in_extras=no + if test "$build_cpu" = "x86_64" ; then + # AG_PROC_CC has already decided that we weren't + # cross compiling, so change that decision + cross_compiling=yes + echo may be cross compiling after all + fi fi fi fi - case "$host_cpu" in i386|x86_64) enable_parallel_by_default=yes @@ -5673,53 +5678,53 @@ fi if test "${enable_iconv}" = "yes" ; then # Does it all work, now? - if test "$cross_compiling" = yes; then : - enable_iconv=yes -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include - int main() { +#include + #include +int +main () +{ iconv_open("UTF-8", "UTF-8"); return 0; - } + + ; + return 0; +} _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_c_try_link "$LINENO"; then : enable_iconv=yes else enable_iconv=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test "${enable_iconv}" = "no" ; then # Try adding -liconv ? # We did not use AC_CHECK_LIB because iconv is sometimes macro-renamed ORIG_LIBS="$LIBS" LIBS="$LIBS -liconv" - if test "$cross_compiling" = yes; then : - enable_iconv=yes -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include - int main() { +#include + #include +int +main () +{ iconv_open("UTF-8", "UTF-8"); return 0; - } + + ; + return 0; +} _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_c_try_link "$LINENO"; then : enable_iconv=yes else enable_iconv=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test "${enable_iconv}" = "no" ; then LIBS="$ORIG_LIBS" else @@ -5736,6 +5741,7 @@ $as_echo_n "checking $msg... " >&6; } $as_echo "$iconv_usage_result" >&6; } fi + if test "${check_for_mprotect}" = "yes" ; then msg="for mmap and mprotect" { $as_echo "$as_me:${as_lineno-$LINENO}: checking $msg" >&5 @@ -6180,6 +6186,14 @@ _ACEOF +if test "${ac_cv_sizeof_void_p}" != "4" ; then + if test "${ac_cv_sizeof_void_p}" != "8" ; then + echo "Something has gone wrong getting the pointer size; see config.log" + exit 1 + fi +fi + + ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default" if test "x$ac_cv_type_intptr_t" = xyes; then : diff --git a/racket/src/cs/c/configure b/racket/src/cs/c/configure index 0f0d4f04c6..596514d8cd 100755 --- a/racket/src/cs/c/configure +++ b/racket/src/cs/c/configure @@ -4690,12 +4690,17 @@ fi SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} CC="'"'"${CC}"' -m32"' fi need_cc_in_extras=no + if test "$build_cpu" = "x86_64" ; then + # AG_PROC_CC has already decided that we weren't + # cross compiling, so change that decision + cross_compiling=yes + echo may be cross compiling after all + fi fi fi fi - if test "${enable_libfw}" = "yes" ; then FRAMEWORK_INSTALL_DIR=/Library/Frameworks FRAMEWORK_REL_INSTALL=no @@ -5073,53 +5078,53 @@ fi if test "${enable_iconv}" = "yes" ; then # Does it all work, now? - if test "$cross_compiling" = yes; then : - enable_iconv=yes -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include - int main() { +#include + #include +int +main () +{ iconv_open("UTF-8", "UTF-8"); return 0; - } + + ; + return 0; +} _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_c_try_link "$LINENO"; then : enable_iconv=yes else enable_iconv=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test "${enable_iconv}" = "no" ; then # Try adding -liconv ? # We did not use AC_CHECK_LIB because iconv is sometimes macro-renamed ORIG_LIBS="$LIBS" LIBS="$LIBS -liconv" - if test "$cross_compiling" = yes; then : - enable_iconv=yes -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include - int main() { +#include + #include +int +main () +{ iconv_open("UTF-8", "UTF-8"); return 0; - } + + ; + return 0; +} _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_c_try_link "$LINENO"; then : enable_iconv=yes else enable_iconv=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test "${enable_iconv}" = "no" ; then LIBS="$ORIG_LIBS" else @@ -5135,6 +5140,7 @@ $as_echo_n "checking $msg... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $iconv_usage_result" >&5 $as_echo "$iconv_usage_result" >&6; } fi + if test "${enable_iconv}" = "no" ; then $as_echo "#define RKTIO_NO_ICONV 1" >>confdefs.h @@ -5317,6 +5323,7 @@ if test "${ac_cv_sizeof_void_p}" != "4" ; then fi fi + ############## subconfigure ################ # Before libtool setup diff --git a/racket/src/cs/c/configure.ac b/racket/src/cs/c/configure.ac index 9bddef2efc..b6fd8aafba 100644 --- a/racket/src/cs/c/configure.ac +++ b/racket/src/cs/c/configure.ac @@ -481,44 +481,7 @@ fi AC_LANG_C -iconv_lib_flag="" -if test "${skip_iconv_check}" = "no" ; then - if test "${enable_iconv}" = "yes" ; then - AC_CHECK_HEADER(iconv.h, enable_iconv=yes, enable_iconv=no) - if test "${enable_iconv}" = "yes" ; then - # Does it all work, now? - AC_TRY_RUN( -[ #include ] -[ #include ] - int main() { -[ iconv_open("UTF-8", "UTF-8");] - return 0; - }, enable_iconv=yes, enable_iconv=no, enable_iconv=yes) - if test "${enable_iconv}" = "no" ; then - # Try adding -liconv ? - # We did not use AC_CHECK_LIB because iconv is sometimes macro-renamed - ORIG_LIBS="$LIBS" - LIBS="$LIBS -liconv" - AC_TRY_RUN( -[ #include ] -[ #include ] - int main() { -[ iconv_open("UTF-8", "UTF-8");] - return 0; - }, enable_iconv=yes, enable_iconv=no, enable_iconv=yes) - if test "${enable_iconv}" = "no" ; then - LIBS="$ORIG_LIBS" - else - iconv_lib_flag=" -liconv" - fi - fi - fi - fi - [ msg="iconv is usable" ] - AC_MSG_CHECKING($msg) - iconv_usage_result="$enable_iconv$iconv_lib_flag" - AC_MSG_RESULT($iconv_usage_result) -fi +m4_include(../ac/iconv.m4) if test "${enable_iconv}" = "no" ; then AC_DEFINE(RKTIO_NO_ICONV,1,[Do not use iconv]) fi @@ -608,12 +571,7 @@ fi AC_CHECK_SIZEOF([void *]) -if test "${ac_cv_sizeof_void_p}" != "4" ; then - if test "${ac_cv_sizeof_void_p}" != "8" ; then - echo "Something has gone wrong getting the pointer size; see config.log" - exit 1 - fi -fi +m4_include(../ac/valid_sizeof.m4) ############## subconfigure ################ diff --git a/racket/src/racket/configure.ac b/racket/src/racket/configure.ac index cd839482b2..00c5e65900 100644 --- a/racket/src/racket/configure.ac +++ b/racket/src/racket/configure.ac @@ -883,44 +883,7 @@ AC_MSG_RESULT($using_gnu_cpp) # Although rktio takes care of iconv, we need to know whether # to link to it -iconv_lib_flag="" -if test "${skip_iconv_check}" = "no" ; then - if test "${enable_iconv}" = "yes" ; then - AC_CHECK_HEADER(iconv.h, enable_iconv=yes, enable_iconv=no) - if test "${enable_iconv}" = "yes" ; then - # Does it all work, now? - AC_TRY_RUN( -[ #include ] -[ #include ] - int main() { -[ iconv_open("UTF-8", "UTF-8");] - return 0; - }, enable_iconv=yes, enable_iconv=no, enable_iconv=yes) - if test "${enable_iconv}" = "no" ; then - # Try adding -liconv ? - # We did not use AC_CHECK_LIB because iconv is sometimes macro-renamed - ORIG_LIBS="$LIBS" - LIBS="$LIBS -liconv" - AC_TRY_RUN( -[ #include ] -[ #include ] - int main() { -[ iconv_open("UTF-8", "UTF-8");] - return 0; - }, enable_iconv=yes, enable_iconv=no, enable_iconv=yes) - if test "${enable_iconv}" = "no" ; then - LIBS="$ORIG_LIBS" - else - iconv_lib_flag=" -liconv" - fi - fi - fi - fi - [ msg="iconv is usable" ] - AC_MSG_CHECKING($msg) - iconv_usage_result="$enable_iconv$iconv_lib_flag" - AC_MSG_RESULT($iconv_usage_result) -fi +m4_include(../ac/iconv.m4) if test "${check_for_mprotect}" = "yes" ; then [ msg="for mmap and mprotect" ] @@ -1045,6 +1008,8 @@ AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF([void *]) AC_CHECK_SIZEOF(bool, unused, [#include ]) +m4_include(../ac/valid_sizeof.m4) + AC_TYPE_INTPTR_T AC_TYPE_UINTPTR_T