From patchwork Fri Feb 10 14:26:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 93785 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp526199qgi; Fri, 10 Feb 2017 06:27:32 -0800 (PST) X-Received: by 10.200.55.115 with SMTP id p48mr7886304qtb.209.1486736852150; Fri, 10 Feb 2017 06:27:32 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j5si1338379qkf.305.2017.02.10.06.27.31; Fri, 10 Feb 2017 06:27:32 -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 32412634C6; Fri, 10 Feb 2017 14:27:31 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 9EFE660D87; Fri, 10 Feb 2017 14:27:25 +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 2305762D3B; Fri, 10 Feb 2017 14:27:24 +0000 (UTC) Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) by lists.linaro.org (Postfix) with ESMTPS id 9F8CF60D77 for ; Fri, 10 Feb 2017 14:27:20 +0000 (UTC) Received: by mail-lf0-f44.google.com with SMTP id z134so22219813lff.3 for ; Fri, 10 Feb 2017 06:27:20 -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=aPfaVHQiJMrI+eCyt4fxrr37KXIrCrxIM3Wvrog9AZ4=; b=CZaHYOi+CNfdTR+ZJ0512Aps8XrWk3grhdj6OF/tTEWPdeWgOSjuv9ov9Pjj785hP5 FbjBDP6jpTSpJ2olWRG7LqbUbyH9p1i+1WD8wW3VS3vPnMN9dzjIZfHOKh2JLjC+x8Ce /8C6t7daSCE4n4EMEVrMXOg52KUFrKUM551ZeP3Nua6R6wWNoVi8+KUI42WQOEdmRWjg B6ZtiTYhWrtlusdW/IYHomb0F94eyycesi5wm09REsD0X9qrq8bLqo/ehHUUmbVzFW/m BSZAlk9kK7GsLsrYcwyc9OA/mAtOWWQgK8hQqXMFfXdFhQH3O1SGt3VtvVQQgRf3BxB7 zdhA== X-Gm-Message-State: AMke39lSwTiUoiSKsjDU9FaTu1UrrIi0oB7CbeJD6a6dtIZtIS7uKAXxO7KWsIn+av5iEjcznqo= X-Received: by 10.25.86.2 with SMTP id k2mr3126124lfb.51.1486736839460; Fri, 10 Feb 2017 06:27:19 -0800 (PST) Received: from localhost.localdomain (ppp109-252-7-40.pppoe.spdop.ru. [109.252.7.40]) by smtp.gmail.com with ESMTPSA id m26sm581426ljb.24.2017.02.10.06.27.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Feb 2017 06:27:18 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 10 Feb 2017 17:26:50 +0300 Message-Id: <20170210142650.23061-1-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.11.0.295.gd7dffce Subject: [lng-odp] [PATCH] 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. Both -latomic and -mcx16 needs to be provided in that case. This patch adds additional checks to find combination of required -latomic and -mcx16 options. Signed-off-by: Maxim Uvarov --- configure.ac | 16 --------- platform/Makefile.inc | 2 ++ platform/linux-generic/m4/configure.m4 | 59 ++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 16 deletions(-) -- 2.11.0.295.gd7dffce 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/Makefile.inc b/platform/Makefile.inc index 7059d910..8fde4062 100644 --- a/platform/Makefile.inc +++ b/platform/Makefile.inc @@ -9,9 +9,11 @@ VPATH = $(srcdir) $(builddir) lib_LTLIBRARIES = $(LIB)/libodp-linux.la AM_LDFLAGS += -version-number '$(ODP_LIBSO_VERSION)' +AM_LDFLAGS += $(LD_LIBATOMIC) AM_CFLAGS += "-DGIT_HASH=$(VERSION)" AM_CFLAGS += $(VISIBILITY_CFLAGS) +AM_CFLAGS += $(MCX16_CFLAGS) #The implementation will need to retain the deprecated implementation AM_CFLAGS += -Wno-deprecated-declarations diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index d3e5528c..ec77075a 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -28,6 +28,65 @@ 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" +AC_SUBST(MCX16_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_16(&x, 0); + __atomic_store_16(&x, y, 0); + __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0); + return 0; + } + ]])], + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) + echo "libatomic is needed." + LD_LIBATOMIC="-latomic") + +CFLAGS="$ODP_CFLAGS -latomic $MCX16_CFLAGS" +AC_MSG_CHECKING([CFLAGS=$CFLAGS]) +AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [[int main() { + unsigned __int128 x = 0, y = 0; + y = __atomic_load_16(&x, 0); + __atomic_store_16(&x, y, 0); + __atomic_compare_exchange_16(&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" +AC_SUBST(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])