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

[cmdline] use / in -print-mod-uid as dir separator on windows #13861

Merged
merged 1 commit into from
Dec 21, 2021

Conversation

gares
Copy link
Member

@gares gares commented Feb 15, 2021

@MSoegtropIMC I've opted for the most conservative solution, I've flipped \ for / only in this option

Fix #13827

@gares gares added this to the 8.14+rc1 milestone Feb 15, 2021
@gares gares added the kind: fix This fixes a bug or incorrect documentation. label Feb 15, 2021
@MSoegtropIMC
Copy link
Contributor

MSoegtropIMC commented Feb 15, 2021

To be extra safe, you might want to check for files starting with \. This is fairly rare in Windows, one typically either uses relative paths or has a drive letter as well. C:/a/b works, a/b works, but /a/b can lead to interesting (very hard to debug) effects. I would consider throwing an error (or a warning) that one should either use relative paths or absolute paths with a drive letter.

let fix_windows_dirsep s =
if Sys.win32 then Str.(global_replace (regexp_string "\\") "/" s)
else s

Copy link
Member

Choose a reason for hiding this comment

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

Umm, the below code is already using Filename.concat which should do the right thing on Win32, so this seems wrong. Looking at the original bug, the problem seems to be in the Makefiles that mess with quoting, so it seems to me that the problem should be handled there.

In fact, this whole operation get_native_name seems to be ultra-costly, as it loads the whole summary, etc... the name of the native file can be easily computed without calling Coq [this is what we do in Dune] and indeed it seems like a better approach to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, this whole operation get_native_name seems to be ultra-costly, as it loads the whole summary, etc... the name of the native file can be easily computed without calling Coq [this is what we do in Dune] and indeed it seems like a better approach to me.

Are you saying that you coded, in dune, the whole -R and -Q resolution strategy?

Copy link
Member

Choose a reason for hiding this comment

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

No, dune already knows about these flags natively, so the operation of producing the name for native is quite easy:

https://github.com/ocaml/dune/blob/86522e99241cea205cc3202e419e6a6e003cc3e8/src/dune_rules/coq_module.ml#L43-L47

Indeed having a bit more information about library resolution would be very interesting as it would solve the current problem of having to generate all source files before calling coqdep, but that's offtopic here.

As far as I can see the bug is a bug in the Makefiles, that are quoting incorrectly somewhere, so IMO it should be solved there, not in Coq which is doing the right thing. [If filename.concat is buggy upstream that's a different story, but then we should provide our own, not hack ad-hoc here]

@gares
Copy link
Member Author

gares commented Feb 15, 2021

Well, Filename would spit / if it did detect cygwin, but it does not. The "problem" is that we require a unix environment to run coq_makefile, but coq itself is compiled to also work without cygwin (so filename spits \ which is the default on windows). Given that this option is only used by coq_makefile I think it is safe (as ci shows) to flip the \ to /.

@gares
Copy link
Member Author

gares commented Feb 15, 2021

To be extra safe, you might want to check for files starting with .

Out of inspiration I replaced (.)\ with \1/, hope it covers all your weird cases

Copy link
Member

@ejgallego ejgallego left a comment

Choose a reason for hiding this comment

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

It seems that the problem here is that the makefiles are incorrect w.r.t. quoting, so instead of this hack we should fix the makefiles instead to preserve the \.

@ejgallego
Copy link
Member

ejgallego commented Feb 15, 2021

Well, Filename would spit / if it did detect cygwin, but it does not.

The problem is not that thing work when / is used and don't when \ is, but that coq_makefile is eating the \ symbol altogether, this points to broken quoting, which should be solved in the makefiles themselves [likely other stuff is broken such as spaces]

@silene
Copy link
Contributor

silene commented Jun 2, 2021

This pull request is a one-liner. Either we apply it or we close it. Keeping it as a draft forever is just a waste of time.

@gares gares modified the milestones: 8.14+rc1, 8.15+rc1 Jun 3, 2021
@SkySkimmer
Copy link
Contributor

In https://github.com/coq/coq/wiki/Coq-Call-2021-11-10 we said we would go with this solution

@SkySkimmer SkySkimmer marked this pull request as ready for review November 28, 2021 09:56
@SkySkimmer SkySkimmer requested a review from a team as a code owner November 28, 2021 09:56
@SkySkimmer SkySkimmer removed this from the 8.15+rc1 milestone Dec 3, 2021
@ppedrot
Copy link
Member

ppedrot commented Dec 9, 2021

@SkySkimmer don't you want to assign and merge this one? It has been lingering quite a bit.

@ppedrot ppedrot self-assigned this Dec 21, 2021
@ppedrot ppedrot added this to the 8.16+rc1 milestone Dec 21, 2021
@ppedrot
Copy link
Member

ppedrot commented Dec 21, 2021

Since we collectively agreed on merging this I don't see any point in keeping this around. Let's fire and forget.

@ppedrot
Copy link
Member

ppedrot commented Dec 21, 2021

@coqbot merge now

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Dec 21, 2021

@ppedrot: You can't merge the PR because some changes are requested.

@ppedrot ppedrot dismissed ejgallego’s stale review December 21, 2021 14:14

collective agreement

@ppedrot
Copy link
Member

ppedrot commented Dec 21, 2021

@coqbot merge now

@coqbot-app coqbot-app bot merged commit 01d5913 into coq:master Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: fix This fixes a bug or incorrect documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

coq_makefile not producing valid paths for native objects under Cygwin
6 participants