This is an archive of the discontinued LLVM Phabricator instance.

[Driver,X86] Ignore -mfpmath= for assembler input
ClosedPublic

Authored by MaskRay on Aug 28 2023, 12:11 PM.

Details

Summary

Some options are only claimed in AddX86TargetArgs/etc (called by
Clang::RenderTargetOptions).
For assembler input, Add*TargetArgs is not called. If an option is
unclaimed, it either leads to a -Wunused-command-line-argument warning
or an error (if TargetSpecific is set)

// clang '-###' --target=x86_64 -mfpmath=sse -c a.s
clang: error: unsupported option '-mfpmath=sse' for target 'x86_64'

For -mfpmath=, it's actually claimed by RenderFloatingPointOptions,
which should be moved to AddARMTargetArgs/AddX86TargetArgs later
(non-AArch32-non-x86 targets give a frontend error).
This change is localized and similar to D153691, for release/17.x
backporting.

Fix https://github.com/llvm/llvm-project/issues/65023

Diff Detail

Event Timeline

MaskRay created this revision.Aug 28 2023, 12:11 PM
Herald added a reviewer: ctetreau. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
MaskRay requested review of this revision.Aug 28 2023, 12:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2023, 12:11 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay added inline comments.Aug 28 2023, 12:16 PM
clang/lib/Driver/ToolChains/Arch/X86.cpp
121–127

Note: ClangAs::ConstructJob doesn't call Clang::RenderTargetOptions (and can't as the function is in Clang::). bool ForAS is a workaround used by ARM and will also be used by AArch64. I plan to clean this up at some point, but for release/17.x I intentionally make it simple.

thesamesam accepted this revision.Aug 28 2023, 1:27 PM
This revision is now accepted and ready to land.Aug 28 2023, 1:27 PM

Tested by parona on Libera Chat IRC. Thanks!

This revision was automatically updated to reflect the committed changes.