From patchwork Thu Mar 14 19:44:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138407 X-Patchwork-Delegate: jerinj@marvell.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 B631143CB4; Thu, 14 Mar 2024 20:44:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5914C42E9D; Thu, 14 Mar 2024 20:44:43 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A639F400D7 for ; Thu, 14 Mar 2024 20:44:39 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 026FE20B74C2; Thu, 14 Mar 2024 12:44:38 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 026FE20B74C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710445479; bh=lbH6fbRO9thEZRZ4TgysgoZJseQp4W13loSK24pB0D4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nY2v4AAIB1+Dc/v/AyPuKz3q/nHF4VnD3YkGqXz2qXplurn0/qar1T7Y8cr+pxOBw mseS9Ir8mVkIF05ehXxzLOtqlMZxl8ZPzfwYTJ9UQk+kUiD/fK/P+84RhJCPfQXJI3 ZV6X9JcflqIUSt6ajd8rmHPRKN49r8/i87s4wqyA= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Harman Kalra , Tyler Retzlaff Subject: [PATCH] build: build only one library type on Windows Date: Thu, 14 Mar 2024 12:44:37 -0700 Message-Id: <1710445477-23848-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710445477-23848-1-git-send-email-roretzla@linux.microsoft.com> References: <1710445477-23848-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 --- config/meson.build | 20 +++++++ drivers/meson.build | 51 ++++++++++-------- drivers/net/octeontx/base/meson.build | 2 +- lib/meson.build | 98 +++++++++++++++++++---------------- 4 files changed, 101 insertions(+), 70 deletions(-) diff --git a/config/meson.build b/config/meson.build index 8c8b019..2090846 100644 --- a/config/meson.build +++ b/config/meson.build @@ -516,4 +516,24 @@ 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 + +if is_windows and not is_ms_compiler + is_shared_enabled=false +else + is_shared_enabled=true +endif + +if is_windows + install_static = get_option('default_library') == 'static' + install_shared = get_option('default_library') == 'shared' +else + install_static=true + install_shared=true endif diff --git a/drivers/meson.build b/drivers/meson.build index 66931d4..e7cfda6 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -80,7 +80,7 @@ foreach subpath:subdirs subdir(class) skip_class = false foreach d:std_deps - if not is_variable('shared_rte_' + d) + if not is_variable('static_rte_' + d) skip_class = true reason = 'missing internal dependency, "@0@"'.format(d) if dpdk_libs_deprecated.contains(d) @@ -173,7 +173,7 @@ foreach subpath:subdirs if not build break endif - if not is_variable('shared_rte_' + d) + if not is_variable('static_rte_' + d) build = false reason = 'missing internal dependency, "@0@"'.format(d) if dpdk_libs_deprecated.contains(d) @@ -188,7 +188,9 @@ foreach subpath:subdirs +'\tPlease enable missing dependency "@0@"'.format(d)) endif else - shared_deps += [get_variable('shared_rte_' + d)] + if is_shared_enabled + shared_deps += [get_variable('shared_rte_' + d)] + endif static_deps += [get_variable('static_rte_' + d)] endif endforeach @@ -247,7 +249,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,7 +273,7 @@ foreach subpath:subdirs endif endif - if is_windows + if is_windows and is_shared_enabled if is_ms_linker def_file = custom_target(lib_name + '_def', command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'], @@ -296,30 +298,33 @@ foreach subpath:subdirs 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) + 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) + + set_variable('shared_@0@'.format(lib_name), shared_dep) + endif static_dep = declare_dependency( include_directories: includes, dependencies: static_deps) dpdk_drivers += static_lib - set_variable('shared_@0@'.format(lib_name), shared_dep) set_variable('static_@0@'.format(lib_name), static_dep) # for drivers, we only need to add dependency objects for static libs, # shared lib drivers are not linked in diff --git a/drivers/net/octeontx/base/meson.build b/drivers/net/octeontx/base/meson.build index 8e5e8c1..a793c19 100644 --- a/drivers/net/octeontx/base/meson.build +++ b/drivers/net/octeontx/base/meson.build @@ -10,7 +10,7 @@ sources = [ depends = ['ethdev', 'mempool_octeontx'] static_objs = [] foreach d: depends - if not is_variable('shared_rte_' + d) + if not is_variable('static_rte_' + d) subdir_done() endif static_objs += get_variable('static_rte_' + d) diff --git a/lib/meson.build b/lib/meson.build index 179a272..e92ba35 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -184,7 +184,7 @@ foreach l:libraries if not build break endif - if not is_variable('shared_rte_' + d) + if not is_variable('static_rte_' + d) build = false reason = 'missing internal dependency, "@0@"'.format(d) if dpdk_libs_deprecated.contains(d) @@ -197,7 +197,9 @@ foreach l:libraries + '\tPlease add missing dependency "@0@" to "enable_libs" option'.format(d)) endif else - shared_deps += [get_variable('shared_rte_' + d)] + if is_shared_enabled + shared_deps += [get_variable('shared_rte_' + d)] + endif static_deps += [get_variable('static_rte_' + d)] endif endforeach @@ -242,7 +244,7 @@ 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) @@ -260,35 +262,37 @@ 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_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', + if is_shared_enabled + if is_ms_linker + 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] + output: '@0@_exports.def'.format(libname)) + lk_deps += [def_file] - lk_args = ['-Wl,--version-script=' + mingw_map.full_path()] + 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 - lk_args = ['-Wl,--version-script=' + version_map] + if is_windows + mingw_map = custom_target(libname + '_mingw', + 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()] + else + lk_args = ['-Wl,--version-script=' + version_map] + endif endif endif @@ -304,27 +308,29 @@ 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) + 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 + set_variable('shared_rte_' + name, shared_dep) + dpdk_shared_lib_deps += shared_dep + endif - set_variable('shared_rte_' + name, shared_dep) + dpdk_static_libraries = [static_lib] + dpdk_static_libraries set_variable('static_rte_' + name, static_dep) - dpdk_shared_lib_deps += shared_dep dpdk_static_lib_deps += static_dep if developer_mode message('lib/@0@: Defining dependency "@1@"'.format(l, name)) From patchwork Fri Mar 15 06:30:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138421 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 7D66B43CA6; Fri, 15 Mar 2024 07:30:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAB9642E6B; Fri, 15 Mar 2024 07:30:25 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6710842DCA for ; Fri, 15 Mar 2024 07:30:24 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id ABF8520B74C3; Thu, 14 Mar 2024 23:30:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ABF8520B74C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710484223; bh=+xrHICIioWpl4hd7AA+EgZS16wE6KICDIS1nz3zN+uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=crx/mjr4TXqQxnMSext/RK0RnN/Pnxl8YGgRRL3UmQGa6FAzRLpBPc4OmN7ZPQDG4 axs8SlxFHm5aNiV4Try0vB7l7DCkf5fgvrbFBRs+8pertPx5MM3ez7WVCGeQK/OEWT tBgNjGZNR1QHngP19iWI6IIA9zyd52rxVbc39Ejg= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Harman Kalra , Tyler Retzlaff Subject: [PATCH v2 2/2] buildtools: when building static library use static deps Date: Thu, 14 Mar 2024 23:30:22 -0700 Message-Id: <1710484222-17310-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710484222-17310-1-git-send-email-roretzla@linux.microsoft.com> References: <1710445477-23848-1-git-send-email-roretzla@linux.microsoft.com> <1710484222-17310-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 static deps when default_library=static and use shared deps when using default_library=shared. Signed-off-by: Tyler Retzlaff --- buildtools/chkincs/meson.build | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/buildtools/chkincs/meson.build b/buildtools/chkincs/meson.build index f2dadca..66245a5 100644 --- a/buildtools/chkincs/meson.build +++ b/buildtools/chkincs/meson.build @@ -20,11 +20,19 @@ 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')] -# add the rest of the libs to the dependencies -foreach l:dpdk_libs_enabled - deps += get_variable('shared_rte_' + l) -endforeach +if is_shared_enabled + deps = [get_variable('shared_rte_bus_vdev'), get_variable('shared_rte_bus_pci')] + # add the rest of the libs to the dependencies + foreach l:dpdk_libs_enabled + deps += get_variable('shared_rte_' + l) + endforeach +else + deps = [get_variable('static_rte_bus_vdev'), get_variable('static_rte_bus_pci')] + # add the rest of the libs to the dependencies + foreach l:dpdk_libs_enabled + deps += get_variable('static_rte_' + l) + endforeach +endif executable('chkincs', sources, c_args: cflags,