bflattened / bflat

C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)
GNU Affero General Public License v3.0
3.56k stars 102 forks source link

Cannot run bflat on ARM64 #199

Open queequac opened 2 weeks ago

queequac commented 2 weeks ago

I downloaded the ZIP file manually as well as installed bflat 8.0.2 alternatively via winget. In both cases I cannot run it on my ARM64 machine (Windows Developer Kit 2023, Windows 11 Pro, German locale)

It simply shows a dialog with The process entry point "__chkstk" was not found in the DLL "C:\...\bflat.exe".

queequac commented 2 weeks ago

Supplement: It works fine on other machines, i.e. my work mate (Surface Book 3, Windows 10 Enterprise, German locale). Only difference between both machines: X64 instead of ARM64 and the OS version.

But cannot really imagine that there is an issue when using Windows 11 instead of 10, so I stick to my assumption that ARM64 does not execute bflat as expected.

MichalStrehovsky commented 2 weeks ago

This symbol is normally provided by the Visual C++ runtime library, but bflat cannot ship those because they require a Visual Studio license. So instead bflat links against it's own shim of this library that pretty much has everything the linker complains about. chkstk is exported from kernel32.dll on x64 so there's no shim for this (it would have to be written in assembly). Looks like it's not exported on arm64.

The fix is probably to revert https://github.com/bflattened/runtime/pull/26/commits/739bfd9d08cb72cf7d49d910957d32d226650098 but I don't have an ARM64 capable windows machine anymore so can't test.

queequac commented 2 weeks ago

I can check later if I am able to build bflat. In that case I could test it for you on arm64 after reverting the mentioned commit.

queequac commented 2 weeks ago

I am able to build bflat (had to add <CompilerHost Condition="'$(CompilerHost)' == '' and '$(NETCoreSdkRuntimeIdentifier)' == 'win-arm64'">windows-arm64</CompilerHost> to the project file when building on ARM64, but afterwards it worked and created the layouts).

Now I realized the commit to be reverted is in the runtime repo and the whole build process is simply downloading those packages. Any quick hint how I can build the runtime part and how to make the bflat build using my modified runtime?

MichalStrehovsky commented 2 weeks ago

Checkout the bflat-release/8.0 branch and execute build.cmd clr.nativeaotruntime -c Release -arch arm64 (you might need some prerequisites such as CMake - the repo build is the same as for the official dotnet/runtime repo. You should get outputs under artifacts/bin/coreclr/windows.arm64.Release/aotsdk. The replace the binaries that bflat build downloaded with the new binaries.

I'll just try and see if I can produce the binaries for you to try. First step at https://github.com/bflattened/runtime/pull/73.

MichalStrehovsky commented 2 weeks ago

The CI run https://github.com/bflattened/bflat/actions/runs/9546778614 should have a possibly fixed build of bflat. Could you give bflat-windows-arm64.zip a try?

queequac commented 1 week ago

Sorry for the late reply, I was distracted by a few things (incl. Euro24 😁). The provided build runs like a charm. I did not test across all features, but I think it should work and would be a good candidate for an official release.

MichalStrehovsky commented 1 week ago

Great, thank you! I'll need to run some validation myself and then release it