From patchwork Thu Feb 16 20:26:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 94107 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2680883obz; Thu, 16 Feb 2017 12:27:05 -0800 (PST) X-Received: by 10.36.196.8 with SMTP id v8mr15170514itf.115.1487276825141; Thu, 16 Feb 2017 12:27:05 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 19si8227580iof.183.2017.02.16.12.27.04; Thu, 16 Feb 2017 12:27:05 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 94A41635CF; Thu, 16 Feb 2017 20:27:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id B58D760B0E; Thu, 16 Feb 2017 20:26:55 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2712E60C03; Thu, 16 Feb 2017 20:26:53 +0000 (UTC) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by lists.linaro.org (Postfix) with ESMTPS id 48B7560B05 for ; Thu, 16 Feb 2017 20:26:51 +0000 (UTC) Received: by mail-lf0-f41.google.com with SMTP id z127so13667822lfa.2 for ; Thu, 16 Feb 2017 12:26:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wsh2tbJinPM59zEP9jUI442uEe9nnsqGESROztcWrzA=; b=dWbPButYCFnnYMLpaxLAI0yhaH+ovc6z5QqrajFnS0yd6eZ0+SiAYOL/bD0JTg2/JH tLvtU/VD1mXnLrmPzLOKzbo7kbJyhwuxaoIJwpgzBL1oH2odUhmx/V2Mbf7NchDIyEtA 0L/pCTQ5Jp6K+x2z5xCKKw8fVd0rNuw+RbUcZqG5nbXUmuT8i+D2yDLInEQF+dTb3Z5e zHwqCL9kaUDT6zW8ZZBjwI3nZgzX99OBrem0xBRdblIAvkmoBxy3omdz4dkHtHm2aVej C2gwlwW+rA0czqXRsTFP51Alu310ghPdNUyu7yz9N1AARBv5qnvqZroenrresmS3aZkf 24Wg== X-Gm-Message-State: AMke39lP4dcv6mns4JlCqAqdPJ/ahiyRrbfvOcOQaZSycKpJHmMopLLyA9OKx43QagM+QdnSIWU= X-Received: by 10.46.80.29 with SMTP id e29mr1124490ljb.121.1487276809923; Thu, 16 Feb 2017 12:26:49 -0800 (PST) Received: from localhost.localdomain (ppp95-165-131-83.pppoe.spdop.ru. [95.165.131.83]) by smtp.gmail.com with ESMTPSA id a16sm1987552lfk.64.2017.02.16.12.26.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Feb 2017 12:26:49 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 16 Feb 2017 23:26:24 +0300 Message-Id: <20170216202624.8535-1-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.11.0.295.gd7dffce Subject: [lng-odp] [PATCHv2] configure: libatomic check X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" upcoming patch ip fragmentation example fails to with gcc 4.8.4 on linking __atomic_compare_exchange_16 functions on x86. For some version of gcc both -latomic and -mcx16 needs to be provided in that case. For clang only -mcx16. That options are set internally for platform but do not set for examples. This patch unhides setting this options, make them common and printed on configure log. Signed-off-by: Maxim Uvarov --- v2: unhide options and make frag code compile. CI now happy: https://travis-ci.org/muvarov/odp/builds/202380977 configure.ac | 16 ---------- platform/linux-generic/m4/configure.m4 | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 16 deletions(-) -- 2.11.0.295.gd7dffce Reviewed-by: Christophe Milard diff --git a/configure.ac b/configure.ac index 6153efd2..a514f6be 100644 --- a/configure.ac +++ b/configure.ac @@ -314,22 +314,6 @@ ODP_CFLAGS="$ODP_CFLAGS -std=c99" # Extra flags for example to suppress certain warning types ODP_CFLAGS="$ODP_CFLAGS $ODP_CFLAGS_EXTRA" -######################################################################### -# Check if compiler supports cmpxchng16 -########################################################################## -if test "${CC}" != "gcc" -o ${CC_VERSION_MAJOR} -ge 5; then - my_save_cflags="$CFLAGS" - - CFLAGS=-mcx16 - AC_MSG_CHECKING([whether CC supports -mcx16]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], - [AC_MSG_RESULT([yes])] - [ODP_CFLAGS="$ODP_CFLAGS $CFLAGS"], - [AC_MSG_RESULT([no])] - ) - CFLAGS="$my_save_cflags" -fi - ########################################################################## # Default include setup ########################################################################## diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index d3e5528c..92172d4b 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -28,6 +28,63 @@ AC_LINK_IFELSE( echo "Use newer version. For gcc > 4.7.0" exit -1) +######################################################################### +# Check if compiler supports cmpxchng16 +########################################################################## +my_save_cflags="$CFLAGS" + +CFLAGS=-mcx16 +AC_MSG_CHECKING([whether CC supports -mcx16]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [MCX16_CFLAGS="-mcx16"], + [AC_MSG_RESULT([no])] + ) +CFLAGS="$my_save_cflags" + +######################################################################### +# Check if compiler supports __atomic_compare_exchange +########################################################################## +my_save_cflags="$CFLAGS" +LD_LIBATOMIC="" + +AC_MSG_CHECKING(if libatomic required) +AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [[int main() { + unsigned __int128 x = 0, y = 0; + y = __atomic_load_n(&x, 0); + __atomic_store_n(&x, y, 0); + __atomic_compare_exchange_n(&x, &y, x, 0, 0, 0); + return 0; + } + ]])], + AC_MSG_RESULT(yes) + LD_LIBATOMIC="-latomic" + echo "adding -lbatomic", + AC_MSG_RESULT(no)) + +CFLAGS="$my_save_cflags $LD_LIBATOMIC $MCX16_CFLAGS" +AC_MSG_CHECKING([CFLAGS=$CFLAGS]) +AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [[int main() { + unsigned __int128 x = 0, y = 0; + y = __atomic_load_n(&x, 0); + __atomic_store_n(&x, y, 0); + __atomic_compare_exchange_n(&x, &y, x, 0, 0, 0); + return 0; + } + ]])], + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) + echo "atomic operations compilation fail." + exit -1) + +# Restore LDFLAGS +CFLAGS="$my_save_cflags $MCX16_CFLAGS" +LDFLAGS="$LDFLAGS $LD_LIBATOMIC" + m4_include([platform/linux-generic/m4/odp_pthread.m4]) m4_include([platform/linux-generic/m4/odp_openssl.m4]) m4_include([platform/linux-generic/m4/odp_pcap.m4])