Re: Problem with C11 _Atomic
On Tue, Jan 02, 2018 at 03:17:14PM +0100, Pierre DAVID wrote: > On Mon, Jan 01, 2018 at 11:09:07PM +0200, Konstantin Belousov wrote: > >clang issues a calls to libatomic, which we do not provide. > >As a workaround, use the following command to compile. The resulting > >binary works on all practically usable machines. > > $ cc -march=core2 source.c > >You might want to turn off sse3/4.1 if you are concerned about older > >pentium4. > > > > Thanks for your help. I wish that the C11 status of FreeBSD will soon > be complete out of the box, without the help of such a hack. This is not FreeBSD but clang. Also I looked at the generated reference, and the referenced symbol was absent in the gcc' 7.2.0 libatomic. Same common problem with i386 and same cmpxchg8b is popular because the default arch is i486. This is a clang way of operations. ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Problem with C11 _Atomic
On Mon, Jan 01, 2018 at 11:09:07PM +0200, Konstantin Belousov wrote: On Mon, Jan 01, 2018 at 09:47:40PM +0100, Pierre DAVID wrote: Hi, I'm on a recent current: FreeBSD biceps.ma.maison 12.0-CURRENT FreeBSD 12.0-CURRENT #2 r327239: Wed Dec 27 18:25:46 CET 2017 p...@biceps.ma.maison:/usr/obj/usr/src/amd64.amd64/sys/BICEPS amd64 with clang 5.0.1: FreeBSD clang version 5.0.1 (tags/RELEASE_501/final 320880) (based on LLVM 5.0.1) Target: x86_64-unknown-freebsd12.0 Thread model: posix InstalledDir: /usr/bin I'm having a problem with the following source file: -- #include struct foo { int f1 ; char f2 ; int f3 ; } ; _Atomic struct foo a ; struct foo b ; int main (int argc, char *argv []) { b = (struct foo) {.f1 = 5, .f2 = 7, .f3 = 9 } ; // atomic_store (&a, b) ; a = b ; } -- This code does not compile/link with: % cc foo.c -lstdthreads /tmp/foo-a0ef26.o: In function `main': foo.c:(.text+0x63): undefined reference to `__sync_lock_test_and_set_16' cc: error: linker command failed with exit code 1 (use -v to see invocation) The gcc internal seems to be linked as "cc -v" told me: % cc -v foo.c -lstdthreads ... "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/foo-d7a21b.o -lstdthreads -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o The problem occurs with "atomic_store(&a, b)" as well as with "a = b". If I remove the f3 member, the struct foo is only 8 bytes and the code compiles/links. Did I missed something? clang issues a calls to libatomic, which we do not provide. As a workaround, use the following command to compile. The resulting binary works on all practically usable machines. $ cc -march=core2 source.c You might want to turn off sse3/4.1 if you are concerned about older pentium4. Thanks for your help. I wish that the C11 status of FreeBSD will soon be complete out of the box, without the help of such a hack. Pierre ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Problem with C11 _Atomic
On Mon, Jan 01, 2018 at 09:47:40PM +0100, Pierre DAVID wrote: > Hi, > > I'm on a recent current: > FreeBSD biceps.ma.maison 12.0-CURRENT FreeBSD 12.0-CURRENT #2 r327239: > Wed Dec 27 18:25:46 CET 2017 > p...@biceps.ma.maison:/usr/obj/usr/src/amd64.amd64/sys/BICEPS amd64 > > with clang 5.0.1: > FreeBSD clang version 5.0.1 (tags/RELEASE_501/final 320880) (based on > LLVM 5.0.1) > Target: x86_64-unknown-freebsd12.0 > Thread model: posix > InstalledDir: /usr/bin > > I'm having a problem with the following source file: > > -- > #include > > struct foo > { > int f1 ; > char f2 ; > int f3 ; > } ; > > _Atomic struct foo a ; > struct foo b ; > > int main (int argc, char *argv []) > { > b = (struct foo) {.f1 = 5, .f2 = 7, .f3 = 9 } ; > // atomic_store (&a, b) ; > a = b ; > } > -- > > This code does not compile/link with: > % cc foo.c -lstdthreads > /tmp/foo-a0ef26.o: In function `main': > foo.c:(.text+0x63): undefined reference to `__sync_lock_test_and_set_16' > cc: error: linker command failed with exit code 1 (use -v to see > invocation) > > The gcc internal seems to be linked as "cc -v" told me: > % cc -v foo.c -lstdthreads > ... > "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 > --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o > /usr/lib/crtbegin.o -L/usr/lib /tmp/foo-d7a21b.o -lstdthreads -lgcc > --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s > --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o > > The problem occurs with "atomic_store(&a, b)" as well as with "a = b". > > If I remove the f3 member, the struct foo is only 8 bytes and the code > compiles/links. > > Did I missed something? clang issues a calls to libatomic, which we do not provide. As a workaround, use the following command to compile. The resulting binary works on all practically usable machines. $ cc -march=core2 source.c You might want to turn off sse3/4.1 if you are concerned about older pentium4. ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Problem with C11 _Atomic
Hi, I'm on a recent current: FreeBSD biceps.ma.maison 12.0-CURRENT FreeBSD 12.0-CURRENT #2 r327239: Wed Dec 27 18:25:46 CET 2017 p...@biceps.ma.maison:/usr/obj/usr/src/amd64.amd64/sys/BICEPS amd64 with clang 5.0.1: FreeBSD clang version 5.0.1 (tags/RELEASE_501/final 320880) (based on LLVM 5.0.1) Target: x86_64-unknown-freebsd12.0 Thread model: posix InstalledDir: /usr/bin I'm having a problem with the following source file: -- #include struct foo { int f1 ; char f2 ; int f3 ; } ; _Atomic struct foo a ; struct foo b ; int main (int argc, char *argv []) { b = (struct foo) {.f1 = 5, .f2 = 7, .f3 = 9 } ; // atomic_store (&a, b) ; a = b ; } -- This code does not compile/link with: % cc foo.c -lstdthreads /tmp/foo-a0ef26.o: In function `main': foo.c:(.text+0x63): undefined reference to `__sync_lock_test_and_set_16' cc: error: linker command failed with exit code 1 (use -v to see invocation) The gcc internal seems to be linked as "cc -v" told me: % cc -v foo.c -lstdthreads ... "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/foo-d7a21b.o -lstdthreads -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o The problem occurs with "atomic_store(&a, b)" as well as with "a = b". If I remove the f3 member, the struct foo is only 8 bytes and the code compiles/links. Did I missed something? Thanks in advance, Pierre ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"