summaryrefslogtreecommitdiff
path: root/ext/ffi_c/libffi/msvcc.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ffi_c/libffi/msvcc.sh')
-rwxr-xr-xext/ffi_c/libffi/msvcc.sh78
1 files changed, 69 insertions, 9 deletions
diff --git a/ext/ffi_c/libffi/msvcc.sh b/ext/ffi_c/libffi/msvcc.sh
index dcdbeab..65fbfef 100755
--- a/ext/ffi_c/libffi/msvcc.sh
+++ b/ext/ffi_c/libffi/msvcc.sh
@@ -42,8 +42,10 @@
# format and translated into something sensible for cl or ml.
#
+args_orig=$@
args="-nologo -W3"
-md=-MD
+static_crt=
+debug_crt=
cl="cl"
ml="ml"
safeseh="-safeseh"
@@ -62,31 +64,65 @@ do
shift 1
;;
-m64)
- cl="cl" # "$MSVC/x86_amd64/cl"
ml="ml64" # "$MSVC/x86_amd64/ml64"
safeseh=
shift 1
;;
+ -clang-cl)
+ cl="clang-cl"
+ safeseh=
+ shift 1
+ ;;
-O0)
args="$args -Od"
shift 1
;;
-O*)
- # If we're optimizing, make sure we explicitly turn on some optimizations
- # that are implicitly disabled by debug symbols (-Zi).
- args="$args $1 -OPT:REF -OPT:ICF -INCREMENTAL:NO"
+ # Runtime error checks (enabled by setting -RTC1 in the -DFFI_DEBUG
+ # case below) are not compatible with optimization flags and will
+ # 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
;;
-g)
# Enable debug symbol generation.
- args="$args -Zi -DEBUG"
+ args="$args -Zi"
shift 1
;;
-DFFI_DEBUG)
- # Link against debug CRT and enable runtime error checks.
+ # Enable runtime error checks.
args="$args -RTC1"
defines="$defines $1"
- md=-MDd
+ shift 1
+ ;;
+ -DUSE_STATIC_RTL)
+ # Link against static CRT.
+ static_crt=1
+ shift 1
+ ;;
+ -DUSE_DEBUG_RTL)
+ # Link against debug CRT.
+ debug_crt=1
shift 1
;;
-c)
@@ -126,6 +162,10 @@ do
# to do here.
shift 1
;;
+ -pedantic)
+ # libffi tests -pedantic with -Wall, so drop it also.
+ shift 1
+ ;;
-Werror)
args="$args -WX"
shift 1
@@ -170,6 +210,23 @@ do
esac
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 "$static_crt" ]; then
+ md=-MT
+else
+ md=-MD
+fi
+
+if [ -n "$debug_crt" ]; then
+ md="${md}d"
+fi
+
if [ -n "$assembly" ]; then
if [ -z "$outdir" ]; then
outdir="."
@@ -189,7 +246,10 @@ if [ -n "$assembly" ]; then
else
args="$md $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=$?
fi