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 <stdatomic.h>

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"

Reply via email to