diff --git a/Changes b/Changes index 2f1913113..5ffdad782 100644 --- a/Changes +++ b/Changes @@ -61,6 +61,8 @@ Runtime system: which is still open (Alain Frisch, review by Damien Doligez) - Signal handling: for read-and-clear, use GCC/Clang atomic builtins 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: - PR#6316: Scanf.scanf failure on %u formats when reading big integers diff --git a/Makefile b/Makefile index 19b4a2acc..6d13e171c 100644 --- a/Makefile +++ b/Makefile @@ -471,6 +471,7 @@ utils/config.ml: utils/config.mlp config/Makefile -e 's|%%CCOMPTYPE%%|cc|' \ -e 's|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS)|' \ -e 's|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|' \ + -e '/c_compiler =/s| -Werror||' \ -e 's|%%PACKLD%%|$(PACKLD)|' \ -e 's|%%BYTECCLIBS%%|$(BYTECCLIBS)|' \ -e 's|%%NATIVECCLIBS%%|$(NATIVECCLIBS)|' \ diff --git a/asmrun/Makefile b/asmrun/Makefile index e549edbd2..c70a4ed05 100644 --- a/asmrun/Makefile +++ b/asmrun/Makefile @@ -18,8 +18,8 @@ FLAGS=-I../byterun -DCAML_NAME_SPACE -DNATIVE_CODE \ -DTARGET_$(ARCH) -DMODEL_$(MODEL) -DSYS_$(SYSTEM) $(IFLEXDIR) CFLAGS=$(FLAGS) $(NATIVECCCOMPOPTS) DFLAGS=$(FLAGS) -g -DDEBUG $(NATIVECCCOMPOPTS) -PFLAGS=$(FLAGS) -pg -O -DPROFILING $(NATIVECCPROFOPTS) -PICFLAGS=$(FLAGS) -O $(SHAREDCCCOMPOPTS) $(NATIVECCCOMPOPTS) +PFLAGS=$(FLAGS) -pg -DPROFILING $(NATIVECCPROFOPTS) $(NATIVECCCOMPOPTS) +PICFLAGS=$(FLAGS) $(SHAREDCCCOMPOPTS) $(NATIVECCCOMPOPTS) COBJS=startup_aux.o startup.o \ main.o fail.o roots.o globroots.o signals.o signals_asm.o \ diff --git a/config/auto-aux/ansi.c b/config/auto-aux/ansi.c index 01d46252a..a68850974 100644 --- a/config/auto-aux/ansi.c +++ b/config/auto-aux/ansi.c @@ -14,8 +14,12 @@ int main() { #ifdef __STDC__ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L return 0; #else return 1; #endif +#else + return 2; +#endif } diff --git a/config/auto-aux/bytecopy.c b/config/auto-aux/bytecopy.c deleted file mode 100644 index 34f29c486..000000000 --- a/config/auto-aux/bytecopy.c +++ /dev/null @@ -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); -} diff --git a/config/auto-aux/expm1.c b/config/auto-aux/cckind.c similarity index 57% rename from config/auto-aux/expm1.c rename to config/auto-aux/cckind.c index 2cfbe7371..2385a53bc 100644 --- a/config/auto-aux/expm1.c +++ b/config/auto-aux/cckind.c @@ -2,23 +2,27 @@ /* */ /* 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 */ /* under the terms of the GNU Library General Public License, with */ /* the special exception on linking described in file ../../LICENSE. */ /* */ /***********************************************************************/ -#include +/* 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) -{ - x = 3.1415; - x = expm1(x); - x = log1p(x); - return 0; -} +#if defined(__INTEL_COMPILER) +icc __INTEL_COMPILER +#elif defined(__clang_major__) && defined(__clang_minor__) +clang __clang_major __clang_minor__ +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) +gcc __GNUC__ __GNUC_MINOR__ +#else +unknown +#endif diff --git a/config/auto-aux/dblalign.c b/config/auto-aux/dblalign.c index e86fb198e..f89c9b523 100644 --- a/config/auto-aux/dblalign.c +++ b/config/auto-aux/dblalign.c @@ -15,9 +15,9 @@ #include #include -double foo; +volatile double foo; -void access_double(double *p) +void access_double(volatile double *p) { foo = *p; } @@ -38,8 +38,8 @@ int main(void) signal(SIGBUS, sig_handler); #endif if(setjmp(failure) == 0) { - access_double((double *) n); - access_double((double *) (n+1)); + access_double((volatile double *) n); + access_double((volatile double *) (n+1)); res = 0; } else { res = 1; @@ -48,5 +48,5 @@ int main(void) #ifdef SIGBUS signal(SIGBUS, SIG_DFL); #endif - exit(res); + return res; } diff --git a/config/auto-aux/divmod.c b/config/auto-aux/divmod.c deleted file mode 100644 index e85e4b3fc..000000000 --- a/config/auto-aux/divmod.c +++ /dev/null @@ -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; -} diff --git a/config/auto-aux/endian.c b/config/auto-aux/endian.c index 91312f716..5dc623ab7 100644 --- a/config/auto-aux/endian.c +++ b/config/auto-aux/endian.c @@ -11,6 +11,7 @@ /* */ /***********************************************************************/ +#include #include "m.h" #ifndef ARCH_SIXTYFOUR @@ -23,7 +24,7 @@ char * bigendian = "ABCDEFGH"; char * littleendian = "HGFEDCBA"; #endif -main(void) +int main(void) { long n[2]; char * p; @@ -32,8 +33,8 @@ main(void) n[1] = 0; p = (char *) n; if (strcmp(p, bigendian) == 0) - exit(0); + return 0; if (strcmp(p, littleendian) == 0) - exit(1); - exit(2); + return 1; + return 2; } diff --git a/config/auto-aux/hasgot b/config/auto-aux/hasgot index 53d578660..384a2475b 100755 --- a/config/auto-aux/hasgot +++ b/config/auto-aux/hasgot @@ -30,9 +30,9 @@ while : ; do shift done -(echo "main() {" +(echo "int main() {" for f in $*; do echo " $f();"; done - echo "}") >> hasgot.c + echo " return 0; }") >> hasgot.c if test "$verbose" = yes; then echo "hasgot $args: $cc $opts -o tst hasgot.c $libs" >&2 diff --git a/config/auto-aux/hasgot2 b/config/auto-aux/hasgot2 index 0e9cef9b0..ab969c6a8 100644 --- a/config/auto-aux/hasgot2 +++ b/config/auto-aux/hasgot2 @@ -30,9 +30,9 @@ while : ; do shift done -(echo "main() {" +(echo "int main() {" for f in $*; do echo " (void) & $f;"; done - echo "}") >> hasgot.c + echo " return 0; }") >> hasgot.c if test "$verbose" = yes; then echo "hasgot2 $args: $cc $opts -o tst hasgot.c $libs" >&2 diff --git a/config/auto-aux/int64align.c b/config/auto-aux/int64align.c index c1439869f..d63d6f919 100644 --- a/config/auto-aux/int64align.c +++ b/config/auto-aux/int64align.c @@ -26,9 +26,9 @@ typedef long long int64_t; #error "No 64-bit integer type available" #endif -int64_t foo; +volatile int64_t foo; -void access_int64(int64_t *p) +void access_int64(volatile int64_t *p) { foo = *p; } @@ -49,8 +49,8 @@ int main(void) signal(SIGBUS, sig_handler); #endif if(setjmp(failure) == 0) { - access_int64((int64_t *) n); - access_int64((int64_t *) (n+1)); + access_int64((volatile int64_t *) n); + access_int64((volatile int64_t *) (n+1)); res = 0; } else { res = 1; @@ -59,5 +59,5 @@ int main(void) #ifdef SIGBUS signal(SIGBUS, SIG_DFL); #endif - exit(res); + return res; } diff --git a/config/auto-aux/longlong.c b/config/auto-aux/longlong.c deleted file mode 100644 index e18f9e28f..000000000 --- a/config/auto-aux/longlong.c +++ /dev/null @@ -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 -#include - -/* 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; -} diff --git a/config/auto-aux/schar.c b/config/auto-aux/schar.c deleted file mode 100644 index a9c355e51..000000000 --- a/config/auto-aux/schar.c +++ /dev/null @@ -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); -} diff --git a/config/auto-aux/schar2.c b/config/auto-aux/schar2.c deleted file mode 100644 index 9d18d2ac4..000000000 --- a/config/auto-aux/schar2.c +++ /dev/null @@ -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); -} diff --git a/config/auto-aux/sighandler.c b/config/auto-aux/sighandler.c deleted file mode 100644 index 3c341feae..000000000 --- a/config/auto-aux/sighandler.c +++ /dev/null @@ -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 - -int main(void) -{ - SIGRETURN (*old)(); - old = signal(SIGQUIT, SIG_DFL); - return 0; -} diff --git a/config/auto-aux/sizes.c b/config/auto-aux/sizes.c index daa9615d1..d756952f6 100644 --- a/config/auto-aux/sizes.c +++ b/config/auto-aux/sizes.c @@ -16,7 +16,10 @@ int main(int argc, char **argv) { printf("%d %d %d %d %d\n", - sizeof(int), sizeof(long), sizeof(long *), sizeof(short), - sizeof(long long)); + (int) sizeof(int), + (int) sizeof(long), + (int) sizeof(long *), + (int) sizeof(short), + (int) sizeof(long long)); return 0; } diff --git a/config/auto-aux/stackov.c b/config/auto-aux/stackov.c deleted file mode 100644 index 3e3181bd8..000000000 --- a/config/auto-aux/stackov.c +++ /dev/null @@ -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 -#include -#include - -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; -} diff --git a/configure b/configure index 0598d5e5f..2dcf38a7e 100755 --- a/configure +++ b/configure @@ -13,7 +13,8 @@ # # ######################################################################### -echo Configuring OCaml version `head -1 VERSION` +ocamlversion=`head -1 VERSION` +echo "Configuring OCaml version $ocamlversion" configure_options="$*" prefix=/usr/local @@ -40,7 +41,6 @@ verbose=no with_curses=yes debugruntime=noruntimed with_sharedlibs=yes -gcc_warnings="-Wall" partialld="ld -r" with_debugger=ocamldebugger with_ocamldoc=ocamldoc @@ -267,50 +267,13 @@ fi inf "Using compiler $cc." -# Check for buggy versions of GCC -# 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. +# Determine the C compiler family (GCC, Clang, etc) -buggycc="no" - -case "$target,$cc" in - i[3456]86-*-*,gcc*) - case `$cc --version` in - 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 to proceed or 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;; +ccfamily=`$cc -E cckind.c | grep '^[a-z]' | tr -s ' ' '-'` +case $? in + 0) inf "Compiler family and version: $ccfamily.";; + *) err "Unable to preprocess the test program.\n" \ + "Make sure the C compiler $cc is properly installed.";; esac # Configure the bytecode compiler @@ -327,17 +290,49 @@ iflexdir="" SO="so" 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 cc,*-*-nextstep*) # GNU C extensions disabled, but __GNUC__ still defined! - bytecccompopts="-fno-defer-pop $gcc_warnings -U__GNUC__ -posix" + bytecccompopts="$bytecccompopts -U__GNUC__ -posix" bytecclinkopts="-posix";; *,*-*-rhapsody*) # Almost the same as NeXTStep - bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC" + bytecccompopts="$bytecccompopts -DSHRINKED_GNUC" mathlib="";; *,*-*-darwin*) - bytecccompopts="$gcc_warnings" mathlib="" mkexe="$mkexe -Wl,-no_compact_unwind" # 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 "#endif" >> m.h;; *,*-*-haiku*) - bytecccompopts="-fno-defer-pop $gcc_warnings" # No -lm library mathlib="";; *,*-*-beos*) - bytecccompopts="-fno-defer-pop $gcc_warnings" # No -lm library mathlib="";; *gcc,alpha*-*-osf*) - bytecccompopts="-fno-defer-pop $gcc_warnings" if cc="$bytecc" sh ./hasgot -mieee; then bytecccompopts="-mieee $bytecccompopts"; fi @@ -368,30 +360,22 @@ case "$bytecc,$target" in if cc="$bytecc" sh ./hasgot -mieee; then bytecccompopts="-mieee $bytecccompopts"; fi;; - cc,mips-*-irix6*) - # Add -n32 flag to ensure compatibility with native-code compiler - bytecccompopts="-n32" + *,mips-*-irix6*) # Turn off warning "unused library" 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*) # For the Cray T3E - bytecccompopts="-DUMK";; - *gcc*,powerpc-*-aix*) - # Avoid name-space pollution by requiring Unix98-conformant includes - bytecccompopts="-fno-defer-pop $gcc_warnings -D_XOPEN_SOURCE=500";; + bytecccompopts="$bytecccompopts -DUMK";; *,powerpc-*-aix*) - bytecccompopts="-D_XOPEN_SOURCE=500";; - *gcc*,*-*-cygwin*) + # Avoid name-space pollution by requiring Unix98-conformant includes + bytecccompopts="$bytecccompopts -D_XOPEN_SOURCE=500";; + *,*-*-cygwin*) case $target in i686-*) flavor=cygwin;; x86_64-*) flavor=cygwin64;; *) err "unknown cygwin variant";; esac - bytecccompopts="-fno-defer-pop $gcc_warnings -U_WIN32" + bytecccompopts="$bytecccompopts -U_WIN32" dllccompopts="-U_WIN32 -DCAML_DLL" if test $with_sharedlibs = yes; then flexlink="flexlink -chain $flavor -merge-manifest -stack 16777216" @@ -411,8 +395,7 @@ case "$bytecc,$target" in fi exe=".exe" ostype="Cygwin";; - *gcc*,*-*-mingw*) - bytecccompopts="-fno-defer-pop $gcc_warnings" + *,*-*-mingw*) dllccompopt="-DCAML_DLL" if test $with_sharedlibs = yes; then case "$target" in @@ -435,34 +418,32 @@ case "$bytecc,$target" in TOOLCHAIN="mingw" SO="dll" ;; - *gcc*,x86_64-*-linux*) - bytecccompopts="-fno-defer-pop $gcc_warnings" + *,x86_64-*-linux*) # Tell gcc that we can use 32-bit code addresses for threaded code # unless we are compiled for a shared library (-fPIC option) echo "#ifndef __PIC__" >> m.h echo "# define ARCH_CODE32" >> m.h echo "#endif" >> m.h;; - *gcc*) - bytecccompopts="-fno-defer-pop $gcc_warnings";; 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 -# Check C compiler +# Check C compiler. -sh ./runtest ansi.c +cc="$bytecc $bytecccompopts $bytecclinkopts" sh ./runtest ansi.c case $? in - 0) inf "The C compiler is ANSI-compliant." ;; - 1) err "The C compiler $cc is not ANSI-compliant.\n" \ - "You need an ANSI C compiler to build OCaml.";; + 0) inf "The C compiler is ISO C99 compliant." ;; + 1) wrn "The C compiler is ANSI / ISO C90 compliant, but not ISO C99 compliant.";; + 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 wrn "Unable to compile the test program.\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 err "Unable to compile the test program.\n" \ "Make sure the C compiler $cc is properly installed." @@ -869,23 +850,16 @@ else nativecc="$ccoption" fi -nativecccompopts='' +nativecccompopts="$bytecccompopts" +nativeccprofopts='' nativecclinkopts='' # FIXME the naming of nativecclinkopts is broken: these are options for # ld (for shared libs), not for cc nativeccrpath="$byteccrpath" case "$arch,$nativecc,$system,$target" in - *,*,nextstep,*) nativecccompopts="$gcc_warnings -U__GNUC__ -posix" - nativecclinkopts="-posix";; - *,*,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 + *,*,nextstep,*) nativecclinkopts="-posix";; + *,*,rhapsody,*) if $arch64; then partialld="ld -r -arch ppc64"; fi;; amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";; amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";; 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 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 cclibs="$cclibs $mathlib"