Skip to content

msvc: #1687: handle case where output file is a directory #1836

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

Closed

Conversation

AudranDoublet
Copy link
Contributor

As described in #1687, MSBuild may provide as output file (/Fo) a folder, ending with a trailing backslash, for example /FoRelease\.

msvc detects this case and chose {folder}/{input_file_name}.obj as output file. For example, for /cfoo.c /FoRelease\, the expected output path (by linker and msbuild) is Release/foo.obj.

Currently, we would use Release.obj, leading to:

  • concurrent write to the same object if the project contains multiple source
  • output file can't be found by other MSVC tools

The proposed fix simply check if the std::path::Path contains a trailing backslash (see https://users.rust-lang.org/t/trailing-in-paths/43166) and correctly guess the path if so.

@@ -788,7 +788,20 @@ pub fn parse_arguments(
);
}
Some(o) => {
if o.extension().is_none() && compilation {
if o.as_os_str()
Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry for the latency.
compilation is gone from the check, is that expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Np. It is intentional, at least. compilation is checked a bit earlier in this function (l760): this check was always true

@sylvestre sylvestre force-pushed the bug/msvc/1687-guess-obj-name branch from a61a9a3 to cec7c09 Compare January 26, 2024 08:28
@sylvestre sylvestre force-pushed the bug/msvc/1687-guess-obj-name branch from cec7c09 to d511d09 Compare February 20, 2024 12:41
@sylvestre sylvestre force-pushed the bug/msvc/1687-guess-obj-name branch from d511d09 to 44905c6 Compare February 22, 2024 07:52
@sylvestre
Copy link
Collaborator

rustfmt isn't happy and some builds are failing
please reopen when they have been fixed

@sylvestre sylvestre closed this Feb 22, 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