From patchwork Mon Apr 15 17:12: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: 139294 X-Patchwork-Delegate: david.marchand@redhat.com 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 516A843E7C; Mon, 15 Apr 2024 19:13:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3C6940608; Mon, 15 Apr 2024 19:12:53 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 46597400EF for ; Mon, 15 Apr 2024 19:12:50 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 8D0E920FC5F8; Mon, 15 Apr 2024 10:12:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8D0E920FC5F8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713201169; bh=HI2/3+28PICxvfENaylJE6ZA54gc/A2/asVTh6xSb7M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Akryg6LVZDOMFseWfEYBtRrbJ9xiCo4zZZdRBK389NAdjChVnqOv6DxsPG1t2TYKe EZ9yFBOR2FZtzw5aSRY48wTDF41rBb/OwzNDaBn+Sh9+cJhCdbVzzWCDhsSGJJzIcx 6DbO6yKbXkJq9TsiR4aXtRZtBNJ/HuILBWlKOB94= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Harman Kalra , Tyler Retzlaff Subject: [PATCH v5 1/2] build: build only one library type on Windows Date: Mon, 15 Apr 2024 10:12:47 -0700 Message-Id: <1713201168-2233-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1713201168-2233-1-git-send-email-roretzla@linux.microsoft.com> References: <1710445477-23848-1-git-send-email-roretzla@linux.microsoft.com> <1713201168-2233-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 is the only compiler that can produce usable shared libraries for DPDK on Windows because of the use of exported TLS variables. Disable building of shared libraries with LLVM and MinGW so that remaining __declspec macros needed for the functional libraries built by MSVC can be used without triggering errors in LLVM and MinGW builds. For Windows only install the default_library type to avoid confusion. Windows builds cannot build both shared and static in a single pass so install only the functional variant. Signed-off-by: Tyler Retzlaff Reviewed-by: Bruce Richardson --- config/meson.build | 24 +++++++++++++++++++ drivers/meson.build | 59 ++++++++++++++++++++-------------------------- lib/meson.build | 67 +++++++++++++++++++++-------------------------------- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/config/meson.build b/config/meson.build index 8c8b019..9882d33 100644 --- a/config/meson.build +++ b/config/meson.build @@ -516,4 +516,28 @@ if get_option('default_library') == 'both' NOTE: DPDK always builds both shared and static libraries. Please set "default_library" to either "static" or "shared" to select default linkage for apps and any examples.''') +elif get_option('default_library') == 'shared' and is_windows and not is_ms_compiler + error( ''' + Unsupported value "shared" for "default_library" option. + + NOTE: DPDK Windows shared is only supported when building with MSVC. Please set + "default_library" to either "static" or use MSVC.''') +endif + +is_shared_enabled=true +install_static = true +install_shared = true +if is_windows + install_static = get_option('default_library') == 'static' + install_shared = get_option('default_library') == 'shared' + if not is_ms_compiler or not install_shared + is_shared_enabled = false + else + # building shared libraries + dpdk_conf.set('RTE_BUILD_SHARED_LIB', true) + + # enable export / import of thread_local variables + add_project_arguments('/experimental:tlsDllInterface', language: 'c') + add_project_link_arguments('/experimental:tlsDllInterface', language: 'c') + endif endif diff --git a/drivers/meson.build b/drivers/meson.build index 66931d4..173403a 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -247,7 +247,7 @@ foreach subpath:subdirs include_directories: includes, dependencies: static_deps, c_args: cflags, - install: true) + install: install_static) # now build the shared driver version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), drv_path) @@ -271,48 +271,39 @@ foreach subpath:subdirs endif endif - if is_windows - if is_ms_linker + if is_shared_enabled + if is_ms_compiler def_file = custom_target(lib_name + '_def', command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], input: version_map, output: '@0@_exports.def'.format(lib_name)) lk_deps += [def_file] - - lk_args = ['-Wl,/def:' + def_file.full_path()] - if meson.version().version_compare('<0.54.0') - lk_args += ['-Wl,/implib:drivers\\lib' + lib_name + '.dll.a'] - endif + lk_args = ['/def:' + def_file.full_path()] else - mingw_map = custom_target(lib_name + '_mingw', - command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], - input: version_map, - output: '@0@_mingw.map'.format(lib_name)) - lk_deps += [mingw_map] - - lk_args = ['-Wl,--version-script=' + mingw_map.full_path()] + lk_args = ['-Wl,--version-script=' + version_map] endif - else - lk_args = ['-Wl,--version-script=' + version_map] endif - shared_lib = shared_library(lib_name, sources, - objects: objs, - include_directories: includes, - dependencies: shared_deps, - c_args: cflags, - link_args: lk_args, - link_depends: lk_deps, - version: abi_version, - soversion: so_version, - install: true, - install_dir: driver_install_path) - - # create a dependency object and add it to the global dictionary so - # testpmd or other built-in apps can find it if necessary - shared_dep = declare_dependency(link_with: shared_lib, - include_directories: includes, - dependencies: shared_deps) + shared_dep = {} + if is_shared_enabled + shared_lib = shared_library(lib_name, sources, + objects: objs, + include_directories: includes, + dependencies: shared_deps, + c_args: cflags, + link_args: lk_args, + link_depends: lk_deps, + version: abi_version, + soversion: so_version, + install: install_shared, + install_dir: driver_install_path) + + # create a dependency object and add it to the global dictionary so + # testpmd or other built-in apps can find it if necessary + shared_dep = declare_dependency(link_with: shared_lib, + include_directories: includes, + dependencies: shared_deps) + endif static_dep = declare_dependency( include_directories: includes, dependencies: static_deps) diff --git a/lib/meson.build b/lib/meson.build index 179a272..8b28314 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -242,11 +242,13 @@ foreach l:libraries c_args: cflags, dependencies: static_deps, include_directories: includes, - install: true) + install: install_static) static_dep = declare_dependency( include_directories: includes, dependencies: static_deps) + dpdk_static_libraries = [static_lib] + dpdk_static_libraries + if not use_function_versioning or is_windows # use pre-build objects to build shared lib sources = [] @@ -260,33 +262,14 @@ foreach l:libraries version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), l) lk_deps = [version_map] - if is_ms_linker - def_file = custom_target(libname + '_def', - command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], - input: version_map, - output: '@0@_exports.def'.format(libname)) - lk_deps += [def_file] - + if is_shared_enabled if is_ms_compiler - lk_args = ['/def:' + def_file.full_path()] - if meson.version().version_compare('<0.54.0') - lk_args += ['/implib:lib\\librte_' + l + '.dll.a'] - endif - else - lk_args = ['-Wl,/def:' + def_file.full_path()] - if meson.version().version_compare('<0.54.0') - lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a'] - endif - endif - else - if is_windows - mingw_map = custom_target(libname + '_mingw', + def_file = custom_target(libname + '_def', command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], input: version_map, - output: '@0@_mingw.map'.format(libname)) - lk_deps += [mingw_map] - - lk_args = ['-Wl,--version-script=' + mingw_map.full_path()] + output: '@0@_exports.def'.format(libname)) + lk_deps += [def_file] + lk_args = ['/def:' + def_file.full_path()] else lk_args = ['-Wl,--version-script=' + version_map] endif @@ -304,23 +287,25 @@ foreach l:libraries output: name + '.sym_chk') endif - shared_lib = shared_library(libname, - sources, - objects: objs, - c_args: cflags, - dependencies: shared_deps, - include_directories: includes, - link_args: lk_args, - link_depends: lk_deps, - version: abi_version, - soversion: so_version, - install: true) - shared_dep = declare_dependency(link_with: shared_lib, - include_directories: includes, - dependencies: shared_deps) + shared_dep = {} + if is_shared_enabled + shared_lib = shared_library(libname, + sources, + objects: objs, + c_args: cflags, + dependencies: shared_deps, + include_directories: includes, + link_args: lk_args, + link_depends: lk_deps, + version: abi_version, + soversion: so_version, + install: install_shared) + shared_dep = declare_dependency(link_with: shared_lib, + include_directories: includes, + dependencies: shared_deps) - dpdk_libraries = [shared_lib] + dpdk_libraries - dpdk_static_libraries = [static_lib] + dpdk_static_libraries + dpdk_libraries = [shared_lib] + dpdk_libraries + endif set_variable('shared_rte_' + name, shared_dep) set_variable('static_rte_' + name, static_dep) From patchwork Mon Apr 15 17:12: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: 139293 X-Patchwork-Delegate: david.marchand@redhat.com 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 DA49343E7C; Mon, 15 Apr 2024 19:12:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7641D4021E; Mon, 15 Apr 2024 19:12:51 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 53E1D4021E for ; Mon, 15 Apr 2024 19:12:50 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 998E220FC5F9; Mon, 15 Apr 2024 10:12:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 998E220FC5F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713201169; bh=Wrd61EGnv7yHZ2AHzVFtnuIN8ZYdw8g2VbJ63rGV6AU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iz2aEVvvO3ih5vyDmc5HEcnUxUjqf85N+GzgIneY2WkaHWJ7L3CISHwHZKSEOWmhF HPk2oH0ebMQQxJk3PpUYe0VhdusjiZTL0owMDhhEQAGVMyRkjm42Je2sGslRNS1wqL OVNGIpxl3DlPTP/A2f+iGfTgzfhVdjRsOk6E04KE= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Harman Kalra , Tyler Retzlaff Subject: [PATCH v5 2/2] buildtools: when building static library use static deps Date: Mon, 15 Apr 2024 10:12:48 -0700 Message-Id: <1713201168-2233-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1713201168-2233-1-git-send-email-roretzla@linux.microsoft.com> References: <1710445477-23848-1-git-send-email-roretzla@linux.microsoft.com> <1713201168-2233-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 Use the value of default_library and use it when building deps instead of always using static deps so we get the correct static or shared deps. Signed-off-by: Tyler Retzlaff Reviewed-by: Bruce Richardson --- buildtools/chkincs/meson.build | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/buildtools/chkincs/meson.build b/buildtools/chkincs/meson.build index f2dadca..5546489 100644 --- a/buildtools/chkincs/meson.build +++ b/buildtools/chkincs/meson.build @@ -20,10 +20,11 @@ sources += gen_c_files.process(dpdk_chkinc_headers) # some driver SDK headers depend on these two buses, which are mandatory in build # so we always include them in deps list -deps = [get_variable('shared_rte_bus_vdev'), get_variable('shared_rte_bus_pci')] +library_type = get_option('default_library') +deps = [get_variable(library_type + '_rte_bus_vdev'), get_variable(library_type + '_rte_bus_pci')] # add the rest of the libs to the dependencies foreach l:dpdk_libs_enabled - deps += get_variable('shared_rte_' + l) + deps += get_variable(library_type + '_rte_' + l) endforeach executable('chkincs', sources,