-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
[WIP] MSVC support for selecting specific toolset versions and product types #3717
Conversation
Version Specific CodeThe implementation contains a variable to enable/disable the specific version support. When disabled, the implementation is the same as the current master.
The implementation contains code to print the module call tree (stack trace) to stderr based on a hard-coded internal variable. The number of frames outside the current module is configurable but currently set to one. The call trees are identical for the current master and the proposed implementation with the experimental code disabled:
A call tree when the experimental code is active with file and line locations is:
The call tree files can also be used to compare/update the existing README for the msvc tools. Extended MSVC_VERSION FormatThe MSVC_VERSION format was extended to allow:
Without a product qualifier (e.g., "BT"), there is a subtle but significant change semantically: the product selected will be the newest/latest toolset that matches the user specification within installed toolsets for a given (host,target) combination. Without a product qualifier, any product type could be returned based on the installed toolsets. This only affects multiple installations of the same product version (e.g., 14.1 and 14.Exp and/or 14.2Com and 14.BT). This means that a user does not need to specify "14.1Exp" explicitly if there is a single 14.1 product installation. On the flip side, it also means that "14.1Exp" may be returned for a "14.1" request. This might make SConstruct files a little more portable as "14.1" could be used any computer that has a 14.1 product installed regardless of product type. In local testing, "14.1Exp" was returned for an "arm" target. In the local installations of 14.1 Community and 14.1 Express, the "newest" toolset for an arm target was in the 14.1 Express installation as it was installed recently. With a product qualifier, a specific product version and type is used. The regular expression to validate/parse the extended MSVC_VERSION format is:
Internal Data StructuresThere are a number of new data structures that are constructed to support specific toolset versions and product types. The data structures can be "pretty-printed" to stderr based on an internal variable. Some examples of the internal structures are:
MSVC_TOOLSET and ExampleThe following environment variable was added to support specific toolset versions and product types:
The example below is based on #3664. There are no 14.1 products are installed. The 14.2 Build Tools product is installed with the 14.16 toolset.
The example shows the MSVC_TOOLSET state evolution at four locations:
Sample SConstruct FileThe SConstruct file used for testing is attached below as a text file. The SConstuct file and c files are attached in the zip file. Combinations in the SConstruct file have been tested on both x86 and amd64 computers with 14.0 Community, 14.1 Community, 14.1 Express, 14.2 Community, and 14.2 Build Tools installed and Python 3.7. The implementation has an internal variable and list that allows a 2017+ product to be ignore for testing. The comments indicating which tool is selected is obviously dependent on the toolsets installed. File: SConstruct.txt |
…sion. Ignore componentId that is not in the selection ranking dictionary (safety measure: indicates module variables are not consistent).
… it replaces find_vc_pdir_vswhere (share common prefix).
…n of the vswhere function (find_vc_pdir_vswhere_instance) to DummyVsWhere: necessary as long as both functions co-exist.
…stalled_vcs (the test suite was bypassing the cached function unnecessarily setting up the installed vcs multiple times). Rename the existing find_vc_pdir_* with a "_classic" suffix. Set function names for find_vc_pdir and find_vc_pdir_vswhere based on experimental flag (all tests work without changes).
… files ends in a "#" character, replace the "#' with a serial number from 001 to 999 and 000 based file existence.
…rk serial number processing for rewriting debug/trace file names.
… been set when Sync is False: debug and trace both using serial numbers.
…onstructing the installed visual studios list.
…from function return with anonymous variables ("_").
…symbolic constants rather than a binary literal. Add comment for each binary bit field constant that contains the corresponding base 10 equivalent.
…fix, trace support, and trace/debug file name synchronization.
Note to self:
|
I'd rather add MSVC_TYPE to MSVC_VERSION instead of embedding two types of info in MSVC_VERSION.. and needed more complicated decoding logic.. |
@jcbrill - are you subscribed to scons-devel and/or our discord server? I'm not going to merge the new tracing logic. I think it's a dead end. we'd like to do something more holistic, and potential re-implement MSVC altogether. |
The PR is roughly the third implementation of the specific version support. There are a few details concerning the progression in #3664. The initial versions used a separate variable. Using a separate variable makes it harder to "upcast/promote" a requested version to a newer toolset (which is the point of #3664). Expanding the definition of MSVC_VERSION was suggested in #3265. A toolset is not product specific (i.e., it is ambiguous when installed in more than one product). I have not spent much time in the specific version code in the last 5-6 weeks. There are a number of very subtle issues. There are also issues that didn't exist before: the product is installed but the desired toolset may not be installed for all host/target pairs which can change the product used. This happened during testing where an older version of MSVS had a newer toolset installed for ARM targets. This could be a support challenge in that toolset installations/combinations are specific to an end-users installation and may not be easily diagnosed. The current implementation is backwards compatible with all existing code. When the experimental code is disabled it works exactly like the current master. Possibly adding a command-line option to enable the experimental code would allow the current logic by default and the specific version by user-specified option. At the time, I was trying to minimize the number of files modified and to minimize the number of places that it "hooks" into the current logic. I am currently not subscribed to scons-devel or the discord server. I can subscribe to scons-devel. I am using Outlook 2007 on a desktop which does not play nice with mailing lists. With respect to the tracing logic, I figured as much. That is why the last update moves almost all of the code into a sub-folder: it is trivial for me to merge into the master. |
Hmm. not sure I understand what you mean by
If a user requests 14.1, then only 14.1 should satisfy that request. Otherwise they should not request a version and get the newest version. Though I guess there are situations where version between N and M could be also usable. But we don't currently support that. From the manpage:
I think it's reasonable to say, I only want to use an Express (or enterprise) version, for example, and not specify the version number. Thoughts? |
In the toolset specific versions:
The MSVC_TOOLSET and Example above shows this exact case: 14.1 is requested and the 14.2 Build Tools are installed with the 14.1 toolset. This is the issue in #3664. |
Expanded example with third option:
|
The issue that I see with the specific version numbers is that it introduces an end-user maintenance problem as there are frequent toolset releases as compared to product releases. As an SCons user, I'm not sure I want to specify the specific version because I don't want to have to keep changing my build files. The product releases are not that big a deal as they are every couple of years. I see the utility of #3664 (list item 2 above). The builds were configured to use 14.1 and who know what other requirements tied them to the 14.1 tools. It would be nice in a new installation of 14.2 with the 14.1 toolset that the existing build system "just works". There are a number of "edge/corner cases". I tried to adhere to the "Principle of Least Astonishment" in the implementation. When something goes wrong with the specific versions, it is almost imperative that an exception is raised as the toolset support is via an argument to the vcvars batch file. Silently doing the wrong thing is worse than raising an exception. |
One of the first principles of SCons.. The build should be repeatable regardless of user's environment. So, if a user requests version X.1, then get version X.1, even if they have version X.2. We're not going to change a fundamental principle of SCons (reproducible builds) because you don't want to update your build scripts when there's new releases of the tools. Now, if you were suggesting that we introduced a way for the build system to EXPLICITLY introduce flexibility, that would be acceptable. But not without explicitly requesting it. So MSVC_CHOOSE_VERSION(or even MSVC_VERSION if it's a callable) as a python function which gets passed the list of available versions and selects, that'd be fine. But asking for 14.1 and accepting 14.2... nope. BTW. I'm totally not saying that what you need SCons to do is unreasonable, just that it changes a fundamental SCons principle, and so wouldn't be merge-able without some explicit way to tell SCons to be flexible. |
It is helpful to stop thinking in terms of products and start thinking in terms of toolsets and from an end user's perspective.
In #3664, the desire is to use the 14.1 toolset not the 14.1 product. I suggest you post the (somewhat offensive) comment above in #3664 and then close the issue as "not going to happen". #3265 is nineteen (19) months old. My first post with a prototype solution that solved both issues was approximately 3 weeks after #3664 was posted. #3265 was so old I was unaware of its existence. When necessary, I have been able to modify the msvc code locally since 2.X. I have not had the luxury to wait around for msvc enhancements or fixes. My personal build scripts rely on approximately 3500 lines of python code and configuration data. When there is a build problem with SCons itself, by the time I have diagnosed the problem in most cases the solution is also apparent. Yesterday, I offered a number of bite-size PRs that address all outstanding issues. It has been my experience that There was an open window starting in June for active contributions and participation that is now rapidly closing. Furthermore, my interest has waned considerably. It seems that my work here will be complete once #3723 and #3764 are either accepted, explicitly rejected, or die a death of neglect. |
To be clear, it is not my need. The trace code (jbrill-mscommon-trace) branch and msvc specific version code (jbrill-msvc-specific-version) branch are available in my fork of the SCons repository. Good luck and godspeed. |
This PR expands MSVC support for end-user selection of specific MSVC toolset versions (e.g., 14.26, 14.26.27, 14.26.27023) and/or specific MSVS product type installations (e.g., Enterprise, Community, Build Tools).
This PR unifies #3265 and #3664:
MSVC tool supports choosing specific msvc version down to minor version #3265 is an enhancement to allow a user-specified msvc toolset down to the minor version number.
MSVC Version 14.1 not found with 14.2 installed #3664 involves supporting an msvc toolset that is installed in a later product version. The motivating example is supporting a 14.1 toolset via a 14.2 product installation when a 14.1 product is not installed.
The definition of MSVC_VERSION was extended to allow specification of an msvc toolset down to the minor version and/or the specification of an msvs product type.
The implementation is backwards compatible with current definitions of MSVC_VERSION. There are subtle, but important, changes in semantics due to the change from a "product" orientation to a "toolset" orientation.
The proposed implementation is "wired-in" to the existing code base in a few select locations. The existing code base continues to operate on an MSVC_VERSION that is compatible with the _VCVER version list (e.g., "14.2"). A single internal environment variable and dictionary was added to maintain the specific version and product state.
There is a single hard-coded variable at the top of the source file that selectively enables/disables the specific version support. When disabled, the functionality is the same as the current master. The hooks into the existing code were intentionally minimized to ease updating/merging from the master. The bulk of the new code was added at the bottom of the file. This might allow an optional command-line option to selectively enable the version specific support by an end-user.
There are four (4) new exception types that are propagated outside of the vc.py module that cause SCons to exit with an error code.
Known issues:
Contributor Checklist:
CHANGES.txt
(and read theREADME.rst
)