Skip to contentSkip to conversation

windows: build warnings with clang

PATCH Superseded Nick Connolly 5 participants 8 messages Nov 27, 2020 – Dec 12, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 windows: build warnings with clang

Compiling with Clang (11.0, --buildtype=debug) for Windows produces deprecated warnings related to secure crt functions.

Disable this by defining -D_CRT_SECURE_NO_WARNINGS.

It is unclear exactly which commit this fixes. It is probably a consequence of building more libraries for Windows.

---
 config/meson.build | 5 +++++
 1 file changed, 5 insertions(+)
config/meson.build +5 -0
index c02802c18..a3154e29c 100644
@@ -279,6 +279,11 @@ if is_windows
 		add_project_arguments('-D__USE_MINGW_ANSI_STDIO', language: 'c')
 	endif
 
+	# Disable secure CRT deprecated warnings for clang
+	if cc.get_id() == 'clang'
+		add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c')
+	endif
+
 	add_project_link_arguments('-lws2_32', language: 'c')
 
 	# Contrary to docs, VirtualAlloc2() is exported by mincore.lib
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Nick Connolly

Compiling with Clang (11.0, --buildtype=debug) for Windows produces deprecated warnings related to secure crt functions.

Please explain what these warnings mean and why disabling them is OK. FWIW, I examined present warnings and found no useful ones. Also, --buildtype=debug is not necessary to trigger these warnings.

Proposed wording (feel free to adjust):

Microsoft CRT defines Windows-specific secure alternatives to standard library functions and triggers warnings when "insecure" functions are used [1]. However, calling code already has all necessary checks around those functions, so these warnings are not useful for DPDK. MinGW provides its own CRT without this issue.

[1]:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160

Quoted 4 lines

Disable this by defining -D_CRT_SECURE_NO_WARNINGS.

It is unclear exactly which commit this fixes. It is probably a consequence of building more libraries for Windows.

Tip: Unless you want to make this paragraph part of the commit, you can write such notices below "---" line, like version info.

Quoted 22 lines
---
 config/meson.build | 5 +++++
 1 file changed, 5 insertions(+)
config/meson.build +5 -0
index c02802c18..a3154e29c 100644
@@ -279,6 +279,11 @@ if is_windows
 		add_project_arguments('-D__USE_MINGW_ANSI_STDIO', language: 'c')
 	endif
 
+	# Disable secure CRT deprecated warnings for clang
+	if cc.get_id() == 'clang'
+		add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c')
+	endif
+
 	add_project_link_arguments('-lws2_32', language: 'c')
 
 	# Contrary to docs, VirtualAlloc2() is exported by mincore.lib
#2 lore raw

PATCH v2 1/1 windows: build warnings with clang

In reply to Nick Connolly

Microsoft CRT defines Windows-specific secure alternatives to standard library functions and triggers warnings when "insecure" functions are used [1]. However, calling code already has all necessary checks around those functions, so these warnings are not useful for DPDK. MinGW provides its own CRT without this issue.

[1]:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160

Disable this by defining -D_CRT_SECURE_NO_WARNINGS.

---
v2:
* Adjust commit wording as per Dmitry Kozlyuk <[email protected]>

Note: It is unclear exactly which commit this fixes. It is probably a consequence of building more libraries for Windows.

 config/meson.build | 5 +++++
 1 file changed, 5 insertions(+)
config/meson.build +5 -0
index c02802c18..a3154e29c 100644
@@ -279,6 +279,11 @@ if is_windows
 		add_project_arguments('-D__USE_MINGW_ANSI_STDIO', language: 'c')
 	endif
 
+	# Disable secure CRT deprecated warnings for clang
+	if cc.get_id() == 'clang'
+		add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c')
+	endif
+
 	add_project_link_arguments('-lws2_32', language: 'c')
 
 	# Contrary to docs, VirtualAlloc2() is exported by mincore.lib
Signature · 1 line
2.25.1
Acked-by on v2 1/1
#3 lore raw
Quoted 11 lines · Nick Connolly

Microsoft CRT defines Windows-specific secure alternatives to standard library functions and triggers warnings when "insecure" functions are used [1]. However, calling code already has all necessary checks around those functions, so these warnings are not useful for DPDK. MinGW provides its own CRT without this issue.

[1]:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160

Disable this by defining -D_CRT_SECURE_NO_WARNINGS.

Quoted 7 lines

---
v2:
* Adjust commit wording as per Dmitry Kozlyuk <[email protected]>

Note: It is unclear exactly which commit this fixes. It is probably a consequence of building more libraries for Windows.

#4 lore raw

03/12/2020 01:02, Dmitry Kozlyuk:

Quoted 17 lines · Nick Connolly
Quoted 16 lines

Microsoft CRT defines Windows-specific secure alternatives to standard library functions and triggers warnings when "insecure" functions are used [1]. However, calling code already has all necessary checks around those functions, so these warnings are not useful for DPDK. MinGW provides its own CRT without this issue.

[1]:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160

Disable this by defining -D_CRT_SECURE_NO_WARNINGS.

---
v2:
* Adjust commit wording as per Dmitry Kozlyuk <[email protected]>

Quoted 4 lines
Quoted 2 lines

Note: It is unclear exactly which commit this fixes. It is probably a consequence of building more libraries for Windows.

Applied, thanks

#5 lore raw

Copying [email protected] - given that 20.11 has now been released I assume this needs to be applied there as well.

Quoted 24 lines · Thomas Monjalon

03/12/2020 01:02, Dmitry Kozlyuk:

Quoted 12 lines · Nick Connolly
Quoted 11 lines

Microsoft CRT defines Windows-specific secure alternatives to standard library functions and triggers warnings when "insecure" functions are used [1]. However, calling code already has all necessary checks around those functions, so these warnings are not useful for DPDK. MinGW provides its own CRT without this issue.

[1]:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160

Disable this by defining -D_CRT_SECURE_NO_WARNINGS.

Quoted 8 lines
Quoted 7 lines

---
v2:
* Adjust commit wording as per Dmitry Kozlyuk <[email protected]>

Note: It is unclear exactly which commit this fixes. It is probably a consequence of building more libraries for Windows.

Applied, thanks

#6 lore raw
Quoted 2 lines · Nick Connolly

Copying [email protected] - given that 20.11 has now been released I assume this needs to be applied there as well.

This patch was ignored due to the backport scanning scripts check commit message from upstream git repo, not mail thread. Remember to add "Cc: [email protected]" in message body, or a "Fixes" tag.

Applied to 20.11.4 now.

Quoted 27 lines · Thomas Monjalon
Quoted 24 lines

03/12/2020 01:02, Dmitry Kozlyuk:

Quoted 12 lines · Nick Connolly
Quoted 11 lines

Microsoft CRT defines Windows-specific secure alternatives to standard library functions and triggers warnings when "insecure" functions are used [1]. However, calling code already has all necessary checks around those functions, so these warnings are not useful for DPDK. MinGW provides its own CRT without this issue.

[1]:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcpp%2Fc-runtime-library%2Fsecurity-features-in-the-crt%3Fview%3Dmsvc-160&amp;data=04%7C01%7Cxuemingl%40nvidia.com%7C93c0adf5be2246c07dcf08d89c2532f5%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637431030883808802%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=LJVdh0nUgUEXT9vukPmwPffPugpiDFhe7EWp2rU7DuQ%3D&amp;reserved=0

Disable this by defining -D_CRT_SECURE_NO_WARNINGS.

Quoted 8 lines
Quoted 7 lines

---
v2:
* Adjust commit wording as per Dmitry Kozlyuk <[email protected]>

Note: It is unclear exactly which commit this fixes. It is probably a consequence of building more libraries for Windows.

Applied, thanks

Acked-by on v2 1/1
#7 lore raw
In reply to Nick Connolly

Hi Nick,

Thanks for this patch. Could not see the deprecated warnings anymore.

Quoted 6 lines · Nick Connolly

Microsoft CRT defines Windows-specific secure alternatives to standard library functions and triggers warnings when "insecure" functions are used [1]. However, calling code already has all necessary checks around those functions, so these warnings are not useful for DPDK. MinGW provides its own CRT without this issue.

Quoted 7 lines

[1]:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160

Disable this by defining -D_CRT_SECURE_NO_WARNINGS.

---