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

Fix compiler family detection issue with clang-cl on macOS #1328

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NobodyXu
Copy link
Collaborator

Fixed #1327

@NobodyXu NobodyXu requested a review from madsmtm December 22, 2024 13:57
@NobodyXu
Copy link
Collaborator Author

I can't know for sure if the compiler is clang-cl, so can't apply the workaround reliably.

Alternatively, we could combine cfg(macos) with accept cl flags check.

if both are true then it's likely clang-cl on macOS, which needs workaroud.

@NobodyXu NobodyXu requested a review from thomcc December 23, 2024 00:13
@madsmtm madsmtm added the bug label Jan 1, 2025
Copy link
Collaborator

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

It is not clear to me why we even support clang-cl on macOS and Linux? cl.exe is not something you'd run on those platforms, so why would you ever run clang-cl? (Not a blocker for fixing this, just something I'd like to understand ;) )

cfg(macos)

That's a bad idea IMO, since this problem is also present on Linux and Windows hosts, just less prominently since their root paths usually start with a lowercase letter (on Linux), or prefixed with the drive letter (on Windows), but that's not a requirement!

Actually, the -- separator seems to be supported by normal Clang too, so why don't we just do this workaround everywhere?

This would also avoid issues if the user did e.g. .file("-l").

@NobodyXu
Copy link
Collaborator Author

NobodyXu commented Jan 2, 2025

It is not clear to me why we even support clang-cl on macOS and Linux? cl.exe is not something you'd run on those platforms, so why would you ever run clang-cl?

Based on the original issue, I believe they are using cargo-xwin to cross compile to msvc windows from a unix environment.

Actually, the -- separator seems to be supported by normal Clang too, so why don't we just do this workaround everywhere?

Does gcc and other compiler support it?

If they mostly do, we can add -- to compiler detection.

This would also avoid issues if the user did e.g. .file("-l").

Good idea

@madsmtm
Copy link
Collaborator

madsmtm commented Jan 2, 2025

Does gcc and other compiler support it?

$ touch foo.c
$ clang -c -- foo.c
$ gcc -c -- foo.c
gcc: error: unrecognized command-line option '--'

Doesn't seem like it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler family detection issue with clang-cl on macOS
2 participants