GPR#226: select higher levels of optimization for GCC and Clang when
compiling the run-time system and C stub code. Also: select "gnu99" mode (= ISO C99 + GNU extensions). Also: gcc/clang warnings are errors when in development mode. (Turned off for release builds.) Also: clean up and modernize the autoconf tests in config/auto-aux (Merge of branch 'cc-optim'.) git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16379 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
commit
d55c7c8e9a
2
Changes
2
Changes
|
@ -61,6 +61,8 @@ Runtime system:
|
||||||
which is still open (Alain Frisch, review by Damien Doligez)
|
which is still open (Alain Frisch, review by Damien Doligez)
|
||||||
- Signal handling: for read-and-clear, use GCC/Clang atomic builtins
|
- Signal handling: for read-and-clear, use GCC/Clang atomic builtins
|
||||||
if available. (Xavier Leroy)
|
if available. (Xavier Leroy)
|
||||||
|
- GPR#226: select higher levels of optimization for GCC and Clang when
|
||||||
|
compiling the run-time system and C stub code. (Xavier Leroy)
|
||||||
|
|
||||||
Standard library:
|
Standard library:
|
||||||
- PR#6316: Scanf.scanf failure on %u formats when reading big integers
|
- PR#6316: Scanf.scanf failure on %u formats when reading big integers
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -471,6 +471,7 @@ utils/config.ml: utils/config.mlp config/Makefile
|
||||||
-e 's|%%CCOMPTYPE%%|cc|' \
|
-e 's|%%CCOMPTYPE%%|cc|' \
|
||||||
-e 's|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS)|' \
|
-e 's|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS)|' \
|
||||||
-e 's|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|' \
|
-e 's|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|' \
|
||||||
|
-e '/c_compiler =/s| -Werror||' \
|
||||||
-e 's|%%PACKLD%%|$(PACKLD)|' \
|
-e 's|%%PACKLD%%|$(PACKLD)|' \
|
||||||
-e 's|%%BYTECCLIBS%%|$(BYTECCLIBS)|' \
|
-e 's|%%BYTECCLIBS%%|$(BYTECCLIBS)|' \
|
||||||
-e 's|%%NATIVECCLIBS%%|$(NATIVECCLIBS)|' \
|
-e 's|%%NATIVECCLIBS%%|$(NATIVECCLIBS)|' \
|
||||||
|
|
|
@ -18,8 +18,8 @@ FLAGS=-I../byterun -DCAML_NAME_SPACE -DNATIVE_CODE \
|
||||||
-DTARGET_$(ARCH) -DMODEL_$(MODEL) -DSYS_$(SYSTEM) $(IFLEXDIR)
|
-DTARGET_$(ARCH) -DMODEL_$(MODEL) -DSYS_$(SYSTEM) $(IFLEXDIR)
|
||||||
CFLAGS=$(FLAGS) $(NATIVECCCOMPOPTS)
|
CFLAGS=$(FLAGS) $(NATIVECCCOMPOPTS)
|
||||||
DFLAGS=$(FLAGS) -g -DDEBUG $(NATIVECCCOMPOPTS)
|
DFLAGS=$(FLAGS) -g -DDEBUG $(NATIVECCCOMPOPTS)
|
||||||
PFLAGS=$(FLAGS) -pg -O -DPROFILING $(NATIVECCPROFOPTS)
|
PFLAGS=$(FLAGS) -pg -DPROFILING $(NATIVECCPROFOPTS) $(NATIVECCCOMPOPTS)
|
||||||
PICFLAGS=$(FLAGS) -O $(SHAREDCCCOMPOPTS) $(NATIVECCCOMPOPTS)
|
PICFLAGS=$(FLAGS) $(SHAREDCCCOMPOPTS) $(NATIVECCCOMPOPTS)
|
||||||
|
|
||||||
COBJS=startup_aux.o startup.o \
|
COBJS=startup_aux.o startup.o \
|
||||||
main.o fail.o roots.o globroots.o signals.o signals_asm.o \
|
main.o fail.o roots.o globroots.o signals.o signals_asm.o \
|
||||||
|
|
|
@ -14,8 +14,12 @@
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
|
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
return 2;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
/***********************************************************************/
|
|
||||||
/* */
|
|
||||||
/* OCaml */
|
|
||||||
/* */
|
|
||||||
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
||||||
/* */
|
|
||||||
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
|
||||||
/* en Automatique. All rights reserved. This file is distributed */
|
|
||||||
/* under the terms of the GNU Library General Public License, with */
|
|
||||||
/* the special exception on linking described in file ../../LICENSE. */
|
|
||||||
/* */
|
|
||||||
/***********************************************************************/
|
|
||||||
|
|
||||||
char buffer[27];
|
|
||||||
|
|
||||||
#ifdef reverse
|
|
||||||
#define cpy(s1,s2,n) copy(s2,s1,n)
|
|
||||||
#else
|
|
||||||
#define cpy copy
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
|
||||||
{
|
|
||||||
cpy("abcdefghijklmnopqrstuvwxyz", buffer, 27);
|
|
||||||
if (strcmp(buffer, "abcdefghijklmnopqrstuvwxyz") != 0) exit(1);
|
|
||||||
cpy(buffer, buffer+3, 26-3);
|
|
||||||
if (strcmp(buffer, "abcabcdefghijklmnopqrstuvw") != 0) exit(1);
|
|
||||||
cpy("abcdefghijklmnopqrstuvwxyz", buffer, 27);
|
|
||||||
cpy(buffer+3, buffer, 26-3);
|
|
||||||
if (strcmp(buffer, "defghijklmnopqrstuvwxyzxyz") != 0) exit(1);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
|
@ -2,23 +2,27 @@
|
||||||
/* */
|
/* */
|
||||||
/* OCaml */
|
/* OCaml */
|
||||||
/* */
|
/* */
|
||||||
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
/* Xavier Leroy, projet Gallium, INRIA Rocquencourt */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright 2011 Institut National de Recherche en Informatique et */
|
/* Copyright 2015 Institut National de Recherche en Informatique et */
|
||||||
/* en Automatique. All rights reserved. This file is distributed */
|
/* en Automatique. All rights reserved. This file is distributed */
|
||||||
/* under the terms of the GNU Library General Public License, with */
|
/* under the terms of the GNU Library General Public License, with */
|
||||||
/* the special exception on linking described in file ../../LICENSE. */
|
/* the special exception on linking described in file ../../LICENSE. */
|
||||||
/* */
|
/* */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
#include <math.h>
|
/* Determine vendor and version of C compiler */
|
||||||
|
|
||||||
volatile double x;
|
/* This file is to be preprocessed and its output examined. */
|
||||||
|
/* It is not C source code to be executed. */
|
||||||
|
/* This helps with cross-compilation. */
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
#if defined(__INTEL_COMPILER)
|
||||||
{
|
icc __INTEL_COMPILER
|
||||||
x = 3.1415;
|
#elif defined(__clang_major__) && defined(__clang_minor__)
|
||||||
x = expm1(x);
|
clang __clang_major __clang_minor__
|
||||||
x = log1p(x);
|
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||||
return 0;
|
gcc __GNUC__ __GNUC_MINOR__
|
||||||
}
|
#else
|
||||||
|
unknown
|
||||||
|
#endif
|
|
@ -15,9 +15,9 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
double foo;
|
volatile double foo;
|
||||||
|
|
||||||
void access_double(double *p)
|
void access_double(volatile double *p)
|
||||||
{
|
{
|
||||||
foo = *p;
|
foo = *p;
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ int main(void)
|
||||||
signal(SIGBUS, sig_handler);
|
signal(SIGBUS, sig_handler);
|
||||||
#endif
|
#endif
|
||||||
if(setjmp(failure) == 0) {
|
if(setjmp(failure) == 0) {
|
||||||
access_double((double *) n);
|
access_double((volatile double *) n);
|
||||||
access_double((double *) (n+1));
|
access_double((volatile double *) (n+1));
|
||||||
res = 0;
|
res = 0;
|
||||||
} else {
|
} else {
|
||||||
res = 1;
|
res = 1;
|
||||||
|
@ -48,5 +48,5 @@ int main(void)
|
||||||
#ifdef SIGBUS
|
#ifdef SIGBUS
|
||||||
signal(SIGBUS, SIG_DFL);
|
signal(SIGBUS, SIG_DFL);
|
||||||
#endif
|
#endif
|
||||||
exit(res);
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
/***********************************************************************/
|
|
||||||
/* */
|
|
||||||
/* OCaml */
|
|
||||||
/* */
|
|
||||||
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
||||||
/* */
|
|
||||||
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
|
||||||
/* en Automatique. All rights reserved. This file is distributed */
|
|
||||||
/* under the terms of the GNU Library General Public License, with */
|
|
||||||
/* the special exception on linking described in file ../../LICENSE. */
|
|
||||||
/* */
|
|
||||||
/***********************************************************************/
|
|
||||||
|
|
||||||
/* Test semantics of division and modulus for negative arguments */
|
|
||||||
|
|
||||||
long div4[] =
|
|
||||||
{ -4,-3,-3,-3,-3,-2,-2,-2,-2,-1,-1,-1,-1,0,0,0,
|
|
||||||
0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4 };
|
|
||||||
|
|
||||||
long divm4[] =
|
|
||||||
{ 4,3,3,3,3,2,2,2,2,1,1,1,1,0,0,0,
|
|
||||||
0,0,0,0,-1,-1,-1,-1,-2,-2,-2,-2,-3,-3,-3,-3,-4 };
|
|
||||||
|
|
||||||
long mod4[] =
|
|
||||||
{ 0,-3,-2,-1,0,-3,-2,-1,0,-3,-2,-1,0,-3,-2,-1,
|
|
||||||
0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0 };
|
|
||||||
|
|
||||||
long modm4[] =
|
|
||||||
{ 0,-3,-2,-1,0,-3,-2,-1,0,-3,-2,-1,0,-3,-2,-1,
|
|
||||||
0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0 };
|
|
||||||
|
|
||||||
long q1 = 4;
|
|
||||||
long q2 = -4;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = -16; i <= 16; i++) {
|
|
||||||
if (i / q1 != div4[i+16]) return 1;
|
|
||||||
if (i / q2 != divm4[i+16]) return 1;
|
|
||||||
if (i % q1 != mod4[i+16]) return 1;
|
|
||||||
if (i % q2 != modm4[i+16]) return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -11,6 +11,7 @@
|
||||||
/* */
|
/* */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include "m.h"
|
#include "m.h"
|
||||||
|
|
||||||
#ifndef ARCH_SIXTYFOUR
|
#ifndef ARCH_SIXTYFOUR
|
||||||
|
@ -23,7 +24,7 @@ char * bigendian = "ABCDEFGH";
|
||||||
char * littleendian = "HGFEDCBA";
|
char * littleendian = "HGFEDCBA";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
long n[2];
|
long n[2];
|
||||||
char * p;
|
char * p;
|
||||||
|
@ -32,8 +33,8 @@ main(void)
|
||||||
n[1] = 0;
|
n[1] = 0;
|
||||||
p = (char *) n;
|
p = (char *) n;
|
||||||
if (strcmp(p, bigendian) == 0)
|
if (strcmp(p, bigendian) == 0)
|
||||||
exit(0);
|
return 0;
|
||||||
if (strcmp(p, littleendian) == 0)
|
if (strcmp(p, littleendian) == 0)
|
||||||
exit(1);
|
return 1;
|
||||||
exit(2);
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,9 @@ while : ; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
(echo "main() {"
|
(echo "int main() {"
|
||||||
for f in $*; do echo " $f();"; done
|
for f in $*; do echo " $f();"; done
|
||||||
echo "}") >> hasgot.c
|
echo " return 0; }") >> hasgot.c
|
||||||
|
|
||||||
if test "$verbose" = yes; then
|
if test "$verbose" = yes; then
|
||||||
echo "hasgot $args: $cc $opts -o tst hasgot.c $libs" >&2
|
echo "hasgot $args: $cc $opts -o tst hasgot.c $libs" >&2
|
||||||
|
|
|
@ -30,9 +30,9 @@ while : ; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
(echo "main() {"
|
(echo "int main() {"
|
||||||
for f in $*; do echo " (void) & $f;"; done
|
for f in $*; do echo " (void) & $f;"; done
|
||||||
echo "}") >> hasgot.c
|
echo " return 0; }") >> hasgot.c
|
||||||
|
|
||||||
if test "$verbose" = yes; then
|
if test "$verbose" = yes; then
|
||||||
echo "hasgot2 $args: $cc $opts -o tst hasgot.c $libs" >&2
|
echo "hasgot2 $args: $cc $opts -o tst hasgot.c $libs" >&2
|
||||||
|
|
|
@ -26,9 +26,9 @@ typedef long long int64_t;
|
||||||
#error "No 64-bit integer type available"
|
#error "No 64-bit integer type available"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int64_t foo;
|
volatile int64_t foo;
|
||||||
|
|
||||||
void access_int64(int64_t *p)
|
void access_int64(volatile int64_t *p)
|
||||||
{
|
{
|
||||||
foo = *p;
|
foo = *p;
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ int main(void)
|
||||||
signal(SIGBUS, sig_handler);
|
signal(SIGBUS, sig_handler);
|
||||||
#endif
|
#endif
|
||||||
if(setjmp(failure) == 0) {
|
if(setjmp(failure) == 0) {
|
||||||
access_int64((int64_t *) n);
|
access_int64((volatile int64_t *) n);
|
||||||
access_int64((int64_t *) (n+1));
|
access_int64((volatile int64_t *) (n+1));
|
||||||
res = 0;
|
res = 0;
|
||||||
} else {
|
} else {
|
||||||
res = 1;
|
res = 1;
|
||||||
|
@ -59,5 +59,5 @@ int main(void)
|
||||||
#ifdef SIGBUS
|
#ifdef SIGBUS
|
||||||
signal(SIGBUS, SIG_DFL);
|
signal(SIGBUS, SIG_DFL);
|
||||||
#endif
|
#endif
|
||||||
exit(res);
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
/***********************************************************************/
|
|
||||||
/* */
|
|
||||||
/* OCaml */
|
|
||||||
/* */
|
|
||||||
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
||||||
/* */
|
|
||||||
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
|
||||||
/* en Automatique. All rights reserved. This file is distributed */
|
|
||||||
/* under the terms of the GNU Library General Public License, with */
|
|
||||||
/* the special exception on linking described in file ../../LICENSE. */
|
|
||||||
/* */
|
|
||||||
/***********************************************************************/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/* Check for the availability of "long long" type as per ISO C9X */
|
|
||||||
|
|
||||||
/* Meaning of return code:
|
|
||||||
0 long long OK, printf with %ll
|
|
||||||
1 long long OK, printf with %q
|
|
||||||
2 long long OK, no printf
|
|
||||||
3 long long not suitable */
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
long long l;
|
|
||||||
unsigned long long u;
|
|
||||||
char buffer[64];
|
|
||||||
|
|
||||||
if (sizeof(long long) != 8) return 3;
|
|
||||||
l = 123456789123456789LL;
|
|
||||||
buffer[0] = '\0';
|
|
||||||
sprintf(buffer, "%lld", l);
|
|
||||||
if (strcmp(buffer, "123456789123456789") == 0) return 0;
|
|
||||||
/* the MacOS X library uses qd to format long longs */
|
|
||||||
buffer[0] = '\0';
|
|
||||||
sprintf (buffer, "%qd", l);
|
|
||||||
if (strcmp (buffer, "123456789123456789") == 0) return 1;
|
|
||||||
return 2;
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
/***********************************************************************/
|
|
||||||
/* */
|
|
||||||
/* OCaml */
|
|
||||||
/* */
|
|
||||||
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
||||||
/* */
|
|
||||||
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
|
||||||
/* en Automatique. All rights reserved. This file is distributed */
|
|
||||||
/* under the terms of the GNU Library General Public License, with */
|
|
||||||
/* the special exception on linking described in file ../../LICENSE. */
|
|
||||||
/* */
|
|
||||||
/***********************************************************************/
|
|
||||||
|
|
||||||
char foo[]="\377";
|
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
i = foo[0];
|
|
||||||
exit(i != -1);
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
/***********************************************************************/
|
|
||||||
/* */
|
|
||||||
/* OCaml */
|
|
||||||
/* */
|
|
||||||
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
||||||
/* */
|
|
||||||
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
|
||||||
/* en Automatique. All rights reserved. This file is distributed */
|
|
||||||
/* under the terms of the GNU Library General Public License, with */
|
|
||||||
/* the special exception on linking described in file ../../LICENSE. */
|
|
||||||
/* */
|
|
||||||
/***********************************************************************/
|
|
||||||
|
|
||||||
signed char foo[]="\377";
|
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
i = foo[0];
|
|
||||||
exit(i != -1);
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
/***********************************************************************/
|
|
||||||
/* */
|
|
||||||
/* OCaml */
|
|
||||||
/* */
|
|
||||||
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
||||||
/* */
|
|
||||||
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
|
||||||
/* en Automatique. All rights reserved. This file is distributed */
|
|
||||||
/* under the terms of the GNU Library General Public License, with */
|
|
||||||
/* the special exception on linking described in file ../../LICENSE. */
|
|
||||||
/* */
|
|
||||||
/***********************************************************************/
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
SIGRETURN (*old)();
|
|
||||||
old = signal(SIGQUIT, SIG_DFL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -16,7 +16,10 @@
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
printf("%d %d %d %d %d\n",
|
printf("%d %d %d %d %d\n",
|
||||||
sizeof(int), sizeof(long), sizeof(long *), sizeof(short),
|
(int) sizeof(int),
|
||||||
sizeof(long long));
|
(int) sizeof(long),
|
||||||
|
(int) sizeof(long *),
|
||||||
|
(int) sizeof(short),
|
||||||
|
(int) sizeof(long long));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
/***********************************************************************/
|
|
||||||
/* */
|
|
||||||
/* OCaml */
|
|
||||||
/* */
|
|
||||||
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
||||||
/* */
|
|
||||||
/* Copyright 2001 Institut National de Recherche en Informatique et */
|
|
||||||
/* en Automatique. All rights reserved. This file is distributed */
|
|
||||||
/* under the terms of the GNU Library General Public License, with */
|
|
||||||
/* the special exception on linking described in file ../../LICENSE. */
|
|
||||||
/* */
|
|
||||||
/***********************************************************************/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
|
|
||||||
static char sig_alt_stack[SIGSTKSZ];
|
|
||||||
static char * system_stack_top;
|
|
||||||
|
|
||||||
#if defined(TARGET_i386) && defined(SYS_linux_elf)
|
|
||||||
static void segv_handler(int signo, struct sigcontext sc)
|
|
||||||
{
|
|
||||||
char * fault_addr = (char *) sc.cr2;
|
|
||||||
#else
|
|
||||||
static void segv_handler(int signo, siginfo_t * info, void * context)
|
|
||||||
{
|
|
||||||
char * fault_addr = (char *) info->si_addr;
|
|
||||||
#endif
|
|
||||||
struct rlimit limit;
|
|
||||||
|
|
||||||
if (getrlimit(RLIMIT_STACK, &limit) == 0 &&
|
|
||||||
((long) fault_addr & (sizeof(long) - 1)) == 0 &&
|
|
||||||
fault_addr < system_stack_top &&
|
|
||||||
fault_addr >= system_stack_top - limit.rlim_cur - 0x2000) {
|
|
||||||
_exit(0);
|
|
||||||
} else {
|
|
||||||
_exit(4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
|
||||||
{
|
|
||||||
stack_t stk;
|
|
||||||
struct sigaction act;
|
|
||||||
|
|
||||||
stk.ss_sp = sig_alt_stack;
|
|
||||||
stk.ss_size = SIGSTKSZ;
|
|
||||||
stk.ss_flags = 0;
|
|
||||||
#if defined(TARGET_i386) && defined(SYS_linux_elf)
|
|
||||||
act.sa_handler = (void (*)(int)) segv_handler;
|
|
||||||
act.sa_flags = SA_ONSTACK | SA_NODEFER;
|
|
||||||
#else
|
|
||||||
act.sa_sigaction = segv_handler;
|
|
||||||
act.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_NODEFER;
|
|
||||||
#endif
|
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
system_stack_top = (char *) &act;
|
|
||||||
if (sigaltstack(&stk, NULL) != 0) { perror("sigaltstack"); return 2; }
|
|
||||||
if (sigaction(SIGSEGV, &act, NULL) != 0) { perror("sigaction"); return 2; }
|
|
||||||
/* We used to trigger a stack overflow at this point to test whether
|
|
||||||
the code above works, but this causes problems with POSIX threads
|
|
||||||
on some BSD systems. So, instead, we just test that all this
|
|
||||||
code compiles, indicating that the required syscalls are there. */
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -13,7 +13,8 @@
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
echo Configuring OCaml version `head -1 VERSION`
|
ocamlversion=`head -1 VERSION`
|
||||||
|
echo "Configuring OCaml version $ocamlversion"
|
||||||
|
|
||||||
configure_options="$*"
|
configure_options="$*"
|
||||||
prefix=/usr/local
|
prefix=/usr/local
|
||||||
|
@ -40,7 +41,6 @@ verbose=no
|
||||||
with_curses=yes
|
with_curses=yes
|
||||||
debugruntime=noruntimed
|
debugruntime=noruntimed
|
||||||
with_sharedlibs=yes
|
with_sharedlibs=yes
|
||||||
gcc_warnings="-Wall"
|
|
||||||
partialld="ld -r"
|
partialld="ld -r"
|
||||||
with_debugger=ocamldebugger
|
with_debugger=ocamldebugger
|
||||||
with_ocamldoc=ocamldoc
|
with_ocamldoc=ocamldoc
|
||||||
|
@ -267,50 +267,13 @@ fi
|
||||||
|
|
||||||
inf "Using compiler $cc."
|
inf "Using compiler $cc."
|
||||||
|
|
||||||
# Check for buggy versions of GCC
|
# Determine the C compiler family (GCC, Clang, etc)
|
||||||
# These checks are not done for cross-compilation (yet at least) because after
|
|
||||||
# 15 years, I doubt someone will try to use an experimental (2.96) or
|
|
||||||
# known-unstable (2.7.2.1) version for cross-compilation.
|
|
||||||
|
|
||||||
buggycc="no"
|
ccfamily=`$cc -E cckind.c | grep '^[a-z]' | tr -s ' ' '-'`
|
||||||
|
case $? in
|
||||||
case "$target,$cc" in
|
0) inf "Compiler family and version: $ccfamily.";;
|
||||||
i[3456]86-*-*,gcc*)
|
*) err "Unable to preprocess the test program.\n" \
|
||||||
case `$cc --version` in
|
"Make sure the C compiler $cc is properly installed.";;
|
||||||
2.7.2.1) cat <<'EOF'
|
|
||||||
|
|
||||||
WARNING: you are using gcc version 2.7.2.1 on an Intel x86 processor.
|
|
||||||
This version of gcc is known to generate incorrect code for the
|
|
||||||
OCaml runtime system on some Intel x86 machines. (The symptom
|
|
||||||
is a crash of boot/ocamlc when compiling stdlib/pervasives.mli.)
|
|
||||||
In particular, the version of gcc 2.7.2.1 that comes with
|
|
||||||
Linux RedHat 4.x / Intel is affected by this problem.
|
|
||||||
Other Linux distributions might also be affected.
|
|
||||||
If you are using one of these configurations, you are strongly advised
|
|
||||||
to use another version of gcc, such as 2.95, which are
|
|
||||||
known to work well with OCaml.
|
|
||||||
|
|
||||||
Press <enter> to proceed or <interrupt> to stop.
|
|
||||||
EOF
|
|
||||||
read reply;;
|
|
||||||
2.96*) cat <<'EOF'
|
|
||||||
|
|
||||||
WARNING: you are using gcc version 2.96 on an Intel x86 processor.
|
|
||||||
Certain patched versions of gcc 2.96 are known to generate incorrect
|
|
||||||
code for the OCaml runtime system. (The symptom is a segmentation
|
|
||||||
violation on boot/ocamlc.) Those incorrectly patched versions can be found
|
|
||||||
in RedHat 7.2 and Mandrake 8.0 and 8.1; other Linux distributions
|
|
||||||
might also be affected. (See bug #57760 on bugzilla.redhat.com)
|
|
||||||
|
|
||||||
Auto-configuration will now select gcc compiler flags that work around
|
|
||||||
the problem. Still, if you observe segmentation faults while running
|
|
||||||
ocamlc or ocamlopt, you are advised to try another version of gcc,
|
|
||||||
such as 2.95.3 or 3.2.
|
|
||||||
|
|
||||||
EOF
|
|
||||||
buggycc="gcc.2.96";;
|
|
||||||
|
|
||||||
esac;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Configure the bytecode compiler
|
# Configure the bytecode compiler
|
||||||
|
@ -327,17 +290,49 @@ iflexdir=""
|
||||||
SO="so"
|
SO="so"
|
||||||
TOOLCHAIN="cc"
|
TOOLCHAIN="cc"
|
||||||
|
|
||||||
|
# Choose reasonable options based on compiler kind
|
||||||
|
# We select high optimization levels, provided we can turn off:
|
||||||
|
# - strict type-based aliasing analysis (too risky for the OCaml runtime)
|
||||||
|
# - strict no-overflow conditions on signed integer arithmetic
|
||||||
|
# (the OCaml runtime assumes Java-style behavior of signed integer arith.)
|
||||||
|
# Concerning optimization level, -O3 is somewhat risky, so take -O2
|
||||||
|
# Concerning language version, gnu99 is ISO C99 plus GNU extensions
|
||||||
|
# that are often used in standard headers. GCC defaults to gnu89,
|
||||||
|
# which is not C99. Clang defaults to gnu99 or gnu11, which is fine.
|
||||||
|
|
||||||
|
case "$ocamlversion" in
|
||||||
|
*+dev*) gcc_warnings="-Wall -Werror";;
|
||||||
|
*) gcc_warnings="-Wall";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$ccfamily" in
|
||||||
|
clang-*)
|
||||||
|
bytecccompopts="-O2 -fno-strict-aliasing -fwrapv $gcc_warnings";;
|
||||||
|
gcc-[012]-*)
|
||||||
|
# Some versions known to miscompile OCaml, e,g, 2.7,2.1, some 2.96.
|
||||||
|
# Plus: C99 support unknown.
|
||||||
|
err "This version of GCC is too old. Please use GCC version 3 or above.";;
|
||||||
|
gcc-3-[0123])
|
||||||
|
# No -fwrapv option yet
|
||||||
|
bytecccompopts="-std=gnu99 -O $gcc_warnings";;
|
||||||
|
gcc-*)
|
||||||
|
bytecccompopts="-std=gnu99 -O2 -fno-strict-aliasing -fwrapv $gcc_warnings";;
|
||||||
|
*)
|
||||||
|
bytecccompopts="-O";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Adjust according to target
|
||||||
|
|
||||||
case "$bytecc,$target" in
|
case "$bytecc,$target" in
|
||||||
cc,*-*-nextstep*)
|
cc,*-*-nextstep*)
|
||||||
# GNU C extensions disabled, but __GNUC__ still defined!
|
# GNU C extensions disabled, but __GNUC__ still defined!
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings -U__GNUC__ -posix"
|
bytecccompopts="$bytecccompopts -U__GNUC__ -posix"
|
||||||
bytecclinkopts="-posix";;
|
bytecclinkopts="-posix";;
|
||||||
*,*-*-rhapsody*)
|
*,*-*-rhapsody*)
|
||||||
# Almost the same as NeXTStep
|
# Almost the same as NeXTStep
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
|
bytecccompopts="$bytecccompopts -DSHRINKED_GNUC"
|
||||||
mathlib="";;
|
mathlib="";;
|
||||||
*,*-*-darwin*)
|
*,*-*-darwin*)
|
||||||
bytecccompopts="$gcc_warnings"
|
|
||||||
mathlib=""
|
mathlib=""
|
||||||
mkexe="$mkexe -Wl,-no_compact_unwind"
|
mkexe="$mkexe -Wl,-no_compact_unwind"
|
||||||
# Tell gcc that we can use 32-bit code addresses for threaded code
|
# Tell gcc that we can use 32-bit code addresses for threaded code
|
||||||
|
@ -346,15 +341,12 @@ case "$bytecc,$target" in
|
||||||
echo "# define ARCH_CODE32" >> m.h
|
echo "# define ARCH_CODE32" >> m.h
|
||||||
echo "#endif" >> m.h;;
|
echo "#endif" >> m.h;;
|
||||||
*,*-*-haiku*)
|
*,*-*-haiku*)
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings"
|
|
||||||
# No -lm library
|
# No -lm library
|
||||||
mathlib="";;
|
mathlib="";;
|
||||||
*,*-*-beos*)
|
*,*-*-beos*)
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings"
|
|
||||||
# No -lm library
|
# No -lm library
|
||||||
mathlib="";;
|
mathlib="";;
|
||||||
*gcc,alpha*-*-osf*)
|
*gcc,alpha*-*-osf*)
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings"
|
|
||||||
if cc="$bytecc" sh ./hasgot -mieee; then
|
if cc="$bytecc" sh ./hasgot -mieee; then
|
||||||
bytecccompopts="-mieee $bytecccompopts";
|
bytecccompopts="-mieee $bytecccompopts";
|
||||||
fi
|
fi
|
||||||
|
@ -368,30 +360,22 @@ case "$bytecc,$target" in
|
||||||
if cc="$bytecc" sh ./hasgot -mieee; then
|
if cc="$bytecc" sh ./hasgot -mieee; then
|
||||||
bytecccompopts="-mieee $bytecccompopts";
|
bytecccompopts="-mieee $bytecccompopts";
|
||||||
fi;;
|
fi;;
|
||||||
cc,mips-*-irix6*)
|
*,mips-*-irix6*)
|
||||||
# Add -n32 flag to ensure compatibility with native-code compiler
|
|
||||||
bytecccompopts="-n32"
|
|
||||||
# Turn off warning "unused library"
|
# Turn off warning "unused library"
|
||||||
bytecclinkopts="-n32 -Wl,-woff,84";;
|
bytecclinkopts="-n32 -Wl,-woff,84";;
|
||||||
cc*,mips-*-irix6*)
|
|
||||||
# (For those who want to force "cc -64")
|
|
||||||
# Turn off warning "unused library"
|
|
||||||
bytecclinkopts="-Wl,-woff,84";;
|
|
||||||
*,alpha*-*-unicos*)
|
*,alpha*-*-unicos*)
|
||||||
# For the Cray T3E
|
# For the Cray T3E
|
||||||
bytecccompopts="-DUMK";;
|
bytecccompopts="$bytecccompopts -DUMK";;
|
||||||
*gcc*,powerpc-*-aix*)
|
|
||||||
# Avoid name-space pollution by requiring Unix98-conformant includes
|
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings -D_XOPEN_SOURCE=500";;
|
|
||||||
*,powerpc-*-aix*)
|
*,powerpc-*-aix*)
|
||||||
bytecccompopts="-D_XOPEN_SOURCE=500";;
|
# Avoid name-space pollution by requiring Unix98-conformant includes
|
||||||
*gcc*,*-*-cygwin*)
|
bytecccompopts="$bytecccompopts -D_XOPEN_SOURCE=500";;
|
||||||
|
*,*-*-cygwin*)
|
||||||
case $target in
|
case $target in
|
||||||
i686-*) flavor=cygwin;;
|
i686-*) flavor=cygwin;;
|
||||||
x86_64-*) flavor=cygwin64;;
|
x86_64-*) flavor=cygwin64;;
|
||||||
*) err "unknown cygwin variant";;
|
*) err "unknown cygwin variant";;
|
||||||
esac
|
esac
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings -U_WIN32"
|
bytecccompopts="$bytecccompopts -U_WIN32"
|
||||||
dllccompopts="-U_WIN32 -DCAML_DLL"
|
dllccompopts="-U_WIN32 -DCAML_DLL"
|
||||||
if test $with_sharedlibs = yes; then
|
if test $with_sharedlibs = yes; then
|
||||||
flexlink="flexlink -chain $flavor -merge-manifest -stack 16777216"
|
flexlink="flexlink -chain $flavor -merge-manifest -stack 16777216"
|
||||||
|
@ -411,8 +395,7 @@ case "$bytecc,$target" in
|
||||||
fi
|
fi
|
||||||
exe=".exe"
|
exe=".exe"
|
||||||
ostype="Cygwin";;
|
ostype="Cygwin";;
|
||||||
*gcc*,*-*-mingw*)
|
*,*-*-mingw*)
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings"
|
|
||||||
dllccompopt="-DCAML_DLL"
|
dllccompopt="-DCAML_DLL"
|
||||||
if test $with_sharedlibs = yes; then
|
if test $with_sharedlibs = yes; then
|
||||||
case "$target" in
|
case "$target" in
|
||||||
|
@ -435,34 +418,32 @@ case "$bytecc,$target" in
|
||||||
TOOLCHAIN="mingw"
|
TOOLCHAIN="mingw"
|
||||||
SO="dll"
|
SO="dll"
|
||||||
;;
|
;;
|
||||||
*gcc*,x86_64-*-linux*)
|
*,x86_64-*-linux*)
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings"
|
|
||||||
# Tell gcc that we can use 32-bit code addresses for threaded code
|
# Tell gcc that we can use 32-bit code addresses for threaded code
|
||||||
# unless we are compiled for a shared library (-fPIC option)
|
# unless we are compiled for a shared library (-fPIC option)
|
||||||
echo "#ifndef __PIC__" >> m.h
|
echo "#ifndef __PIC__" >> m.h
|
||||||
echo "# define ARCH_CODE32" >> m.h
|
echo "# define ARCH_CODE32" >> m.h
|
||||||
echo "#endif" >> m.h;;
|
echo "#endif" >> m.h;;
|
||||||
*gcc*)
|
|
||||||
bytecccompopts="-fno-defer-pop $gcc_warnings";;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Configure compiler to use in further tests
|
# Configure compiler to use in further tests.
|
||||||
|
|
||||||
cc="$bytecc -O $bytecclinkopts"
|
cc="$bytecc $bytecclinkopts"
|
||||||
export cc cclibs verbose
|
export cc cclibs verbose
|
||||||
|
|
||||||
# Check C compiler
|
# Check C compiler.
|
||||||
|
|
||||||
sh ./runtest ansi.c
|
cc="$bytecc $bytecccompopts $bytecclinkopts" sh ./runtest ansi.c
|
||||||
case $? in
|
case $? in
|
||||||
0) inf "The C compiler is ANSI-compliant." ;;
|
0) inf "The C compiler is ISO C99 compliant." ;;
|
||||||
1) err "The C compiler $cc is not ANSI-compliant.\n" \
|
1) wrn "The C compiler is ANSI / ISO C90 compliant, but not ISO C99 compliant.";;
|
||||||
"You need an ANSI C compiler to build OCaml.";;
|
2) err "The C compiler $cc is not ISO C compliant.\n" \
|
||||||
|
"You need an ISO C99 compiler to build OCaml.";;
|
||||||
*)
|
*)
|
||||||
if $cross_compiler; then
|
if $cross_compiler; then
|
||||||
wrn "Unable to compile the test program.\n" \
|
wrn "Unable to compile the test program.\n" \
|
||||||
"This failure is expected for cross-compilation:\n" \
|
"This failure is expected for cross-compilation:\n" \
|
||||||
"we will assume the C compiler is ANSI-compliant."
|
"we will assume the C compiler is ISO C99-compliant."
|
||||||
else
|
else
|
||||||
err "Unable to compile the test program.\n" \
|
err "Unable to compile the test program.\n" \
|
||||||
"Make sure the C compiler $cc is properly installed."
|
"Make sure the C compiler $cc is properly installed."
|
||||||
|
@ -869,23 +850,16 @@ else
|
||||||
nativecc="$ccoption"
|
nativecc="$ccoption"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nativecccompopts=''
|
nativecccompopts="$bytecccompopts"
|
||||||
|
nativeccprofopts=''
|
||||||
nativecclinkopts=''
|
nativecclinkopts=''
|
||||||
# FIXME the naming of nativecclinkopts is broken: these are options for
|
# FIXME the naming of nativecclinkopts is broken: these are options for
|
||||||
# ld (for shared libs), not for cc
|
# ld (for shared libs), not for cc
|
||||||
nativeccrpath="$byteccrpath"
|
nativeccrpath="$byteccrpath"
|
||||||
|
|
||||||
case "$arch,$nativecc,$system,$target" in
|
case "$arch,$nativecc,$system,$target" in
|
||||||
*,*,nextstep,*) nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
|
*,*,nextstep,*) nativecclinkopts="-posix";;
|
||||||
nativecclinkopts="-posix";;
|
*,*,rhapsody,*) if $arch64; then partialld="ld -r -arch ppc64"; fi;;
|
||||||
*,*,rhapsody,*darwin[1-5].*)
|
|
||||||
nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";;
|
|
||||||
*,*,rhapsody,*) nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs";;
|
|
||||||
*,gcc*,cygwin,*) nativecccompopts="$gcc_warnings -U_WIN32";;
|
|
||||||
*,gcc*,*,*) nativecccompopts="$gcc_warnings";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$arch,$nativecc,$system,$model" in
|
|
||||||
amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
|
amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
|
||||||
amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
|
amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
|
||||||
power,gcc*,elf,ppc) partialld="ld -r -m elf32ppclinux";;
|
power,gcc*,elf,ppc) partialld="ld -r -m elf32ppclinux";;
|
||||||
|
@ -1692,21 +1666,6 @@ if $no_naked_pointers; then
|
||||||
echo "#define NO_NAKED_POINTERS" >> m.h
|
echo "#define NO_NAKED_POINTERS" >> m.h
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add Unix-style optimization flag
|
|
||||||
bytecccompopts="-O $bytecccompopts"
|
|
||||||
dllcccompopts="-O $dllcccompopts"
|
|
||||||
nativecccompopts="-O $nativecccompopts"
|
|
||||||
sharedcccompopts="-O $sharedcccompopts"
|
|
||||||
|
|
||||||
# Final twiddling of compiler options to work around known bugs
|
|
||||||
|
|
||||||
nativeccprofopts="$nativecccompopts"
|
|
||||||
case "$buggycc" in
|
|
||||||
gcc.2.96)
|
|
||||||
bytecccompopts="$bytecccompopts -fomit-frame-pointer"
|
|
||||||
nativecccompopts="$nativecccompopts -fomit-frame-pointer";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Finish generated files
|
# Finish generated files
|
||||||
|
|
||||||
cclibs="$cclibs $mathlib"
|
cclibs="$cclibs $mathlib"
|
||||||
|
|
Loading…
Reference in New Issue