From: Bruce Richardson <bruce.richardson@intel.com>
To: Andre Muezerie <andremue@linux.microsoft.com>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH v4 1/4] eal: add macro to embed information in binaries
Date: Wed, 4 Jun 2025 15:13:55 +0100 [thread overview]
Message-ID: <aEBUo5B5EIT2eLG1@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <1744839898-15745-2-git-send-email-andremue@linux.microsoft.com>
On Wed, Apr 16, 2025 at 02:44:55PM -0700, Andre Muezerie wrote:
> DPDK uses GCC attribute "used" through macro __rte_used to indicate
> that a variable not referenced in the code should be assumed being
> used and therefore not be optimized away. This technique is used to embed
> information in the binaries, by having crafted information stored in
> them.
>
> MSVC offers similar functionality, but it differs significantly: MSVC
> requires a pragma to be used to send a command to the linker telling it
> explicitly the name of the symbol that should be included (even if not
> referenced). As a side-effect, variables called out to be included cannot
> be static, otherwise their symbols are not "seen" by the linker. This
> restriction requires some DPDK code to be refactored.
>
> To assimilate these requirements/restrictions, macro RTE_INCLUDE is
> introduced in this patch.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
> lib/eal/common/eal_common_options.c | 2 +-
> lib/eal/include/rte_common.h | 6 ++++++
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
> index b6fff7ec05..8d115a5bd7 100644
> --- a/lib/eal/common/eal_common_options.c
> +++ b/lib/eal/common/eal_common_options.c
> @@ -135,7 +135,7 @@ static const char *default_solib_dir = RTE_EAL_PMD_PATH;
> * Note: PLEASE DO NOT ALTER THIS without making a corresponding
> * change to usertools/dpdk-pmdinfo.py
> */
> -static const char dpdk_solib_path[] __rte_used =
> +RTE_INCLUDE(const char, dpdk_solib_path)[] =
> "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
>
> TAILQ_HEAD(device_option_list, device_option);
> diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
> index a6085dce27..4c5a3b668f 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -231,6 +231,12 @@ typedef uint16_t unaligned_uint16_t;
> /**
> * Force symbol to be generated even if it appears to be unused.
> */
> +#ifdef RTE_TOOLCHAIN_MSVC
> +#define RTE_INCLUDE(type, name) __pragma(comment(linker, "/include:" RTE_STR(name))) type name
> +#else
> +#define RTE_INCLUDE(type, name) __attribute__((used)) type name
Any reason we shouldn't also have "static" here, for the non-MSVC case?
As a general question, is this needed for any/many tasks other than putting
in place strings? Rather than having a general include macro,
I'm just wondering if we are better doing specific macros for the driver
string, and then other-string use-cases.
/Bruce
next prev parent reply other threads:[~2025-06-04 14:14 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 19:39 [PATCH 0/4] allow pmdinfo to be inserted and parsed using MSVC Andre Muezerie
2025-04-11 19:39 ` [PATCH 1/4] eal: add macro to embed information in binaries Andre Muezerie
2025-04-11 19:39 ` [PATCH 2/4] buildtools: use " Andre Muezerie
2025-04-11 20:07 ` Dmitry Kozlyuk
2025-04-11 19:39 ` [PATCH 3/4] usertools: parse strings from PE images Andre Muezerie
2025-04-11 20:09 ` Dmitry Kozlyuk
2025-04-11 19:39 ` [PATCH 4/4] drivers: use macro to embed information in binaries Andre Muezerie
2025-04-15 1:21 ` [PATCH v2 0/4] allow pmdinfo to be inserted and parsed using MSVC Andre Muezerie
2025-04-15 1:21 ` [PATCH v2 1/4] eal: add macro to embed information in binaries Andre Muezerie
2025-04-15 1:21 ` [PATCH v2 2/4] buildtools: use " Andre Muezerie
2025-04-15 7:44 ` Dmitry Kozlyuk
2025-04-15 14:36 ` Andre Muezerie
2025-04-15 1:21 ` [PATCH v2 3/4] usertools: parse strings from PE images Andre Muezerie
2025-04-15 11:19 ` Robin Jarry
2025-04-15 1:21 ` [PATCH v2 4/4] drivers: use macro to embed information in binaries Andre Muezerie
2025-04-16 0:05 ` Stephen Hemminger
2025-04-17 17:10 ` Andre Muezerie
2025-04-15 22:31 ` [PATCH v3 0/4] allow pmdinfo to be inserted and parsed using MSVC Andre Muezerie
2025-04-15 22:31 ` [PATCH v3 1/4] eal: add macro to embed information in binaries Andre Muezerie
2025-04-15 22:31 ` [PATCH v3 2/4] buildtools: use " Andre Muezerie
2025-04-15 22:31 ` [PATCH v3 3/4] usertools: parse strings from PE images Andre Muezerie
2025-04-15 22:31 ` [PATCH v3 4/4] drivers: use macro to embed information in binaries Andre Muezerie
2025-04-16 21:44 ` [PATCH v4 0/4] allow pmdinfo to be inserted and parsed using MSVC Andre Muezerie
2025-04-16 21:44 ` [PATCH v4 1/4] eal: add macro to embed information in binaries Andre Muezerie
2025-06-04 14:13 ` Bruce Richardson [this message]
2025-06-04 14:52 ` Andre Muezerie
2025-04-16 21:44 ` [PATCH v4 2/4] buildtools: use " Andre Muezerie
2025-06-04 11:04 ` David Marchand
2025-06-04 13:59 ` Andre Muezerie
2025-04-16 21:44 ` [PATCH v4 3/4] usertools: parse strings from PE images Andre Muezerie
2025-04-16 21:44 ` [PATCH v4 4/4] drivers: use macro to embed information in binaries Andre Muezerie
2025-06-03 1:01 ` [PATCH v4 0/4] allow pmdinfo to be inserted and parsed using MSVC Andre Muezerie
2025-06-04 12:03 ` David Marchand
2025-06-04 13:56 ` Andre Muezerie
2025-06-04 13:50 ` [PATCH v5 " Andre Muezerie
2025-06-04 13:50 ` [PATCH v5 1/4] eal: add macro to embed information in binaries Andre Muezerie
2025-06-04 13:50 ` [PATCH v5 2/4] buildtools: use " Andre Muezerie
2025-06-04 13:50 ` [PATCH v5 3/4] usertools: parse strings from PE images Andre Muezerie
2025-06-04 13:50 ` [PATCH v5 4/4] drivers: use macro to embed information in binaries Andre Muezerie
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=aEBUo5B5EIT2eLG1@bricha3-mobl1.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=andremue@linux.microsoft.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).