[cfe-dev] Advice for fixing some misguided code

Martin J. O'Riordan via cfe-dev cfe-dev at lists.llvm.org
Fri Aug 26 03:04:16 PDT 2016


I long while back, I added a static function to my 'Subtarget'
implementation that allows me to pass all of the '-cc1' arguments from CLang
to the LLVM backend.

 

The reason I added this was because I would routinely get examples of "bugs"
from developers that consisted of only assembly code, and no information
about how the compiler was invoked, nor the C or C++ source.

 

So I partially addressed this by placing all the '-cc1' options into a large
comment section at the end of each generated assembly file to help with my
diagnostics, and this information is passed from CLang to LLVM using this
call.

 

But this breaks the natural decoupling of the CLang front-end and the LLVM
backend, so that other clients of 'libclang' implicitly have this weak
extern reference.

 

Using the GCC or CLang compilers, the use of weak-externs is not a problem
so my additional function does not need to be linked into the image, but
with VC++ it is a problem as there is no real equivalent that I know of for
weak-extern; and this means that I cannot build many of the additional CLang
utilities unless I also link them against the back-end, which is not the
right thing to do.

 

I think that the right solution would be to decouple how I pass this
information from CLang to LLVM, and I would like to seek advice from the
community on how I might better implement this requirement.  Or if there is
an existing mechanism I could use to do this.

 

Thanks in advance,

 

            MartinO

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160826/912bb875/attachment.html>


More information about the cfe-dev mailing list