[cfe-dev] Implementing "external" built-in functions

David Chisnall David.Chisnall at cl.cam.ac.uk
Fri Jul 19 12:01:02 PDT 2013


This is a particularly irritating misfeature of clang.  In some parts of compiler-rt, I've hacked around this with #pragma redefine_extname, which causes clang to see one name when doing this analysis but use another when emitting the object code.

I don't really understand the rationale for the error.  At best it should be a warning, but in my experience it's a warning with a 100% false positive rate...

David

On 19 Jul 2013, at 11:04, Emmanuel Blot <eblot.ml at gmail.com> wrote:

> Hi,
> 
> clang emits calls to external functions for built-in functions it
> cannot implement, the way GCC does:
> 
> From GCC doc about built-in functions for memory accesses:
> "Not all operations are supported by all target processors. If a
> particular operation cannot be implemented on the target processor, a
> warning will be generated and a call an external function will be
> generated. The external function will carry the same name as the
> builtin, with an additional suffix `_n' where n is the size of the
> data type."
> 
> Is is possible to implement those "external" built-in functions and
> compile them with clang? The "problem" is that clang recognizes their
> signature, and emit an error, such as:
> 
> error: definition of builtin function
>   '__sync_fetch_and_and_4'
> 
> I'm unable to find a clang front-end option switch to disable this behavior.
> What is the recommended way to compile such a built-in function?
> 
> I'm looking for a way to compile those functions in a dedicated
> library, outside the clang build tree.
> 
> Thanks,
> Emmanuel.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list