Skip to contentSkip to conversation

eal/windows: fix build warnings in MinGW

PATCH Superseded Tal Shnaiderman 5 participants 16 messages Apr 18, 2021 – May 4, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal/windows: fix build warnings in MinGW

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the header.

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined
#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Fixed by defining the marco only to the clang compiler.

Fixes 45d62067c237 ("eal: make OS shims internal")
---
 lib/librte_eal/windows/include/rte_os_shim.h | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/windows/include/rte_os_shim.h +2 -0
index f40fb62d1d..db0ea6f1b3 100644
@@ -17,7 +17,9 @@
 
 #define strdup(str) _strdup(str)
 #define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr)
+#ifndef RTE_TOOLCHAIN_GCC
 #define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)
+#endif
 
 #define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
 #define read(fd, buf, n) _read(fd, buf, n)
Signature · 1 line
2.16.1.windows.4
#1 lore raw

18/04/2021 19:08, Tal Shnaiderman:

Quoted 8 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the header.

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined
#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build test?

Quoted 1 line

Fixed by defining the marco only to the clang compiler.

That's a very common typo: s/marco/macro/

#2 lore raw
Quoted 10 lines

Subject: Re: [PATCH] eal/windows: fix build warnings in MinGW

External email: Use caution opening links or attachments

18/04/2021 19:08, Tal Shnaiderman:

Quoted 4 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the header.

Quoted 5 lines
Quoted 3 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined
#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build test?

It's a good question, I see CI is passing without warnings, Dmitry can you reproduce it?

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-mingw32/include/string.h:119: note: this is the location of the previous definition
#define strncasecmp _strnicmp

I'm using:
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0 -meson 0.53.2

Quoted 5 lines
Quoted 2 lines

Fixed by defining the marco only to the clang compiler.

That's a very common typo: s/marco/macro/

Thanks, will fix in v2 if this patch is indeed needed.

Quoted 1 line
#3 lore raw

Hi Tal,

2021-04-18 19:04 (UTC+0000), Tal Shnaiderman:

Quoted 24 lines
Quoted 10 lines

Subject: Re: [PATCH] eal/windows: fix build warnings in MinGW

External email: Use caution opening links or attachments

18/04/2021 19:08, Tal Shnaiderman:

Quoted 4 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the header.

Quoted 5 lines
Quoted 3 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined
#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build test?

It's a good question, I see CI is passing without warnings, Dmitry can you reproduce it?

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-mingw32/include/string.h:119: note: this is the location of the previous definition
#define strncasecmp _strnicmp

I'm using:

Review

Quoted 2 lines
(quoted diff) +0 -2
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
-meson 0.53.2

I can't reproduce it using the same versions.
Do you invoke meson with other options than "-Dexamples=..."?

#4 lore raw
Quoted 35 lines

Subject: Re: [PATCH] eal/windows: fix build warnings in MinGW

External email: Use caution opening links or attachments

Hi Tal,

2021-04-18 19:04 (UTC+0000), Tal Shnaiderman:

Quoted 9 lines
Quoted 9 lines

Subject: Re: [PATCH] eal/windows: fix build warnings in MinGW

External email: Use caution opening links or attachments

18/04/2021 19:08, Tal Shnaiderman:

Quoted 3 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the

header.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined
#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build test?

It's a good question, I see CI is passing without warnings, Dmitry can you

reproduce it?

Quoted 4 lines

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-

mingw32/include/string.h:119:

Quoted 3 lines

note: this is the location of the previous definition #define strncasecmp _strnicmp

Quoted 6 lines
Quoted 3 lines

I'm using:
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0 -meson 0.53.2

I can't reproduce it using the same versions.
Do you invoke meson with other options than "-Dexamples=..."?

This is the meson line I'm using:

meson "-Dexamples=helloworld" build --wipe --default-library=static --buildtype debug

The problem however is that MinGW's string.h defines the macro in line 119, for some reason my build includes it and the rest doesn't.

#5 lore raw
Quoted 50 lines

Subject: Re: [dpdk-dev] [PATCH] eal/windows: fix build warnings in MinGW

External email: Use caution opening links or attachments

Quoted 37 lines

Subject: Re: [PATCH] eal/windows: fix build warnings in MinGW

External email: Use caution opening links or attachments

Hi Tal,

2021-04-18 19:04 (UTC+0000), Tal Shnaiderman:

Quoted 10 lines
Quoted 10 lines

Subject: Re: [PATCH] eal/windows: fix build warnings in MinGW

External email: Use caution opening links or attachments

18/04/2021 19:08, Tal Shnaiderman:

Quoted 4 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the

header.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined #define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build test?

It's a good question, I see CI is passing without warnings, Dmitry can you

reproduce it?

Quoted 4 lines

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-

mingw32/include/string.h:119:

Quoted 3 lines

note: this is the location of the previous definition #define strncasecmp _strnicmp

Quoted 7 lines
Quoted 4 lines

I'm using:

(quoted diff) +0 -2
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
-meson

0.53.2

I can't reproduce it using the same versions.
Do you invoke meson with other options than "-Dexamples=..."?

Quoted 7 lines

This is the meson line I'm using:

meson "-Dexamples=helloworld" build --wipe --default-library=static -- buildtype debug

The problem however is that MinGW's string.h defines the macro in line 119, for some reason my build includes it and the rest doesn't.

Hi Dmitry,

I also noticed warnings in clang on my setup that are related to rte_os_shim.h:

[185/314] Compiling C object drivers/a715181@@tmp_rte_common_mlx5@sta/common_mlx5_mlx5_common_mp.c.obj.
In file included from ../drivers/common/mlx5/mlx5_common_mp.c:13:
In file included from ..\drivers\common/mlx5/mlx5_common_utils.h:8:
In file included from ..\drivers\common/mlx5/mlx5_common.h:17:
..\lib/librte_eal/windows/include\rte_os_shim.h:22:51: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]

#define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
                                                  ^

However don't see it in CI, I'm using clang version 9.0.1

#6 lore raw

19/04/2021 20:06, Tal Shnaiderman:

Quoted 45 lines
Quoted 33 lines
Quoted 25 lines

2021-04-18 19:04 (UTC+0000), Tal Shnaiderman:

Quoted 5 lines
Quoted 5 lines

18/04/2021 19:08, Tal Shnaiderman:

Quoted 4 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the

header.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined #define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build test?

It's a good question, I see CI is passing without warnings, Dmitry can you

reproduce it?

Quoted 4 lines

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-

mingw32/include/string.h:119:

Quoted 3 lines

note: this is the location of the previous definition #define strncasecmp _strnicmp

Quoted 7 lines
Quoted 4 lines

I'm using:

(quoted diff) +0 -2
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
-meson

0.53.2

I can't reproduce it using the same versions.
Do you invoke meson with other options than "-Dexamples=..."?

Quoted 7 lines

This is the meson line I'm using:

meson "-Dexamples=helloworld" build --wipe --default-library=static -- buildtype debug

The problem however is that MinGW's string.h defines the macro in line 119, for some reason my build includes it and the rest doesn't.

Hi Dmitry,

I also noticed warnings in clang on my setup that are related to rte_os_shim.h:

Quoted 8 lines

[185/314] Compiling C object drivers/a715181@@tmp_rte_common_mlx5@sta/common_mlx5_mlx5_common_mp.c.obj.
In file included from ../drivers/common/mlx5/mlx5_common_mp.c:13:
In file included from ..\drivers\common/mlx5/mlx5_common_utils.h:8:
In file included from ..\drivers\common/mlx5/mlx5_common.h:17:
..\lib/librte_eal/windows/include\rte_os_shim.h:22:51: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]

#define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
                                                  ^

However don't see it in CI, I'm using clang version 9.0.1

It seems we should improve our CI.
Please open suggestions in the CI bugzilla.

#7 lore raw
Quoted 57 lines · Thomas Monjalon

19/04/2021 20:06, Tal Shnaiderman:

Quoted 52 lines
Quoted 33 lines
Quoted 25 lines

2021-04-18 19:04 (UTC+0000), Tal Shnaiderman:

Quoted 5 lines
Quoted 5 lines

18/04/2021 19:08, Tal Shnaiderman:

Quoted 4 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the

header.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined #define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build test?

It's a good question, I see CI is passing without warnings, Dmitry can you

reproduce it?

Quoted 4 lines

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-

mingw32/include/string.h:119:

Quoted 3 lines

note: this is the location of the previous definition #define strncasecmp _strnicmp

Quoted 7 lines
Quoted 4 lines

I'm using:

(quoted diff) +0 -2
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
-meson

0.53.2

I can't reproduce it using the same versions.
Do you invoke meson with other options than "-Dexamples=..."?

Quoted 7 lines

This is the meson line I'm using:

meson "-Dexamples=helloworld" build --wipe --default-library=static -- buildtype debug

The problem however is that MinGW's string.h defines the macro in line 119, for some reason my build includes it and the rest doesn't.

Hi Dmitry,

I also noticed warnings in clang on my setup that are related to rte_os_shim.h:

[185/314] Compiling C object drivers/a715181@@tmp_rte_common_mlx5@sta/common_mlx5_mlx5_common_mp.c.obj. In file included from ../drivers/common/mlx5/mlx5_common_mp.c:13:
In file included from ..\drivers\common/mlx5/mlx5_common_utils.h:8:
In file included from ..\drivers\common/mlx5/mlx5_common.h:17:
..\lib/librte_eal/windows/include\rte_os_shim.h:22:51: warning:
token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]

Quoted 3 lines
#define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
                                                  ^

However don't see it in CI, I'm using clang version 9.0.1

Quoted 2 lines

It seems we should improve our CI.
Please open suggestions in the CI bugzilla.

Please do.

Will this only be caught by mingw64 on windows? Will we get the same issues with a linux mingw install? I'm guessing yes, but don't know mingw very well. We may be able to install the mingw package under our github actions pipeline.

#8 lore raw

2021-04-19 15:29 (UTC-0400), Aaron Conole:

Quoted 62 lines
Quoted 57 lines · Thomas Monjalon

19/04/2021 20:06, Tal Shnaiderman:

Quoted 52 lines
Quoted 33 lines
Quoted 25 lines

2021-04-18 19:04 (UTC+0000), Tal Shnaiderman:

Quoted 5 lines
Quoted 5 lines

18/04/2021 19:08, Tal Shnaiderman:

Quoted 4 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the

header.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined #define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build test?

It's a good question, I see CI is passing without warnings, Dmitry can you

reproduce it?

Quoted 4 lines

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-

mingw32/include/string.h:119:

Quoted 3 lines

note: this is the location of the previous definition #define strncasecmp _strnicmp

Quoted 7 lines
Quoted 4 lines

I'm using:

(quoted diff) +0 -2
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
-meson

0.53.2

I can't reproduce it using the same versions.
Do you invoke meson with other options than "-Dexamples=..."?

Quoted 7 lines

This is the meson line I'm using:

meson "-Dexamples=helloworld" build --wipe --default-library=static -- buildtype debug

The problem however is that MinGW's string.h defines the macro in line 119, for some reason my build includes it and the rest doesn't.

Hi Dmitry,

I also noticed warnings in clang on my setup that are related to rte_os_shim.h:

[185/314] Compiling C object drivers/a715181@@tmp_rte_common_mlx5@sta/common_mlx5_mlx5_common_mp.c.obj. In file included from ../drivers/common/mlx5/mlx5_common_mp.c:13:
In file included from ..\drivers\common/mlx5/mlx5_common_utils.h:8:
In file included from ..\drivers\common/mlx5/mlx5_common.h:17:
..\lib/librte_eal/windows/include\rte_os_shim.h:22:51: warning:
token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]

Quoted 3 lines
#define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
                                                  ^

However don't see it in CI, I'm using clang version 9.0.1

Quoted 2 lines

It seems we should improve our CI.
Please open suggestions in the CI bugzilla.

Quoted 6 lines

Please do.

Will this only be caught by mingw64 on windows? Will we get the same issues with a linux mingw install? I'm guessing yes, but don't know mingw very well. We may be able to install the mingw package under our github actions pipeline.

Yes, Linux MinGW-w64 produces the same warning (about strncasecmp). __VA_ARGS__ warning won't show up with GNU compiler, obviously. It may with ICC, but I don't have it to check.

I figured out it's not --default-library=static, but --buildtype=debug that caues the arning to appear, my mistake in previous message.

#9 lore raw

Is that related to a recent patch (I think it was David's, but don't quote me on that) that enabled a debug build mode when it sees git repo info within the build root?

Cheers,
Lincoln

Quoted 85 lines · Dmitry Kozlyuk

2021-04-19 15:29 (UTC-0400), Aaron Conole:

Quoted 7 lines
Quoted 5 lines · Thomas Monjalon

19/04/2021 20:06, Tal Shnaiderman:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

2021-04-18 19:04 (UTC+0000), Tal Shnaiderman:

Quoted 3 lines
Quoted 3 lines

18/04/2021 19:08, Tal Shnaiderman:

Quoted 2 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

warning below on function redefinition whenever compiling a

file

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

including the

header.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined #define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build

test?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

It's a good question, I see CI is passing without warnings,

Dmitry

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 1 line

can you

reproduce it?

Quoted 4 lines

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-

mingw32/include/string.h:119:

Quoted 7 lines

note: this is the location of the previous definition #define strncasecmp _strnicmp

I'm using:

(quoted diff) +0 -2
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
-meson

0.53.2

I can't reproduce it using the same versions.
Do you invoke meson with other options than "-Dexamples=..."?

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

This is the meson line I'm using:

meson "-Dexamples=helloworld" build --wipe --default-library=static

--

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

buildtype debug

The problem however is that MinGW's string.h defines the macro in

line 119,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

for some reason my build includes it and the rest doesn't.

Hi Dmitry,

I also noticed warnings in clang on my setup that are related to

rte_os_shim.h:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

[185/314] Compiling C object drivers/a715181@@tmp_rte_common_mlx5@sta

/common_mlx5_mlx5_common_mp.c.obj.

Quoted 13 lines
Quoted 10 lines
Quoted 9 lines

In file included from ../drivers/common/mlx5/mlx5_common_mp.c:13:
In file included from ..\drivers\common/mlx5/mlx5_common_utils.h:8:
In file included from ..\drivers\common/mlx5/mlx5_common.h:17:
..\lib/librte_eal/windows/include\rte_os_shim.h:22:51: warning:
token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]

#define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
                                                  ^

However don't see it in CI, I'm using clang version 9.0.1

Quoted 2 lines

It seems we should improve our CI.
Please open suggestions in the CI bugzilla.

Quoted 6 lines

Please do.

Will this only be caught by mingw64 on windows? Will we get the same issues with a linux mingw install? I'm guessing yes, but don't know mingw very well. We may be able to install the mingw package under our github actions pipeline.

Yes, Linux MinGW-w64 produces the same warning (about strncasecmp). __VA_ARGS__ warning won't show up with GNU compiler, obviously. It may with ICC, but I don't have it to check.

I figured out it's not --default-library=static, but --buildtype=debug that caues the arning to appear, my mistake in previous message.

Signature · 7 lines
*Lincoln Lavoie*
Principal Engineer, Broadband Technologies
21 Madbury Rd., Ste. 100, Durham, NH 03824
[email protected]
https://www.iol.unh.edu
+1-603-674-2755 (m)
<https://www.iol.unh.edu>
#10 lore raw
In reply to Dmitry Kozlyuk
Quoted 80 lines

Subject: Re: [dpdk-ci] [PATCH] eal/windows: fix build warnings in MinGW

External email: Use caution opening links or attachments

2021-04-19 15:29 (UTC-0400), Aaron Conole:

Quoted 9 lines
Quoted 7 lines · Thomas Monjalon

19/04/2021 20:06, Tal Shnaiderman:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

2021-04-18 19:04 (UTC+0000), Tal Shnaiderman:

Quoted 5 lines
Quoted 5 lines

18/04/2021 19:08, Tal Shnaiderman:

Quoted 4 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

header.

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined #define strncasecmp(s1, s2,
count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build

test?

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 12 lines
Quoted 3 lines

It's a good question, I see CI is passing without warnings, Dmitry can you

reproduce it?

Quoted 4 lines

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-

mingw32/include/string.h:119:

Quoted 3 lines

note: this is the location of the previous definition #define strncasecmp _strnicmp

Quoted 7 lines
Quoted 4 lines

I'm using:
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0 -meson
0.53.2

I can't reproduce it using the same versions.
Do you invoke meson with other options than "-Dexamples=..."?

This is the meson line I'm using:

meson "-Dexamples=helloworld" build --wipe
--default-library=static -- buildtype debug

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

The problem however is that MinGW's string.h defines the macro in line 119, for some reason my build includes it and the rest doesn't.

Hi Dmitry,

I also noticed warnings in clang on my setup that are related to

rte_os_shim.h:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

[185/314] Compiling C object

drivers/a715181@@tmp_rte_common_mlx5@sta/common_mlx5_mlx5_co mmon_mp.c.obj.

Quoted 13 lines
Quoted 10 lines
Quoted 9 lines

In file included from ../drivers/common/mlx5/mlx5_common_mp.c:13:
In file included from ..\drivers\common/mlx5/mlx5_common_utils.h:8:
In file included from ..\drivers\common/mlx5/mlx5_common.h:17:
..\lib/librte_eal/windows/include\rte_os_shim.h:22:51: warning:
token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
#define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
^ However don't
see it in CI, I'm using clang version 9.0.1

Quoted 2 lines

It seems we should improve our CI.
Please open suggestions in the CI bugzilla.

Quoted 6 lines

Please do.

Will this only be caught by mingw64 on windows? Will we get the same issues with a linux mingw install? I'm guessing yes, but don't know mingw very well. We may be able to install the mingw package under our github actions pipeline.

Quoted 6 lines

Yes, Linux MinGW-w64 produces the same warning (about strncasecmp). __VA_ARGS__ warning won't show up with GNU compiler, obviously. It may with ICC, but I don't have it to check.

I figured out it's not --default-library=static, but --buildtype=debug that caues the arning to appear, my mistake in previous message.

Right, using --buildtype=release doesn't reproduce the error.

BTW, how does release build passes if I excluded the definition from RTE_TOOLCHAIN_GCC?

#11 lore raw
In reply to Tal Shnaiderman

Hi Tal,

2021-04-19 18:06 (UTC+0000), Tal Shnaiderman:

Quoted 10 lines

I also noticed warnings in clang on my setup that are related to rte_os_shim.h:

[185/314] Compiling C object drivers/a715181@@tmp_rte_common_mlx5@sta/common_mlx5_mlx5_common_mp.c.obj.
In file included from ../drivers/common/mlx5/mlx5_common_mp.c:13:
In file included from ..\drivers\common/mlx5/mlx5_common_utils.h:8:
In file included from ..\drivers\common/mlx5/mlx5_common.h:17:
..\lib/librte_eal/windows/include\rte_os_shim.h:22:51: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]

#define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
                                                  ^

However don't see it in CI, I'm using clang version 9.0.1

This warning only appears with --buildtype=debug, that's why I missed it. I don't see a good way to fix it except #define open _open, RTE_FMT_xxx approach is not applicable here.

#12 lore raw
In reply to Tal Shnaiderman

2021-04-19 06:57 (UTC+0000), Tal Shnaiderman:

Quoted 27 lines

[...]

Quoted 26 lines
Quoted 4 lines
Quoted 4 lines

18/04/2021 19:08, Tal Shnaiderman:

Quoted 3 lines

the strncasecmp marco defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the

header.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined
#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Why the tests are passing? Are we allowing warnings in build test?

It's a good question, I see CI is passing without warnings, Dmitry can you

reproduce it?

Quoted 4 lines

On my side the collision is with the following file:

C:/mingw-w64/x86_64/mingw64/x86_64-w64-

mingw32/include/string.h:119:

Quoted 6 lines

note: this is the location of the previous definition #define strncasecmp _strnicmp

I'm using:
-gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0 -meson 0.53.2

Quoted 8 lines
Quoted 2 lines

I can't reproduce it using the same versions.
Do you invoke meson with other options than "-Dexamples=..."?

This is the meson line I'm using:

meson "-Dexamples=helloworld" build --wipe --default-library=static --buildtype debug

The problem however is that MinGW's string.h defines the macro in line 119, for some reason my build includes it and the rest doesn't.

--default-library=static it the key, it changes MinGW from using inline functions to using macros for strncasecmp().
MinGW portion devtools/check-meson-builds.sh should test this variant.

I searched for other defines from rte_os_shim.h in MinGW includes and it seems strncasecmp() is the only problematic one. Thanks, I'm ready to ack v2 as soon as you send it.

#13 lore raw

PATCH v2 1/1 eal/windows: fix build warnings in MinGW

In reply to Tal Shnaiderman

the strncasecmp macro defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the header in debug mode.

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined
#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Fixed by defining the macro only to the clang compiler.

Fixes 45d62067c237 ("eal: make OS shims internal")

---
v2: fix commit message typo [Thomas]

---
 lib/librte_eal/windows/include/rte_os_shim.h | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/windows/include/rte_os_shim.h +2 -0
index f40fb62d1d..db0ea6f1b3 100644
@@ -17,7 +17,9 @@
 
 #define strdup(str) _strdup(str)
 #define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr)
+#ifndef RTE_TOOLCHAIN_GCC
 #define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)
+#endif
 
 #define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
 #define read(fd, buf, n) _read(fd, buf, n)
Signature · 1 line
2.16.1.windows.4
Acked-by on v2 1/1
#14 lore raw

2021-04-21 19:09 (UTC+0300), Tal Shnaiderman:

Quoted 9 lines

the strncasecmp macro defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the header in debug mode.

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined
#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Quoted 5 lines

Fixed by defining the macro only to the clang compiler.

Fixes 45d62067c237 ("eal: make OS shims internal")

With librte_eal -> eal fixup,

#15 lore raw

26/04/2021 17:58, Dmitry Kozlyuk:

Quoted 10 lines

2021-04-21 19:09 (UTC+0300), Tal Shnaiderman:

Quoted 9 lines

the strncasecmp macro defined in rte_os_shim.h is already defined in MinGW-w64, as a result the compiler prints out the warning below on function redefinition whenever compiling a file including the header in debug mode.

..\lib/librte_eal/windows/include/rte_os_shim.h:21:
warning: "strncasecmp" redefined
#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)

Quoted 8 lines
Quoted 5 lines

Fixed by defining the macro only to the clang compiler.

Fixes 45d62067c237 ("eal: make OS shims internal")

With librte_eal -> eal fixup,

Applied, thanks.