Skip to content

Commit

Permalink
Fix [d58e31517203396e]: configure --enable-64bit=aarch64 broken
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Jan 2, 2025
2 parents 690eacc + 66dcee7 commit 8c45746
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
52 changes: 50 additions & 2 deletions win/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4236,7 +4236,7 @@ printf "%s\n" "$ac_cv_win32" >&6; }
if test "$ac_cv_win32" != "yes"; then
as_fn_error $? "${CC} cannot produce win32 executables." "$LINENO" 5
fi
if test "$do64bit" != "arm64"; then
if test "$do64bit" != "arm64" -a "$do64bit" != "aarch64"; then
extra_cflags="$extra_cflags -DHAVE_CPUID=1"
fi

Expand Down Expand Up @@ -4957,7 +4957,7 @@ then :

printf "%s\n" "#define MP_64BIT 1" >>confdefs.h

if test "$do64bit" = "arm64"
if test "$do64bit" = "arm64" -o "$do64bit" = "aarch64"
then :

if test "$GCC" = "yes"
Expand Down Expand Up @@ -5359,6 +5359,54 @@ printf "%s\n" "#define HAVE_INTRIN_H 1" >>confdefs.h

fi

# See if the compiler supports cpuid header.

if test "${GCC}" = "yes" ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cpuid-header support in compiler" >&5
printf %s "checking for cpuid-header support in compiler... " >&6; }
if test ${tcl_cv_cpuidhead+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))))
# include <cpuid.h>
#endif
int
main (void)
{
unsigned int regs;
__get_cpuid(0, &regs, &regs, &regs, &regs);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
tcl_cv_cpuidhead=yes
else case e in #(
e) tcl_cv_cpuidhead=no ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cpuidhead" >&5
printf "%s\n" "$tcl_cv_cpuidhead" >&6; }
if test "$tcl_cv_cpuidhead" = "yes"; then

printf "%s\n" "#define HAVE_CPUID_H 1" >>confdefs.h

fi
fi

# See if the <wspiapi.h> header file is present

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for wspiapi.h" >&5
Expand Down
24 changes: 23 additions & 1 deletion win/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ AS_IF([test "$tcl_ok" = "yes"], [
AC_DEFINE(TCL_WITH_EXTERNAL_TOMMATH, 1, [Tcl with external libtommath])
AS_IF([test "$do64bit" != "no"], [
AC_DEFINE(MP_64BIT, 1, [Using libtommath.dll in 64-bit mode])
AS_IF([test "$do64bit" = "arm64"], [
AS_IF([test "$do64bit" = "arm64" -o "$do64bit" = "aarch64"], [
AS_IF([test "$GCC" = "yes"],[
AC_SUBST(ZLIB_LIBS,[\${ZLIB_DIR_NATIVE}/win64-arm/libz.dll.a])
AC_SUBST(TOMMATH_LIBS,[\${TOMMATH_DIR_NATIVE}/win64-arm/libtommath.dll.a])
Expand Down Expand Up @@ -255,6 +255,28 @@ if test "$tcl_cv_intrinsics" = "yes"; then
[Defined when the compilers supports intrinsics])
fi

# See if the compiler supports cpuid header.

if test "${GCC}" = "yes" ; then
AC_CACHE_CHECK(for cpuid-header support in compiler,
tcl_cv_cpuidhead,
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))))
# include <cpuid.h>
#endif
]], [[
unsigned int regs;
__get_cpuid(0, &regs, &regs, &regs, &regs);
]])],
[tcl_cv_cpuidhead=yes],
[tcl_cv_cpuidhead=no])
)
if test "$tcl_cv_cpuidhead" = "yes"; then
AC_DEFINE(HAVE_CPUID_H, 1,
[Defined when the compilers supports cpuid header])
fi
fi

# See if the <wspiapi.h> header file is present

AC_CACHE_CHECK(for wspiapi.h,
Expand Down
2 changes: 1 addition & 1 deletion win/tcl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
if test "$ac_cv_win32" != "yes"; then
AC_MSG_ERROR([${CC} cannot produce win32 executables.])
fi
if test "$do64bit" != "arm64"; then
if test "$do64bit" != "arm64" -a "$do64bit" != "aarch64"; then
extra_cflags="$extra_cflags -DHAVE_CPUID=1"
fi
Expand Down
4 changes: 2 additions & 2 deletions win/tclWin32Dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

#include "tclWinInt.h"
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))))
#if defined(HAVE_CPUID_H)
# include <cpuid.h>
#elif defined(HAVE_INTRIN_H)
# include <intrin.h>
Expand Down Expand Up @@ -439,7 +439,7 @@ TclWinCPUID(
{
int status = TCL_ERROR;

#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))))
#if defined(HAVE_CPUID_H)

unsigned int *regs = (unsigned int *)regsPtr;
__get_cpuid(index, &regs[0], &regs[1], &regs[2], &regs[3]);
Expand Down

0 comments on commit 8c45746

Please sign in to comment.