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

clang reports that -mcpu= option is unsupported when used together with --version #64958

Closed
mgabka opened this issue Aug 24, 2023 · 4 comments
Closed
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

Comments

@mgabka
Copy link
Contributor

mgabka commented Aug 24, 2023

When running:
clang -mcpu=native -v:
on X86 we can see following error:
clang: error: unsupported option '-mcpu=' for target 'x86_64-unknown-linux-gnu'
or
clang: error: unsupported option '-mcpu=' for target 'aarch64-unknown-linux-gnu'
when executed on aarch64.

clang 16 was fine with it, the issue exists with clang 17 rc3 and on the main branch.

@mgabka mgabka added the clang Clang issues not falling into any other category label Aug 24, 2023
@EugeneZelenko EugeneZelenko added clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' and removed clang Clang issues not falling into any other category labels Aug 24, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 24, 2023

@llvm/issue-subscribers-clang-driver

@MaskRay
Copy link
Member

MaskRay commented Aug 25, 2023

-mcpu= is invalid for x86. GCC prints a warning while Clang prints an error. https://maskray.me/blog/2022-08-28-march-mcpu-mtune

% gcc -mcpu=native -c q.c
gcc: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead

-mcpu= can be used with AArch64.

I agree that the current diagnostic is not great[1], but do you have a specific reason to use other options along with -v without an input file? This is a corner case that Clang does not handle well.

% ~/llvm-prebuilt/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang -march=native -v
...
clang-16: warning: argument unused during compilation: '-march=native' [-Wunused-command-line-argument]
% ~/llvm-prebuilt/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/clang -march=native -Werror -v
...
clang-16: error: argument unused during compilation: '-march=native' [-Werror,-Wunused-command-line-argument]
clang-16: error: argument unused during compilation: '-Werror' [-Werror,-Wunused-command-line-argument]

[1]: Without an input file, clangDriver doesn't create jobs for actions. ConstructJob is not called. Most options are not claimed.

@mgabka
Copy link
Contributor Author

mgabka commented Aug 29, 2023

I hit it when using spec2k17, from what I can see in the compiler detection stage it is applying all the optimization flags and append at the end "-v" to detect compiler version.

mgabka added a commit that referenced this issue Sep 11, 2023
…ons when there is no compiler jobs

The upstream commit: https://reviews.llvm.org/D151590
added a new flag to mark target specific compiler options.

The side effect of it was that in cases when -### or -v is used without any
input file, clang started emitting an error.
It happened like that becasue there is no compilation actions created
which could consume/verify these target specific options.

This patch changes that error to a warning about unused option in situations
when there is no actions and still generates error when there are actions.

Fix for #64958

Differential Revision: https://reviews.llvm.org/D159361
@mgabka mgabka closed this as completed Sep 11, 2023
@mgabka
Copy link
Contributor Author

mgabka commented Sep 11, 2023

Fixed by https://reviews.llvm.org/D159361

ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this issue Sep 19, 2023
…ons when there is no compiler jobs

The upstream commit: https://reviews.llvm.org/D151590
added a new flag to mark target specific compiler options.

The side effect of it was that in cases when -### or -v is used without any
input file, clang started emitting an error.
It happened like that becasue there is no compilation actions created
which could consume/verify these target specific options.

This patch changes that error to a warning about unused option in situations
when there is no actions and still generates error when there are actions.

Fix for llvm#64958

Differential Revision: https://reviews.llvm.org/D159361
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
Development

No branches or pull requests

4 participants