Replies: 6 comments 13 replies
-
| Many thanks for your great outline. | 
Beta Was this translation helpful? Give feedback.
-
| Additional research results for  Please report any errors and misinformation. MSVC setup: 
 Compile combinations: 
 Link combinations: 
 Compile/link combinations: 
 The compiler and linker flags specification and inclusion needs to be done independently. In the presence of linking external libraries, there is no reasonable way for SCons to know the architecture/ABI of the linked binaries. A construction variable for the compiler could be one/two valued:  A construction variable for the linker could be two/three valued:  At this point, I'm unsure of the effectiveness of validation of the options. Even validating the TARGET_ARCH, MSVC toolset version, Windows SDK version becomes difficult/unreliable if SCons MSVC auto-detection was bypassed. Perhaps just the "obviously* wrong can be caught. Diagnosis of MSVC compiler/linker errors can sometimes be challenging and time consuming especially when run on remote computers. Catching as many errors as possible during configuration is far easier than trying to diagnose where and when everything went wrong. | 
Beta Was this translation helpful? Give feedback.
-
| For those following along, in order to build one's own  Unless I'm missing something, and showing my lack of knowledge of how to actually use SCons, this would require at least two SCons environments as the  Feel free to weigh in on how this could be accomplished. | 
Beta Was this translation helpful? Give feedback.
-
| I wrote a very small example that I needed to test how windows object hooks behave on the several systems. You can find the code at https://github.com/LeonarddeR/scons_arm64_poc In short, relevant findings are: 
 | 
Beta Was this translation helpful? Give feedback.
-
| Thank you for your extensive overview. | 
Beta Was this translation helpful? Give feedback.
-
| Attached archive of my modified files used for testing: It should just work (I hope). Notes: 
 | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Preliminary research notes and thoughts for producing
ARM64ECcompatible binaries (ARM64X) with MSVC.Example assuming a Visual Studio 2022 installation with the latest
ARM64toolkit version and latest Windows SDK:myprog.cvcvarsalls.batinvocation:"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" arm64"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64_arm64compile:
link:
dump headers:
ARM64ECis an alternate ABI (application binary interface) on WindowsARM64computers.ARM64ECis not implemented via WoW redirection onARM64similar tox86andarmbinary architectures.Challenges for directly supporting
ARM64ECbinaries in SCons:With respect to setting up MSVC,
ARM64ECis not a host/target toolset architecture. The call to host/target architecture argument forvcvarsall.batis the same for targetingARM64andARM64EC(e.g.,arm64,amd64_arm64, etc.).Adding
ARM64ECas a "virtual architecture" is a bit challenging given the current implementation as the native host architecture of a Windows ARM64 box isARM64and is only supported by certain MSVC toolset versions and Windows SDK versions.The requirements for
ARM64ECare based on the MSVC toolset version and the Windows SDK version.The minimum toolset version appears to be at least
14.31. The minimum Windows SDK version appears to be at least10.0.22621.0. However, there appear to be combinations of MSVC toolset version and Windows SDK version that may result in build errors.In quick-and-dirty testing, attempting to build with MSVC toolset
14.31and the latest Windows SDK failed. Attempting to build with MSVC toolset14.31and Windows SDK10.0.22621.0succeeded.Note: MSVC documentation may indicate a minimum MSVC toolset version of
14.34.When using modern Visual Studio versions, the MSVC toolset version and the windows SDK version should be known when validating MSVC arguments and detecting the the installed toolsets and Windows SDKs.
Aside: there is an undocumented internal environment variable that forces the MSVC toolset version and Windows SDK version as command line arguments when running the
vcvarsbatch files. This can be useful when the msvc cache is enabled in the presence of updates to the MSVC toolsets and/or Windows SDK versions in which the "older" versions are not uninstalled to prevent inadvertently using cached paths that may still exist but are not the latest.The MSVC toolset version and Windows SDK version are not saved in the SCons environment.
Adding
/arm64ECto theCCFLAGSconstruction variable probably should be done inTool\msvc.py.Adding
/MACHINE:ARM64ECto theLINKFLAGSconstruction variable probably should be done inTool\mslink.pyOne possible way to implement support for
ARM64ECwould be to add a new construction variable for MSVC that indicates a desire to target theARM64ECABI. For example,MSVC_ARM64EC_ABI=True.There might be enough information in
Tool\MSCommon\*.pyto determine if targeting theARM64ECis likely to succeed based on the target architecture (AMD64), MSVC toolset version, and Windows SDK version.Adding an internal-use only variable to the SCons environment, for example
_MSVC_ARM64EC_ABI, that is either True or False following validation could be used by themsvcandmslinktools to determine if the compiler and linker flags forARM64ECshould be added or not.Validating arguments is somewhat complicated and reasonably necessary. Debugging
vcvarsallbatch file failures and MSVC command-line tool errors due to unsupported arguments is usually a challenge.The MSVC toolset version and Windows SDK version have first-class support via the
MSVC_TOOLSET_VERSIONandMSVC_SDK_VERSIONconstruction variables, respectively.It is not sufficient to use
MSVC_VERSIONin determining ifARM64ECis supported. Attempting to addARM64ECas an architecture could be more difficult than it appears on the surface.Edits:
Adding a construction variable and then setting an internal environment variable as dissussed above is problematic if msvc auto-detection is bypassed.
Interesting external
ARM64ECdiscussion: http://www.emulators.com/docs/abc_arm64ec_explained.htmRevised possible implementation:
Add a function (e.g.,
msvc_is_arm64ec(env)) indicating if the build is for theARM64ECABI that is imported fromSCons.Tool.MSCommonin the msvc tools (e.g.,msvcandmslink, etc) which is used to add the relevant command-line options if necessary.The implementation of the function could be in
SCons\MSCommon\Tool\vc.py. The implementation could then use the known information from the environment to decide if building withARM64ECis likely to succeed or issue a warning (unsure) or an error (known to be invalid) based on the environment configuration.If the msvc batch file was invoked when setting up msvc, additional information could be stored in a "private" key in the environment. If the msvc batch file processing was bypassed, limited checks would be available and may have to assume the user is sure that the build will succeed.
One additional construction variable (e.g.,
MSVC_ARM64EC_ABI=True) is required and all of the "heavy lifting" is in the appropriate source file underMSCommon. The msvc tools are already importing functions fromMSCommonanyway.Beta Was this translation helpful? Give feedback.
All reactions