From patchwork Fri Jan 31 03:07:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 65400 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AD9BDA0524; Fri, 31 Jan 2020 04:08:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 200F61C0B0; Fri, 31 Jan 2020 04:07:56 +0100 (CET) Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 83FCC1C030 for ; Fri, 31 Jan 2020 04:07:52 +0100 (CET) Received: by mail-lj1-f193.google.com with SMTP id q8so5620337ljb.2 for ; Thu, 30 Jan 2020 19:07:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bXWEXN2ALw3di/Rr732lxI4x13ETr+1H/yyU6YvNjWA=; b=vDJ+meAPBA2mLzdyK+2FB/qmAQ7D7kpJUzp8oQdxPLHrDGopWXwVXKYUn18NsAXtVr 49LL2ao4Dfexe2nSWjG6UW6FIpt8HriUcIP5oMW7P63Bg5IZeGyIy/G6yjpe4IpVeBYG ut4aqUG7sOXMkkh5RrY788cY0YfIYXp3JILrirkvEFwP77ba51hdyCVJtW37xnaF4+nU yR5F/yEi6FlH3iuS6YnNpftnpi0Him7Kd8zA7z24kFR+W2Wi3coo1YnnyJzVglBm6Lo/ v6pCZvlqRmhhJDkeq3arrjoh2namHBEycD3Ky865doHiBv6FFw6ZjXRsz1UJGVqNm57S fqeg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=bXWEXN2ALw3di/Rr732lxI4x13ETr+1H/yyU6YvNjWA=; b=cCrwOjh8+MIhiBi6M6RNH/e5oTsSHjuKiKVwWWB4IFCkCLblF3GD5cUrIWWBrpM1t7 iDpKEIT3PG1KzXo6GRfP0YqYxKTrxJlctdVoFtxnRpctLc1F2i1HYf1rBQgWv8ToZypg us4Q07YFzCyz15qJKXQta1D4o/R8vvFu5T9Q0jfD4TihlpihGVSVNmndAE4NdyhG8Bvg /TzpXsitsBghKNflczNuzA00X05cp1FUeyh920hp0zIUl5i/0Ruyfom+MVacVnCX5vkD ckLfNxaqUQuoL8lvcMHlgY6kpN4IZ5nu6zHrJT0zHV+JnOj6MiJtmQQbu0/19sk6h/rU 6kmA== X-Gm-Message-State: APjAAAWvZ6dPKbD7P86acF1p0nX7trMND8sgK18ziXaacc3JUW4VWuYC HKHhcwiJVn4yHf5xL6x0G12x9ox5JtUwZQ== X-Google-Smtp-Source: APXvYqysbQMdY8/269881Dh5tZXIogQV05ZhlOw7k0Y/gz6eYJ/V9RirdWcXBWiytp5flsOIoDIP5A== X-Received: by 2002:a2e:8907:: with SMTP id d7mr4845533lji.71.1580440071858; Thu, 30 Jan 2020 19:07:51 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id e12sm3630332lfc.70.2020.01.30.19.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 19:07:51 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk Date: Fri, 31 Jan 2020 06:07:39 +0300 Message-Id: <20200131030744.19596-2-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> References: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/6] eal: introduce portable format attribute X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When using __attribute__((format(...)) on functions, GCC on Windows assumes MS-specific format string by default, even if the underlying stdio implementation is ANSI-compliant (either MS Unicersal CRT or MinGW implementation). Wrap attribute into a macro that forces GNU-specific format string when using GCC. Signed-off-by: Dmitry Kozlyuk diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 4b5f3a31f..2f086bb9c 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -89,6 +89,21 @@ typedef uint16_t unaligned_uint16_t; */ #define RTE_SET_USED(x) (void)(x) +/** + * Check format string and its arguments at compile-time. + * + * GCC on Windows assumes MS-specific format string by default, + * even if the underlying stdio implementation is ANSI-compliant, + * so this must be overridden. + */ +#if defined(RTE_TOOLCHAIN_GCC) +#define __rte_format(archetype, format_index, first_arg) \ + __attribute__((format(gnu_##archetype, format_index, first_arg))) +#else +#define __rte_format(archetype, format_index, first_arg) \ + __attribute__((format(archetype, format_index, first_arg))) +#endif + #define RTE_PRIORITY_LOG 101 #define RTE_PRIORITY_BUS 110 #define RTE_PRIORITY_CLASS 120 From patchwork Fri Jan 31 03:07:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 65401 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A1E46A0524; Fri, 31 Jan 2020 04:08:10 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2E97B1C0C0; Fri, 31 Jan 2020 04:07:58 +0100 (CET) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by dpdk.org (Postfix) with ESMTP id 9821E1C0AC for ; Fri, 31 Jan 2020 04:07:53 +0100 (CET) Received: by mail-lj1-f194.google.com with SMTP id y6so5627474lji.0 for ; Thu, 30 Jan 2020 19:07:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CcvlBJtd/EWPTS6QuDV24RBhXf5nKUwf9qYBJAGNiK8=; b=aAS6SRkP+waRITU/F9FGKzsPR0pMOVOycAfrDywx0aRIUaUNqcJcle65HEfKHLA21+ di/UVUF3YCPMCP90kAWEfLLfSntyF1HXFwRUXTcjoteK9ja+L2OLmwfpwSTbRlExqwnc IZY6PYPwn/4h4jBOmuD4jYzSXrxESIW1RpOTYJrkGt1FkZEmVtNMY6lcklUtBshh2Hqa Cn+q+k0aGu8QjzsXpb4ixQ9GgrO4/eeq5pjpsYUExPeewF0Yjezih78FHwrdCP9v0CK0 fbdO07sRUYBXtkemjMvJZx5r6RX9M92nY90WueE1FvLvB7dYfeUkuFT067Vt2RMgOyaM cZYw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=CcvlBJtd/EWPTS6QuDV24RBhXf5nKUwf9qYBJAGNiK8=; b=shn7njLOuECSgEOMSdCMCx+uwMXnXJea2JsOJPCUX5qB35wpfRwSFHLH6nGjPAsr6u JgFouSX4XgsbEwRmZ1d74o46/YfHS8DntqJqpS8mM4QHmrL5jlf5EjbfOdZAaonDa0kj siMULibRRWDLquyqGaz6nh/dJTiov0XQk5WWuXZdfbYbxyjz7+WTSjjNmgHZQeT2z7uA Zf7ilhnMLHoX6NKjoLEHrFWBJ71jA2rELBWy/wp739NgPxwobT+Lt9J1VjD4FVhtyHcR qWwkmGPdlN+1rzHKIvnpTiZz+afpSCEqzEjgtAnd2yWxPp5vcRScW8+fy58XsQJ5v8Qo cbMg== X-Gm-Message-State: APjAAAW2ToswPg3kmo8omNWLufEh9XIjEENfutx1v6jWHh2xtsZ4SO4Q s6SGm2va9uzSNA/Q0gvinlQ/UUJ9UzUkdg== X-Google-Smtp-Source: APXvYqz735deYX2D2LzlfaYNIS4lzLXXMdzqzTc6nSnO34L599FuANTYzQ+NhLrRRdJTHd/WlG3XWA== X-Received: by 2002:a2e:868c:: with SMTP id l12mr4659726lji.194.1580440072962; Thu, 30 Jan 2020 19:07:52 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id e12sm3630332lfc.70.2020.01.30.19.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 19:07:52 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk Date: Fri, 31 Jan 2020 06:07:40 +0300 Message-Id: <20200131030744.19596-3-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> References: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/6] eal: use portable format attribute X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use portable format attribute for logging and panic messages. Signed-off-by: Dmitry Kozlyuk diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 2f086bb9c..dc406ce27 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -799,7 +799,7 @@ rte_str_to_size(const char *str) void rte_exit(int exit_code, const char *format, ...) __attribute__((noreturn)) - __attribute__((format(printf, 2, 3))); + __rte_format(printf, 2, 3); #ifdef __cplusplus } diff --git a/lib/librte_eal/common/include/rte_debug.h b/lib/librte_eal/common/include/rte_debug.h index 748d32c80..c47c6bcdc 100644 --- a/lib/librte_eal/common/include/rte_debug.h +++ b/lib/librte_eal/common/include/rte_debug.h @@ -73,7 +73,7 @@ void __rte_panic(const char *funcname , const char *format, ...) #endif #endif __attribute__((noreturn)) - __attribute__((format(printf, 2, 3))); + __rte_format(printf, 2, 3); #ifdef __cplusplus } diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 882dfa0ab..4418e02f2 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -137,7 +137,7 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev); int rte_devargs_parsef(struct rte_devargs *da, const char *format, ...) -__attribute__((format(printf, 2, 0))); +__rte_format(printf, 2, 0); /** * Insert an rte_devargs in the global list. diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h index 1bb0e6694..823efea4e 100644 --- a/lib/librte_eal/common/include/rte_log.h +++ b/lib/librte_eal/common/include/rte_log.h @@ -282,7 +282,7 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...) __attribute__((cold)) #endif #endif - __attribute__((format(printf, 3, 4))); + __rte_format(printf, 3, 4); /** * Generates a log message. @@ -311,7 +311,7 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...) * - Negative on error. */ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) - __attribute__((format(printf,3,0))); + __rte_format(printf, 3, 0); /** * Generates a log message. From patchwork Fri Jan 31 03:07:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 65402 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 02296A0524; Fri, 31 Jan 2020 04:08:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2CAB41C0C6; Fri, 31 Jan 2020 04:07:59 +0100 (CET) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by dpdk.org (Postfix) with ESMTP id 8FC101C0AF for ; Fri, 31 Jan 2020 04:07:54 +0100 (CET) Received: by mail-lj1-f175.google.com with SMTP id x14so5538264ljd.13 for ; Thu, 30 Jan 2020 19:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gxG5MVDIJU9ZSNekIBXd5nC27e5b11t9Fc+fEsEnEf0=; b=DgpSoheZfBJVk1mtZo809PYcWuqWoOsLmgBCGU/3Fx+zuQwhgkcPUD4pKCedRUgaq9 1UnIlyStTYKLBJRXb+FMz35zOLq3yG1bnY1Flr7sL9wqc3YwvAU8HVDVr5JggAY/X7y9 VN3rNcGlyVLOIb89UxOLKoWoae23MQ3sKYynB7AG+xcGzUlYlE0W7Coaw/Z032vzBmHE natbulNnp+2fmCiQGq1DyOd5Qq9cvJj3JMZZp5N52aBLhktO9sZpMOV6+s8NaC2PauFO k9CTClC1jOODMbtC9Nwghkc7tzzY7bv0nvT2hH5twR7542Y/08X9UYjCY8pWbxBpB8fH n0vQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=gxG5MVDIJU9ZSNekIBXd5nC27e5b11t9Fc+fEsEnEf0=; b=c9eRiCidFqtSysnJsewI62HjQ6I/koKvMLHwGK6rPYAFrr2nSJZ8egNvBUZz/4x2B7 /EI1vHRQ70ozXY3898MlpEwgMwd/b3mzew8rt33PnXSKwQ6YSKs/oejN0zvnG+ehmJVw qaPr9WqWh0AsTMcob5seh8cJhbFhlrLxMsTioqLjEgI+fZyLUOFFw4ozFfw1fek3TAz9 TzlEpHqnsKmwH+dU5rzrezicISU8IMAyihCvBlBvfa2D2qI3P0vV3Mm6yRArz6j/ryiV j06NqroqEdSyBQzK+Wr/TatBVbajuaueFFZaSzQVbGW5g5MTC+p8XOFoeucMa15K2wpd 7OTA== X-Gm-Message-State: APjAAAWytL18aRy9p1tPspangX2ufaejzqbURoXZ9SJNGggC5NeQmfkN rdm8DalAs50uoXt6StRD5co7MFdUhsUZ5A== X-Google-Smtp-Source: APXvYqwoa0ru0Lxzzmaeis9oEHpz9RYr8VDLnL1EhloEmO2knmZcDAiqAM6kcTuUw3PGkZi1J7AJlg== X-Received: by 2002:a05:651c:32b:: with SMTP id b11mr4647520ljp.203.1580440073951; Thu, 30 Jan 2020 19:07:53 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id e12sm3630332lfc.70.2020.01.30.19.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 19:07:53 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Olivier Matz Date: Fri, 31 Jan 2020 06:07:41 +0300 Message-Id: <20200131030744.19596-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> References: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 3/6] cmdline: use portable format attribute X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use portable format attribute for output strings. Signed-off-by: Dmitry Kozlyuk diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h index 27d2effdf..952a50829 100644 --- a/lib/librte_cmdline/cmdline.h +++ b/lib/librte_cmdline/cmdline.h @@ -7,6 +7,8 @@ #ifndef _CMDLINE_H_ #define _CMDLINE_H_ +#include + #include #include #include @@ -34,7 +36,7 @@ struct cmdline *cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_ void cmdline_set_prompt(struct cmdline *cl, const char *prompt); void cmdline_free(struct cmdline *cl); void cmdline_printf(const struct cmdline *cl, const char *fmt, ...) - __attribute__((format(printf,2,3))); + __rte_format(printf, 2, 3); int cmdline_in(struct cmdline *cl, const char *buf, int size); int cmdline_write_char(struct rdline *rdl, char c); From patchwork Fri Jan 31 03:07:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 65403 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A7596A0524; Fri, 31 Jan 2020 04:08:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7F31C1C0AF; Fri, 31 Jan 2020 04:08:02 +0100 (CET) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by dpdk.org (Postfix) with ESMTP id A8EC31C0B0 for ; Fri, 31 Jan 2020 04:07:55 +0100 (CET) Received: by mail-lj1-f194.google.com with SMTP id o15so58790ljg.6 for ; Thu, 30 Jan 2020 19:07:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lqfbabfrWSJAOsLi7d8Doq9bLNlFJak8eOTz/WMgvOU=; b=BZCWYcqx2FIBRWZtSCEbRVdJDJKH089gOTDScTCZfVijNvKK1CUXs9F0aapaLHF/Q5 7wrKU974YhAo9/40cEs/XMDhqM9Jij0W2zN/EmUnCcjPg3w907ipMRjuIha6BBMDfbie C8MYy9Ds0/+rllCT7DdaFQXuf+8wdXPlWgROZ5FtkC+QD9blTsf6GjqbNko94IHk8j1a VcYocNcu3+WiwXXr7l6xyU62zyGhlNpMg2szytnDAxMRNC2NtZqy7AK/GlLvAoNuX92e x96fwYCMEvcVyOMql8Ay/pi3FjEsdDQu2sL/qgVA+LU5j3YJ+PGsWDVh1lYY3u8rpdGq xZ2g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lqfbabfrWSJAOsLi7d8Doq9bLNlFJak8eOTz/WMgvOU=; b=l9Rfw01MHF6vAFpOw2SL4GgOSAlmmHIGOUuxSUoFWtwoGhWFXbQDl3rE/kxLlRqD+O 4YqdJD7PsUMM7BQ/lf8tqZDD3H8LR//8mJyFWrVO+S+lohK2R3tFnNy+GEBhI+MmuV7U 7LrVQB59MDq+MkFX7x8mrpszKmapr0TzJJGlHrcvLdkFGGswVCXDvAbUr2o2Wq7DqcJC 9SHM9L46BxqlA1HO0oVkHL1QvfUFsnA7Efd5Y+C5m+utn2dpmcXvIsPVUEyzw+7RBMIv IB5HzTDGgNIJ5OUZA0DrC0hy4O5uAlWcJ3yYN/I0lXaKTKAeboI0rx11Cc6QglmmDrIp iSkA== X-Gm-Message-State: APjAAAWAODNwpgvgJKdDMoRikGZm5RnEm3sHjt0itaUjxYHC0GDEjDn2 a5kvve7l0lN/wEajiMBIlwDfXrrPGjU3Kg== X-Google-Smtp-Source: APXvYqy1wHDFbwJ0nS9NmiRRwjEKQCfy2n30IlYw21UHKIpHm9qcfFwXCIGv8TqWXo9N+Rs66NKrGw== X-Received: by 2002:a2e:1459:: with SMTP id 25mr4777782lju.189.1580440074963; Thu, 30 Jan 2020 19:07:54 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id e12sm3630332lfc.70.2020.01.30.19.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 19:07:54 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Bruce Richardson , Thomas Monjalon Date: Fri, 31 Jan 2020 06:07:42 +0300 Message-Id: <20200131030744.19596-5-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> References: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 4/6] build: MinGW-w64 support for Meson X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" MinGW-w64 linker does not mimic MS linker options, so the build system must differentiate between linkers on Windows. Use GNU linker options with GCC and MS linker options with Clang. MinGW-w64 by default uses MSVCRT stdio, which does not comply to ANSI, most notably its formatting and string handling functions. MinGW-w64 support for the Universal CRT (UCRT) is ongoing, but the toolchain provides its own standard-complying implementation of stdio. The latter is used in the patch to support formatting in DPDK. Signed-off-by: Dmitry Kozlyuk diff --git a/config/meson.build b/config/meson.build index 28a57f56f..a2f6f5ab1 100644 --- a/config/meson.build +++ b/config/meson.build @@ -14,6 +14,10 @@ foreach env:supported_exec_envs set_variable('is_' + env, exec_env == env) endforeach +# MS linker requires special treatment. +# FIXME: use cc.get_linker_id() after upgrading to Meson >=0.53. +is_ms_linker = is_windows and (cc.get_id() == 'clang') + # set the major version, which might be used by drivers and libraries # depending on the configuration options pver = meson.project_version().split('.') @@ -241,6 +245,16 @@ if is_freebsd add_project_arguments('-D__BSD_VISIBLE', language: 'c') endif +if is_windows + # Require platform SDK for Windows 7 and above. + add_project_arguments('-D_WIN32_WINNT=0x0601', language: 'c') + + # Use MinGW-w64 stdio, because DPDK assumes ANSI-compliant formatting. + if cc.get_id() == 'gcc' + add_project_arguments('-D__USE_MINGW_ANSI_STDIO', language: 'c') + endif +endif + if get_option('b_lto') if cc.has_argument('-ffat-lto-objects') add_project_arguments('-ffat-lto-objects', language: 'c') diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build index 4be5118ce..eae8c2ba8 100644 --- a/lib/librte_eal/meson.build +++ b/lib/librte_eal/meson.build @@ -20,6 +20,9 @@ endif if cc.has_function('getentropy', prefix : '#include ') cflags += '-DRTE_LIBEAL_USE_GETENTROPY' endif +if cc.get_id() == 'gcc' + cflags += '-D__USE_MINGW_ANSI_STDIO' +endif sources = common_sources + env_sources objs = common_objs + env_objs headers = common_headers + env_headers diff --git a/lib/meson.build b/lib/meson.build index 0af3efab2..9c3cc55d5 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -148,12 +148,16 @@ foreach l:libraries command: [map_to_def_cmd, '@INPUT@', '@OUTPUT@'], input: version_map, output: 'rte_@0@_exports.def'.format(name)) - lk_deps = [version_map, def_file] - if is_windows + + if is_ms_linker lk_args = ['-Wl,/def:' + def_file.full_path(), '-Wl,/implib:lib\\' + implib] else lk_args = ['-Wl,--version-script=' + version_map] + endif + + lk_deps = [version_map, def_file] + if not is_windows # on unix systems check the output of the # experimental syms script, using it as a # dependency of the .so build From patchwork Fri Jan 31 03:07:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 65404 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 65ACAA0524; Fri, 31 Jan 2020 04:08:44 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CD1911C0D0; Fri, 31 Jan 2020 04:08:03 +0100 (CET) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id 92A871C0B6 for ; Fri, 31 Jan 2020 04:07:56 +0100 (CET) Received: by mail-lf1-f68.google.com with SMTP id f24so3800847lfh.3 for ; Thu, 30 Jan 2020 19:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N78Jw+Bg/CcVJoMwPrnj7nZUefQSQUZpIAYbBU/w/bM=; b=bY3wvbXnaZgTxaOBZj4lNyR7HBIcJuXzdWuI8uohczi3X65Uu1tRPcPDSjqXpnVWVG bD5jFoZOZV/la+OlTCnBC5lwwJAYBp8k78+24s88fF9HJHoYjX514ljVtOlSMl6VsOA4 zKh6uxMtKFyuwVNby/yiWAkJYqjx7CVCB39LNvzE97LjE57CxwWUELG8hI70QxsIFuoe 7jVrYv9DDmZcoPUmYzmZmpdyrrssmna0CqkwYDYpnWrMuXSxcGr2BWLphCblOTM1ilRc CtN6G0T/f5UTr49wBlnBX7TMmnYrxz7rMD+nILr7sc00RAkTcnygtcKnpPQZEWMbU3Ke pkBg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=N78Jw+Bg/CcVJoMwPrnj7nZUefQSQUZpIAYbBU/w/bM=; b=ROLUSCCybICZ00PNl+LuYlJNNrURGqHQKqVfAJxmNMydK30zQzBoL7BhhySX/rQG4+ KVGSBHSm3K6F25qsGMpbyBdsOkq/lHG+iRH5dUgg8nicbpEXZCCa1YTu+SqVHb0RR1zp z3CkAjMReXDFtFLGfmAN5IFIpJgZ6EjIZX0qPDRLmlTmjnCBz66dFyDjgZuirnckVrtR f2+09StYBwQELvkoHJvT8XJpLiiy6cnFo7XaoLBXfqmgA+j3KHp+ldEfcnstNRBJpf+Y Ky8VAKoXGLKCyekR9qW6+63G+JGkvrN11HoG9J9HdZsLWTCnQQrKVse0Md8R/dg7IV4e xvfw== X-Gm-Message-State: APjAAAXubvUQWhjsGFldNQjj/Ksow8ko1TWTh99y8QrLcx3Y8O6QrDlM J89IjOlX5iOdiziNBvq+RNXZIkssahS0CA== X-Google-Smtp-Source: APXvYqzO1QfUVit/+Brgfiq3F3+1V4NvLo+ygXa/NIYhRBXFtXL7OHI6ZELIMD4zIJwlu6JGvHmnDQ== X-Received: by 2002:a19:9159:: with SMTP id y25mr4364955lfj.63.1580440075864; Thu, 30 Jan 2020 19:07:55 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id e12sm3630332lfc.70.2020.01.30.19.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 19:07:55 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Bruce Richardson Date: Fri, 31 Jan 2020 06:07:43 +0300 Message-Id: <20200131030744.19596-6-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> References: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 5/6] build: add cross-file for MinGW-w64 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add Meson configuration to cross-compile for Windows using MinGW-w64. It may require adjustments in some cases, but at least it provides the foundation. Signed-off-by: Dmitry Kozlyuk create mode 100644 meson_mingw.txt diff --git a/meson_mingw.txt b/meson_mingw.txt new file mode 100644 index 000000000..80f04343a --- /dev/null +++ b/meson_mingw.txt @@ -0,0 +1,14 @@ +[binaries] +c = '/usr/bin/x86_64-w64-mingw32-gcc' +cpp = '/usr/bin/x86_64-w64-mingw32-g++' +ld = '/usr/bin/x86_64-w64-mingw32-ld' # Meson 0.53.0 +c_ld = '/usr/bin/x86_64-w64-mingw32-ld' +ar = '/usr/bin/x86_64-w64-mingw32-ar' +strip = '/usr/bin/x86_64-w64-mingw32-strip' +pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config' + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'native' +endian = 'little' From patchwork Fri Jan 31 03:07:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 65405 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 51F2EA0524; Fri, 31 Jan 2020 04:08:53 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 643B41C0D8; Fri, 31 Jan 2020 04:08:05 +0100 (CET) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by dpdk.org (Postfix) with ESMTP id A15C31C0B9 for ; Fri, 31 Jan 2020 04:07:57 +0100 (CET) Received: by mail-lj1-f195.google.com with SMTP id q8so5620464ljb.2 for ; Thu, 30 Jan 2020 19:07:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kYup3UILgKLePgHKM51+bveaaI7180cEgRh4dsMKBa4=; b=mP/KPbSzsLjC2pdTwYUzpiVZ7/T8SDzM6PPQD9WQvEororD2VRTSZ3CnF5TBeP/pI1 fdijYAgpcNFiAspiceFTnvsKBVAnKx/WaKk0R2iSadOMFtwAaU6r7XKnq0SneI89OmOO QzitjZ2P6vU6f9XuOBEVu3Emb6NqDgQG0rvbIjjmI3dLaHVp1O4P6kwRJLlGIq1APxag WmKCK/ZnqveJJgMH8sCi2gvvNmBz8BvbmNhJDiayWrmUmyBkCDWtRZDNbfLT3Ry05/wD BGY8oceSP6NRxoMlArwCz9rw/dr4K9AzUnUZKKaOKf+BY+CZD+qd5op8souljOgkNcFa nRZA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=kYup3UILgKLePgHKM51+bveaaI7180cEgRh4dsMKBa4=; b=l73+uHXfRPOsqBj260fZhsLeh5ms5YfRzx6150gIgjruuKbG2PCu0DwTsSOPi99fgw HtQeVC9LPyk9HV3D4BoiqdaFPM0bQdcvyOgf/+5cdZAKf3RPRDg6hhz5Ln8BE0+ODjv7 AQri4HYLNkSwy02sGco5cA7EL3QIjArHny+4MIwIEhWdguHp2ulSO8cRs43Q1gRMFDMj ryuBv9Es+pM22Vq9NU+kmHwei5WGSi358+ihMUF3acC/QKR/IRV0LYQCnpDTmwosGSFN 2iB5zRUHiZpo7xmktWrtF8sMFLk/2pV069qINvf9TxlBUfCTKoToRs5NjOpOwO8vPSBJ y+QQ== X-Gm-Message-State: APjAAAU703cvgQVSzzdyNns5fj7laprvzf1xcm2RiWxDz8m7Kgkldd0B lwaiv3/bATSvj7jFL1rBpicss8GMeFWS2Q== X-Google-Smtp-Source: APXvYqxmQi9M5pEEtDfes3rpzGZiki4TrYjU+lRaed5VfJBCRuEr7BwE1Bulh3ynLlBhWNyWUogi2g== X-Received: by 2002:a2e:88c5:: with SMTP id a5mr4707961ljk.201.1580440076869; Thu, 30 Jan 2020 19:07:56 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.googlemail.com with ESMTPSA id e12sm3630332lfc.70.2020.01.30.19.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 19:07:56 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon , John McNamara , Marko Kovacevic Date: Fri, 31 Jan 2020 06:07:44 +0300 Message-Id: <20200131030744.19596-7-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> References: <20200131030744.19596-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 6/6] doc: guide for Windows build using MinGW-w64 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Instructions for different toolchains presented as options on the corresponging steps of the guide, so that common parts may be reused. Signed-off-by: Dmitry Kozlyuk diff --git a/doc/guides/windows_gsg/build_dpdk.rst b/doc/guides/windows_gsg/build_dpdk.rst index 6711e07e2..eabc459fb 100644 --- a/doc/guides/windows_gsg/build_dpdk.rst +++ b/doc/guides/windows_gsg/build_dpdk.rst @@ -7,15 +7,22 @@ Compiling the DPDK Target from Source System Requirements ------------------- -The DPDK and its applications require the Clang-LLVM C compiler -and Microsoft MSVC linker. +Building the DPDK and its applications requires one of the following +environments: + +* The Clang-LLVM C compiler and Microsoft MSVC linker. +* The MinGW-w64 toolchain (either native or cross). + The Meson Build system is used to prepare the sources for compilation with the Ninja backend. The installation of these tools is covered in this section. +Option 1. Clang-LLVM C Compiler and Microsoft MSVC Linker +--------------------------------------------------------- + Install the Compiler --------------------- +~~~~~~~~~~~~~~~~~~~~ Download and install the clang compiler from `LLVM website `_. @@ -25,7 +32,7 @@ For example, Clang-LLVM direct download link:: Install the Linker ------------------- +~~~~~~~~~~~~~~~~~~ Download and install the Build Tools for Visual Studio to link and build the files on windows, @@ -34,6 +41,15 @@ When installing build tools, select the "Visual C++ build tools" option and ensure the Windows SDK is selected. +Option 2. MinGW-w64 Toolchain +----------------------------- + +Obtain the latest version from +`MinGW-w64 website `_. +On Windows, install to a folder without spaces in its name, like ``C:\MinGW``. +This path is assumed for the rest of this guide. + + Install the Build System ------------------------ @@ -56,23 +72,41 @@ Build the code The build environment is setup to build the EAL and the helloworld example by default. -Using the ninja backend -~~~~~~~~~~~~~~~~~~~~~~~~ +Option 1. Native Build on Windows +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Specifying the compiler might be required to complete the meson command. +When using Clang-LLVM, specifying the compiler might be required to complete +the meson command: .. code-block:: console set CC=clang +When using MinGW-w64, it is sufficient to have toolchain executables in PATH: + +.. code-block:: console + + set PATH=C:\MinGW\mingw64\bin;%PATH% + To compile the examples, the flag ``-Dexamples`` is required. .. code-block:: console cd C:\Users\me\dpdk meson -Dexamples=helloworld build - cd build - ninja + ninja -C build + +Option 2. Cross-Compile with MinGW-w64 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The cross-file option must be specified for Meson. +Depending on the distribution, paths in this file may need adjustments. + +.. code-block:: console + + meson --cross-file meson_mingw.txt -Dexamples=helloworld build + ninja -C build + Run the helloworld example ========================== @@ -87,3 +121,8 @@ Navigate to the examples in the build directory and run `dpdk-helloworld.exe`. hello from core 3 hello from core 0 hello from core 2 + +Note for MinGW-w64: applications are linked to ``libwinpthread-1.dll`` +by default. To run the example, either add toolchain executables directory +to the PATH or copy the library to the working directory. +Alternatively, static linking may be used (mind the LGPLv2.1 license).