Skip to content

Visual Studio updates#14

Merged
alainfrisch merged 6 commits intoocaml:masterfrom
dra27:visual-studio
Jan 15, 2016
Merged

Visual Studio updates#14
alainfrisch merged 6 commits intoocaml:masterfrom
dra27:visual-studio

Conversation

@dra27
Copy link
Member

@dra27 dra27 commented Jan 1, 2016

Happy New Year! Several patches arising from recent work testing OCaml trunk on various old Visual Studio installations:

  • Previously added .gitattributes omitted the important normalisation of existing files (sorry!)
  • It is still possible to build OCaml on some old but just about supported Microsoft compilers whose development was before Microsoft's major security overhaul for Windows XP SP2 and so which don't include the secure versions of CRT functions (this includes msvcrt.dll used by the mingw ports). Corrected the #ifdef logic to share the mingw branch with older Microsoft C compilers too. This minor adjustment enables compilation in Microsoft Visual Studio .NET 2003 and also in the Windows Server 2003 SP1 SDK (which is a pre-release Visual Studio 2005 compiler).
  • Two changes which aid bootstrapping FlexDLL from within OCaml (this essentially extends support already required for building Cygwin OCaml from sources). MSVC_DETECT allows all of the complex logic for detecting both 32 and 64-bit Microsoft C compilers to be disabled in favour of just trusting the environment (as for an OCaml compilation). The bootstrapping process shortly to become an OCaml PR allows a bytecode flexlink.exe to be compiled before starting make -f Makefile.nt world, hence .cmo artefacts may now be seen. The checkenv script (which must be run manually) informs the user if it looks safe to run make MSVC_DETECT=0 CHAINS=msvc[64] ...

25b0862 fixed one; this hopefully fixes
all the others.
Specifying make MSVC_DETECT=0 ... overrides all of the detection logic for
the Microsoft C Compiler and simply assumes that the environment is
correct. This obviously means that building both 32 and 64-bit CHAINS is
not possible.

checkenv script added which outputs a warning if the environment appears
not to include the Windows SDK, tools or the Microsoft C Runtime. The
script also attempts to determine the architecture of cl.exe and so advise
which CHAINS value can be built with MSVC_DETECT=0. No checking logic
added to Makefile, so specifying CHAINS=msvc64 with an x86 compiler and
vice versa will simply build invalid object files.

Updated CHANGES and also added execute bit to findwinsdk.
The Windows Platform SDK includes a release with a CRT which falls between
Visual Studio .NET 2003 and Visual Studio 2005 and which does not include
the secure versions of many CRT functions, including `_putenv_s`.

In `flexdll_dlopen`, the logic for selecting `setenv`, `putenv` or
`_putenv_s` now correctly relies on the CYGWIN and __STDC_SECURE_LIB__
defines only. The only code change to actual code is the need to declare a
variable at the start of the block to comply with C89 for the Microsoft C
Compiler.
Bootstrapping flexlink from within an OCaml distribution creates a
bytecode version of flexlink.
It is somewhat strange having to install .obj and .o files in a BINDIR
when a LIBDIR is available.

Old behaviour is preserved - so flexlink will always prefer flexdll_*.$(O)
and flexdll_initer_*.$(O) from the same directory as flexlink, but if they
are missing then the search path is used, as for any other object file.

The default manifests must still be in the same directory as flexlink.
flexlink.opt is created by OCaml when bootstrapping FlexDLL.
alainfrisch added a commit that referenced this pull request Jan 15, 2016
@alainfrisch alainfrisch merged commit db1d82a into ocaml:master Jan 15, 2016
@alainfrisch
Copy link
Collaborator

Thanks!

@dra27 dra27 deleted the visual-studio branch January 18, 2016 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants