Skip to content
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

(many) Upgrade to .NET 7 RC1 #347

Merged
merged 1 commit into from
Oct 11, 2022
Merged

(many) Upgrade to .NET 7 RC1 #347

merged 1 commit into from
Oct 11, 2022

Conversation

perlun
Copy link
Collaborator

@perlun perlun commented Oct 4, 2022

.NET 7 is not yet released; it's likely to be released next month. This PR tries to see how well-prepared we are for it. 🙂

@perlun perlun added the enhancement New feature or request label Oct 4, 2022
@perlun perlun changed the title (ci) Use .NET 7 in CI (many) Upgrade to .NET 7 Oct 4, 2022
@perlun perlun force-pushed the feature/use-net-7-in-ci branch 2 times, most recently from 029f0ac to abcfc05 Compare October 4, 2022 17:53
@perlun
Copy link
Collaborator Author

perlun commented Oct 4, 2022

Most automated test seem to work nicely OOTB. The only issue found thus far is this, from https://github.com/perlang-org/perlang/actions/runs/3184319266/jobs/5192588306:

$ make docs-test-examples SHELL="sh -x -e"
for e in docs/examples/quickstart/*.per ; do echo -e \\n\\e[1m[$e]\\e[0m ; src/Perlang.ConsoleApp/bin/Release/net7.0/linux-x64/publish/perlang $e ; done
+ echo -e \n\e[1m[docs/examples/quickstart/hello_world.per]\e[0m
-e 
[docs/examples/quickstart/hello_world.per]
+ src/Perlang.ConsoleApp/bin/Release/net7.0/linux-x64/publish/perlang docs/examples/quickstart/hello_world.per
Hello World
+ echo -e \n\e[1m[docs/examples/quickstart/pi.per]\e[0m
-e 
[docs/examples/quickstart/pi.per]
+ src/Perlang.ConsoleApp/bin/Release/net7.0/linux-x64/publish/perlang docs/examples/quickstart/pi.per
31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989
for e in docs/examples/the-language/*.per ; do echo -e \\n\\e[1m[$e]\\e[0m ; src/Perlang.ConsoleApp/bin/Release/net7.0/linux-x64/publish/perlang $e ; done
+ echo -e \n\e[1m[docs/examples/the-language/calling-base64-encode.per]\e[0m
-e 
[docs/examples/the-language/calling-base64-encode.per]
+ src/Perlang.ConsoleApp/bin/Release/net7.0/linux-x64/publish/perlang docs/examples/the-language/calling-base64-encode.per
[line 4] Error at 'Base64': Undefined identifier 'Base64'
make: *** [Makefile:42: docs-test-examples] Error 65

I can easily reproduce this locally, and it seems to have something to do with the (dynamic) loading of the stdlib .dll files which contain things like the Base64 class. Will see what I can find. 🕵️‍♂️ 🤓

@perlun
Copy link
Collaborator Author

perlun commented Oct 4, 2022

Something does indeed go wrong. Thanks to monodis1, I've identified that something related to the types in Perlang.Stdlib.dll is indeed severely broken in .NET 7.

In an existing build based on 78fbc1f, built with .NET 6

$ ~/.perlang/release/bin/perlang -V
Perlang 0.2.0 (built from git commit 78fbc1f) on .NET 6.0.5

  Number of detected (v)CPUs: 20
  Running in 64-bit mode: True
  Operating system info: Unix 5.18.0.4

$ monodis --typedef /home/per/.perlang/release/bin/Perlang.Stdlib.dll
Typedef Table
1: (null) (flist=1, mlist=1, flags=0x0, extends=0x0)
2: Microsoft.CodeAnalysis.EmbeddedAttribute (flist=1, mlist=1, flags=0x100100, extends=0x21)
3: System.Runtime.CompilerServices.NullableAttribute (flist=1, mlist=2, flags=0x100100, extends=0x21)
4: System.Runtime.CompilerServices.NullableContextAttribute (flist=2, mlist=4, flags=0x100100, extends=0x21)
5: Perlang.Stdlib.Argv (flist=3, mlist=5, flags=0x100001, extends=0x2d)
6: Perlang.Stdlib.Base64 (flist=4, mlist=7, flags=0x100181, extends=0x2d)
7: Perlang.Stdlib.Libc (flist=4, mlist=9, flags=0x100181, extends=0x2d)
8: Perlang.Stdlib.Posix (flist=4, mlist=13, flags=0x100181, extends=0x2d)
9: Perlang.Stdlib.Time (flist=4, mlist=18, flags=0x100181, extends=0x2d)
10: Perlang.Exceptions.IllegalStateException (flist=4, mlist=19, flags=0x100001, extends=0x2c)
11: Perlang.Exceptions.StdlibException (flist=4, mlist=20, flags=0x100081, extends=0x61)
12: Perlang.Stdlib.Libc/Internal (flist=4, mlist=21, flags=0x100183, extends=0x2d)
13: Perlang.Stdlib.Posix/Internal (flist=4, mlist=22, flags=0x100183, extends=0x2d)

The above list is correct; those types are expected to be present in this assembly. Now, take a look at the corresponding output in the .NET build...

In a build generated from the contents in this PR

$ monodis --typedef src/Perlang.ConsoleApp/bin/Release/net7.0/linux-x64/publish/Perlang.Stdlib.dll 
Typedef Table
1: (null) (flist=1, mlist=1, flags=0x0, extends=0x0)
2: Perlang.Stdlib.Argv (flist=1, mlist=1, flags=0x100001, extends=0x5)
3: Perlang.Exceptions.IllegalStateException (flist=2, mlist=2, flags=0x100001, extends=0x10)
4: Perlang.Exceptions.StdlibException (flist=2, mlist=3, flags=0x100081, extends=0x15)

TL;DR: Something goes terribly wrong when we build the -self-contained true /p:PublishReadyToRun=true version. 🤔 Note that this only happens when building in this way; if I create a normal, debug build it looks just like the .NET 6-based release build:

$ monodis --typedef src/Perlang.ConsoleApp/bin/Debug/net7.0/Perlang.Stdlib.dll 
Typedef Table
1: (null) (flist=1, mlist=1, flags=0x0, extends=0x0)
2: Microsoft.CodeAnalysis.EmbeddedAttribute (flist=1, mlist=1, flags=0x100100, extends=0x21)
3: System.Runtime.CompilerServices.NullableAttribute (flist=1, mlist=2, flags=0x100100, extends=0x21)
4: System.Runtime.CompilerServices.NullableContextAttribute (flist=2, mlist=4, flags=0x100100, extends=0x21)
5: Perlang.Stdlib.Argv (flist=3, mlist=5, flags=0x100001, extends=0x2d)
6: Perlang.Stdlib.Base64 (flist=4, mlist=7, flags=0x100181, extends=0x2d)
7: Perlang.Stdlib.Libc (flist=4, mlist=9, flags=0x100181, extends=0x2d)
8: Perlang.Stdlib.Posix (flist=4, mlist=13, flags=0x100181, extends=0x2d)
9: Perlang.Stdlib.Time (flist=4, mlist=18, flags=0x100181, extends=0x2d)
10: Perlang.Exceptions.IllegalStateException (flist=4, mlist=19, flags=0x100001, extends=0x2c)
11: Perlang.Exceptions.StdlibException (flist=4, mlist=20, flags=0x100081, extends=0x61)
12: Perlang.Stdlib.Libc/Internal (flist=4, mlist=21, flags=0x100183, extends=0x2d)
13: Perlang.Stdlib.Posix/Internal (flist=4, mlist=22, flags=0x100183, extends=0x2d)

1: 🙏 available in mono-utils - there doesn't seem to be something like it in .NET (Core) yet

@perlun
Copy link
Collaborator Author

perlun commented Oct 4, 2022

I guess this could be causing it: https://devblogs.microsoft.com/dotnet/announcing-dotnet-7-preview-7/#trimming-and-nativeaot-all-assemblies-trimmed-by-default

Trimming and NativeAOT: All assemblies trimmed by default

To better align with user expectations and produce smaller and more efficient apps, trimming now trims all assemblies in console apps by default. This change only affects apps that are published with PublishTrimmed=true, and it only affects apps that had existing trim warnings. It also only affects plain .NET apps that don’t use the Windows Desktop, Android, iOS, WASM, or ASP.NET SDK.

Previous behavior

Previously, only assemblies that were opted-in with true in the library project file were trimmed.

@perlun perlun mentioned this pull request Oct 4, 2022
@perlun

This comment was marked as outdated.

@perlun

This comment was marked as outdated.

@perlun
Copy link
Collaborator Author

perlun commented Oct 4, 2022

Argh, I was looking at the wrong file. 🙈 🤯 The problem still seems to persist, which CI was kind enough to highlight...

$ monodis --typedef /home/per/git/perlang/src/Perlang.ConsoleApp/bin/Release/net7.0/linux-x64/publish/Perlang.Stdlib.dll 
Typedef Table
1: (null) (flist=1, mlist=1, flags=0x0, extends=0x0)
2: Perlang.Stdlib.Argv (flist=1, mlist=1, flags=0x100001, extends=0x5)
3: Perlang.Exceptions.IllegalStateException (flist=2, mlist=2, flags=0x100001, extends=0x10)
4: Perlang.Exceptions.StdlibException (flist=2, mlist=3, flags=0x100081, extends=0x15)

@perlun
Copy link
Collaborator Author

perlun commented Oct 8, 2022

The problem has now been resolved, with some help from the MS guys. 🙏 Given that .NET 7 is likely to ship before Perlang 0.3.0, let's get this merged now. 👍

@perlun perlun changed the title (many) Upgrade to .NET 7 (many) Upgrade to .NET 7 RC1 Oct 8, 2022
@perlun perlun merged commit 88f0c89 into master Oct 11, 2022
@perlun perlun deleted the feature/use-net-7-in-ci branch October 11, 2022 18:22
@perlun perlun added this to the 0.3.0 milestone Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant