Skip to content

tool/cosmocc: Properly handle dependency output #1091

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

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

trungnt2910
Copy link
Collaborator

@trungnt2910 trungnt2910 commented Jan 18, 2024

a2753de contains some regressions, causing fixupobj to be inappropriately suppressed when -MD or -MMD is passed.

This commit reverts most changes by a2753de, and:

  • Treats all invocations of the compiler with -M and -MM as with the cpp intent, since these flags imply -E.
  • Handles the dependency output path specified by -MF.
    • This is trivial for cosmocross since the script does not throw objects to and from temporary directories.
    • For cosmocc, the file names are calculated based on the -MF value provided by the user. If this flag is not specified, the script generates the file name based on the output file using GCC rules. Then, before calling the real compilers, an additional -MF flag is passed to override the dependency outputs with mangled file names.

a2753de contains some regressions, causing `fixupobj` to be
inappropriately suppressed when `-MD` or `-MMD` is passed.

This commit reverts most changes by a2753de, and:
- Treats all invocations of the compiler with `-M` and `-MM` as with the
`cpp` intent, since these flags imply `-E`.
- Handle the dependency output path specified by `-MF`.
  + This is trivial for `cosmocross` since the script does not throw
  objects to and from temporary directories.
  + For `cosmocc`, the file names are calculated based on the `-MF`
  value provided by the user. If this flag is not specified, the script
  generates the file name based on the output file using GCC rules.
  Then, before calling the real compilers, an additional `-MF` flag is
  passed to override the dependency outputs with mangled file names.
Copy link
Owner

@jart jart left a comment

Choose a reason for hiding this comment

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

Thank you!

@jart jart merged commit 83a8686 into jart:master Jan 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