public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8'
@ 2014-09-25  7:08 mathieu.malaterre at gmail dot com
  2014-09-25  7:16 ` [Bug c/63368] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2014-09-25  7:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368

            Bug ID: 63368
           Summary: undefined reference to `__sync_val_compare_and_swap_8'
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mathieu.malaterre at gmail dot com

If I am reading the online documentation properly:

https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins

__sync_val_compare_and_swap on some targets will result in a function call
(where direct code generation is not available or not yet implemented). 

It seems to be happening in my testcase, however __sync_val_compare_and_swap_8
does not seems to be defined anywhere else.

Steps:

$ cat t.c 
#include <stdint.h>

int main()
{
  int64_t x = 0, y = 1; 
  y = __sync_val_compare_and_swap(&x, x, y);
  return 0;
}
$ gcc t.c
/tmp/cc6JIpFx.o: In function `main':
t.c:(.text+0x64): undefined reference to `__sync_val_compare_and_swap_8'
collect2: ld returned 1 exit status
$ gcc t.c -lgcc_s
/tmp/ccu3ReMZ.o: In function `main':
t.c:(.text+0x64): undefined reference to `__sync_val_compare_and_swap_8'
collect2: ld returned 1 exit status
$ gcc t.c -lgcc
/tmp/ccO8gyeR.o: In function `main':
t.c:(.text+0x64): undefined reference to `__sync_val_compare_and_swap_8'
collect2: ld returned 1 exit status


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/63368] undefined reference to `__sync_val_compare_and_swap_8'
  2014-09-25  7:08 [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8' mathieu.malaterre at gmail dot com
@ 2014-09-25  7:16 ` pinskia at gcc dot gnu.org
  2014-09-25  7:31 ` [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits) mathieu.malaterre at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-09-25  7:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Libatomic includes them in 4.9 and above. As it says not yet implemented you
need one for the target you are using.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits)
  2014-09-25  7:08 [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8' mathieu.malaterre at gmail dot com
  2014-09-25  7:16 ` [Bug c/63368] " pinskia at gcc dot gnu.org
@ 2014-09-25  7:31 ` mathieu.malaterre at gmail dot com
  2014-09-25  7:34 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2014-09-25  7:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368

Mathieu Malaterre <mathieu.malaterre at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |---
            Summary|undefined reference to      |Provide an implementation
                   |`__sync_val_compare_and_swa |for
                   |p_8'                        |`__sync_val_compare_and_swa
                   |                            |p_8' on powerpc (32bits)

--- Comment #2 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
Thanks for the clarification.

I've re-open the bug for a request to support __sync_val_compare_and_swap
(64bits) on PowerPC 32bits.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits)
  2014-09-25  7:08 [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8' mathieu.malaterre at gmail dot com
  2014-09-25  7:16 ` [Bug c/63368] " pinskia at gcc dot gnu.org
  2014-09-25  7:31 ` [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits) mathieu.malaterre at gmail dot com
@ 2014-09-25  7:34 ` pinskia at gcc dot gnu.org
  2014-09-25  8:38 ` mathieu.malaterre at gmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-09-25  7:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-latomic is there already.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits)
  2014-09-25  7:08 [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8' mathieu.malaterre at gmail dot com
                   ` (2 preceding siblings ...)
  2014-09-25  7:34 ` pinskia at gcc dot gnu.org
@ 2014-09-25  8:38 ` mathieu.malaterre at gmail dot com
  2014-09-30  7:30 ` mathieu.malaterre at gmail dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2014-09-25  8:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368

--- Comment #4 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
As stated in my original report I am running a PowerPC/32bits machine (not an
ARM based one).

AFAIK gcc 4.9.1 does not provide such implementation [*]. Could you please
clarify what you mean by 'libatomic is there already' ?

[*]
% cat t.c            
#include <stdint.h>

int main()
{
  int64_t x = 0, y = 1; 
  y = __sync_val_compare_and_swap(&x, x, y);
  return 0;
}


% gcc -v t.c -latomic
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/powerpc-linux-gnu/4.9/lto-wrapper
Target: powerpc-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.1-15'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm
--disable-libquadmath --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-powerpc/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-powerpc
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-powerpc
--with-arch-directory=ppc --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-secureplt --disable-softfloat --with-cpu=default32
--disable-softfloat --enable-targets=powerpc-linux,powerpc64-linux
--enable-multiarch --with-long-double-128 --enable-multilib
--enable-checking=release --build=powerpc-linux-gnu --host=powerpc-linux-gnu
--target=powerpc-linux-gnu
Thread model: posix
gcc version 4.9.1 (Debian 4.9.1-15) 
COLLECT_GCC_OPTIONS='-v'
 /usr/lib/gcc/powerpc-linux-gnu/4.9/cc1 -quiet -v -imultiarch powerpc-linux-gnu
-D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux
-Asystem=linux -Asystem=unix -Asystem=posix t.c -msecure-plt -quiet -dumpbase
t.c -auxbase t -version -o /tmp/ccNTY4Ab.s
GNU C (Debian 4.9.1-15) version 4.9.1 (powerpc-linux-gnu)
    compiled by GNU C version 4.9.1, GMP version 6.0.0, MPFR version 3.1.2-p3,
MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/powerpc-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/powerpc-linux-gnu/4.9/../../../../powerpc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/powerpc-linux-gnu/4.9/include
 /usr/local/include
 /usr/lib/gcc/powerpc-linux-gnu/4.9/include-fixed
 /usr/include/powerpc-linux-gnu
 /usr/include
End of search list.
GNU C (Debian 4.9.1-15) version 4.9.1 (powerpc-linux-gnu)
    compiled by GNU C version 4.9.1, GMP version 6.0.0, MPFR version 3.1.2-p3,
MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c43d4b06b119d970361c68b09a8c4f80
COLLECT_GCC_OPTIONS='-v'
 as -v -a32 -mppc -many -mbig -o /tmp/cckOC6zg.o /tmp/ccNTY4Ab.s
GNU assembler version 2.24.51 (powerpc-linux-gnu) using BFD version (GNU
Binutils for Debian) 2.24.51.20140918
COMPILER_PATH=/usr/lib/gcc/powerpc-linux-gnu/4.9/:/usr/lib/gcc/powerpc-linux-gnu/4.9/:/usr/lib/gcc/powerpc-linux-gnu/:/usr/lib/gcc/powerpc-linux-gnu/4.9/:/usr/lib/gcc/powerpc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/powerpc-linux-gnu/4.9/:/usr/lib/gcc/powerpc-linux-gnu/4.9/../../../powerpc-linux-gnu/:/usr/lib/gcc/powerpc-linux-gnu/4.9/../../../../lib/:/lib/powerpc-linux-gnu/:/lib/../lib/:/usr/lib/powerpc-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/powerpc-linux-gnu/4.9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v'
 /usr/lib/gcc/powerpc-linux-gnu/4.9/collect2 -plugin
/usr/lib/gcc/powerpc-linux-gnu/4.9/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/powerpc-linux-gnu/4.9/lto-wrapper
-plugin-opt=-fresolution=/tmp/cc3I7gDk.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/
--build-id --eh-frame-hdr -V -m elf32ppclinux --hash-style=gnu -dynamic-linker
/lib/ld.so.1
/usr/lib/gcc/powerpc-linux-gnu/4.9/../../../powerpc-linux-gnu/crt1.o
/usr/lib/gcc/powerpc-linux-gnu/4.9/../../../powerpc-linux-gnu/crti.o
/usr/lib/gcc/powerpc-linux-gnu/4.9/crtbegin.o
-L/usr/lib/gcc/powerpc-linux-gnu/4.9
-L/usr/lib/gcc/powerpc-linux-gnu/4.9/../../../powerpc-linux-gnu
-L/usr/lib/gcc/powerpc-linux-gnu/4.9/../../../../lib -L/lib/powerpc-linux-gnu
-L/lib/../lib -L/usr/lib/powerpc-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/powerpc-linux-gnu/4.9/../../.. /tmp/cckOC6zg.o -latomic -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/powerpc-linux-gnu/4.9/crtend.o
/usr/lib/gcc/powerpc-linux-gnu/4.9/../../../powerpc-linux-gnu/crtn.o
GNU ld (GNU Binutils for Debian) 2.24.51.20140918
  Supported emulations:
   elf32ppclinux
   elf32ppc
   elf32ppcsim
   elf64ppc
/tmp/cckOC6zg.o: In function `main':
t.c:(.text+0x74): undefined reference to `__sync_val_compare_and_swap_8'
collect2: error: ld returned 1 exit status


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits)
  2014-09-25  7:08 [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8' mathieu.malaterre at gmail dot com
                   ` (3 preceding siblings ...)
  2014-09-25  8:38 ` mathieu.malaterre at gmail dot com
@ 2014-09-30  7:30 ` mathieu.malaterre at gmail dot com
  2015-05-28 12:09 ` mathieu.malaterre at gmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2014-09-30  7:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368

Mathieu Malaterre <mathieu.malaterre at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |VERIFIED
         Resolution|INVALID                     |WONTFIX

--- Comment #6 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
@Jonathan thanks for the clarification. I've moved the issue from
resolved/invalid to verified/wontfix. I guess no-one really works on ppc32
these days.

regards


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits)
  2014-09-25  7:08 [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8' mathieu.malaterre at gmail dot com
                   ` (4 preceding siblings ...)
  2014-09-30  7:30 ` mathieu.malaterre at gmail dot com
@ 2015-05-28 12:09 ` mathieu.malaterre at gmail dot com
  2021-08-16 22:07 ` glaubitz at physik dot fu-berlin.de
  2023-05-09  3:55 ` vital.had at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2015-05-28 12:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368

--- Comment #7 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
For anyone reading this. the comment "-latomic is there already." means:

replace __sync_val_compare_and_swap(ptr, oldval, newval) in your code with
__atomic_compare_exchange(ptr, &oldval, &newval, false, __ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST) then link with -latomic


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits)
  2014-09-25  7:08 [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8' mathieu.malaterre at gmail dot com
                   ` (5 preceding siblings ...)
  2015-05-28 12:09 ` mathieu.malaterre at gmail dot com
@ 2021-08-16 22:07 ` glaubitz at physik dot fu-berlin.de
  2023-05-09  3:55 ` vital.had at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: glaubitz at physik dot fu-berlin.de @ 2021-08-16 22:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368

--- Comment #8 from John Paul Adrian Glaubitz <glaubitz at physik dot fu-berlin.de> ---
FWIW, it seems the situation seems to be the same on 32-bit SPARC:

> https://reviews.llvm.org/D98575#2947973

So, I guess the suggested solution would be the one from Comment 7.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits)
  2014-09-25  7:08 [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8' mathieu.malaterre at gmail dot com
                   ` (6 preceding siblings ...)
  2021-08-16 22:07 ` glaubitz at physik dot fu-berlin.de
@ 2023-05-09  3:55 ` vital.had at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: vital.had at gmail dot com @ 2023-05-09  3:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368

Sergey Fedorov <vital.had at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vital.had at gmail dot com

--- Comment #9 from Sergey Fedorov <vital.had at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> -latomic is there already.

It does not work with `__sync*` builtins. `__sync_val_compare_and_swap_8`
remains undefined on `ppc`.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-05-09  3:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-25  7:08 [Bug c/63368] New: undefined reference to `__sync_val_compare_and_swap_8' mathieu.malaterre at gmail dot com
2014-09-25  7:16 ` [Bug c/63368] " pinskia at gcc dot gnu.org
2014-09-25  7:31 ` [Bug c/63368] Provide an implementation for `__sync_val_compare_and_swap_8' on powerpc (32bits) mathieu.malaterre at gmail dot com
2014-09-25  7:34 ` pinskia at gcc dot gnu.org
2014-09-25  8:38 ` mathieu.malaterre at gmail dot com
2014-09-30  7:30 ` mathieu.malaterre at gmail dot com
2015-05-28 12:09 ` mathieu.malaterre at gmail dot com
2021-08-16 22:07 ` glaubitz at physik dot fu-berlin.de
2023-05-09  3:55 ` vital.had at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).