Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nanobind: disable CRT insecure warning for clang-cl #1800

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

trim21
Copy link

@trim21 trim21 commented Nov 28, 2024

@WillAyd

Remind me if I'm wrong about this.

In my understanding the intention of compiler.get_id() == 'msvc'? dep_compile_args += ['-D_CRT_SECURE_NO_WARNINGS'] is to disable CRT insecure warning on windows.

But I'm using clang-cl with nanobind and on win32, deprecation notice is not actually disabled, we need to add argument to command compiling nanobind itself.

we may should also add -Wno-deprecated-declarations to clang when it's windows, but I haven't be able to make clang work with meson on win32 yet. looks like it's broken by default, mesonbuild/meson#10022 . Maybe consider this after it's fixed by meson.

@trim21 trim21 changed the title nanobind: disable deprecated warning when using clang-cl nanobind: disable clang-cl CRT insecure warning Nov 28, 2024
@eli-schwartz
Copy link
Member

But I'm using clang-cl with nanobind and on win32, deprecation notice is not actually disabled, we need to add argument to command compiling nanobind itself.

So you're saying it's needed to avoid deprecation notices in the nanobind library, rather than just avoiding them in the nanobind headers?

@trim21
Copy link
Author

trim21 commented Nov 28, 2024

But I'm using clang-cl with nanobind and on win32, deprecation notice is not actually disabled, we need to add argument to command compiling nanobind itself.

So you're saying it's needed to avoid deprecation notices in the nanobind library, rather than just avoiding them in the nanobind headers?

The warning is emitted from nb_ndarray.cpp, not from nanobind header files.

[5/13] Compiling C++ object subprojects/nanobind-2.2.0/libnanobind.a.p/src_nb_ndarray.cpp.obj
../subprojects/nanobind-2.2.0/src/nb_ndarray.cpp(514,18): warning: 'strcpy' is deprecated: This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
  514 |             std::strcpy(dtype, "bool");
      |                  ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h(130,1): note: 'strcpy' has been explicitly marked deprecated here
  130 | __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1(
      | ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt.h(835,5): note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1'
  835 |     __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _SalAttributeDst, _DstType, _Dst, _TType1, _TArg1)
      |     ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt.h(1894,17): note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_EX'
 1894 |                 _CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_SalAttributeDst _DstType *_Dst, _TType1 _TArg1);
      |                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\include\vcruntime.h(356,55): note: expanded from macro '_CRT_INSECURE_DEPRECATE'
  356 |         #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
      |                                                       ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\include\vcruntime.h(346,47): note: expanded from macro '_CRT_DEPRECATE_TEXT'
  346 | #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
      |                                               ^
1 warning generated.

@trim21
Copy link
Author

trim21 commented Nov 28, 2024

And I just try msvc (19.41.34123) with dep_compile_args += ['-D_CRT_SECURE_NO_WARNINGS'] removed in nanobind/meson.build, and this wraning is not generated by default when compiling nb_ndarray.cpp.

Now I'm not sure why we have this line here? Is it because some other version of msvc will emit this warning?

@trim21 trim21 changed the title nanobind: disable clang-cl CRT insecure warning nanobind: disable CRT insecure warning for clang-cl Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants