Skip to content

Commit

Permalink
Add the -d2VolatileMetadata- switch to cl
Browse files Browse the repository at this point in the history
Visual Studio 2019 and 2022 turn on the generation of volatile metadata
by default, which can cause problems for flexlink which doesn't know how
to process the .voltbl section properly.

This information has been enabled to aid emulation of AMD64 on ARM64, so
for now risk slower emulated performance pending direct compilation to
ARM64 on Windows anyway.
  • Loading branch information
dra27 committed Nov 30, 2021
1 parent 01c6f16 commit 8cd4f51
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ OCaml 4.14.0
(Sébastien Hinderer, review by David Allsopp, Daniel Bünzli, Xavier Leroy
and Gabriel Scherer)

- #10797: Compile with -d2VolatileMetadata- on supporting versions of Visual
Studio. This suppresses the addition of .voltbl sections and eliminates
linking errors in systhreads.
(David Allsopp, review by ???)

### Bug fixes:

- #9214, #10709: Wrong unmarshaling of function pointers in debugger mode.
Expand Down
13 changes: 13 additions & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ AC_DEFUN([OCAML_CC_HAS_DEBUG_PREFIX_MAP], [
CFLAGS="$saved_CFLAGS"
])

AC_DEFUN([OCAML_CL_HAS_VOLATILE_METADATA], [
AC_MSG_CHECKING([whether the C compiler supports -d2VolatileMetadata-])
saved_CFLAGS="$CFLAGS"
CFLAGS="-d2VolatileMetadata- $CFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([int main() { return 0; }])],
[cl_has_volatile_metadata=true
AC_MSG_RESULT([yes])],
[cl_has_volatile_metadata=false
AC_MSG_RESULT([no])])
CFLAGS="$saved_CFLAGS"
])

# Save C compiler related variables
AC_DEFUN([OCAML_CC_SAVE_VARIABLES], [
saved_CC="$CC"
Expand Down
24 changes: 24 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ AS_CASE([$host],
[common_cflags="-nologo -O2 -Gy- -MD $cc_warnings"
common_cppflags="-D_CRT_SECURE_NO_DEPRECATE"
internal_cppflags='-DUNICODE -D_UNICODE'
OCAML_CL_HAS_VOLATILE_METADATA
AS_IF([test "x$cl_has_volatile_metadata" = "xtrue"],
[internal_cflags='-d2VolatileMetadata-'])
internal_cppflags="$internal_cppflags -DWINDOWS_UNICODE="
internal_cppflags="${internal_cppflags}\$(WINDOWS_UNICODE)"],
[xlc-*],
Expand Down

0 comments on commit 8cd4f51

Please sign in to comment.