[llvm-commits] [compiler-rt] r153735 - /compiler-rt/trunk/lib/atomic.c

Alexander Potapenko glider at google.com
Fri Mar 30 05:47:41 PDT 2012


Dunno if this is correct.

$ cat t.c
int main() {
  volatile __uint128_t a = 0;
  return (int)a;
}

$ clang t.c
$ clang t.c  -m32
t.c:2:12: error: unknown type name '__uint128_t'
  volatile __uint128_t a = 0;
           ^
1 diagnostic generated.

$ gcc t.c
$ gcc t.c -m32
t.c: In function ‘main’:
t.c:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘a’
t.c:2: error: ‘a’ undeclared (first use in this function)
t.c:2: error: (Each undeclared identifier is reported only once
t.c:2: error: for each function it appears in.)


On Fri, Mar 30, 2012 at 4:46 PM, David Chisnall <csdavec at swan.ac.uk> wrote:
> I can disable that if __LP64__ is not defined, but I think a better solution would be for clang to support __uint128_t in 32-bit mode...
>
> David
>
> On 30 Mar 2012, at 13:43, Alexander Potapenko wrote:
>
>> Apparently __uint128_t is a 32-bit-specific problem:
>>
>> $ /usr/local/google/asan/asan-llvm-trunk/llvm/build/Release+Asserts/bin/clang
>> -Wall -Werror -O3 -fomit-frame-pointer
>> --sysroot=/usr/local/google/asan/asan-llvm-trunk/llvm/projects/compiler-rt/SDKs/linux
>> -c -fPIC -o /usr/local/google/asan/asan-llvm-trunk/llvm/build/tools/clang/runtime/compiler-rt/clang_linux/full-i386/i386/SubDir.lib/atomic.o
>> /usr/local/google/asan/asan-llvm-trunk/llvm/projects/compiler-rt/lib/atomic.c
>> /usr/local/google/asan/asan-llvm-trunk/llvm/projects/compiler-rt/lib/atomic.c:153:3:
>> error: implicitly declaring library function 'memcpy' with type 'void
>> *(void *, const void *, unsigned long)' [-Werror]
>>  memcpy(dest, src, size);
>>  ^
>> /usr/local/google/asan/asan-llvm-trunk/llvm/projects/compiler-rt/lib/atomic.c:153:3:
>> note: please include the header <string.h> or explicitly provide a
>> declaration for 'memcpy'
>> /usr/local/google/asan/asan-llvm-trunk/llvm/projects/compiler-rt/lib/atomic.c:185:7:
>> error: implicitly declaring library function 'memcmp' with type 'int
>> (const void *, const void *, unsigned long)' [-Werror]
>>  if (memcmp(ptr, expected, size) == 0) {
>>      ^
>> /usr/local/google/asan/asan-llvm-trunk/llvm/projects/compiler-rt/lib/atomic.c:185:7:
>> note: please include the header <string.h> or explicitly provide a
>> declaration for 'memcmp'
>> 2 errors generated.
>>
>> (Ok)
>>
>> $ /usr/local/google/asan/asan-llvm-trunk/llvm/build/Release+Asserts/bin/clang
>> -Wall -Werror -O3 -fomit-frame-pointer -m32
>> --sysroot=/usr/local/google/asan/asan-llvm-trunk/llvm/projects/compiler-rt/SDKs/linux
>> -c -fPIC -o /usr/local/google/asan/asan-llvm-trunk/llvm/build/tools/clang/runtime/compiler-rt/clang_linux/full-i386/i386/SubDir.lib/atomic.o
>> /usr/local/google/asan/asan-llvm-trunk/llvm/projects/compiler-rt/lib/atomic.c
>>
>> /usr/local/google/asan/asan-llvm-trunk/llvm/projects/compiler-rt/lib/atomic.c:149:3:
>> error: use of undeclared identifier '__uint128_t'
>>  LOCK_FREE_CASES();
>> ...
>> (Bad)
>>
>>
>>
>>
>> On Fri, Mar 30, 2012 at 12:53 PM, Alexander Potapenko <glider at google.com> wrote:
>>> We're seeing several compilation failures on the ASan bot while building LLVM:
>>>
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/atomic.c:149:3:
>>> error: use of undeclared identifier '__uint128_t'
>>>  LOCK_FREE_CASES();
>>>  ^
>>>  COMPILE:   clang_linux/full-i386/i386:
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/comparedf2.c
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/atomic.c:137:26:
>>> note: expanded from macro 'LOCK_FREE_CASES'
>>>        LOCK_FREE_ACTION(__uint128_t);\
>>> ...
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/atomic.c:153:3:
>>> error: implicitly declaring library function 'memcpy' with type 'void
>>> *(void *, const void *, unsigned int)' [-Werror]
>>>  memcpy(dest, src, size);
>>>  ^
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/atomic.c:153:3:
>>> note: please include the header <string.h> or explicitly provide a
>>> declaration for 'memcpy'
>>> ...
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/atomic.c:185:7:
>>> error: implicitly declaring library function 'memcmp' with type 'int
>>> (const void *, const void *, unsigned int)' [-Werror]
>>>  if (memcmp(ptr, expected, size) == 0) {
>>>      ^
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/atomic.c:185:7:
>>> note: please include the header <string.h> or explicitly provide a
>>> declaration for 'memcmp'
>>> ...
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/atomic.c:247:1:
>>> error: unknown type name '__uint128_t'
>>> OPTIMISED_CASES
>>> ^
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/atomic.c:220:39:
>>> note: expanded from macro 'OPTIMISED_CASES'
>>>  OPTIMISED_CASE(16, IS_LOCK_FREE_16, __uint128_t)\
>>>                                      ^
>>> /usr/local/google/home/asanbot/b2/slave/linux/build/llvm/projects/compiler-rt/lib/atomic.c:236:26:
>>> note: expanded from macro 'OPTIMISED_CASE'
>>> void  __atomic_store_##n(type *dest, type val, int model) {\
>>>                         ^
>>> fatal error: too many errors emitted, stopping now [-ferror-limit=]
>>
>>
>>
>> --
>> Alexander Potapenko
>> Software Engineer
>> Google Moscow
>



-- 
Alexander Potapenko
Software Engineer
Google Moscow




More information about the llvm-commits mailing list