Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

fix quoting in win64.mak: add them only when invoking command#2438

Merged
dlang-bot merged 1 commit intodlang:masterfrom
rainers:win64_mak_quotes
Mar 4, 2019
Merged

fix quoting in win64.mak: add them only when invoking command#2438
dlang-bot merged 1 commit intodlang:masterfrom
rainers:win64_mak_quotes

Conversation

@rainers
Copy link
Member

@rainers rainers commented Jan 3, 2019

...not when setting variable. This avoids having to skillfully quote variables with spaces in them: use "CC=%cl64%" instead of "CC=\"%cl64%\""

Not sure how the existing misquoting was supposed to work. Using quotes with the command is agnostic to using / instead of \ as a path separator, too.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @rainers!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + druntime#2438"

@rainers rainers changed the title fix quoting in wn64.mak: add them only when invoking command fix quoting in win64.mak: add them only when invoking command Jan 3, 2019
@jacob-carlborg
Copy link
Contributor

Should the other makefiles be quoted as well?

@rainers
Copy link
Member Author

rainers commented Jan 4, 2019

Should the other makefiles be quoted as well?

Do you mean win32.mak? IIRC DM tools don't work too well with spaces in path names to begin with.
For posix two mechanisms exist to deal with spaces, quotes and escaping with \ . I don't want to mess with that...

@rainers
Copy link
Member Author

rainers commented Jan 4, 2019

I removed auto-merege as I just noticed that I forgot to remove the quotes from the definition of CC and AR, which should be done for consistency. It will break patching by the auto-tester, though. I'll update here and hope for braddr/at-client#10 to go anywhere...

@thewilsonator
Copy link
Contributor

OK.

@dlang-bot dlang-bot merged commit 8a8a602 into dlang:master Mar 4, 2019
@CyberShadow
Copy link
Member

Oof, this broke Digger. Did not see this when it was posted. Will see if Digger can detect / patch around this.

@CyberShadow
Copy link
Member

CyberShadow commented Mar 19, 2019

This is also unlike how it's done in Phobos and DMD:

https://github.com/dlang/phobos/blob/ccfe79be52ec12c0c22c783dac69d41b7fcd5c27/win32.mak#L70
https://github.com/dlang/dmd/blob/2ae5408b5923fc0d5e6ba3b9f292b449d0cae0c0/src/win32.mak#L447

Working around this will require special handling for this Druntime makefile specifically.

@rainers Would you mind going into a bit more detail for your motivations behind this change? Was it just some random cleanup opportunity you noticed, or does this PR facilitate some prior goal?

Edit: Found the Phobos PR (for win64.mak only as well): dlang/phobos#6825

@rainers
Copy link
Member Author

rainers commented Mar 19, 2019

@CyberShadow Sorry for the breakage. How does digger invoke make?

As you noticed this is for win64.mak only (it is also used to build model 32mscoff). I wouldn't expect dmc to work in a path with spaces to begin with, so there is little need to patch win32.mak.

The default path for VS installations contain spaces, though. The previous version of the makefiles was quite a mess: some paths were expected to be quoted, some not. Some were forwarded with pretty broken escaping, e.g. "AR=\$(AR)"\"" should have been "AR=\"$(AR)\"".

The basic idea of the change is to unify that and simplify specifiying arguments by "AR=<path with paces>", so the variables themselves never contain quotes. Being quoted when invoked also makes it agnostic to using / or \ in the path.

@CyberShadow
Copy link
Member

@CyberShadow Sorry for the breakage.

No problem, Digger's goal is to deal with breakages like these throughout D's history.

How does digger invoke make?

I just finished implementing the workaround:
CyberShadow/ae@b4a0312

The default path for VS installations contain spaces, though. The previous version of the makefiles was quite a mess: some paths were expected to be quoted, some not. Some were forwarded with pretty broken escaping, e.g. "AR=\$(AR)"\"" should have been "AR=\"$(AR)\"".

Yes, combined with cmd.exe escaping it was quite messy:

digger: Running: "make" -f win64.mak ... ^"CC=\^"C:\...\cl.exe\^"^" ^"LD=\^"...

The basic idea of the change is to unify that and simplify specifiying arguments by "AR=<path with paces>", so the variables themselves never contain quotes. Being quoted when invoked also makes it agnostic to using / or \ in the path.

I think at some point for posix.mak the lack of quoting was actually abused to add switches to CC and such, but I don't think this is the case for the Windows makefiles.

@rainers
Copy link
Member Author

rainers commented Mar 19, 2019

I just finished implementing the workaround:

Thanks, looks good.

digger: Running: "make" -f win64.mak ... ^"CC=^"C:...\cl.exe^"^" ^"LD=^"...

Wow, that looks even worse than what I used until recently.

I think at some point for posix.mak the lack of quoting was actually abused to add switches to CC and such, but I don't think this is the case for the Windows makefiles.

Yeah, that's a possible abuse. I didn't need it, and I hope noone else did ;-)

@MartinNowak
Copy link
Member

@CyberShadow
Copy link
Member

Yes, you'll need to remove quoting for Phobos/Druntime makefile invocations.

BTW, your quote function doesn't look quite in line with how cmd / CommandLineToArgvW parse their input. I recommend refactoring command line building to work on string[] instead of concatenating strings. Since you use spawnShell, escapeShellCommand should be appropriate.

@rainers
Copy link
Member Author

rainers commented Mar 28, 2019

Sorry for the breakage. I was already wondering why the nightlies are missing... See dlang/installer#368

@MartinNowak
Copy link
Member

Thanks for the fix :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants