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

meson: fix MSVC support #2951

Merged
merged 1 commit into from
Jan 4, 2022
Merged

meson: fix MSVC support #2951

merged 1 commit into from
Jan 4, 2022

Conversation

eli-schwartz
Copy link
Contributor

Regression from commit a5f2c45. It is not possible to unconditionally add the asm sources, since not all compilers understand the .s file extension.

Specifically for meson, only compilers inheriting from the GNU mixin will allow a .s file at configure time.

zstd doesn't support asm for MSVC for the same basic reason; if/when Windows asm support is added, it would involve preprocessing with nasm, most likely.

Regression from commit a5f2c45. It is
not possible to unconditionally add the asm sources, since not all
compilers understand the .s file extension.

Specifically for meson, only compilers inheriting from the GNU mixin
will allow a .s file at configure time.

zstd doesn't support asm for MSVC for the same basic reason; if/when
Windows asm support is added, it would involve preprocessing with nasm,
most likely.
@eli-schwartz
Copy link
Contributor Author

Discovered while attempting to update the meson WrapDB entry for zstd. We have Windows CI, and it failed.

@Cyan4973
Copy link
Contributor

Cyan4973 commented Dec 27, 2021

2 comments :

  • Maybe we need to upgrade our CI test suite with a test illustrating this issue.
  • The fix seems entirely meson build oriented, meaning any other build system will face the same issue, and will need to be fixed accordingly. I wonder if we could find a source-code level solution, that would avoid being build-system dependent.

@eli-schwartz
Copy link
Contributor Author

Fundamentally, testing this would mean "attempt to build using MSVC" I guess.

My understanding was that your build matrix already tests cmake using the MSVC compiler and VS solution files backend, but does not test meson on windows except using mingw-gcc (and the ninja backend).

I don't know what a source code solution would be, to the fact that you have source code files that are only valid inputs to certain compilers. Asm isn't portable. The GNU Compiler Collection includes drivers for many programming languages, including C/C++ but also fortran, ada, objc, Java, golang, and, of relevance here, gas. GNU as. An asm dialect specific to GNU, which clang also implements, but MSVC doesn't. Nor, one presumes, do most alternative C compilers unless they happen to inherit from gcc or clang.

You cannot pass an invalid source file to a compiler that doesn't accept it. I don't see any way of working around that anywhere other than a build system, because it is the build system that passes files to the compiler.

And, one alternative to writing GNU asm is to write nasm.exe-compatible asm, which works everywhere independent of compiler. Of course, that is because you need to use the nasm compiler instead. This will require even more build system modifications, not "source code" modifications, but at least it will be the same build system modifications to each build system.

@eli-schwartz
Copy link
Contributor Author

Regarding #2957 I do not have any clue why the current CI that runs cmake tests on VS + MSVC passed, but conda forge failed. I had originally assumed that it must work in cmake because I dunno, maybe cmake automatically ignores incompatible file extensions. I'm not a heavy cmake user so I wouldn't know. :D

The VS solution files presumably don't need to be updated since they can never include the asm source file to begin with (and don't need to do so conditionally).

@eli-schwartz
Copy link
Contributor Author

Is there anything more that you'd like me to do in this PR?

@Cyan4973
Copy link
Contributor

Cyan4973 commented Jan 4, 2022

Is there anything more that you'd like me to do in this PR?

Probably not, but since we have an ongoing action with regards to asm files, I wanted to couple the fate of this PR with it.
cc @terrelln .

Copy link
Contributor

@terrelln terrelln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

The file itself can be parsed as valid C (or anything that supports the C preprocessor) when ZSTD_ENABLE_ASM_X86_64_BMI2 isn't 1, because after the C preprocessor runs, the file will be empty.

Is it meson that is erroring, because it doesn't recognize the extension and doesn't pass it to the compiler, or is it the compiler that is erroring?

@eli-schwartz
Copy link
Contributor Author

The former.

@terrelln terrelln merged commit 6c50042 into facebook:dev Jan 4, 2022
terrelln added a commit to terrelln/zstd that referenced this pull request Jan 5, 2022
After merging facebook#2951 I realized that we will want to explicitly disable
assembly when we aren't including the assembly source file. Otherwise,
if some non clang/gcc compiler does support assembly, it would fail to
build.
@terrelln
Copy link
Contributor

terrelln commented Jan 5, 2022

@eli-schwartz I put up #2972, as I realized a small problem after I merged your PR.

Thanks the the PR!

@eli-schwartz eli-schwartz deleted the msvc-no-asm branch January 5, 2022 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants