DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: dev@dpdk.org
Cc: alialnu@nvidia.com, David Marchand <david.marchand@redhat.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH v2] net/sfc: fix broken build with clang 3.4.x
Date: Thu, 22 Jul 2021 10:49:05 +0300	[thread overview]
Message-ID: <20210722074905.1838130-1-andrew.rybchenko@oktetlabs.ru> (raw)
In-Reply-To: <20210722074651.1837621-1-andrew.rybchenko@oktetlabs.ru>

Old clanng requires libatomic as well as gcc. Avoid compiler name and
version based checks. Add custom test for 16-byte atomic operations
to find out if libatomic is required to build.

Fixes: 96fd2bd69b58 ("net/sfc: support flow action count in transfer rules")
Bugzilla ID: 760

Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/net/sfc/meson.build | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/net/sfc/meson.build b/drivers/net/sfc/meson.build
index 4625859077..a1ad792b80 100644
--- a/drivers/net/sfc/meson.build
+++ b/drivers/net/sfc/meson.build
@@ -40,8 +40,20 @@ foreach flag: extra_flags
     endif
 endforeach
 
-# for gcc compiles we need -latomic for 128-bit atomic ops
-if cc.get_id() == 'gcc'
+# for gcc and old Clang compiles we need -latomic for 128-bit atomic ops
+atomic_check_code = '''
+int main(void)
+{
+    __int128 a = 0;
+    __int128 b;
+
+    b = __atomic_load_n(&a, __ATOMIC_RELAXED);
+    __atomic_store(&b, &a, __ATOMIC_RELAXED);
+    __atomic_store_n(&b, a, __ATOMIC_RELAXED);
+    return 0;
+}
+'''
+if not cc.links(atomic_check_code)
     libatomic_dep = cc.find_library('atomic', required: false)
     if not libatomic_dep.found()
         build = false
@@ -51,11 +63,7 @@ if cc.get_id() == 'gcc'
 
     # libatomic could be half-installed when above check finds it but
     # linkage fails
-    atomic_link_code = '''
-    #include <stdio.h>
-    void main() { printf("libatomic link check\n"); }
-    '''
-    if not cc.links(atomic_link_code, dependencies: libatomic_dep)
+    if not cc.links(atomic_check_code, dependencies: libatomic_dep)
         build = false
         reason = 'broken dependency, "libatomic"'
         subdir_done()
-- 
2.30.2


  reply	other threads:[~2021-07-22  7:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-22  7:46 [dpdk-dev] [PATCH] " Andrew Rybchenko
2021-07-22  7:49 ` Andrew Rybchenko [this message]
2021-07-22  9:12   ` [dpdk-dev] [PATCH v2] " David Marchand
2021-07-22 19:44     ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210722074905.1838130-1-andrew.rybchenko@oktetlabs.ru \
    --to=andrew.rybchenko@oktetlabs.ru \
    --cc=alialnu@nvidia.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).