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

[UWP] Could not determine vs dep dependency prefix string #11257

Closed
Neumann-A opened this issue Jan 8, 2023 · 8 comments · Fixed by #11259
Closed

[UWP] Could not determine vs dep dependency prefix string #11257

Neumann-A opened this issue Jan 8, 2023 · 8 comments · Fixed by #11259

Comments

@Neumann-A
Copy link
Contributor

Describe the bug
thorvg fails to configure with:
ERROR: Could not determine vs dep dependency prefix string. output: b"Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31937 for x64\r\nCopyright (C) Microsoft Corporation. All rights reserved.\r\n\r\ncl : Command line error D8048 : cannot compile C file 'incdetect.c' with the /ZW option\r\n" b''

cross file:
meson-x64-uwp-dbg.log
(due to #11143 all flags are passed via the compiler)
configure log:
config-x64-uwp-dbg-out.log
meson log:
config-x64-uwp-dbg-meson-log.txt.log

pixman for example works fine with the cross file so what is going on here?

@Neumann-A Neumann-A reopened this Jan 8, 2023
@Neumann-A
Copy link
Contributor Author

Ok what is going on here is that meson is using the wrong compiler flags to compile a .c file. It uses cxx instead of c .....

@Neumann-A
Copy link
Contributor Author

To give more detail. The project thorvg is defined as a cpp project so meson uses the cpp flags for the detection but MSVC sees the *.c ending of the file and compiles it as a C file which won't work with the /ZW flag. As such meson should add /TC or /TP flag to inform MSVC how the file should be compiled or change the file ending according to the language it actually checks.

eli-schwartz added a commit to eli-schwartz/meson that referenced this issue Jan 8, 2023
…language

It is possible, albeit possibly inadvisable, for the exact combination
of MSVC and "$CXX has C++ specific flags in it" to occur. When this
happens, and cl.exe is given a filename ending in .c, it complains that
you cannot compile a .c file with that option.

Instead, pick the first filename matching that language and use that as
the temporary filename. This more or less matches what we do in
compiler-time checks. And it's the proper thing to do, rather than
assume that cl.exe, when detected as the current C++ compiler, can
*also* compile C because it's *also* a C compiler.

Fixes mesonbuild#11257
@eli-schwartz
Copy link
Member

eli-schwartz commented Jan 8, 2023

  1. this is true and Meson does the same thing for GCC, passing -x{lang} when feeding in a blank source as - (read from stdin)

  2. (due to Regression: No build machine compiler for xx with meson 0.64.1 on osx #11143 all flags are passed via the compiler)

    That's not what was said there. You should only put flags that are intrinsic to the compiler correctly identifying as the correct compiler -- instead you copied all c_args over, including stuff like -W3 -DDEBUG -DWIN32 which do not contribute to making the compiler correctly identify as itself? For a GCC comparison, you would never define CC='gcc -Wall -O3 -DDEBUG' but you would keep -specs /usr/lib/musl/lib/musl-gcc.specs there, or -m32 (for telling a multilib GCC on x86_64 to operate as an i686 compiler). This may or may not cause issues some of the time, but not all of the time -- for example, there are certain options that GCC / clang support as "do not count this for an unused flag".

...

Aside: you do not need to add either /nologo or /utf-8 since Meson always adds both of those (you can stop Meson from using /utf-8 only by passing your own competing /source-charset).

@eli-schwartz
Copy link
Member

eli-schwartz commented Jan 8, 2023

I have posted a PR which should fix this. It checks the compiler language and ends up using incdetect.cpp instead of incdetect.c (there is a language -> extensions map which is easy to use for this -- /TC / /TP would need to be hardcoded again).

@Neumann-A
Copy link
Contributor Author

@eli-schwartz: To be clear: The flags are coming from CMake and the native/cross files are generated with the flags from CMake. From the description in https://www.reddit.com/r/cpp/comments/ztsabe/comment/j1jw013/?context=3 which is related to #11143 I need to pass all flags via the compiler to force them and not make the project overwrite them (furthermore I am not going to filter them just to make meson happy .... ).
My current workaround is to hardcode /TC|/TP into CMAKE_C|CXX_FLAGS in the cmake toolchain and hopefully be done with it in meson.

Be aware that I also applied:

--- a/meson.build
+++ b/meson.build
@@ -1,6 +1,6 @@
 project('thorvg',
         'cpp',
-        default_options : ['buildtype=debugoptimized', 'b_sanitize=none', 'werror=false', 'optimization=s', 'cpp_std=c++14'],
+        default_options : ['cpp_std=c++14'],
         version : '0.8.3',
         license : 'MIT')

to make thorvg even compile. Somehow the default_options 'buildtype=debugoptimized' (and maybe 'optimization=s' )took precedence over what vcpkg passes on the command line/native file, resulting in /O1 being passed alongside with /RTC in debug builds which are incompatible.

@eli-schwartz
Copy link
Member

You might be interested in always passing -Dbuildtype=plain -Ddebug=false -Doptimization=plain on the command line, to override any specified default options and suppress Meson adding any buildtype flags itself. This may be useful as a standard template for Meson projects, in fact.

From the description in https://www.reddit.com/r/cpp/comments/ztsabe/comment/j1jw013/?context=3 which is related to #11143 I need to pass all flags via the compiler to force them and not make the project overwrite them

The project should not be overwriting cpp_args, but the native/cross files have less precedence compared to passing -Dc_args=... as a command-line option to meson setup.

Anyway, I am not overly concerned with where you define them :D but I do notice they seem to be getting passed twice, for the most part?

@eli-schwartz
Copy link
Member

At any rate, if you have time to give #11259 a test run and see if that solves the problem for you, that would be neat. :)

@Neumann-A
Copy link
Contributor Author

-Dbuildtype=plain -Ddebug=false -Doptimization=plain

does -Dbuildtype=plain -Ddebug=<somevalue> not imply -Doptimization=plain ? I assumed so due to:
WARNING: Recommend using either -Dbuildtype or -Doptimization + -Ddebug. Using both is redundant since they override each other. See: https://mesonbuild.com/Builtin-options.html#build-type-options

At any rate, if you have time to give #11259 a test run and see if that solves the problem for you, that would be neat. :)

Seems to work. Will add it as a patch to vcpkg-tool-meson. Still adding /TC, /TP in the toolchain because it might fix issues in other build scripts unrelated to meson.

xclaesse pushed a commit that referenced this issue Jan 8, 2023
…language

It is possible, albeit possibly inadvisable, for the exact combination
of MSVC and "$CXX has C++ specific flags in it" to occur. When this
happens, and cl.exe is given a filename ending in .c, it complains that
you cannot compile a .c file with that option.

Instead, pick the first filename matching that language and use that as
the temporary filename. This more or less matches what we do in
compiler-time checks. And it's the proper thing to do, rather than
assume that cl.exe, when detected as the current C++ compiler, can
*also* compile C because it's *also* a C compiler.

Fixes #11257
nirbheek pushed a commit that referenced this issue Feb 6, 2023
…language

It is possible, albeit possibly inadvisable, for the exact combination
of MSVC and "$CXX has C++ specific flags in it" to occur. When this
happens, and cl.exe is given a filename ending in .c, it complains that
you cannot compile a .c file with that option.

Instead, pick the first filename matching that language and use that as
the temporary filename. This more or less matches what we do in
compiler-time checks. And it's the proper thing to do, rather than
assume that cl.exe, when detected as the current C++ compiler, can
*also* compile C because it's *also* a C compiler.

Fixes #11257
nirbheek pushed a commit that referenced this issue Feb 6, 2023
…language

It is possible, albeit possibly inadvisable, for the exact combination
of MSVC and "$CXX has C++ specific flags in it" to occur. When this
happens, and cl.exe is given a filename ending in .c, it complains that
you cannot compile a .c file with that option.

Instead, pick the first filename matching that language and use that as
the temporary filename. This more or less matches what we do in
compiler-time checks. And it's the proper thing to do, rather than
assume that cl.exe, when detected as the current C++ compiler, can
*also* compile C because it's *also* a C compiler.

Fixes #11257
nirbheek pushed a commit that referenced this issue Feb 18, 2023
…language

It is possible, albeit possibly inadvisable, for the exact combination
of MSVC and "$CXX has C++ specific flags in it" to occur. When this
happens, and cl.exe is given a filename ending in .c, it complains that
you cannot compile a .c file with that option.

Instead, pick the first filename matching that language and use that as
the temporary filename. This more or less matches what we do in
compiler-time checks. And it's the proper thing to do, rather than
assume that cl.exe, when detected as the current C++ compiler, can
*also* compile C because it's *also* a C compiler.

Fixes #11257
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 a pull request may close this issue.

2 participants