dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.85k stars 4.62k forks source link

LoongArch64: Track the progress of nativeaot test cases passing on LoongArch64. #104661

Open sunlijun-610 opened 1 month ago

sunlijun-610 commented 1 month ago

This issue will track the progress of nativeaot test cases passing on LoongArch64

sunlijun-610 commented 1 month ago

Currently, I've just tested the smoke tests of nativeaot, in runtime/src/tests/nativeaot/SmokeTests. In smoke tests, linux-loongarch64 requires testing 15 test cases. And currently, 13 cases can be passed through.

The two failed tests are SmokeTests/DynamicGenerics/DynamicGenerics/native/DynamicGenerics and SmokeTests/UnitTests/UnitTests/native/UnitTests, each have a small test failure. ThreadLocalStatics.TLSTesting.ThreadLocalStatics_Test failed in DynamicGenerics and BasicThreading.Run failed in UnitTests. I think they maybe both related to TLS, but LoongArch64 currently lacks TLS support, and is working toward it.

Another issue is, while compiling smoke tests SharedLibrary, it will report errors like ld.lld : error : relocation R_LARCH_PCALA_LO12 cannot be used against symbol 'memmove'; recompile with -fPIC [/home/sunlijun/runtime/src/tests/nativeaot/SmokeTests/SharedLibrary/SharedLibrary.csproj] [/home/sunlijun/runtime/src/tests/build.proj].

The reason why I didn't test coreclr tests and libraries tests is that it usually reports an unstable error like EXEC : error : One or more errors occurred. (Code generation failed for method '[S.P.CoreLib]System.Globalization.CalendricalCalculationsHelper.EquationOfTime(float64)') [/home/sunlijun/runtime_test/runtime/src/libraries/Common/tests/Common.Tests.csproj::TargetFramework=net9.0-linux] while compiling the .o file using ilc-published/ilc. It's currently too unstable to test them. We are analyzing and trying to solve it.

am11 commented 1 month ago

Another issue is, while compiling smoke tests SharedLibrary, it will report errors like ld.lld : error : relocation R_LARCH_PCALA_LO12 cannot be used against symbol 'memmove'; recompile with -fPIC [/home/sunlijun/runtime/src/tests/nativeaot/SmokeTests/SharedLibrary/SharedLibrary.csproj] [/home/sunlijun/runtime/src/tests/build.proj].

Does this fix the error: https://github.com/am11/runtime/commit/5d76762786bc431fec6e84fa3c960ceae78871f1?

sunlijun-610 commented 1 month ago

Another issue is, while compiling smoke tests SharedLibrary, it will report errors like ld.lld : error : relocation R_LARCH_PCALA_LO12 cannot be used against symbol 'memmove'; recompile with -fPIC [/home/sunlijun/runtime/src/tests/nativeaot/SmokeTests/SharedLibrary/SharedLibrary.csproj] [/home/sunlijun/runtime/src/tests/build.proj].

Does this fix the error: 5d76762?

No, it doesn't. CMAKE_POSITION_INDEPENDENT_CODE should have already been set up in eng/native/configureplatform.cmake, so it seems unralated to the error. Thanks!

am11 commented 1 month ago

Ah, it's included by INC_PLATFORM_DIR. You can try setting <LinkerFlavor>bfd</LinkerFlavor> in that test project to see if it works. It might be the problem with lld's LA64 port. See similar reports https://github.com/search?q=repo%3Allvm%2Fllvm-project+%22cannot+be+used+against+symbol%22&type=issues

sunlijun-610 commented 1 month ago

Ah, it's included by INC_PLATFORM_DIR. You can try setting <LinkerFlavor>bfd</LinkerFlavor> in that test project to see if it works. It might be the problem with lld's LA64 port. See similar reports https://github.com/search?q=repo%3Allvm%2Fllvm-project+%22cannot+be+used+against+symbol%22&type=issues

Yes, you're right! I tried to use ld.bfd to link, and it was compiled and run successfully. Thanks a lot for your help!

am11 commented 1 month ago

Great! You can open an issue in llvm repo with SharedLibrary's .o file attached; that bfd links the object while lld doesn't accept R_LARCH_PCALA_LO12. The default is bfd in production targets so it's not critical. When building the repo we use lld for everything unless otherwise specified.

am11 commented 2 weeks ago

The two failed tests are SmokeTests/DynamicGenerics/DynamicGenerics/native/DynamicGenerics and SmokeTests/UnitTests/UnitTests/native/UnitTests, each have a small test failure. ThreadLocalStatics.TLSTesting.ThreadLocalStatics_Test failed in DynamicGenerics and BasicThreading.Run failed in UnitTests. I think they maybe both related to TLS, but LoongArch64 currently lacks TLS support, and is working toward it.

TLS is now supported https://github.com/dotnet/runtime/pull/106254#issuecomment-2285121714, they should be passing now?

sunlijun-610 commented 2 weeks ago

The two failed tests are SmokeTests/DynamicGenerics/DynamicGenerics/native/DynamicGenerics and SmokeTests/UnitTests/UnitTests/native/UnitTests, each have a small test failure. ThreadLocalStatics.TLSTesting.ThreadLocalStatics_Test failed in DynamicGenerics and BasicThreading.Run failed in UnitTests. I think they maybe both related to TLS, but LoongArch64 currently lacks TLS support, and is working toward it.

TLS is now supported #106254 (comment), they should be passing now?

No, they still cannot pass. More precisely, they have a very low probability of passing, possibly less than 20%. And they have many types of errors when they fail.