From patchwork Wed Mar 6 22:17:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Szczepanek X-Patchwork-Id: 138071 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 5312743B6F; Wed, 6 Mar 2024 23:17:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C7E842ED4; Wed, 6 Mar 2024 23:17:20 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id ADCF8402C0 for ; Wed, 6 Mar 2024 23:17:17 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 91743C15; Wed, 6 Mar 2024 14:17:54 -0800 (PST) Received: from ampere-altra-2-1.usa.Arm.com (ampere-altra-2-1.usa.arm.com [10.118.91.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1A8273F73F; Wed, 6 Mar 2024 14:17:17 -0800 (PST) From: Paul Szczepanek To: thomas@monjalon.net Cc: dev@dpdk.org, Paul Szczepanek , Dhruv Tripathi Subject: [PATCH v1 1/1] lib: allow libraries with no sources Date: Wed, 6 Mar 2024 22:17:09 +0000 Message-Id: <20240306221709.166722-2-paul.szczepanek@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240306221709.166722-1-paul.szczepanek@arm.com> References: <20240306221709.166722-1-paul.szczepanek@arm.com> MIME-Version: 1.0 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 Allow header only libraries. Signed-off-by: Paul Szczepanek Reviewed-by: Dhruv Tripathi --- lib/meson.build | 176 +++++++++++++++++++++++++----------------------- 1 file changed, 91 insertions(+), 85 deletions(-) -- 2.25.1 diff --git a/lib/meson.build b/lib/meson.build index 4fb01f059b..0fcf3336d1 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -220,105 +220,111 @@ foreach l:libraries includes += include_directories(l) dpdk_includes += include_directories(l) - if developer_mode and is_windows and use_function_versioning - message('@0@: Function versioning is not supported by Windows.'.format(name)) - endif + if sources.length() != 0 + if developer_mode and is_windows and use_function_versioning + message('@0@: Function versioning is not supported by Windows.'.format(name)) + endif - if use_function_versioning - cflags += '-DRTE_USE_FUNCTION_VERSIONING' - endif - cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l - if annotate_locks and cc.get_id() == 'clang' and cc.version().version_compare('>=3.5.0') - cflags += '-DRTE_ANNOTATE_LOCKS' - cflags += '-Wthread-safety' - endif + if use_function_versioning + cflags += '-DRTE_USE_FUNCTION_VERSIONING' + endif + cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l + if annotate_locks and cc.get_id() == 'clang' and cc.version().version_compare('>=3.5.0') + cflags += '-DRTE_ANNOTATE_LOCKS' + cflags += '-Wthread-safety' + endif - # first build static lib - static_lib = static_library(libname, - sources, - objects: objs, - c_args: cflags, - dependencies: static_deps, - include_directories: includes, - install: true) - static_dep = declare_dependency( - include_directories: includes, - dependencies: static_deps) + # first build static lib + static_lib = static_library(libname, + sources, + objects: objs, + c_args: cflags, + dependencies: static_deps, + include_directories: includes, + install: true) + static_dep = declare_dependency( + include_directories: includes, + dependencies: static_deps) - if not use_function_versioning or is_windows - # use pre-build objects to build shared lib - sources = [] - objs += static_lib.extract_all_objects(recursive: false) - else - # for compat we need to rebuild with - # RTE_BUILD_SHARED_LIB defined - cflags += '-DRTE_BUILD_SHARED_LIB' - endif + if not use_function_versioning or is_windows + # use pre-build objects to build shared lib + sources = [] + objs += static_lib.extract_all_objects(recursive: false) + else + # for compat we need to rebuild with + # RTE_BUILD_SHARED_LIB defined + cflags += '-DRTE_BUILD_SHARED_LIB' + endif - version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), l) - lk_deps = [version_map] + 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_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'] + 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,/def:' + def_file.full_path()] - if meson.version().version_compare('<0.54.0') - lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a'] + 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 - else - 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] + if developer_mode and not is_windows + # on unix systems check the output of the + # check-symbols.sh script, using it as a + # dependency of the .so build + lk_deps += custom_target(name + '.sym_chk', + command: [check_symbols, + version_map, '@INPUT@'], + capture: true, + input: static_lib, + output: name + '.sym_chk') endif - endif - - if developer_mode and not is_windows - # on unix systems check the output of the - # check-symbols.sh script, using it as a - # dependency of the .so build - lk_deps += custom_target(name + '.sym_chk', - command: [check_symbols, - version_map, '@INPUT@'], - capture: true, - input: static_lib, - 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_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) - dpdk_libraries = [shared_lib] + dpdk_libraries - dpdk_static_libraries = [static_lib] + dpdk_static_libraries + dpdk_libraries = [shared_lib] + dpdk_libraries + dpdk_static_libraries = [static_lib] + dpdk_static_libraries + else # sources.length() == 0 + # if no C files, just set a dependency on header path + shared_dep = declare_dependency(include_directories: includes) + static_dep = shared_dep + endif set_variable('shared_rte_' + name, shared_dep) set_variable('static_rte_' + name, static_dep)