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

conf-cc? #26590

Open
JasonGross opened this issue Sep 20, 2024 · 4 comments
Open

conf-cc? #26590

JasonGross opened this issue Sep 20, 2024 · 4 comments
Assignees

Comments

@JasonGross
Copy link

Would it be possible to add a conf- package for the presence of any C compiler addressable by cc, a la https://github.com/ocaml/opam-repository/blob/master/packages/conf-c%2B%2B/conf-c%2B%2B.1.0/opam ?

@mseri
Copy link
Member

mseri commented Sep 20, 2024

Afaik this was missing since the presence of opam and an ocaml compiler should guarantee the presence of a c compiler. Have you encountered situations where this was not the case?

@JasonGross
Copy link
Author

On Windows, it seems that there may be gcc installed without cc being symlinked. (I'm in fact not sure what cygwin package needs to be installed to get cc symlinked. See this log for more details (full logs at logs_28626321033.zip in case github ever deletes the logs)

@mseri
Copy link
Member

mseri commented Sep 20, 2024

@dra27 do you know if this is a bug in windows?

@dra27
Copy link
Member

dra27 commented Sep 21, 2024

It's not a bug with Windows per se, it's the assumption - it's not portable to assume the C compiler is called "cc"!

My instinct (that is to say my strong opinion) is that randomly symlinking these things in opam is a bad idea (also bear in mind that "symlinking" is not a guaranteed thing in Windows, so it can also mean "shimming"). The mingw-w64-shims package does this exceptionally for mingw-w64 under Cygwin only (with both MSVC and mingw-w64 accessed via MSYS2 this is done much more naturally by adding an appropriate bin directory to PATH).

But, two practical thoughts:

  • I have also had in mind that we should have something along the lines of conf-cc at some point (in fact, there may be another issue already?!) - the Windows compilers already pull in mingw-specific packages for depext purposes, and a conf-cc package would be the obvious place to extend that courtesy elsewhere (and, for example, give a clearer error to macOS beginners who try to build compilers before installing Xcode tools...). opam does provide package variables so a thing which could be being done is to have %{conf-cc:cc}% expanding to the correct name of the C compiler.
  • Shorter-term, as long as one's on OCaml 4.08+ (please do be!), ocamlopt -config-var c_compiler gives you the name of the C compiler used to build OCaml. IIRC it is supposed to give strictly the command (i.e. no additional flags). On Windows, this gives anything from cl (MSVC), gcc (mingw-w64 via MSYS2), i686-w64-mingw32-gcc/x86_64-w64-mingw32-gcc (mingw-w64 via Cygwin).

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

No branches or pull requests

3 participants