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

Add tools.build:asmflags configuration setting for cmake toolchain #17237

Open
wants to merge 2 commits into
base: develop2
Choose a base branch
from

Conversation

jwidauer
Copy link
Contributor

Changelog: Feature

The CMake toolchain supports the tools.build:cflags and tools.build:cxxflags configuration settings, which then populate the CMAKE_C_FLAGS_INIT and the CMAKE_CXX_FLAGS_INIT CMake variables respectively. There doesn't seem to exist an equivalent for the CMAKE_ASM_FLAGS_INIT CMake variable in conan, right now.
This PR adds the new tools.build:asmflags configuration setting, to address this.

In this PR I only included the necessary changes for the CMake toolchain, but I could also add support for this setting in some of the other toolchain generators, if there's interest.

Docs: conan-io/docs#3881

  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

@jwidauer jwidauer force-pushed the add-asm-flags-conf-flag branch from 460b2d1 to 52567e1 Compare October 28, 2024 15:30
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @jwidauer !

@@ -343,6 +344,7 @@ class ParallelBlock(Block):

string(APPEND CONAN_CXX_FLAGS " /MP{{ parallel }}")
string(APPEND CONAN_C_FLAGS " /MP{{ parallel }}")
string(APPEND CONAN_ASM_FLAGS " /MP{{ parallel }}")
Copy link
Member

Choose a reason for hiding this comment

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

TIL, do you have any link that shows that MP also applies to ASM?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this option is really language specific, since it just specifies how many processes should be used to compile the sources. I had a look here and it doesn't specifically mention assembly anywhere. But it's under the "C++, C and Assembler" section, leading me to believe it should also apply.
This addition just makes sure the flag is also supplied to assembly targets.

Copy link
Member

Choose a reason for hiding this comment

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

I think we would need a bit more of evidence, for example https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html#variable:CMAKE_%3CLANG%3E_FLAGS it is not listing it, and in other places, it seems that it requires de definition of a dialect. Otherwise, it might be better to leave it out at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, do you mean just CMAKE_ASM_FLAGS in general? That comes from the CMAKE_<LANG>_FLAGS_INIT flag, with <LANG> == ASM, which is a supported option, as you can see from the enable_language() documentation (also from the project(...) one, but easier to find in the former).
Or am I misunderstanding you and you just mean the /MP flag in particular?

Copy link
Member

Choose a reason for hiding this comment

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

Actually both. If CMAKE_ASM_FLAGS is defined with value, will it apply to all potential dialects ASM_NASM, ASM_MARMASM, ASM_MASM, and ASM-ATT.?

Does the assembler really works with /MP flag? Is it possible that it might produce some error? Indeed the only reference I can find is https://learn.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-170, which seems it applies to the msvc assembler.

My concern is adding something that is not covered by tests, not used or check in our CI, etc. It is not the first time we are impacted by an apparently evident addition, just to find there are cases that it breaks. As this PR is about adding the possibility to inject flags for asm from conf, changing this might be a slightly unrelated issue.

If you tell me that you tested and confirmed it locally, for example by checking the verbose command line arguments, that the /MP is being used correctly and without problems, then we might move forward, but it would need at least some confirmation of manual testing.

Copy link
Member

Choose a reason for hiding this comment

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

Hi @jwidauer

Any feedback about this last comment? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @memsharded
Sorry for the long silence. I got caught up with other stuff at work!
I have now tried the /MP flag using CMake, MSVC and an assembly file and it all works correctly and doesn't produce any errors!
Does that satisfy your concerns or would you want me to do anything else?

conans/model/conf.py Outdated Show resolved Hide resolved
@memsharded memsharded added this to the 2.10.0 milestone Oct 31, 2024
@memsharded memsharded self-assigned this Nov 4, 2024
@memsharded memsharded modified the milestones: 2.10.0, 2.11 Nov 29, 2024
@memsharded memsharded modified the milestones: 2.11.0, 2.12.0 Dec 18, 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