From owner-freebsd-current@freebsd.org Mon Jan 1 20:47:49 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AC6CCE800BC for ; Mon, 1 Jan 2018 20:47:49 +0000 (UTC) (envelope-from pdagog@gmail.com) Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3FF377D19F for ; Mon, 1 Jan 2018 20:47:49 +0000 (UTC) (envelope-from pdagog@gmail.com) Received: by mail-wm0-x231.google.com with SMTP id b141so11844334wme.1 for ; Mon, 01 Jan 2018 12:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :jabber-id:user-agent; bh=ZOJxiKMPo2J2U8PohnFNwU41Flc31E/hsfMLmc2RCjY=; b=Qa14j2yCCNIrcNywqaGtFY77iKHT+lAbueJ701o0PseSzGj/rIQqeIQEFgtklQDZcd rCwBRECScLlA/9B3/CGRzDt/V3C7QcLB8T9Xut5EGq8bThD+sT+w8zJS11iq7WXOYFxg C6NVMcc1kPrIvjBIM2z50Gr/FZ21Nuw1i4XZn1+qvFlbJxw6Oz/TSHpDMN881d3SBXrE RABmWonu2jBAGRNDK32JwjkzEp3Ul5QjsJo2DMop7KLnR0EiRLbw/TPKe+PokI1UElbz 8qukiSXavaBpkazFV1RD5RUlM41byAAj/EDssBH48tP4LnjvAXiyhCGZDUvCFvDmeWMe NwiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:jabber-id:user-agent; bh=ZOJxiKMPo2J2U8PohnFNwU41Flc31E/hsfMLmc2RCjY=; b=fT9GiH8hyzAZSp8yOznhDOo58Ws7+qLZnTAiNuCr7pVP1ARn1xkuzd4xSEz7Ql9aZL dzXba//7wKhL/UjHXP0TsC1SSVqnMJuRffgzOF1jF5IN44sklbFHOHy96jD7YAyJVV3V 49pxgev1cdHzz0cAej2J6h1hZ46Lnsmeh4Yii6GncwVuxYyGMVqeayFabtBmo2Fa7pxE xUrwvWfqzbJWDJIY0nNlVKAk9NjU4a3cCZ+ax7YHaIwp/yle8qjKmyMRwQAolh/c5R/C lHGzsCDgBEATDvmZfhZTnX/h2TWl8/Pn1OyZmCIcMBonLuZMlvdWcimvk5PjciQDi8um jwhA== X-Gm-Message-State: AKGB3mKb9qjKLuNtD44JVk79NyYFTZDzwcXnO1f0GMSfgj9gLcGVw9ZP eAxdbPZFNpUndQmw6R0grFjSCA== X-Google-Smtp-Source: ACJfBotJr9Gbjjk9X3VUaw2kjPo5loLlRIggystbeZk8l1Z+VBbuFfyeTU49MwBI3CyZD2rl8TcMJg== X-Received: by 10.28.142.193 with SMTP id q184mr31427589wmd.62.1514839667414; Mon, 01 Jan 2018 12:47:47 -0800 (PST) Received: from localhost ([2001:470:1f13:1334:41f8:9bee:9e92:34ef]) by smtp.gmail.com with ESMTPSA id j96sm6576671wrj.93.2018.01.01.12.47.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jan 2018 12:47:46 -0800 (PST) Date: Mon, 1 Jan 2018 21:47:40 +0100 From: Pierre DAVID To: freebsd-current@freebsd.org Subject: Problem with C11 _Atomic Message-ID: <20180101204740.GA15590@vagabond> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Jabber-ID: pdagog@gmail.com User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jan 2018 20:47:49 -0000 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 pda@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