Question about LTO pass driver level flags to the plugin

Hi all,
I often meet the problem cause by Link::ConstructJob does not pass
driver level flags relevant to LTO code generation down to the plugin.
So when I compile program like:

clang -c a.c -o a.o -mcpu=cortex-a9 -mfloat-abi=hard -mfpu=vfpv3 -flto
clang -c main.c -o main.o -mcpu=cortex-a9 -mfloat-abi=hard -mfpu=vfpv3
clang a.o main.o -o main -mcpu=cortex-a9 -mfloat-abi=hard -mfpu=vfpv3 -flto

I will got error like:

ld: error: lto-llvm.o-SchABH uses VFP register arguments, output does not

So I need to modify Link::ConstructJob to pass “-plugin-opt=-float-abi=hard” and vfpv3 feature to the plugin.

It’s tedious because some option may be missed in LTO code generation.

For example when I add a new option to llc, and add the same one in clang,

I also need to modify Link::ConstructJob to pass this option to plugin…
Is there a more general solution?


I think Bill's work on extending function attributes should fix this
at some point. The idea is that when building a file with, for
example, -mno-sse or -march=core2 the IL functions would get an
attribute equivalent to those options.

That way you can even have files that use sse and files that don't
LTOed together.

Bill, is that the case?