https://gcc.gnu.org/g:e13b14030a300b3c94895e2c1d922c70ba3a271f
commit r16-7829-ge13b14030a300b3c94895e2c1d922c70ba3a271f Author: Jerry DeLisle <[email protected]> Date: Sat Feb 28 17:30:41 2026 -0800 Fortran: Fix libfortran cannot be cross compiled [PR124286] Remove unneeded check for a sane CLZL and regenerate using the correct version of autoconf. PR fortran/124286 libgfortran/ChangeLog: * acinclude.m4: Remove LIBGFOR_CHECK_SANE_BUILTIN_CLZL. * caf/shmem/allocator.c (next_power_of_two): Use known sane builtin. * configure: Regenerate. * configure.ac: Remove use of LIBGFOR_CHECK_SANE_BUILTIN_CLZL. Diff: --- libgfortran/acinclude.m4 | 11 ------- libgfortran/caf/shmem/allocator.c | 12 ++------ libgfortran/configure | 63 ++------------------------------------- libgfortran/configure.ac | 3 -- 4 files changed, 4 insertions(+), 85 deletions(-) diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 index 13097b4ab926..239ab7147506 100644 --- a/libgfortran/acinclude.m4 +++ b/libgfortran/acinclude.m4 @@ -579,14 +579,3 @@ main () fi ]) -AC_DEFUN([LIBGFOR_CHECK_SANE_BUILTIN_CLZL], [ - AC_RUN_IFELSE([AC_LANG_PROGRAM([[ - int main() - { - return __builtin_clzl(256) != 8; - }]], [[]])], - AC_DEFINE(HAVE_SANE_BUILTIN_CLZL, 1, - [Define if __builtin_clzl behaves as expected.]) - AM_CONDITIONAL([HAVE_SANE_BUILTIN_CLZL],true), - [AM_CONDITIONAL([HAVE_SANE_BUILTIN_CLZL],false)]) -]) diff --git a/libgfortran/caf/shmem/allocator.c b/libgfortran/caf/shmem/allocator.c index bd88f33e2000..795647cdbba1 100644 --- a/libgfortran/caf/shmem/allocator.c +++ b/libgfortran/caf/shmem/allocator.c @@ -78,16 +78,8 @@ allocator_init_supervisor (allocator *a, allocator_shared *s, shared_memory sm) static size_t next_power_of_two (size_t size) { -#ifdef HAVE_SANE_BUILTIN_CLZL - assert (size); -#if (__INTPTR_WIDTH__ == 64) - return 1 << (VOIDP_BITS - __builtin_clzl (size - 1)); -#else - return 1 << (VOIDP_BITS - __builtin_clz (size - 1)); -#endif -#else - return 1 << (int)ceil(log2(size)); -#endif + assert (size != 1); + return (size_t)1 << (__SIZEOF_LONG_LONG__ * __CHAR_BIT__ - __builtin_clzll (size - 1)); } shared_mem_ptr diff --git a/libgfortran/configure b/libgfortran/configure index 41bc382ac4d5..eeb1bce0944e 100755 --- a/libgfortran/configure +++ b/libgfortran/configure @@ -637,8 +637,6 @@ am__EXEEXT_TRUE LTLIBOBJS LIBOBJS get_gcc_base_ver -HAVE_SANE_BUILTIN_CLZL_FALSE -HAVE_SANE_BUILTIN_CLZL_TRUE HAVE_AVX128_FALSE HAVE_AVX128_TRUE tmake_file @@ -13247,6 +13245,8 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF + + #line 13250 "configure" #include "confdefs.h" @@ -32517,57 +32517,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$ac_save_CFLAGS" -# Check if __builtin_clzl behaves (it doesn't on Msys2/ucrt64). - - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - int main() - { - return __builtin_clzl(256) != 8; - } -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -$as_echo "#define HAVE_SANE_BUILTIN_CLZL 1" >>confdefs.h - - if true; then - HAVE_SANE_BUILTIN_CLZL_TRUE= - HAVE_SANE_BUILTIN_CLZL_FALSE='#' -else - HAVE_SANE_BUILTIN_CLZL_TRUE='#' - HAVE_SANE_BUILTIN_CLZL_FALSE= -fi - -else - if false; then - HAVE_SANE_BUILTIN_CLZL_TRUE= - HAVE_SANE_BUILTIN_CLZL_FALSE='#' -else - HAVE_SANE_BUILTIN_CLZL_TRUE='#' - HAVE_SANE_BUILTIN_CLZL_FALSE= -fi - -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - - # Determine what GCC version number to use in filesystem paths. get_gcc_base_ver="cat" @@ -32863,14 +32812,6 @@ if test -z "${HAVE_AVX128_TRUE}" && test -z "${HAVE_AVX128_FALSE}"; then as_fn_error $? "conditional \"HAVE_AVX128\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${HAVE_SANE_BUILTIN_CLZL_TRUE}" && test -z "${HAVE_SANE_BUILTIN_CLZL_FALSE}"; then - as_fn_error $? "conditional \"HAVE_SANE_BUILTIN_CLZL\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${HAVE_SANE_BUILTIN_CLZL_TRUE}" && test -z "${HAVE_SANE_BUILTIN_CLZL_FALSE}"; then - as_fn_error $? "conditional \"HAVE_SANE_BUILTIN_CLZL\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac index fea8292225be..530d15f0152b 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac @@ -799,9 +799,6 @@ LIBGFOR_CHECK_FMA4 # Check if AVX128 works LIBGFOR_CHECK_AVX128 -# Check if __builtin_clzl behaves (it doesn't on Msys2/ucrt64). -LIBGFOR_CHECK_SANE_BUILTIN_CLZL - # Determine what GCC version number to use in filesystem paths. GCC_BASE_VER
