From patchwork Tue Mar 12 07:51:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138201 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E96A343C8E; Tue, 12 Mar 2024 08:52:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B9DC940ED8; Tue, 12 Mar 2024 08:51:55 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id EF4CD406FF for ; Tue, 12 Mar 2024 08:51:50 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id F119A20B74C2; Tue, 12 Mar 2024 00:51:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F119A20B74C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710229909; bh=EEz+7CSOd3HphtmXyVgSHTpLhFaYtj6hShIpekQ4s+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ToRBtGHt3IvNspFGNnL0A71eOj57srw4gutsbQEn1lU2gtNJDY3XvKZ7ML6CKDRZF beBbdvFFN8+jzwVMgF9uneo1DMc3GNva2FnojLrGkvoq9J+FWNKkQfXTiYK4KvSZeZ pABxGPPImtU1Vfss+Jg2z6sjL/GtddPDdRBFDOLw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Dmitry Kozlyuk , Thomas Monjalon , Bruce Richardson , David Marchand , Tyler Retzlaff Subject: [PATCH 1/3] buildtools: ignore exports for MSVC Date: Tue, 12 Mar 2024 00:51:46 -0700 Message-Id: <1710229908-31704-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710229908-31704-1-git-send-email-roretzla@linux.microsoft.com> References: <1710229908-31704-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Update map_to_def to allow exports to be ignored only when building with MSVC. Some data variables need to be exported within code (not via .def) file depending on their type so allow them to be ignored in the .map file. Signed-off-by: Tyler Retzlaff --- buildtools/map_to_win.py | 13 +++++++++---- lib/meson.build | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/buildtools/map_to_win.py b/buildtools/map_to_win.py index aa1752c..2d547f8 100644 --- a/buildtools/map_to_win.py +++ b/buildtools/map_to_win.py @@ -4,9 +4,11 @@ import sys +def is_function_line(ln, cc): + if not ln.startswith('\t') or ":" in ln or ";" not in ln: + return False -def is_function_line(ln): - return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln and "# WINDOWS_NO_EXPORT" not in ln + return not (cc == 'msvc' and "# MSVC_NO_EXPORT" in ln or "# WINDOWS_NO_EXPORT" in ln) # MinGW keeps the original .map file but replaces per_lcore* to __emutls_v.per_lcore* def create_mingw_map_file(input_map, output_map): @@ -27,9 +29,12 @@ def main(args): # This works taking indented lines only which end with a ";" and which don't # have a colon in them, i.e. the lines defining functions only. else: + cc = 'notmsvc' + if len(args) == 4: + cc = args[3] with open(args[1]) as f_in: - functions = [ln[:-2] + '\n' for ln in sorted(f_in.readlines()) - if is_function_line(ln)] + functions = [ln.split(';', 1)[0] + '\n' for ln in sorted(f_in.readlines()) + if is_function_line(ln, cc)] functions = ["EXPORTS\n"] + functions with open(args[2], 'w') as f_out: diff --git a/lib/meson.build b/lib/meson.build index 179a272..f8836a4 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -262,7 +262,7 @@ foreach l:libraries if is_ms_linker def_file = custom_target(libname + '_def', - command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], + command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@', cc.get_id()], input: version_map, output: '@0@_exports.def'.format(libname)) lk_deps += [def_file] @@ -281,7 +281,7 @@ foreach l:libraries else if is_windows mingw_map = custom_target(libname + '_mingw', - command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], + command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@', cc.get_id()], input: version_map, output: '@0@_mingw.map'.format(libname)) lk_deps += [mingw_map] From patchwork Tue Mar 12 07:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138200 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7E4E243C8E; Tue, 12 Mar 2024 08:52:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F5B040E78; Tue, 12 Mar 2024 08:51:54 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B565740282 for ; Tue, 12 Mar 2024 08:51:50 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0A29820B74C3; Tue, 12 Mar 2024 00:51:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0A29820B74C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710229910; bh=INHMifypSW4i0apkPTNXJeg8/qtwK/Seo/PHx2L3heI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bl35pjS7BsIoGKFXHr++eoE87vgQcsLckjmaPJZrFCT3ufEGe45Z485QXAdShj1TZ nboBMQGP3MmbciSbxdOM5dKRqUm03TOzmZ6ikACzOBcvLYj9uP/3w0YoQ4x7GLVz3I J8Ws2Kuw5Oyo4gLI1r77oRWCASbHs/jWES0sCW7w= From: Tyler Retzlaff To: dev@dpdk.org Cc: Dmitry Kozlyuk , Thomas Monjalon , Bruce Richardson , David Marchand , Tyler Retzlaff Subject: [PATCH 2/3] eal: import and export data variables for MSVC Date: Tue, 12 Mar 2024 00:51:47 -0700 Message-Id: <1710229908-31704-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710229908-31704-1-git-send-email-roretzla@linux.microsoft.com> References: <1710229908-31704-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org MSVC requires that data variables be explicitly declared as either imported or exported. Provide macros that allow dpdk to correctly declare data variables as exported for itself and imported for applications. Use new per-library macro to declare variables exported or imported for per-lcore data variables. Signed-off-by: Tyler Retzlaff --- lib/eal/include/meson.build | 1 + lib/eal/include/rte_common.h | 8 ++++++++ lib/eal/include/rte_eal.h | 2 ++ lib/eal/include/rte_eal_export.h | 23 +++++++++++++++++++++++ lib/eal/include/rte_errno.h | 2 ++ lib/eal/version.map | 6 +++--- lib/meson.build | 2 ++ 7 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 lib/eal/include/rte_eal_export.h diff --git a/lib/eal/include/meson.build b/lib/eal/include/meson.build index e94b056..376ae81 100644 --- a/lib/eal/include/meson.build +++ b/lib/eal/include/meson.build @@ -16,6 +16,7 @@ headers += files( 'rte_dev.h', 'rte_devargs.h', 'rte_eal.h', + 'rte_eal_export.h', 'rte_eal_memconfig.h', 'rte_eal_trace.h', 'rte_errno.h', diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 298a5c6..ad80122 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -26,6 +26,14 @@ /* OS specific include */ #include +#ifdef RTE_TOOLCHAIN_MSVC +#define __rte_declare_import __declspec(dllimport) +#define __rte_declare_export __declspec(dllexport) +#else +#define __rte_declare_import +#define __rte_declare_export +#endif + #ifndef RTE_TOOLCHAIN_MSVC #ifndef typeof #define typeof __typeof__ diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h index c2256f8..d0dc91b 100644 --- a/lib/eal/include/rte_eal.h +++ b/lib/eal/include/rte_eal.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -426,6 +427,7 @@ typedef int (*rte_mp_async_reply_t)(const struct rte_mp_msg *request, */ int rte_sys_gettid(void); +__rte_eal_export RTE_DECLARE_PER_LCORE(int, _thread_id); /** diff --git a/lib/eal/include/rte_eal_export.h b/lib/eal/include/rte_eal_export.h new file mode 100644 index 0000000..3901760 --- /dev/null +++ b/lib/eal/include/rte_eal_export.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2024 Microsoft Corporation + */ + +#ifndef _RTE_EAL_EXPORT_H_ +#define _RTE_EAL_EXPORT_H_ + +/** + * @file + * + * Import / Export macros for eal data variables. + */ + +#include + +#ifndef __rte_eal_export +#define __rte_eal_export __rte_declare_import +#else +#undef __rte_eal_export +#define __rte_eal_export __rte_declare_export +#endif + +#endif diff --git a/lib/eal/include/rte_errno.h b/lib/eal/include/rte_errno.h index ba45591..311732f 100644 --- a/lib/eal/include/rte_errno.h +++ b/lib/eal/include/rte_errno.h @@ -15,8 +15,10 @@ extern "C" { #endif +#include #include +__rte_eal_export RTE_DECLARE_PER_LCORE(int, _rte_errno); /**< Per core error number. */ /** diff --git a/lib/eal/version.map b/lib/eal/version.map index c06ceaa..62914d2 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -4,9 +4,9 @@ DPDK_24 { __rte_panic; eal_parse_sysfs_value; # WINDOWS_NO_EXPORT eal_timer_source; # WINDOWS_NO_EXPORT - per_lcore__lcore_id; - per_lcore__rte_errno; - per_lcore__thread_id; + per_lcore__lcore_id; # MSVC_NO_EXPORT + per_lcore__rte_errno; # MSVC_NO_EXPORT + per_lcore__thread_id; # MSVC_NO_EXPORT rte_bus_dump; rte_bus_find; rte_bus_find_by_device; diff --git a/lib/meson.build b/lib/meson.build index f8836a4..f8d88d2 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -235,6 +235,8 @@ foreach l:libraries cflags += '-Wthread-safety' endif + cflags += '-D__rte_@0@_export'.format(name) + # first build static lib static_lib = static_library(libname, sources, From patchwork Tue Mar 12 07:51:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138199 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6AAA443C8E; Tue, 12 Mar 2024 08:51:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 130AE402E6; Tue, 12 Mar 2024 08:51:52 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id C2C2A402E6 for ; Tue, 12 Mar 2024 08:51:50 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 174F920B74C4; Tue, 12 Mar 2024 00:51:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 174F920B74C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710229910; bh=2Y8fhp16FKui49ckXxrT6HSlKdL9mBzDBngBD6Y1UxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCnYVqezyXnnZx1ZlbJ3cKMJcAbecXSeuPY6sph5+J1RonMy3AzLeOiA4R52dashv NcrwuIEMuu/gvy96Bbj1SDF+sAb9Cakm1T2y9silvCgNMH/IB7FjexLIP3g+2+XAom 0XKzfxqQa7ttHrzDXpyf4asMGzaQzOdUAH6CBGTo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Dmitry Kozlyuk , Thomas Monjalon , Bruce Richardson , David Marchand , Tyler Retzlaff Subject: [PATCH 3/3] ethdev: import and export data variables for MSVC Date: Tue, 12 Mar 2024 00:51:48 -0700 Message-Id: <1710229908-31704-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710229908-31704-1-git-send-email-roretzla@linux.microsoft.com> References: <1710229908-31704-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org MSVC requires that data variables be explicitly declared as either imported or exported. Provide macros that allow dpdk to correctly declare data variables as exported for itself and imported for applications. Use new per-library macro to declare variables exported or imported for per-lcore data variables. Signed-off-by: Tyler Retzlaff --- lib/ethdev/meson.build | 1 + lib/ethdev/rte_ethdev_core.h | 3 +++ lib/ethdev/rte_ethdev_export.h | 23 +++++++++++++++++++++++ lib/ethdev/version.map | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 lib/ethdev/rte_ethdev_export.h diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build index f1d2586..b270e02 100644 --- a/lib/ethdev/meson.build +++ b/lib/ethdev/meson.build @@ -23,6 +23,7 @@ sources = files( headers = files( 'rte_cman.h', 'rte_ethdev.h', + 'rte_ethdev_export.h', 'rte_ethdev_trace_fp.h', 'rte_dev_info.h', 'rte_flow.h', diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h index e55fb42..4e7939f 100644 --- a/lib/ethdev/rte_ethdev_core.h +++ b/lib/ethdev/rte_ethdev_core.h @@ -16,6 +16,8 @@ * Applications should not use these directly. */ +#include + struct rte_eth_dev_callback; /** @internal Structure to keep track of registered callbacks */ RTE_TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback); @@ -126,6 +128,7 @@ struct __rte_cache_aligned rte_eth_fp_ops { }; +__rte_ethdev_export extern struct rte_eth_fp_ops rte_eth_fp_ops[RTE_MAX_ETHPORTS]; #endif /* _RTE_ETHDEV_CORE_H_ */ diff --git a/lib/ethdev/rte_ethdev_export.h b/lib/ethdev/rte_ethdev_export.h new file mode 100644 index 0000000..7887bee --- /dev/null +++ b/lib/ethdev/rte_ethdev_export.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2024 Microsoft Corporation + */ + +#ifndef _RTE_ETHDEV_EXPORT_H_ +#define _RTE_ETHDEV_EXPORT_H_ + +/** + * @file + * + * Import / Export macros for ethdev data variables. + */ + +#include + +#ifndef __rte_ethdev_export +#define __rte_ethdev_export __rte_declare_import +#else +#undef __rte_ethdev_export +#define __rte_ethdev_export __rte_declare_export +#endif + +#endif diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 79f6f52..efe426f 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -83,7 +83,7 @@ DPDK_24 { rte_eth_find_next_of; rte_eth_find_next_owned_by; rte_eth_find_next_sibling; - rte_eth_fp_ops; + rte_eth_fp_ops; # MSVC_NO_EXPORT rte_eth_iterator_cleanup; rte_eth_iterator_init; rte_eth_iterator_next;