This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Implement -Wa,-mfpu and friends for assemblers
ClosedPublic

Authored by rengolin on Jul 13 2015, 8:41 AM.

Details

Summary

This patch allows Clang to pass on -Wa,-mfpu, -Wa,-mhwdiv and
-Wa,-mcpu to the integrated assembler (via target-features), but
-march is still not being passed, but validated.

Fixes PR20700. Depends on D11147.

Diff Detail

Event Timeline

rengolin updated this revision to Diff 29579.Jul 13 2015, 8:41 AM
rengolin retitled this revision from to [ARM] Implement -Wa,-mfpu and friends for assemblers.
rengolin updated this object.
rengolin set the repository for this revision to rL LLVM.
rengolin added a subscriber: cfe-commits.
rengolin updated this revision to Diff 29658.Jul 14 2015, 3:04 AM
rengolin added a reviewer: rnk.
rengolin removed rL LLVM as the repository for this revision.

More info.

Gentle ping. I'd like to get this into 3.7.

joerg added a subscriber: joerg.Jul 18 2015, 2:49 AM

I find it confusing that both -mcpu and -Wa,-mcpu are honoured. Shouldn't be warn about conflicts?

I find it confusing that both -mcpu and -Wa,-mcpu are honoured. Shouldn't be warn about conflicts?

My reasoning is that in build systems, CFLAGS is set differently, and where people use the compiler to assemble files, it's common to have ASFLAGS as a composition of CFLAGS and extra options, like -Wa flags. FWIW, GCC doesn't warn either.

joerg added a comment.Jul 18 2015, 1:15 PM

My point remains that -mcpu is already passed to the assembler, so having both -Wa,-mcpu and -mcpu and using one over the other *independent* of order is violates POLA.

So, what do you suggest?

A warning might break -Werror builds that already depend on this option to work.

Checking the last option is not possible using filters, since they have different types.

Replacing -Wa,-mfpu by -mfpu Arg inplace (to allow for last-of filtering) is not possible, since the ArgList is const.

When there is only -Wa and no -mfpu, not doing anything gets the wrong behaviour.

Any other ideas?

cheers,
--renato

rnk edited edge metadata.Jul 22 2015, 10:36 AM

Sorry for ignoring this. I looked at it, didn't like the approach, but couldn't think of a better one.

Here's a dumb idea: what if we alias -Wa,-mcpu= to -mcpu=? This would have the unintended side effect of making -Wa,-mcpu affect the CPU used for *compilation* in addition to assembly, but that seems like not a very big deal. If that's OK, it solves the whole getLastArg problem without complicating the driver C++ code.

lib/Driver/Tools.cpp
536

You probably want to clang-format the patch.

rengolin updated this revision to Diff 30366.Jul 22 2015, 10:52 AM
rengolin edited edge metadata.

Now warning over double use of naked -mxxx and asm -Wa,-mxxx.

Also, improving the tests.

In D11148#209873, @rnk wrote:

Sorry for ignoring this. I looked at it, didn't like the approach, but couldn't think of a better one.

Welcome to my world... This is not my first attempt... :)

Here's a dumb idea: what if we alias -Wa,-mcpu= to -mcpu=? This would have the unintended side effect of making -Wa,-mcpu affect the CPU used for *compilation* in addition to assembly, but that seems like not a very big deal. If that's OK, it solves the whole getLastArg problem without complicating the driver C++ code.

It would, but the behaviour that makes most sense if for the -Wa to override the naked options for the assembler, and never be used for the compiler. If we merge them, -Wa options will work for compilation, too, and won't override naked options when it should.

rengolin updated this revision to Diff 30379.Jul 22 2015, 11:41 AM

Clang format

rengolin marked an inline comment as done.Jul 23 2015, 11:07 AM

Ping?

I know this is boring, but it's an important missing feature.

rnk accepted this revision.Jul 27 2015, 4:03 PM
rnk edited edge metadata.

lgtm

lib/Driver/Tools.cpp
742–743

Can you make the capitalization of the 'd' in HDivArg and WaHdiv match? I don't care which way you go.

This revision is now accepted and ready to land.Jul 27 2015, 4:03 PM
rengolin closed this revision.Jul 27 2015, 4:45 PM

Thanks! r243353