Various compatibility fixes and improvements to msvcc.sh.
* Don't try to mix incompatible optimization flags in debug builds. * Workaround ax_cc_maxopt.m4 not supporting MSVC and change -O3 to -O2. * Fix MSVC warning by properly passing linker flags to compiler. * Make msvcc.sh return 1 if invalid command line options are used rather than silently eating them. * Add more comments.
This commit is contained in:
46
msvcc.sh
46
msvcc.sh
@@ -42,6 +42,7 @@
|
|||||||
# format and translated into something sensible for cl or ml.
|
# format and translated into something sensible for cl or ml.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
args_orig=$@
|
||||||
args="-nologo -W3"
|
args="-nologo -W3"
|
||||||
md=-MD
|
md=-MD
|
||||||
cl="cl"
|
cl="cl"
|
||||||
@@ -72,14 +73,35 @@ do
|
|||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
-O*)
|
-O*)
|
||||||
# If we're optimizing, make sure we explicitly turn on some optimizations
|
# Runtime error checks (enabled by setting -RTC1 in the -DFFI_DEBUG
|
||||||
# that are implicitly disabled by debug symbols (-Zi).
|
# case below) are not compatible with optimization flags and will
|
||||||
args="$args $1 -OPT:REF -OPT:ICF -INCREMENTAL:NO"
|
# cause the build to fail. Therefore, drop the optimization flag if
|
||||||
|
# -DFFI_DEBUG is also set.
|
||||||
|
case $args_orig in
|
||||||
|
*-DFFI_DEBUG*)
|
||||||
|
args="$args"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# The ax_cc_maxopt.m4 macro from the upstream autoconf-archive
|
||||||
|
# project doesn't support MSVC and therefore ends up trying to
|
||||||
|
# use -O3. Use the equivalent "max optimization" flag for MSVC
|
||||||
|
# instead of erroring out.
|
||||||
|
case $1 in
|
||||||
|
-O3)
|
||||||
|
args="$args -O2"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
args="$args $1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
opt="true"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
-g)
|
-g)
|
||||||
# Enable debug symbol generation.
|
# Enable debug symbol generation.
|
||||||
args="$args -Zi -DEBUG"
|
args="$args -Zi"
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
-DFFI_DEBUG)
|
-DFFI_DEBUG)
|
||||||
@@ -126,6 +148,10 @@ do
|
|||||||
# to do here.
|
# to do here.
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
-pedantic)
|
||||||
|
# libffi tests -pedantic with -Wall, so drop it also.
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
-Werror)
|
-Werror)
|
||||||
args="$args -WX"
|
args="$args -WX"
|
||||||
shift 1
|
shift 1
|
||||||
@@ -170,6 +196,13 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# If -Zi is specified, certain optimizations are implicitly disabled
|
||||||
|
# by MSVC. Add back those optimizations if this is an optimized build.
|
||||||
|
# NOTE: These arguments must come after all others.
|
||||||
|
if [ -n "$opt" ]; then
|
||||||
|
args="$args -link -OPT:REF -OPT:ICF -INCREMENTAL:NO"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$assembly" ]; then
|
if [ -n "$assembly" ]; then
|
||||||
if [ -z "$outdir" ]; then
|
if [ -z "$outdir" ]; then
|
||||||
outdir="."
|
outdir="."
|
||||||
@@ -189,7 +222,10 @@ if [ -n "$assembly" ]; then
|
|||||||
else
|
else
|
||||||
args="$md $args"
|
args="$md $args"
|
||||||
echo "$cl $args"
|
echo "$cl $args"
|
||||||
eval "\"$cl\" $args"
|
# Return an error code of 1 if an invalid command line parameter is passed
|
||||||
|
# instead of just ignoring it.
|
||||||
|
eval "(\"$cl\" $args 2>&1 1>&3 | \
|
||||||
|
awk '{print \$0} /D9002/ {error=1} END{exit error}' >&2) 3>&1"
|
||||||
result=$?
|
result=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user