Clarify and slightly modify the use of C compiler related make variables.
Before this commit, there was no distinction between the options used to compile C source files coming with the OCaml distribution and third-party C source files compiled by calling ocamlc or ocamlopt. This commit makes it possible to use options when compiling C source files that come with OCaml without imposing these options to the compilation of third-party code. More specifically, the options in the BYTECCCOMPOPTS and NATIVECCCOMPOPTS variables are not passed to the C compiler when called by ocamlc and ocamlopt any longer. This commit also documents the role of each concerned variable. In addition: - On Unix: * The -Wall and -Werror options are no longer passed to the C compiler by ocamlc and ocamlopt for third-party C source files - For the MinGW port: * The -O option has been removed from the SHAREDCCCOMPOPTS variable * The -Wall and -Wno-unused options are no longer passed to the C compiler by ocamlc and ocamlopt for third-party C source files - For the msvc port: the * The -Ox option has been removed from the SHAREDCCCOMPOPTS variable. * The -Wall and -Wno-unused options are no longer passed to the C compiler by ocamlc and ocamlopt for third-party C source filesmaster
parent
e530682dee
commit
3e81da2234
4
Changes
4
Changes
|
@ -31,6 +31,10 @@ Next version (4.05.0):
|
|||
- GPR#829: better error when opening a module aliased to a functor
|
||||
(Alain Frisch)
|
||||
|
||||
- GPR#911: ocamlc/ocamlopt do not pass warnings-related options to C
|
||||
compiler when called to compile third-party C source files
|
||||
(Sébastien Hinderer)
|
||||
|
||||
### Standard library:
|
||||
|
||||
- GPR#760: Add a functions List.compare_lengths and
|
||||
|
|
4
Makefile
4
Makefile
|
@ -407,8 +407,8 @@ utils/config.ml: utils/config.mlp config/Makefile
|
|||
sed -e 's|%%LIBDIR%%|$(LIBDIR)|' \
|
||||
-e 's|%%BYTERUN%%|$(BINDIR)/ocamlrun|' \
|
||||
-e 's|%%CCOMPTYPE%%|cc|' \
|
||||
-e 's|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS)|' \
|
||||
-e 's|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|' \
|
||||
-e 's|%%BYTECC%%|$(BYTECC) $(SHAREDCCCOMPOPTS)|' \
|
||||
-e 's|%%NATIVECC%%|$(NATIVECC)|' \
|
||||
-e '/c_compiler =/s| -Werror||' \
|
||||
-e 's|%%PACKLD%%|$(PACKLD)|' \
|
||||
-e 's|%%BYTECCLIBS%%|$(BYTECCLIBS)|' \
|
||||
|
|
|
@ -374,8 +374,8 @@ utils/config.ml: utils/config.mlp config/Makefile
|
|||
sed -e "s|%%LIBDIR%%|$(LIBDIR)|" \
|
||||
-e "s|%%BYTERUN%%|ocamlrun|" \
|
||||
-e 's|%%CCOMPTYPE%%|$(CCOMPTYPE)|' \
|
||||
-e "s|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS)|" \
|
||||
-e "s|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|" \
|
||||
-e "s|%%BYTECC%%|$(BYTECC)|" \
|
||||
-e "s|%%NATIVECC%%|$(NATIVECC)|" \
|
||||
-e "s|%%PARTIALLD%%|$(PARTIALLD)|" \
|
||||
-e "s|%%PACKLD%%|$(PACKLD)|" \
|
||||
-e "s|%%BYTECCLIBS%%|$(BYTECCLIBS)|" \
|
||||
|
|
|
@ -68,7 +68,7 @@ X11_INCLUDES=
|
|||
X11_LINK=
|
||||
BYTECCRPATH=
|
||||
SUPPORTS_SHARED_LIBRARIES=true
|
||||
SHAREDCCCOMPOPTS=-O
|
||||
SHAREDCCCOMPOPTS=
|
||||
MKSHAREDLIBRPATH=
|
||||
NATIVECCPROFOPTS=
|
||||
NATIVECCRPATH=
|
||||
|
@ -98,10 +98,10 @@ SAFE_STRING=false
|
|||
########## Configuration for the bytecode compiler
|
||||
|
||||
### Which C compiler to use for the bytecode interpreter.
|
||||
BYTECC=$(TOOLPREF)gcc
|
||||
BYTECC=$(TOOLPREF)gcc -O -mms-bitfields
|
||||
|
||||
### Additional compile-time options for $(BYTECC). (For static linking.)
|
||||
BYTECCCOMPOPTS=-O -mms-bitfields -Wall -Wno-unused
|
||||
BYTECCCOMPOPTS=-Wall -Wno-unused
|
||||
|
||||
### Additional link-time options for $(BYTECC). (For static linking.)
|
||||
BYTECCLINKOPTS=
|
||||
|
@ -168,7 +168,7 @@ SYSTEM=mingw
|
|||
NATIVECC=$(BYTECC)
|
||||
|
||||
### Additional compile-time options for $(NATIVECC).
|
||||
NATIVECCCOMPOPTS=-O -mms-bitfields -Wall -Wno-unused
|
||||
NATIVECCCOMPOPTS=-Wall -Wno-unused
|
||||
|
||||
### Additional link-time options for $(NATIVECC)
|
||||
NATIVECCLINKOPTS=
|
||||
|
|
|
@ -68,7 +68,7 @@ X11_INCLUDES=
|
|||
X11_LINK=
|
||||
BYTECCRPATH=
|
||||
SUPPORTS_SHARED_LIBRARIES=true
|
||||
SHAREDCCCOMPOPTS=-O
|
||||
SHAREDCCCOMPOPTS=
|
||||
MKSHAREDLIBRPATH=
|
||||
NATIVECCPROFOPTS=
|
||||
NATIVECCRPATH=
|
||||
|
@ -98,10 +98,10 @@ SAFE_STRING=false
|
|||
########## Configuration for the bytecode compiler
|
||||
|
||||
### Which C compiler to use for the bytecode interpreter.
|
||||
BYTECC=$(TOOLPREF)gcc
|
||||
BYTECC=$(TOOLPREF)gcc -O -mms-bitfields
|
||||
|
||||
### Additional compile-time options for $(BYTECC). (For static linking.)
|
||||
BYTECCCOMPOPTS=-O -mms-bitfields -Wall -Wno-unused
|
||||
BYTECCCOMPOPTS=-Wall -Wno-unused
|
||||
|
||||
### Additional link-time options for $(BYTECC). (For static linking.)
|
||||
BYTECCLINKOPTS=
|
||||
|
@ -168,7 +168,7 @@ SYSTEM=mingw64
|
|||
NATIVECC=$(BYTECC)
|
||||
|
||||
### Additional compile-time options for $(NATIVECC).
|
||||
NATIVECCCOMPOPTS=-O -mms-bitfields -Wall -Wno-unused
|
||||
NATIVECCCOMPOPTS=-Wall -Wno-unused
|
||||
|
||||
### Additional link-time options for $(NATIVECC)
|
||||
NATIVECCLINKOPTS=
|
||||
|
|
|
@ -63,7 +63,7 @@ X11_INCLUDES=
|
|||
X11_LINK=
|
||||
BYTECCRPATH=
|
||||
SUPPORTS_SHARED_LIBRARIES=true
|
||||
SHAREDCCCOMPOPTS=-Ox
|
||||
SHAREDCCCOMPOPTS=
|
||||
NATIVECCPROFOPTS=
|
||||
NATIVECCRPATH=
|
||||
ASM=ml -nologo -coff -Cp -c -Fo
|
||||
|
@ -92,10 +92,10 @@ SAFE_STRING=false
|
|||
########## Configuration for the bytecode compiler
|
||||
|
||||
### Which C compiler to use for the bytecode interpreter.
|
||||
BYTECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE
|
||||
BYTECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE -O2 -Gy- -MD
|
||||
|
||||
### Additional compile-time options for $(BYTECC). (For static linking.)
|
||||
BYTECCCOMPOPTS=-O2 -Gy- -MD
|
||||
BYTECCCOMPOPTS=
|
||||
|
||||
### Additional link-time options for $(BYTECC). (For static linking.)
|
||||
BYTECCLINKOPTS=
|
||||
|
@ -163,10 +163,10 @@ MODEL=default
|
|||
SYSTEM=win32
|
||||
|
||||
### Which C compiler to use for the native-code compiler.
|
||||
NATIVECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE
|
||||
NATIVECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE -O2 -Gy- -MD
|
||||
|
||||
### Additional compile-time options for $(NATIVECC).
|
||||
NATIVECCCOMPOPTS=-O2 -Gy- -MD
|
||||
NATIVECCCOMPOPTS=
|
||||
|
||||
### Additional link-time options for $(NATIVECC)
|
||||
NATIVECCLINKOPTS=
|
||||
|
|
|
@ -63,7 +63,7 @@ X11_INCLUDES=
|
|||
X11_LINK=
|
||||
BYTECCRPATH=
|
||||
SUPPORTS_SHARED_LIBRARIES=true
|
||||
SHAREDCCCOMPOPTS=-Ox
|
||||
SHAREDCCCOMPOPTS=
|
||||
NATIVECCPROFOPTS=
|
||||
NATIVECCRPATH=
|
||||
ASM=ml64 -nologo -Cp -c -Fo
|
||||
|
@ -91,10 +91,10 @@ SAFE_STRING=false
|
|||
########## Configuration for the bytecode compiler
|
||||
|
||||
### Which C compiler to use for the bytecode interpreter.
|
||||
BYTECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE
|
||||
BYTECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE -O2 -Gy- -MD
|
||||
|
||||
### Additional compile-time options for $(BYTECC). (For static linking.)
|
||||
BYTECCCOMPOPTS=-O2 -Gy- -MD
|
||||
BYTECCCOMPOPTS=
|
||||
|
||||
### Additional compile-time options for $(BYTECC). (For debug version.)
|
||||
BYTECCDBGCOMPOPTS=-DDEBUG -Zi -W3 -Wp64
|
||||
|
@ -168,10 +168,10 @@ MODEL=default
|
|||
SYSTEM=win64
|
||||
|
||||
### Which C compiler to use for the native-code compiler.
|
||||
NATIVECC=cl -nologo
|
||||
NATIVECC=cl -nologo -O2 -Gy- -MD
|
||||
|
||||
### Additional compile-time options for $(NATIVECC).
|
||||
NATIVECCCOMPOPTS=-O2 -Gy- -MD
|
||||
NATIVECCCOMPOPTS=
|
||||
|
||||
### Additional link-time options for $(NATIVECC)
|
||||
NATIVECCLINKOPTS=
|
||||
|
|
|
@ -328,10 +328,29 @@ esac
|
|||
|
||||
# Configure the bytecode compiler
|
||||
|
||||
# The BYTECC make variable defines which compiler and options to use
|
||||
# to compile C code intended to be used by OCaml bytecode programs.
|
||||
# It is used inside OCaml's build system, and also when ocamlc is
|
||||
# called on a third-party C source file and no -cc command-line option
|
||||
# has been specified.
|
||||
|
||||
# The BYTECCCOMPOPTS make variable contains options to pass to the C
|
||||
# compiler but only when compiling C files that belong to the OCaml
|
||||
# distribution.
|
||||
# In other words, when ocamlc is called to compile a third-party C
|
||||
# source file, it will _not_ pass these options to the C compiler.
|
||||
|
||||
# The SHAREDCCCOMPOPTS make variable contains options to use to compile C
|
||||
# source files so that the resulting object files can then be integrated
|
||||
# into shared libraries. It is passed to BYTECC for both C source files
|
||||
# in the OCaml distribution and third-party C source files compiled
|
||||
# with ocamlc.
|
||||
|
||||
bytecc="$cc"
|
||||
mkexe="\$(BYTECC)"
|
||||
mkexedebugflag="-g"
|
||||
bytecccompopts=""
|
||||
byteccprivatecompopts=""
|
||||
bytecclinkopts=""
|
||||
ostype="Unix"
|
||||
exe=""
|
||||
|
@ -357,7 +376,8 @@ esac
|
|||
|
||||
case "$ccfamily" in
|
||||
clang-*)
|
||||
bytecccompopts="-O2 -fno-strict-aliasing -fwrapv $gcc_warnings";;
|
||||
bytecccompopts="-O2 -fno-strict-aliasing -fwrapv";
|
||||
byteccprivatecompopts="$gcc_warnings";;
|
||||
gcc-[012]-*)
|
||||
# Some versions known to miscompile OCaml, e,g, 2.7.2.1, some 2.96.
|
||||
# Plus: C99 support unknown.
|
||||
|
@ -367,11 +387,14 @@ case "$ccfamily" in
|
|||
# Known problems with -fwrapv fixed in 4.2 only.
|
||||
wrn "This version of GCC is rather old. Reducing optimization level."
|
||||
wrn "Consider using GCC version 4.2 or above."
|
||||
bytecccompopts="-std=gnu99 -O $gcc_warnings";;
|
||||
bytecccompopts="-std=gnu99 -O";
|
||||
byteccprivatecompopts="$gcc_warnings";;
|
||||
gcc-4-*)
|
||||
bytecccompopts="-std=gnu99 -O2 -fno-strict-aliasing -fwrapv $gcc_warnings";;
|
||||
bytecccompopts="-std=gnu99 -O2 -fno-strict-aliasing -fwrapv";
|
||||
byteccprivatecompopts="$gcc_warnings";;
|
||||
gcc-*)
|
||||
bytecccompopts="-O2 -fno-strict-aliasing -fwrapv $gcc_warnings";;
|
||||
bytecccompopts="-O2 -fno-strict-aliasing -fwrapv";
|
||||
byteccprivatecompopts="$gcc_warnings";;
|
||||
*)
|
||||
bytecccompopts="-O";;
|
||||
esac
|
||||
|
@ -487,7 +510,7 @@ export cc cclibs verbose
|
|||
|
||||
# Check C compiler.
|
||||
|
||||
cc="$bytecc $bytecccompopts $bytecclinkopts" sh ./runtest ansi.c
|
||||
cc="$bytecc $bytecccompopts $byteccprivatecompopts $bytecclinkopts" sh ./runtest ansi.c
|
||||
case $? in
|
||||
0) inf "The C compiler is ISO C99 compliant." ;;
|
||||
1) wrn "The C compiler is ANSI / ISO C90 compliant, but not ISO C99" \
|
||||
|
@ -843,6 +866,18 @@ fi
|
|||
|
||||
# Configure the native-code compiler
|
||||
|
||||
# The NATIVECC make variable defines which compiler and options to use
|
||||
# to compile C code intended to be used by OCaml native programs.
|
||||
# It is used inside OCaml's build system, and also when ocamlopt is
|
||||
# called on a third-party C source file and no -cc command-line
|
||||
# option has been specified.
|
||||
|
||||
# The NATIVECCCOMPOPTS make variable contains options to pass to the C
|
||||
# compiler, but only when compiling C files that belong to the OCaml
|
||||
# distribution.
|
||||
# In other words, when ocamlopt is called to compile a third-party C
|
||||
# source file, it will _not_ pass these options to the C compiler.
|
||||
|
||||
arch=none
|
||||
model=default
|
||||
system=unknown
|
||||
|
@ -925,6 +960,7 @@ else
|
|||
fi
|
||||
|
||||
nativecccompopts="$bytecccompopts"
|
||||
nativeccprivatecompopts=byteccprivatecompopts
|
||||
nativeccprofopts=''
|
||||
nativecclinkopts=''
|
||||
# FIXME the naming of nativecclinkopts is broken: these are options for
|
||||
|
@ -1920,8 +1956,8 @@ fi
|
|||
|
||||
cclibs="$cclibs $mathlib"
|
||||
|
||||
echo "BYTECC=$bytecc" >> Makefile
|
||||
echo "BYTECCCOMPOPTS=$bytecccompopts" >> Makefile
|
||||
echo "BYTECC=$bytecc $bytecccompopts" >> Makefile
|
||||
echo "BYTECCCOMPOPTS=$byteccprivatecompopts" >> Makefile
|
||||
echo "BYTECCLINKOPTS=$bytecclinkopts" >> Makefile
|
||||
echo "BYTECCLIBS=$cclibs $dllib $curseslibs $pthread_link \
|
||||
$instrumented_runtime_libs" >> Makefile
|
||||
|
@ -1944,8 +1980,8 @@ EOF
|
|||
echo "ARCH=$arch" >> Makefile
|
||||
echo "MODEL=$model" >> Makefile
|
||||
echo "SYSTEM=$system" >> Makefile
|
||||
echo "NATIVECC=$nativecc" >> Makefile
|
||||
echo "NATIVECCCOMPOPTS=$nativecccompopts" >> Makefile
|
||||
echo "NATIVECC=$nativecc $nativecccompopts" >> Makefile
|
||||
echo "NATIVECCCOMPOPTS=$nativeprivatecccompopts" >> Makefile
|
||||
echo "NATIVECCPROFOPTS=$nativeccprofopts" >> Makefile
|
||||
echo "NATIVECCLINKOPTS=$nativecclinkopts" >> Makefile
|
||||
echo "NATIVECCRPATH=$nativeccrpath" >> Makefile
|
||||
|
|
Loading…
Reference in New Issue