Skip to contentSkip to conversation

build: fix using ELF-only linker flags with COFF

PATCH Applied Dmitry Kozlyuk 4 participants 6 messages Jan 12, 2021 – Jan 14, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: fix using ELF-only linker flags with COFF

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 b031e13d7f0d ("build: fix plugin load on static build")

---
Using TLS variables with DLLs is problematic on Windows for now, so not attempting to check or solve the issue with plugin load.

 app/meson.build                   | 2 +-
 buildtools/pkg-config/meson.build | 6 +++++-
 examples/meson.build              | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)
app/meson.build +1 -1
index fd72d7da6..903117b86 100644
@@ -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
 
buildtools/pkg-config/meson.build +5 -1
index 168ee08e5..39a8fd1c8 100644
@@ -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(),
@@ -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,
examples/meson.build +1 -1
index f643ec1ba..b9ab24223 100644
@@ -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
 
Signature · 1 line
2.29.2
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Dmitry Kozlyuk

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 b031e13d7f0d ("build: fix plugin load on static build")
Quoted 8 lines

---
Using TLS variables with DLLs is problematic on Windows for now, so not attempting to check or solve the issue with plugin load.

  app/meson.build                   | 2 +-
  buildtools/pkg-config/meson.build | 6 +++++-
  examples/meson.build              | 2 +-
  3 files changed, 7 insertions(+), 3 deletions(-)
#2 lore raw

13/01/2021 21:27, Ranjit Menon:

Quoted 15 lines · Dmitry Kozlyuk
Quoted 14 lines

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 b031e13d7f0d ("build: fix plugin load on static build")
Quoted 6 lines
Quoted 4 lines

---
Using TLS variables with DLLs is problematic on Windows for now, so not attempting to check or solve the issue with plugin load.

Applied, thanks

Why we didn't catch it in advance in CI?

#3 lore raw
Quoted 27 lines

Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] build: fix using ELF-only linker flags with COFF

External email: Use caution opening links or attachments

13/01/2021 21:27, Ranjit Menon:

Quoted 20 lines · Dmitry Kozlyuk
Quoted 18 lines

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 b031e13d7f0d ("build: fix plugin load on static build")

---
Using TLS variables with DLLs is problematic on Windows for now, so not attempting to check or solve the issue with plugin load.

Quoted 6 lines
Quoted 1 line

Applied, thanks

Why we didn't catch it in advance in CI?

I think Windows CI still passes on builds with warnings, maybe we can change it now that we cleared all of them.

#4 lore raw

14/01/2021 10:27, Tal Shnaiderman:

Quoted 27 lines
Quoted 27 lines

Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] build: fix using ELF-only linker flags with COFF

External email: Use caution opening links or attachments

13/01/2021 21:27, Ranjit Menon:

Quoted 20 lines · Dmitry Kozlyuk
Quoted 18 lines

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 b031e13d7f0d ("build: fix plugin load on static build")

---
Using TLS variables with DLLs is problematic on Windows for now, so not attempting to check or solve the issue with plugin load.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Applied, thanks

Why we didn't catch it in advance in CI?

I think Windows CI still passes on builds with warnings, maybe we can change it now that we cleared all of them.

Yes.
Please can you open a ticket in bugs.dpdk.org in the section lab/jobs? Thank you

#5 lore raw
Quoted 42 lines

Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] build: fix using ELF-only linker flags with COFF

External email: Use caution opening links or attachments

14/01/2021 10:27, Tal Shnaiderman:

Quoted 6 lines
Quoted 6 lines

Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] build: fix using ELF-only linker flags with COFF

External email: Use caution opening links or attachments

Quoted 6 lines
Quoted 6 lines

13/01/2021 21:27, Ranjit Menon:

Quoted 5 lines · Dmitry Kozlyuk
Quoted 4 lines

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

Quoted 22 lines
Quoted 21 lines
Quoted 10 lines
Quoted 10 lines

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 b031e13d7f0d ("build: fix plugin load on static build")
Quoted 6 lines
Quoted 4 lines

---
Using TLS variables with DLLs is problematic on Windows for now, so not attempting to check or solve the issue with plugin load.

Applied, thanks

Why we didn't catch it in advance in CI?

Quoted 7 lines
Quoted 1 line

I think Windows CI still passes on builds with warnings, maybe we can

change it now that we cleared all of them.

Yes.
Please can you open a ticket in bugs.dpdk.org in the section lab/jobs? Thank you

Done, Bug number 614.