-
Notifications
You must be signed in to change notification settings - Fork 207
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 native support for Windows on Arm64 (WoA) #971
Add native support for Windows on Arm64 (WoA) #971
Conversation
@chirontt this looks great on a first pass. I need to figure out where I can build/reproduce the build, but that is the only blocking issue.
Rather than trying to do this, we should just not support winpty on WoA. I assume any WoA version of Windows has support for ConPTY. CDT's legacy use of winpty only exists as a fallback for older Windows versions. Note that ConPTY does not have a native part, and instead uses JNA to access the DLL. (Source link) |
How much impact/effort needed to change the existing Java code to use this ConPTY class? Who will do this work? (not me for sure, as I'm unfamiliar with these code.) If we can remove the need for the
|
I have already done the work to ConPTY - it is used by default and in preference to winpty when running on a version of Windows that supports it. What I don't have access to test is that it works as expected on WoA machine. |
To test if ConPTY is working, create a new terminal to the local console (cmd.exe for example). Hopefully it "just works". If PTY.java fails to load ConPTY it should log an error starting with "Failed start a new style ConPTY" and then it will fallback to winpty. |
This handles group level signals so that process trees can be killed and otherwise signaled. IIRC this has to be a separate process and it exists to ensure things like terminate in CDT debug actually kills all processes. Without starter, you end up with processes still running. The comments in Spawner.java explain this a little. The starter.exe is launched from the spawner.dll (from here in Java)
Not sure why it is redundant? What is possible is to refactor spawner.dll to use JNA (like ConPTY did) so that we don't need native compiled for that part.
If I update the Dockerfiles to include this, and add it to a build, can you test the resulting dlls/exes work as expected? |
Instead of writing some unit code to test ConPTY, I'm playing around with these ConPTY/winpty things using the
Browsing the cdt/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java Lines 295 to 300 in 7a237aa
That block of code always disables the ConPTY, unless the org.eclipse.cdt.core.conpty_enabled system property is true . This property is not set at all by default in the Eclipse IDE, so the ConPTY is disabled by default, and winpty is used instead in Windows.
Some other troubling code in the same cdt/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java Lines 302 to 310 in 7a237aa
Line 302 sets the isWinPTY flag to true just because it's Windows (???). And because it's Windows, the winpty.dll library is also always loaded in line 307; same as the pty.dll library in line 309. All these behaviours need be changed if/when we want to throw out those libraries and replace them with the JNA-based ConPTY class.
One consolation is that, on my WoA box, when I add the following property to the
and also remove all the |
Yes, I'll use my WoA box for testing these WoA-related stuff. |
The code you quoted is a fairly old version of the code (at least before 4c87198 - looks like CDT 10.5 branch)- the default in current main branch is enabled with this bit of code: cdt/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java Lines 295 to 300 in a24f93d
This is still true on latest version - and we should fix that so winpty failing to load is not a catastrophic failure like it is now. I would consider removing winpty on x86_64 too, but everytime I remove support for an ancient feature people chime in how they are affected. |
I am working on this part |
I have made some good progress on refactoring the code to not require winpty, as well as updating docker images. My WIP code is https://github.com/jonahgraham/cdt/tree/woa - but I am done for today. |
- add a new fragment 'org.eclipse.cdt.core.win32.aarch64' containing re-compiled Arm64 natives suitable for the Windows on Arm64 platform. - add the 'serial.dll' binary re-compiled for Windows on Arm64. - add the win32/win32/aarch64 environment triplet to various Maven build scripts to support building CDT software for that environment. The updated dlls/exes are not included in this commit and will be provided in subsequent commits with the corresponding update to build infrastructure Fixes eclipse-cdt#969
52ee09c
to
906609d
Compare
@chirontt I made some small changes to your commit and changed the target branch to eclipse-cdt:support_windows_on_arm64 Changes made:
I am going to merge this now to the support_windows_on_arm64 branch and then add my commits which add the docker build support. That will lead to a testable p2 repo. |
4599e5b
into
eclipse-cdt:support_windows_on_arm64
- add a new fragment 'org.eclipse.cdt.core.win32.aarch64' containing re-compiled Arm64 natives suitable for the Windows on Arm64 platform. - add the 'serial.dll' binary re-compiled for Windows on Arm64. - add the win32/win32/aarch64 environment triplet to various Maven build scripts to support building CDT software for that environment. The updated dlls/exes are not included in this commit and will be provided in subsequent commits with the corresponding update to build infrastructure Part of #969
- add a new fragment 'org.eclipse.cdt.core.win32.aarch64' containing re-compiled Arm64 natives suitable for the Windows on Arm64 platform. - add the 'serial.dll' binary re-compiled for Windows on Arm64. - add the win32/win32/aarch64 environment triplet to various Maven build scripts to support building CDT software for that environment. The updated dlls/exes are not included in this commit and will be provided in subsequent commits with the corresponding update to build infrastructure Part of #969
- add a new fragment 'org.eclipse.cdt.core.win32.aarch64' containing re-compiled Arm64 natives suitable for the Windows on Arm64 platform. - add the 'serial.dll' binary re-compiled for Windows on Arm64. - add the win32/win32/aarch64 environment triplet to various Maven build scripts to support building CDT software for that environment. The updated dlls/exes are not included in this commit and will be provided in subsequent commits with the corresponding update to build infrastructure Part of #969
- add a new fragment 'org.eclipse.cdt.core.win32.aarch64' containing re-compiled Arm64 natives suitable for the Windows on Arm64 platform. - add the 'serial.dll' binary re-compiled for Windows on Arm64. - add the win32/win32/aarch64 environment triplet to various Maven build scripts to support building CDT software for that environment. The updated dlls/exes are not included in this commit and will be provided in subsequent commits with the corresponding update to build infrastructure Part of #969
org.eclipse.cdt.core.win32.aarch64
containing re-compiled Arm64 natives suitable for the WoA platform.serial.dll
binary re-compiled for WoA.win32/win32/aarch64
environment triplet to various Maven build scripts to support building CDT software for that environment.This PR would fix issue #969.
To build the various CDT natives for the WoA platform, a WoA box (or VM) is needed and the MSYS2 for ARM64 is installed on that WoA box to provide a unixy environment for the native build steps below.
Installing MSYS2 for ARM64
Follow the MSYS2 for ARM64 instructions to install the MSYS2 environment on the WoA box. Note that the
clangarm64.exe
shell must be used to provide ARM64 environment/tools for subsequent build steps.The
clangarm64
shell will output the following string for theuname
command:This
uname
output string will be used in variousMakefile
's to detect the WoA runtime environment when building binaries for it.In the
clangarm64
shell, install the needed LLVM-basedMingGW64
compiler for ARM64:The above
mingw-w64-clang-aarch64-clang
package provides a completeMingGW64
toolchain for ARM64, including the GNU make utility available in the form of themingw32-make
command, which can be alias'ed asmake
for ease of use if needed:With the above
mingw-w64-clang-aarch64-clang
package installed, the following compiler commands are all equivalent and are all pointing to the same LLVM Clang compiler for ARM64:gcc
,cc
,clang
,aarch64-w64-mingw32-gcc
, etc.Also install any needed utilities, such as
python
(needed by variousMakefile
's later):Building
winpty.dll
andwinpty-agent.exe
binaries for WoAThere are no
winpty
source code in the CDT repo, apart from the header file winpty.h.Re-compiling these binaries for WoA will need to fetch the official winpty repo source code, especially the 0.3.1 version tag which is compatible with our current pty.cpp source code. But even this 0.3.1 version tag source still doesn't support compiling it for WoA, so I've forked it and added some changes to its
configure
file to support compiling it in the MSYS2 environment for WoA, in my 0.3.1_arm64 branch of the fork.And thus, to compile
winpty
binaries for WoA, we just follow the official build instructions:./configure
thenmake
commands. Here are the complete commands to build it from my fork, running in the MSYS2clangarm64
shell:The above
make
command will eventually fail to compile the Unix adapterwinpty.exe
, as it requires the CYGWIN environment which doesn't exist in WoA, and can be ignored. But the neededwinpty.dll
andwinpty-agent.exe
files would be successfully produced in thebuild
subdirectory (and then be manually copied over to thecdt/core/org.eclipse.cdt.core.win32.aarch64/os/win32/aarch64
folder.)Building
pty.dll
,spawner.dll
andstarter.exe
binaries for WoAWith the above dependency
winpty.dll
binary for WoA available in thecore/org.eclipse.cdt.core.win32.aarch64/os/win32/aarch64
folder, it's now possible to compile thepty.dll
,spawner.dll
andstarter.exe
binaries for WoA, by executing the following commands in the MSYS2clangarm64
shell:$ cd core/org.eclipse.cdt.core.native/native_src $ make
and the
pty.dll
,spawner.dll
andstarter.exe
binaries for WoA would be successfully produced in thecore/org.eclipse.cdt.core.win32.aarch64/os/win32/aarch64
folder.Building
serial.dll
binary for WoASimilarly, the
serial.dll
binary for WoA can be built with the following commands executing in the MSYS2clangarm64
shell:$ cd native/org.eclipse.cdt.native.serial/native_src $ make
and the
serial.dll
binary for WoA would be successfully produced in thenative/org.eclipse.cdt.native.serial/os/win32/aarch
folder.