---

** [bugs:#149] missing prototypes for GCC __atomic_* builtins**

**Status:** open
**Group:** Bug
**Created:** Mon Nov 10, 2014 06:43 PM UTC by Ben Liblit
**Last Updated:** Mon Nov 10, 2014 06:43 PM UTC
**Owner:** nobody

gcc-4.7 introduced a new suite of builtins for atomic operations. These 
`__atomic_*` builtins are intended to replace the older `__sync_*` builtins, 
although the latter are being retained for backward compatibility.  CIL does 
not have any inbuilt prototypes for these newer `__atomic_*` builtins.  If any 
code uses them, CIL generates generic (and wrong) prototypes for what it thinks 
are calls to ordinary, undeclared functions.  These explicit prototypes then 
result in undefined symbol references in the compiled object files, which in 
turn prevent the CIL-transformed program from linking.  This is especially of 
concern to me because the version of GNOME that will ship with Fedora 21 now 
uses these `__atomic_*` builtins for various purposes.  Thus, this CIL bug 
prevents me from building instrumented versions of GNOME applications, which is 
a fairly important thing for me to do.

The attached C source file demonstrates the problem, though without any GNOME 
dependencies.  This source file compiles just fine using `gcc test.c`.  
However, when compiled using `cilly test.c`, we get a compile-time warning 
about `conflicting types for built-in function '__atomic_load_4'`, and then a 
link-time error about `undefined reference to '__atomic_load_4'`.  Inspecting 
intermediate files clearly shows that the cilly-compiled object file has an 
undefined reference to `__atomic_load_4`, but the gcc-compiled object file does 
not.

See 
<https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html#g_t_005f_005fatomic-Builtins>
 for details about the types of these builtin functions.  Note that most are 
overloaded to work with multiple types, similar to the overloading of 
`__sync_*`.  I hope that this will be a relatively easy fix by creating new CIL 
builtin entries for `__atomic_*` similar to those CIL already has for 
`__sync_*`.


---

Sent from sourceforge.net because cil-users@lists.sourceforge.net is subscribed 
to https://sourceforge.net/p/cil/bugs/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/cil/admin/bugs/options.  Or, if this is a mailing 
list, you can unsubscribe from the mailing list.
------------------------------------------------------------------------------
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to