Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix configuration and build system for native Windows #2939

Merged
merged 7 commits into from
Jun 1, 2017

Conversation

dra27
Copy link
Member

@dra27 dra27 commented May 13, 2017

This PR has some duplication with #2938 over the $(EXE) and $(WIN32) variables.

This PR corrects the build system to operate in a preconfigured Cygwin set-up for a native OCaml compiler (at present, autodetection of the Microsoft C Compiler is not merged - as for OCaml, Cygwin must be started from within a Microsoft Developer Tools prompt or PATH, INCLUDE and LIB must be correctly set). This PR fixes various things and when combined with #2938 should allow opam to be built using either mingw or msvc via the lib-ext route (note: the compiled opam will not work). This PR changes the following:

  • Handling is included in configure to detect the mingw compilers, as configure now tests the C compiler used by the OCaml compiler. Special handling is included to detect the AR command which OCamlMakefile insists on using directly.
  • Various fixes to the venerable, yet hardly used on Windows, OCamlMakefile
  • ocamldep on virtually all versions (I think possibly 4.05 is changing the behaviour) requires the -slash argument on Windows or the generated dependencies contain syntax errors for projects like opam with subdirectories.
  • A workaround somewhat similar to msvs-tools's msvs-promote-path is used to allow the Microsoft Linker (link.exe) to be called even when Cygwin's link appears before it in PATH
  • A better default PREFIX is selected for Windows-building (I got tired of accidentally finding C:\usr had been created...)

@dra27 dra27 force-pushed the win-configure branch 3 times, most recently from 1c164d6 to fd3b0e5 Compare May 15, 2017 19:51
@dra27 dra27 force-pushed the win-configure branch 2 times, most recently from 310d485 to 79e90bd Compare May 24, 2017 13:54
OCamlMakefile Outdated
@@ -112,7 +112,7 @@ endif

#################### variables depending on your OCaml-installation

SYSTEM := $(shell ocamlc -config 2>/dev/null | grep system | sed 's/system: //')
SYSTEM := $(shell ocamlc -config 2>/dev/null | grep "^system:" | sed 's/system: //')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer a single | sed -n 's/^system: ?//p pipe (but this is fine)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My way is sloppy - I've changed it!

@AltGr
Copy link
Member

AltGr commented May 29, 2017

Thanks!

@AltGr
Copy link
Member

AltGr commented May 29, 2017

Ok to merge once the conflicts are fixed!

dra27 added 2 commits May 29, 2017 15:17
configure can now identify i686-w64-mingw32-gcc. Code included to
determine the value for AR from $OCAMLLIB/Makefile.config since
OCamlMakefile insists on calling AR directly, rather than using
ocamlmklib.
@dra27
Copy link
Member Author

dra27 commented May 29, 2017

Fixed that pipe, and also 3 others!

@dra27
Copy link
Member Author

dra27 commented May 29, 2017

Do let this run through CI, therefore, just in case!

@AltGr
Copy link
Member

AltGr commented May 30, 2017

gcc seems to be getting an option it doesn't like (error: unrecognized command line option ‘-NODEFAULTLIB:LIBC’), both on Linux and Windows (well clang on OSX has the same complaint too).

dra27 added 5 commits May 30, 2017 10:30
Test for ocamlc -config fails if your OCaml installation path includes
"system"!
ocamldep needs to have the -slash option passed on Windows.
The Microsoft Linker is called link which has the potential to conflict
with coreutils link, depending on the order of directories in PATH. By
default, coreutils link will win, and compilation is broken on MSVC
OCaml.

Simply altering /etc/profile to put the Cygwin directories later isn't
an option as commands like find and sort then get overridden by
Microsoft's "alternative" implementations in system32.

Introduce detection in configure so that if multiple link commands are
found in PATH, identify the first one which is a Microsoft Linker and
alter PATH in Makefile to include its directory first.
Autoconf's default prefix of /usr/local is inappropriate for Windows as
it results in C:\usr\local being created by the opam-installer. When
Windows is detected, the default is changed to C:/OPAM instead.
@dra27
Copy link
Member Author

dra27 commented May 30, 2017

Oops - that's why we have CI! This should fix it - I'd put /e instead of /p in one of the sed expressions...

@dra27
Copy link
Member Author

dra27 commented Jun 1, 2017

Can this one go in too, please?

@AltGr
Copy link
Member

AltGr commented Jun 1, 2017

Yes, I had to re-run the AppVeyor builds but they seem OK now.

@AltGr AltGr merged commit 6925d32 into ocaml:master Jun 1, 2017
@dra27 dra27 deleted the win-configure branch June 3, 2017 10:20
@dra27 dra27 mentioned this pull request Jun 13, 2024
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