From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9FEF44687A; Wed, 4 Jun 2025 15:51:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7194B42DDC; Wed, 4 Jun 2025 15:50:55 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 26F9642D2B for ; Wed, 4 Jun 2025 15:50:53 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1213) id 1AEB1201FF4E; Wed, 4 Jun 2025 06:50:52 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1AEB1201FF4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1749045052; bh=Dp3/QYD5AhJTCtT3wdhjjDyJYST8DZW+rRWzYurVlq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RqfRArkUkcL8ifESfLTx7hB1EbJuBCrasGYpQRntM5Qwk27vW0ABhSDhT3vYyHF6J SNCmidWNzHycAHjSb6gWotmwvN/9bnuIDPUFvpeCtc8FIFAqatz3Gha9cP1LVk+8hW xso7gMK08I6XhqsLCED0wRWzRby2PXfoAEAniJ1w= From: Andre Muezerie To: andremue@linux.microsoft.com Cc: dev@dpdk.org Subject: [PATCH v5 1/4] eal: add macro to embed information in binaries Date: Wed, 4 Jun 2025 06:50:40 -0700 Message-Id: <1749045043-4319-2-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1749045043-4319-1-git-send-email-andremue@linux.microsoft.com> References: <1744400374-26620-1-git-send-email-andremue@linux.microsoft.com> <1749045043-4319-1-git-send-email-andremue@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 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 --- 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 9e7d84f929..17c537737e 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 +#endif + #ifdef RTE_TOOLCHAIN_MSVC #define __rte_used #else -- 2.49.0.vfs.0.3