Skip to content

Commit

Permalink
build: fix linker flags on Windows
Browse files Browse the repository at this point in the history
[ upstream commit da042bc ]

The --export-dynamic linker option is only applicable to ELF.
On Windows, where COFF is used, it causes warnings:

    x86_64-w64-mingw32-ld: warning: --export-dynamic is not supported
    for PE+ targets, did you mean --export-all-symbols? (MinGW)

    LINK : warning LNK4044: unrecognized option '/-export-dynamic';
    ignored (clang)

Don't add --export-dynamic on Windows anywhere.

Fixes: b031e13 ("build: fix plugin load on static build")

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Ranjit Menon <ranjit.menon@intel.com>
  • Loading branch information
PlushBeaver authored and bluca committed Feb 2, 2021
1 parent 6bec454 commit a0e0fe9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/meson.build
Expand Up @@ -26,7 +26,7 @@ lib_execinfo = cc.find_library('execinfo', required: false)

default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
default_ldflags = []
if get_option('default_library') == 'static'
if get_option('default_library') == 'static' and not is_windows
default_ldflags += ['-Wl,--export-dynamic']
endif

Expand Down
6 changes: 5 additions & 1 deletion buildtools/pkg-config/meson.build
Expand Up @@ -37,6 +37,10 @@ Use libdpdk.pc instead of this file to query DPDK compile/link arguments''',
libraries: ['-Wl,--as-needed'] + dpdk_libraries,
libraries_private: dpdk_extra_ldflags)

platform_flags = []
if not is_windows
platform_flags += ['-Wl,--export-dynamic'] # ELF only
endif
pkg.generate(name: 'DPDK', # main DPDK pkgconfig file
filebase: 'libdpdk',
version: meson.project_version(),
Expand All @@ -47,7 +51,7 @@ This is required for a number of static inline functions in the public headers.'
# if libbsd is not enabled, then this is blank
libraries_private: ['-Wl,--whole-archive'] +
dpdk_drivers + dpdk_static_libraries +
['-Wl,--no-whole-archive', '-Wl,--export-dynamic']
['-Wl,--no-whole-archive'] + platform_flags
)

# For static linking with dependencies as shared libraries,
Expand Down
2 changes: 1 addition & 1 deletion examples/meson.build
Expand Up @@ -64,7 +64,7 @@ if cc.has_argument('-Wno-format-truncation')
default_cflags += '-Wno-format-truncation'
endif
default_ldflags = dpdk_extra_ldflags
if get_option('default_library') == 'static'
if get_option('default_library') == 'static' and not is_windows
default_ldflags += ['-Wl,--export-dynamic']
endif

Expand Down

0 comments on commit a0e0fe9

Please sign in to comment.