1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
Description: Fix compiling with gcc-15
Author: Bernd Paysan <bernd@net2o.de>
Last-Update: 2026-03-13
diff --git a/configure.in b/configure.in
index 475a68f..6f957c8 100644
--- a/configure.in
+++ b/configure.in
@@ -39,6 +39,20 @@ AC_SUBST(LTDLINCL)
AC_SUBST(LIBLTDL)
AC_SUBST(LTDL_LDLIBS)
+#suppress "-flto=auto"
+case "$CFLAGS" in
+ *-flto=auto*)
+ CFLAGS=`echo $CFLAGS | sed -e 's/-flto=auto//g' -e 's/-ffat-lto-objects//g' -e 's/ / /g' -e 's/ / /g'`
+ ;;
+esac
+
+#suppress "-flto=auto"
+case "$LDFLAGS" in
+ *-flto=auto*)
+ LDFLAGS=`echo $LDFLAGS | sed -e 's/-flto=auto//g' -e 's/-ffat-lto-objects//g' -e 's/ / /g' -e 's/ / /g'`
+ ;;
+esac
+
#suppress the "-g -O2" default
test "$CFLAGS" || CFLAGS=-O2
@@ -131,7 +148,7 @@ AC_ARG_VAR(ac_cv_sizeof_uint128_t, [sizeof(uint128_t)])
AC_ARG_VAR(ac_cv_c_bigendian, [Is the target big-endian ("yes" or "no")?])
AC_ARG_VAR(no_dynamic_default, [run gforth with --dynamic (0) or --no-dynamic (1) by default])
AC_ARG_VAR(condbranch_opt, [enable (1) or disable (0) using two dispatches for conditional branches])
-AC_ARG_VAR(skipcode, [assembly code for skipping 16 bytes of code])
+AC_ARG_VAR(skipcode, [assembly code for skipping 4 bytes of code])
AC_ARG_VAR(asmcomment, [assembler comment start string])
AC_ARG_VAR(arm_cacheflush, [file containing ARM cacheflush function (without .c)])
AC_ARG_VAR(LTDL_LIBRARY_PATH, [additional directories for libltdl (for some 64-bit platforms)])
@@ -242,6 +259,7 @@ case "$host_cpu" in
;;
i*86)
machine=386
+ test "$skipcode_arch" || skipcode_arch="nopl (%eax,%eax,1)"
CFLAGS="$CFLAGS -fomit-frame-pointer -fforce-addr"
;;
x86_64)
@@ -249,12 +267,15 @@ case "$host_cpu" in
in
*-m32*)
machine=386
+ test "$skipcode_arch" || skipcode_arch="nopl (%eax,%eax,1)"
CFLAGS="$CFLAGS -fomit-frame-pointer -fforce-addr"
CFLAGS_1="$CFLAGS"
CFLAGS="$CFLAGS -march=athlon64"
;;
*)
machine=amd64
+ test "$skipcode_arch" || skipcode_arch="nopl (%rax,%rax,1)"
+ CFLAGS="$CFLAGS -fomit-frame-pointer"
;;
esac
;;
@@ -550,62 +571,51 @@ AC_DEFINE_UNQUOTED(SMALL_OFF_T,$ac_small_off_t,[1 if off_t fits in a Cell])
ENGINE_FLAGS=
AC_SUBST(ENGINE_FLAGS)
-# Check whether GCC understands -fno-gcse
-
-AC_MSG_CHECKING([if $CC understands -fno-gcse])
-CFLAGS_1="$CFLAGS"
-CFLAGS="$CFLAGS -fno-gcse"
-AC_TRY_COMPILE(,,ac_nogcse=yes;ENGINE_FLAGS="$ENGINE_FLAGS -fno-gcse",ac_nogcse=no)
-CFLAGS="$CFLAGS_1"
-AC_MSG_RESULT($ac_nogcse)
-
-# Check whether GCC understands -fno-strict-aliasing
-AC_MSG_CHECKING([if $CC understands -fno-strict-aliasing])
-CFLAGS_1="$CFLAGS"
-CFLAGS="$CFLAGS -fno-strict-aliasing"
-AC_TRY_COMPILE(,,ac_nostrictaliasing=yes;ENGINE_FLAGS="$ENGINE_FLAGS -fno-strict-aliasing",ac_nostrictaliasing=no)
-CFLAGS="$CFLAGS_1"
-AC_MSG_RESULT($ac_nostrictaliasing)
-
-# Check whether GCC understands -fno-crossjumping
-AC_MSG_CHECKING([if $CC understands -fno-crossjumping])
-CFLAGS_1="$CFLAGS"
-CFLAGS="$CFLAGS -fno-crossjumping"
-AC_TRY_COMPILE(,,ac_nocrossjumping=yes;ENGINE_FLAGS="$ENGINE_FLAGS -fno-crossjumping",ac_nocrossjumping=no)
-CFLAGS="$CFLAGS_1"
-AC_MSG_RESULT($ac_nocrossjumping)
-
-# Check whether GCC understands -fno-reorder-blocks
-AC_MSG_CHECKING([if $CC understands -fno-reorder-blocks])
-CFLAGS_1="$CFLAGS"
-CFLAGS="$CFLAGS -fno-reorder-blocks"
-AC_TRY_COMPILE(,,ac_noreorder_blocks=yes;ENGINE_FLAGS="$ENGINE_FLAGS -fno-reorder-blocks",ac_noreorder_blocks=no)
-CFLAGS="$CFLAGS_1"
-AC_MSG_RESULT($ac_noreorder_blocks)
-
-# Check whether GCC understands -falign-labels=1
-AC_MSG_CHECKING([if $CC understands -falign-labels=1])
-CFLAGS_1="$CFLAGS"
-CFLAGS="$CFLAGS -falign-labels=1"
-AC_TRY_COMPILE(,,ac_align_labels=yes;ENGINE_FLAGS="$ENGINE_FLAGS -falign-labels=1",ac_align_labels=no)
-CFLAGS="$CFLAGS_1"
-AC_MSG_RESULT($ac_align_labels)
-
-# Check whether GCC understands -falign-loops=1
-AC_MSG_CHECKING([if $CC understands -falign-loops=1])
-CFLAGS_1="$CFLAGS"
-CFLAGS="$CFLAGS -falign-loops=1"
-AC_TRY_COMPILE(,,ac_align_loops=yes;ENGINE_FLAGS="$ENGINE_FLAGS -falign-loops=1",ac_align_loops=no)
-CFLAGS="$CFLAGS_1"
-AC_MSG_RESULT($ac_align_loops)
-
-# Check whether GCC understands -falign-jumps=1
-AC_MSG_CHECKING([if $CC understands -falign-jumps=1])
-CFLAGS_1="$CFLAGS"
-CFLAGS="$CFLAGS -falign-jumps=1"
-AC_TRY_COMPILE(,,ac_align_jumps=yes;ENGINE_FLAGS="$ENGINE_FLAGS -falign-jumps=1",ac_align_jumps=no)
-CFLAGS="$CFLAGS_1"
-AC_MSG_RESULT($ac_align_jumps)
+# Try a number of flags as workarounds
+
+CHECKFLAGS="$CHECKFLAGS no-gcse caller-saves no-defer-pop no-inline wrapv char-unsigned no-strict-aliasing no-cse-follow-jumps no-reorder-blocks no-reorder-blocks-and-partition no-toplevel-reorder no-trigraphs align-labels=1 align-loops=1 align-jumps=1 no-delete-null-pointer-checks cf-protection=none llvm=--tail-dup-indirect-size=0"
+
+case "$host_os" in
+ *netbsd*)
+ ;;
+ *)
+ CHECKFLAGS="$CHECKFLAGS no-lto"
+ ;;
+esac
+
+if test `$CC -dumpversion | cut -f1 -d.` -lt 14
+then
+ CHECKFLAGS="$CHECKFLAGS no-tree-vectorize"
+fi
+
+for i in $CHECKFLAGS
+do
+ ac_i=$(echo ac_$i | tr '=\-' '__')
+ case "$i" in
+ "llvm="*)
+ i="-m$i"
+ ;;
+ -m*)
+ ;;
+ *)
+ i="-f$i"
+ ;;
+ esac
+ AC_MSG_CHECKING([if $CC understands $i])
+ CFLAGS_1="$CFLAGS"
+ ENGINE_FLAGS_old="$ENGINE_FLAGS"
+ ENGINE_FLAGS="$ENGINE_FLAGS $i"
+ CFLAGS="$CFLAGS $ENGINE_FLAGS"
+ if test "$CROSS" = '#'
+ then
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(){ return 0; }]])],[eval $ac_i=yes;],[eval $ac_i=no; ENGINE_FLAGS="$ENGINE_FLAGS_old"])
+ else
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(){ return 0; }]])],[eval $ac_i=yes;],[eval $ac_i=no; ENGINE_FLAGS="$ENGINE_FLAGS_old"])
+ fi
+ CFLAGS="$CFLAGS_1"
+ ac_result=$(eval echo "\$$ac_i")
+ AC_MSG_RESULT($ac_result)
+done
# Check whether GCC understands __attribute__((unused))
AC_MSG_CHECKING([how to suppress 'unused variable' warnings])
@@ -755,27 +765,34 @@ if test -z "$skipcode"; then
skipcode=no
CFLAGS_1="$CFLAGS"
CFLAGS="$CFLAGS $ENGINE_FLAGS"
- for i in ".skip 16" ".block 16" ".org .+16" ".=.+16" ".space 16"
+ for i in ".skip 4" ".block 4" ".org .+4" ".=.+4" ".space 4" "$skipcode_arch"
do
AC_TRY_RUN(
-[int foo(int,int,int);
-main()
-{
- exit(foo(0,0,0)!=16);
-}
+[#include <stdio.h>
+#include <stdlib.h>
int foo(int x, int y, int z)
{
- static void *labels[]={&&label1, &&label2};
+ static void *labels[]={&&label1, &&label2, &&label3};
if (x) {
y++; /* workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12108 */
- label1:
- asm("$i"); /* or ".space 16" or somesuch */
- label2: ;
+ label1: asm("$i"); /* or ".space 4" or somesuch */
+ label2: asm("$i"); /* or ".space 4" or somesuch */
+ label3: ; /* workaround clang */
}
{
if (y) goto *labels[z]; /* workaround for gcc PR12108 */
return labels[1]-labels[0];
}
+}
+int main(int argc, char ** argv, char ** env)
+{
+ int skip=foo(0,0,0);
+ if(skip<4) {
+ char cmd[80];
+ snprintf(cmd, sizeof(cmd), "objdump -zl --disassemble=foo %s", argv[0]);
+ system(cmd);
+ }
+ return skip<4;
}]
,skipcode=$i; break
,,)
|