Bug#903709: atomic_init() and friends failing on clang

Peter Palfrader weasel at debian.org
Fri Jul 13 16:01:38 BST 2018


Package: clang-6.0
Version: 1:6.0.1-2
Severity: normal

Clang fails to compile the following snippet on (at least) amd64 and i386
while gcc builds it:

#include <stdatomic.h>
void increment(atomic_size_t *arg) {
  atomic_fetch_add(arg, 1);
}

Maybe something is fishy with the include paths, but it's not clear to me.

| [sid-amd64-sbuild] weasel at build-x86-07:~$ clang -v -c x.c 
| clang version 6.0.1-2 (tags/RELEASE_601/final)
| Target: x86_64-pc-linux-gnu
| Thread model: posix
| InstalledDir: /usr/bin
| Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
| Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
| Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
| Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
| Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
| Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
| Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
| Candidate multilib: .;@m64
| Selected multilib: .;@m64
|  "/usr/lib/llvm-6.0/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name x.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -coverage-notes-file /home/weasel/x.gcno -resource-dir /usr/lib/llvm-6.0/lib/clang/6.0.1 -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-6.0/lib/clang/6.0.1/include -internal-externc-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/weasel -ferror-limit 19 -fmessage-length 141 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o x.o -x c x.c
| clang -cc1 version 6.0.1 based upon LLVM 6.0.1 default target x86_64-pc-linux-gnu
| ignoring nonexistent directory "/include"
| #include "..." search starts here:
| #include <...> search starts here:
|  /usr/local/include
|  /usr/lib/llvm-6.0/lib/clang/6.0.1/include
|  /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/include
|  /usr/include/x86_64-linux-gnu
|  /usr/include
| End of search list.
| x.c:3:3: error: address argument to atomic operation must be a pointer to integer or pointer ('atomic_size_t *'
|       (aka '_Atomic(unsigned long) *') invalid)
|   atomic_fetch_add(arg, 1);
|   ^~~~~~~~~~~~~~~~~~~~~~~~
| /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/include/stdatomic.h:192:36: note: expanded from macro 'atomic_fetch_add'
| #define atomic_fetch_add(PTR, VAL) __atomic_fetch_add ((PTR), (VAL),    \
|                                    ^                   ~~~~~
| 1 error generated.
| [sid-amd64-sbuild] weasel at build-x86-07:~$ echo $?
| 1


Note that it builds with -nostdinc (albeit with warnings):

| [sid-amd64-sbuild] weasel at build-x86-07:~$ clang -v -nostdinc -I/usr/lib/llvm-6.0/lib/clang/6.0.1/include -c x.c
| clang version 6.0.1-2 (tags/RELEASE_601/final)
| Target: x86_64-pc-linux-gnu
| Thread model: posix
| InstalledDir: /usr/bin
| Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
| Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
| Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
| Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
| Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
| Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
| Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
| Candidate multilib: .;@m64
| Selected multilib: .;@m64
|  "/usr/lib/llvm-6.0/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name x.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -coverage-notes-file /home/weasel/x.gcno -nostdsysteminc -nobuiltininc -resource-dir /usr/lib/llvm-6.0/lib/clang/6.0.1 -I /usr/lib/llvm-6.0/lib/clang/6.0.1/include -fdebug-compilation-dir /home/weasel -ferror-limit 19 -fmessage-length 141 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o x.o -x c x.c
| clang -cc1 version 6.0.1 based upon LLVM 6.0.1 default target x86_64-pc-linux-gnu
| #include "..." search starts here:
| #include <...> search starts here:
|  /usr/lib/llvm-6.0/lib/clang/6.0.1/include
| End of search list.
| In file included from x.c:1:
| In file included from /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdatomic.h:35:
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:186:10: warning: '__int_least32_t' macro redefined [-Wmacro-redefined]
| # define __int_least32_t int32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:112:10: note: previous definition is here
| # define __int_least32_t int64_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:187:10: warning: '__uint_least32_t' macro redefined [-Wmacro-redefined]
| # define __uint_least32_t uint32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:113:10: note: previous definition is here
| # define __uint_least32_t uint64_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:188:10: warning: '__int_least16_t' macro redefined [-Wmacro-redefined]
| # define __int_least16_t int32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:114:10: note: previous definition is here
| # define __int_least16_t int64_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:189:10: warning: '__uint_least16_t' macro redefined [-Wmacro-redefined]
| # define __uint_least16_t uint32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:115:10: note: previous definition is here
| # define __uint_least16_t uint64_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:190:10: warning: '__int_least8_t' macro redefined [-Wmacro-redefined]
| # define __int_least8_t int32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:116:10: note: previous definition is here
| # define __int_least8_t int64_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:191:10: warning: '__uint_least8_t' macro redefined [-Wmacro-redefined]
| # define __uint_least8_t uint32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:117:10: note: previous definition is here
| # define __uint_least8_t uint64_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:219:10: warning: '__int_least16_t' macro redefined [-Wmacro-redefined]
| # define __int_least16_t int16_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:188:10: note: previous definition is here
| # define __int_least16_t int32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:220:10: warning: '__uint_least16_t' macro redefined [-Wmacro-redefined]
| # define __uint_least16_t uint16_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:189:10: note: previous definition is here
| # define __uint_least16_t uint32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:221:10: warning: '__int_least8_t' macro redefined [-Wmacro-redefined]
| # define __int_least8_t int16_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:190:10: note: previous definition is here
| # define __int_least8_t int32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:222:10: warning: '__uint_least8_t' macro redefined [-Wmacro-redefined]
| # define __uint_least8_t uint16_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:191:10: note: previous definition is here
| # define __uint_least8_t uint32_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:238:10: warning: '__int_least8_t' macro redefined [-Wmacro-redefined]
| # define __int_least8_t int8_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:221:10: note: previous definition is here
| # define __int_least8_t int16_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:239:10: warning: '__uint_least8_t' macro redefined [-Wmacro-redefined]
| # define __uint_least8_t uint8_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:222:10: note: previous definition is here
| # define __uint_least8_t uint16_t
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:376:11: warning: '__int32_c_suffix' macro redefined [-Wmacro-redefined]
| #  define __int32_c_suffix __INT32_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:301:11: note: previous definition is here
| #  define __int32_c_suffix __INT64_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:377:11: warning: '__int16_c_suffix' macro redefined [-Wmacro-redefined]
| #  define __int16_c_suffix __INT32_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:302:11: note: previous definition is here
| #  define __int16_c_suffix __INT64_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:378:11: warning: '__int8_c_suffix' macro redefined [-Wmacro-redefined]
| #  define __int8_c_suffix  __INT32_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:303:12: note: previous definition is here
| #  define  __int8_c_suffix __INT64_C_SUFFIX__
|            ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:414:11: warning: '__int16_c_suffix' macro redefined [-Wmacro-redefined]
| #  define __int16_c_suffix __INT16_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:377:11: note: previous definition is here
| #  define __int16_c_suffix __INT32_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:415:11: warning: '__int8_c_suffix' macro redefined [-Wmacro-redefined]
| #  define __int8_c_suffix  __INT16_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:378:11: note: previous definition is here
| #  define __int8_c_suffix  __INT32_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:435:11: warning: '__int8_c_suffix' macro redefined [-Wmacro-redefined]
| #  define __int8_c_suffix __INT8_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:415:11: note: previous definition is here
| #  define __int8_c_suffix  __INT16_C_SUFFIX__
|           ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:569:10: warning: '__INT_LEAST32_MIN' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST32_MIN   INT32_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:478:10: note: previous definition is here
| # define __INT_LEAST32_MIN   INT64_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:570:10: warning: '__INT_LEAST32_MAX' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST32_MAX   INT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:479:10: note: previous definition is here
| # define __INT_LEAST32_MAX   INT64_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:571:10: warning: '__UINT_LEAST32_MAX' macro redefined [-Wmacro-redefined]
| # define __UINT_LEAST32_MAX UINT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:480:10: note: previous definition is here
| # define __UINT_LEAST32_MAX UINT64_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:572:10: warning: '__INT_LEAST16_MIN' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST16_MIN   INT32_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:481:10: note: previous definition is here
| # define __INT_LEAST16_MIN   INT64_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:573:10: warning: '__INT_LEAST16_MAX' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST16_MAX   INT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:482:10: note: previous definition is here
| # define __INT_LEAST16_MAX   INT64_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:574:10: warning: '__UINT_LEAST16_MAX' macro redefined [-Wmacro-redefined]
| # define __UINT_LEAST16_MAX UINT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:483:10: note: previous definition is here
| # define __UINT_LEAST16_MAX UINT64_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:575:10: warning: '__INT_LEAST8_MIN' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST8_MIN    INT32_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:484:10: note: previous definition is here
| # define __INT_LEAST8_MIN    INT64_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:576:10: warning: '__INT_LEAST8_MAX' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST8_MAX    INT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:485:10: note: previous definition is here
| # define __INT_LEAST8_MAX    INT64_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:577:10: warning: '__UINT_LEAST8_MAX' macro redefined [-Wmacro-redefined]
| # define __UINT_LEAST8_MAX  UINT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:486:10: note: previous definition is here
| # define __UINT_LEAST8_MAX  UINT64_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:613:10: warning: '__INT_LEAST16_MIN' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST16_MIN   INT16_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:572:10: note: previous definition is here
| # define __INT_LEAST16_MIN   INT32_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:614:10: warning: '__INT_LEAST16_MAX' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST16_MAX   INT16_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:573:10: note: previous definition is here
| # define __INT_LEAST16_MAX   INT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:615:10: warning: '__UINT_LEAST16_MAX' macro redefined [-Wmacro-redefined]
| # define __UINT_LEAST16_MAX UINT16_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:574:10: note: previous definition is here
| # define __UINT_LEAST16_MAX UINT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:616:10: warning: '__INT_LEAST8_MIN' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST8_MIN    INT16_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:575:10: note: previous definition is here
| # define __INT_LEAST8_MIN    INT32_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:617:10: warning: '__INT_LEAST8_MAX' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST8_MAX    INT16_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:576:10: note: previous definition is here
| # define __INT_LEAST8_MAX    INT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:618:10: warning: '__UINT_LEAST8_MAX' macro redefined [-Wmacro-redefined]
| # define __UINT_LEAST8_MAX  UINT16_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:577:10: note: previous definition is here
| # define __UINT_LEAST8_MAX  UINT32_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:635:10: warning: '__INT_LEAST8_MIN' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST8_MIN    INT8_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:616:10: note: previous definition is here
| # define __INT_LEAST8_MIN    INT16_MIN
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:636:10: warning: '__INT_LEAST8_MAX' macro redefined [-Wmacro-redefined]
| # define __INT_LEAST8_MAX    INT8_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:617:10: note: previous definition is here
| # define __INT_LEAST8_MAX    INT16_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:637:10: warning: '__UINT_LEAST8_MAX' macro redefined [-Wmacro-redefined]
| # define __UINT_LEAST8_MAX  UINT8_MAX
|          ^
| /usr/lib/llvm-6.0/lib/clang/6.0.1/include/stdint.h:618:10: note: previous definition is here
| # define __UINT_LEAST8_MAX  UINT16_MAX
|          ^
| 36 warnings generated.
| [sid-amd64-sbuild] weasel at build-x86-07:~$ echo $?
| 0


cf. tor#26779: atomic_init() and friends failing on clang
    https://bugs.torproject.org/26779
-- 
                            |  .''`.       ** Debian **
      Peter Palfrader       | : :' :      The  universal
 https://www.palfrader.org/ | `. `'      Operating System
                            |   `-    https://www.debian.org/



More information about the Pkg-llvm-team mailing list