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

Support FreeBSD #272

Closed
perlun opened this issue Feb 7, 2022 · 17 comments · Fixed by #273
Closed

Support FreeBSD #272

perlun opened this issue Feb 7, 2022 · 17 comments · Fixed by #273
Labels
enhancement New feature or request platform support Support for new operating systems and/or architectures
Milestone

Comments

@perlun
Copy link
Collaborator

perlun commented Feb 7, 2022

Moved to GitLab

Please continue to the new version of this issue here: https://gitlab.perlang.org/perlang/perlang/-/issues/272. The GitHub page you are currently reading will not contain the latest information on this issue.


Once the support for FreeBSD (either "official" support or some form of "community support") is there in the .NET platform, we should add support for it in Perlang also. The more platforms we can (easily) support, the better. 🙂

Upstream issues:

More references

@perlun perlun added enhancement New feature or request platform support Support for new operating systems and/or architectures labels Feb 7, 2022
@perlun perlun added this to the "Later" milestone Feb 7, 2022
perlun added a commit that referenced this issue Feb 7, 2022
Minor improvement until we hopefully can resolve #272 one day.
perlun added a commit that referenced this issue Feb 7, 2022
Minor improvement until we hopefully can resolve #272 one day.
@perlun perlun reopened this Feb 7, 2022
@Thefrank
Copy link

Thefrank commented Feb 7, 2022

I, and at least two others, publicly publish net3.1, net5, and net6 SDKs for FreeBSD. Using the Microsoft published SDK outside of FreeBSD to target FreeBSD does however, require manually adding in the FreeBSD RID (sed can do this) and either manually adding the missing NuGet files to your feed or placing them in a place where NuGet can find them doing restore.

As you have this marked as "Later" I assume this is a longterm goal so when you are ready, let me know and I (and likely others!) would be happy to help you get setup with FreeBSD and dotNET :)

@perlun
Copy link
Collaborator Author

perlun commented Feb 8, 2022

Very interesting, thanks for the feedback! 👍🏻🙂 I’m not really a FreeBSD user myself (mostly using Linux) but I definitely wouldn’t mind adding support for FreeBSD in the project. Even other BSD:s would be cool (like NetBSD on arm) but FreeBSD seems to be the most widely used one.

The CI publishing is done from Linux; snapshots are generated for Linux, macOS and Windows from GitHub Actions. So if/when we add FreeBSD support it would be great if it could be cross-compiled from Linux.

I set up an Azure VM with FreeBSD yesterday, so if you have some links I’ll happily try out the .NET SDK. It’s the .NET 6 package that would be interesting in this case.

(and btw, thanks for your interest in the project. You’re the first person to ever write a comment in this repo, apart from me and a colleague I involuntarily involved. 😂🎉)

@perlun
Copy link
Collaborator Author

perlun commented Feb 9, 2022

Ping @Thefrank. 🙂 Do you have a link to your .NET 6 SDK?

@Thefrank
Copy link

Thefrank commented Feb 9, 2022

https://github.com/Thefrank/dotnet-freebsd-crossbuild
or
https://github.com/Thefrank/dotnet-freebsd-native-binaries

These are built for and target FreeBSD 12.2. They SHOULD work under FreeBSD 12.3+

@perlun
Copy link
Collaborator Author

perlun commented Feb 9, 2022

These are built for and target FreeBSD 12.2. They SHOULD work under FreeBSD 12.3+

Thanks, nice! 👍 I quickly downloaded it on my FreeBSD (cloud-based) test VM and dotnet seems to start fine at least:

[10:01:28] per@freebsd-test:~/tmp$ ./dotnet 

Usage: dotnet [options]
Usage: dotnet [path-to-application]

Options:
  -h|--help         Display help.
  --info            Display .NET information.
  --list-sdks       Display the installed SDKs.
  --list-runtimes   Display the installed runtimes.

path-to-application:
  The path to an application .dll file to execute.
[10:01:31] per@freebsd-test:~/tmp$ uname -a
FreeBSD freebsd-test 13.0-RELEASE-p7 FreeBSD 13.0-RELEASE-p7 #0: Mon Jan 31 18:24:03 UTC 2022     root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64

So... what would be the next step? I guess something like this, if we want to cross-build from Linux?

Using the Microsoft published SDK outside of FreeBSD to target FreeBSD does however, require manually adding in the FreeBSD RID (sed can do this) and either manually adding the missing NuGet files to your feed or placing them in a place where NuGet can find them doing restore.

The current steps we use for building a release a roughly the following. Note that --self-contained true and /p:PublishReadyToRun=true are used here. We can probably live without R2R on FreeBSD if it isn't easily doable, but --self-contained is important. What this basically means is that the build ships the required .NET .dlls along with the application, making it completely independent from what happens to be installed on the host OS.

perlang/Makefile

Lines 13 to 14 in 4afdce4

release:
dotnet publish src/Perlang.ConsoleApp/Perlang.ConsoleApp.csproj -c Release -r linux-x64 --self-contained true /p:PublishReadyToRun=true /p:SolutionDir=$$(pwd)/

We also perform link-time "trimming" of the output, to keep the size of the generated binaries down:

<PublishTrimmed>true</PublishTrimmed>

@Thefrank
Copy link

Thefrank commented Feb 9, 2022

dotnet --info is the best way to make sure dotnet "runs"
then
dotnet new console
dotnet run console and/or dotnet publish console --YOUR --SETTINGS --HERE
to make sure it can run/build everything

distribution:

  • --self-contained true is ideal as only a binary blob of the SDK exist right now and self-contained is already known to work correctly.
  • /p:PublishReadyToRun=true should work but only with the sdk from "native-binaries" repo as the crossbuild SDK is currently unable to correctly generate native images when it builds itself
  • LTO and other compiler/linker tricks: I am unsure on these. let me know how it goes :)

@perlun
Copy link
Collaborator Author

perlun commented Feb 10, 2022

dotnet --info is the best way to make sure dotnet "runs"

Thanks. This gave me the following error:

[19:47:32] per@freebsd-test:~/git/perlang (master) $ dotnet --info
Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
   at System.Environment.FailFast(System.String)
   at System.Globalization.GlobalizationMode+Settings..cctor()
   at System.Resources.ManifestBasedResourceGroveler.GetNeutralResourcesLanguage(System.Reflection.Assembly, System.Resources.UltimateResourceFallbackLocation ByRef)
   at System.Resources.ResourceManager.CommonAssemblyInit()
   at System.Resources.ResourceManager..ctor(System.Type)
   at System.SR.get_ResourceManager()
   at System.SR.InternalGetResourceString(System.String)
   at System.SR.GetResourceString(System.String)
   at System.DllNotFoundException..ctor()
   at System.DateTime.get_UtcNow()
   at System.DateTime.get_Now()
   at Microsoft.DotNet.Cli.Program.Main(System.String[])
Abort trap (core dumped)

This is using the native-binaries repo. Perhaps it would be worth mentioning something about this requirement in either the readme for that repo or in https://github.com/Thefrank/dotnet-freebsd-crossbuild? 🤔

[19:52:56] per@freebsd-test:~/git/perlang (master) $ sudo pkg install icu
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	icu: 70.1_1,1

Number of packages to be installed: 1

The process will require 50 MiB more space.
11 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching icu-70.1_1,1.pkg: 100%   11 MiB   5.6MB/s    00:02    
Checking integrity... done (0 conflicting)
[1/1] Installing icu-70.1_1,1...
[1/1] Extracting icu-70.1_1,1: 100%

After installing this, I got a bit further:

[19:53:02] per@freebsd-test:~/git/perlang (master) $ dotnet --info
Unhandled exception. System.DllNotFoundException: Unable to load shared library 'libSystem.Native' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Shared object "liblibSystem.Native" not found, required by "dotnet"
   at System.DateTime.get_UtcNow()
   at System.DateTime.get_Now()
   at Microsoft.DotNet.Cli.Program.Main(String[] args)
Abort trap (core dumped)

Guessing from https://github.com/dotnet/runtime/blob/main/docs/workflow/building/coreclr/freebsd-instructions.md, I installed gettext but it didn't help. I also tried installing linux-c7-lttng-ust-2.4.1, but it failed because the Azure VM I'm using doesn't seem to have Linux support enabled: Cannot install package: kernel missing 64-bit Linux support

I wonder if this could be caused by some particular directory structure being required? I just unpacked this into /usr/home/per/dotnet for now, but maybe that's doomed to fail? The file that it's trying to load definitely seems to be there, from what I can tell:

[19:58:35] per@freebsd-test:~/dotnet$ find . | grep Native
./sdk/6.0.101/Microsoft.DotNet.NativeWrapper.dll
./shared/Microsoft.NETCore.App/6.0.1/libSystem.IO.Compression.Native.so
./shared/Microsoft.NETCore.App/6.0.1/libSystem.Native.so
./shared/Microsoft.NETCore.App/6.0.1/libSystem.Globalization.Native.so
./shared/Microsoft.NETCore.App/6.0.1/libSystem.Net.Security.Native.so
./shared/Microsoft.NETCore.App/6.0.1/libSystem.Security.Cryptography.Native.OpenSsl.so

Using ldd on that particular library seems to reveal an important part of this puzzle though. 💡

[19:59:01] per@freebsd-test:~/dotnet$ ldd ./shared/Microsoft.NETCore.App/6.0.1/libSystem.Native.so
./shared/Microsoft.NETCore.App/6.0.1/libSystem.Native.so:
	libthr.so.3 => /lib/libthr.so.3 (0x80068e000)
	libinotify.so.0 => not found (0)
	libc.so.7 => /lib/libc.so.7 (0x800263000)

I tried with sudo pkg install libinotify and the dependency would now be found:

[20:05:06] per@freebsd-test:~/dotnet$ ldd ./shared/Microsoft.NETCore.App/6.0.1/libSystem.Native.so
./shared/Microsoft.NETCore.App/6.0.1/libSystem.Native.so:
	libthr.so.3 => /lib/libthr.so.3 (0x80068e000)
	libinotify.so.0 => /usr/local/lib/libinotify.so.0 (0x8006bb000)
	libc.so.7 => /lib/libc.so.7 (0x800263000)

And dotnet --info now works! 🎉

[20:06:03] per@freebsd-test:~/dotnet$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.101
 Commit:    ef49f6213a

Runtime Environment:
 OS Name:     FreeBSD
 OS Version:  13
 OS Platform: FreeBSD
 RID:         freebsd.13-x64
 Base Path:   /usr/home/per/dotnet/sdk/6.0.101/

Host (useful for support):
  Version: 6.0.1
  Commit:  3a25a7f1cc

.NET SDKs installed:
  6.0.101 [/usr/home/per/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.1 [/usr/home/per/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.1 [/usr/home/per/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

I'll try building the Perlang project with this SDK in a minute, hope to post some details about it in a separate comment soon.

@perlun
Copy link
Collaborator Author

perlun commented Feb 10, 2022

Trying to build Perlang (just checking out the repo and running make, which should do everything for us) gives me a bunch of errors like this when trying to do NuGet package restore: The repository primary signature validity period has expired., i.e the same error as Servarr/dotnet-bsd#8. I googled my way to the ca_root_nss but this package is unfortunately already installed, so that can't be the problem here... 😐

Here are some of the first errors in the build output:

  Determining projects to restore...
  Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json': 
  Signature type: Author
  Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json':   Subject Name: CN=Sonarsource SA, O=Sonarsource SA, L=GENÈVE, C=CH
  Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json':   SHA256 hash: FC4D3F3F815C1B56A656F1A5D9456AF04B469267D945786057175049B15A62A0
  Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json':   Valid from: 09/17/2019 00:00:00 to 10/15/2021 23:59:59
/usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj : error NU3037: Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json': The author primary signature validity period has expired. [/usr/home/per/git/perlang/Perlang.sln]
/usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj : error NU3028: Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json': The author primary signature's timestamping certificate is not trusted by the trust provider. [/usr/home/per/git/perlang/Perlang.sln]
  Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json': 
  Signature type: Repository
  Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json':   Subject Name: CN=NuGet.org Repository by Microsoft, O=NuGet.org Repository by Microsoft, L=Redmond, S=Washington, C=US
  Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json':   SHA256 hash: 5A2901D6ADA3D18260B9C6DFE2133C95D74B9EEF6AE0E5DC334C8454D1477DF4
  Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json':   Valid from: 02/16/2021 00:00:00 to 05/15/2024 23:59:59
/usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj : error NU3028: Package 'SonarAnalyzer.CSharp 8.29.0.36737' from source 'https://api.nuget.org/v3/index.json': The repository countersignature's timestamping certificate is not trusted by the trust provider. [/usr/home/per/git/perlang/Perlang.sln]
  Package 'StyleCop.Analyzers 1.2.0-beta.321' from source 'https://api.nuget.org/v3/index.json': 
  Signature type: Repository
  Package 'StyleCop.Analyzers 1.2.0-beta.321' from source 'https://api.nuget.org/v3/index.json':   Subject Name: CN=NuGet.org Repository by Microsoft, O=NuGet.org Repository by Microsoft, L=Redmond, S=Washington, C=US
  Package 'StyleCop.Analyzers 1.2.0-beta.321' from source 'https://api.nuget.org/v3/index.json':   SHA256 hash: 0E5F38F57DC1BCC806D8494F4F90FBCEDD988B46760709CBEEC6F4219AA6157D
  Package 'StyleCop.Analyzers 1.2.0-beta.321' from source 'https://api.nuget.org/v3/index.json':   Valid from: 04/10/2018 00:00:00 to 04/14/2021 12:00:00
/usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj : error NU3037: Package 'StyleCop.Analyzers 1.2.0-beta.321' from source 'https://api.nuget.org/v3/index.json': The repository primary signature validity period has expired. [/usr/home/per/git/perlang/Perlang.sln]
/usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj : error NU3028: Package 'StyleCop.Analyzers 1.2.0-beta.321' from source 'https://api.nuget.org/v3/index.json': The repository primary signature's timestamping certificate is not trusted by the trust provider. [/usr/home/per/git/perlang/Perlang.sln]
  Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json': 
  Signature type: Repository
  Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json': 
  Signature type: Repository
  Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json':   Subject Name: CN=NuGet.org Repository by Microsoft, O=NuGet.org Repository by Microsoft, L=Redmond, S=Washington, C=US
  Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json':   SHA256 hash: 0E5F38F57DC1BCC806D8494F4F90FBCEDD988B46760709CBEEC6F4219AA6157D
  Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json':   Valid from: 04/10/2018 00:00:00 to 04/14/2021 12:00:00
/usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj : error NU3037: Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json': The repository primary signature validity period has expired. [/usr/home/per/git/perlang/Perlang.sln]
/usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj : error NU3028: Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json': The repository primary signature's timestamping certificate is not trusted by the trust provider. [/usr/home/per/git/perlang/Perlang.sln]
  Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json':   Subject Name: CN=NuGet.org Repository by Microsoft, O=NuGet.org Repository by Microsoft, L=Redmond, S=Washington, C=US
  Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json':   SHA256 hash: 0E5F38F57DC1BCC806D8494F4F90FBCEDD988B46760709CBEEC6F4219AA6157D
  Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json':   Valid from: 04/10/2018 00:00:00 to 04/14/2021 12:00:00
/usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj : error NU3037: Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json': The repository primary signature validity period has expired. [/usr/home/per/git/perlang/Perlang.sln]
/usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj : error NU3028: Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json': The repository primary signature's timestamping certificate is not trusted by the trust provider. [/usr/home/per/git/perlang/Perlang.sln]
  Failed to restore /usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj (in 2.68 sec).
  Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json': 
  Signature type: Repository
  Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json':   Subject Name: CN=NuGet.org Repository by Microsoft, O=NuGet.org Repository by Microsoft, L=Redmond, S=Washington, C=US
  Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json':   SHA256 hash: 0E5F38F57DC1BCC806D8494F4F90FBCEDD988B46760709CBEEC6F4219AA6157D
  Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json':   Valid from: 04/10/2018 00:00:00 to 04/14/2021 12:00:00
/usr/home/per/git/perlang/src/Perlang.Interpreter/Perlang.Interpreter.csproj : error NU3037: Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json': The repository primary signature validity period has expired. [/usr/home/per/git/perlang/Perlang.sln]
/usr/home/per/git/perlang/src/Perlang.Interpreter/Perlang.Interpreter.csproj : error NU3028: Package 'StyleCop.Analyzers.Unstable 1.2.0.321' from source 'https://api.nuget.org/v3/index.json': The repository primary signature's timestamping certificate is not trusted by the trust provider. [/usr/home/per/git/perlang/Perlang.sln]
  Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json': 
  Signature type: Repository
  Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json':   Subject Name: CN=NuGet.org Repository by Microsoft, O=NuGet.org Repository by Microsoft, L=Redmond, S=Washington, C=US
  Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json':   SHA256 hash: 0E5F38F57DC1BCC806D8494F4F90FBCEDD988B46760709CBEEC6F4219AA6157D
  Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json':   Valid from: 04/10/2018 00:00:00 to 04/14/2021 12:00:00
/usr/home/per/git/perlang/src/Perlang.Interpreter/Perlang.Interpreter.csproj : error NU3037: Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json': The repository primary signature validity period has expired. [/usr/home/per/git/perlang/Perlang.sln]
/usr/home/per/git/perlang/src/Perlang.Interpreter/Perlang.Interpreter.csproj : error NU3028: Package 'JetBrains.Annotations 2020.2.0-eap' from source 'https://api.nuget.org/v3/index.json': The repository primary signature's timestamping certificate is not trusted by the trust provider. [/usr/home/per/git/perlang/Perlang.sln]

I remember there was a timestamping related issue on Debian systems a few months ago (NuGet/Home#10491). This probably has similar root causes.... or what do you think? 🤔

@perlun
Copy link
Collaborator Author

perlun commented Feb 10, 2022

Doing this seems to work fine btw:

[20:20:59] per@freebsd-test:~/tmp$ dotnet new console
The template "Console App" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /usr/home/per/tmp/tmp.csproj...
  Determining projects to restore...
  Restored /usr/home/per/tmp/tmp.csproj (in 108 ms).
Restore succeeded.

[20:21:05] per@freebsd-test:~/tmp$ dotnet run console
Hello, World!

@Thefrank
Copy link

whew! so, yeah I should add some instructions there that are not covered elsewhere (https://github.com/dotnet/runtime/blob/main/docs/workflow/requirements/freebsd-requirements.md#running-on-freebsd). generally dotnet needs these depends to run:

libunwind icu libinotify

Recently, lttng-ust got removed from pkg because of package incompatibilities. dotnet should run OK without it. The good news, dotnet/runtime has already removed it as a build depend but it needs to be manually backported by people building the SDK. (dotnet 6.02 was recently released so if I get some time over the weekend ill put out an SDK for it)

For building packages, you also need openssl ca_root_nss if restore has to pull from the internet. This will work until you hit Microsoft's NuGet repos. Long story short: Signature verification is disabled on Linux and OSX due to the removal of the certs that Microsoft uses on "older" packages because NSS blacklisted a rootcert they use. Side note: The old "Let's Encrypt" cert can cause problems but deleting the now-expired cert should resolve that.
Work around:

mv /usr/share/certs/blacklisted/VeriSign_Universal_Root_Certification_Authority.pem /usr/share/certs/trusted
certctl rehash

WARNING: You are basically trusting an otherwise blacklisted rootcert.

Actual fix:
an actual fix to disable verification under FreeBSD was merged in but is unlikely make it into builds until SDK 6.0.3xx (6.0.2xx if we are lucky). This is also something that can not be manually changed as its handled by the NuGet repos and not anything directly in dotnet's runtime/aspnetcore/installer repos

@perlun
Copy link
Collaborator Author

perlun commented Feb 11, 2022

Thanks! 🙇 👍 So it was indeed the same root cause as the Debian one I think; there is even a blog post that describes that problem more in depth: https://devblogs.microsoft.com/nuget/net-5-nuget-restore-failures-on-linux-distributions-using-nss-or-ca-certificates/

Anyway, running these commands:

mv /usr/share/certs/blacklisted/VeriSign_Universal_Root_Certification_Authority.pem /usr/share/certs/trusted
certctl rehash

...seemed to make things work much better with these NuGet sources. 🎉 And btw, thanks for making this very clear:

WARNING: You are basically trusting an otherwise blacklisted rootcert.

With these changes in place, the Perlang tooling builds without any obvious problems (note, this is in the Debug configuration without R2R or anything like that enabled yet):

[20:25:00] per@freebsd-test:~/git/perlang (master) $ make
./scripts/update_common_constants.rb `pwd`
/usr/home/per/git/perlang/src/Perlang.Common/CommonConstants.Generated.cs updated
dotnet build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /usr/home/per/git/perlang/src/Perlang.Tests.Architecture/Perlang.Tests.Architecture.csproj (in 21.04 sec).
  Restored /usr/home/per/git/perlang/src/Perlang.Tests.Integration/Perlang.Tests.Integration.csproj (in 21.04 sec).
  Restored /usr/home/per/git/perlang/src/Perlang.Stdlib/Perlang.Stdlib.csproj (in 4 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj (in 2 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.Interpreter/Perlang.Interpreter.csproj (in 2 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.ConsoleApp/Perlang.ConsoleApp.csproj (in 1.17 sec).
  Restored /usr/home/per/git/perlang/src/Perlang.Common/Perlang.Common.csproj (in 5 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.Tests/Perlang.Tests.csproj (in 4.76 sec).
  Perlang.Common -> /usr/home/per/git/perlang/src/Perlang.Common/bin/Debug/net6.0/Perlang.Common.dll
  Perlang.Tests.Architecture -> /usr/home/per/git/perlang/src/Perlang.Tests.Architecture/bin/Debug/net6.0/Perlang.Tests.Architecture.dll
  Perlang.Stdlib -> /usr/home/per/git/perlang/src/Perlang.Stdlib/bin/Debug/net6.0/Perlang.Stdlib.dll
  Perlang.Parser -> /usr/home/per/git/perlang/src/Perlang.Parser/bin/Debug/net6.0/Perlang.Parser.dll
  Perlang.Interpreter -> /usr/home/per/git/perlang/src/Perlang.Interpreter/bin/Debug/net6.0/Perlang.Interpreter.dll
  Perlang.ConsoleApp -> /usr/home/per/git/perlang/src/Perlang.ConsoleApp/bin/Debug/net6.0/perlang.dll
  Perlang.Tests.Integration -> /usr/home/per/git/perlang/src/Perlang.Tests.Integration/bin/Debug/net6.0/Perlang.Tests.Integration.dll
  Perlang.Tests -> /usr/home/per/git/perlang/src/Perlang.Tests/bin/Debug/net6.0/Perlang.Tests.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:46.14

Running the result also seems to work (we'll need to make it distinguish between different kind of unices at some point, because Unix 13.0.7.0 (on FreeBSD) and Unix 5.9.0.5 (on my Debian GNU/Linux with kernel 5.9.0-5) isn't very clear. 😁):

[20:25:51] per@freebsd-test:~/git/perlang (master) $ /usr/home/per/git/perlang/src/Perlang.ConsoleApp/bin/Debug/net6.0/perlang -V
Perlang 0.1.0-dev.215 (built from git commit 4afdce4) on .NET 6.0.1

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

I'll also do some more testing in a minute, again posting that in a separate comment to allow people to follow this in real time. 🙂

@perlun
Copy link
Collaborator Author

perlun commented Feb 11, 2022

Alright, so here are some more results of my testing:

Running the REPL

Seems to work pretty well, but backspace doesn't properly print an erase character (it moves the character one step to the right), so the editing experience isn't that great yet:

[20:32:32] per@freebsd-test:~/git/perlang (master) $ /usr/home/per/git/perlang/src/Perlang.ConsoleApp/bin/Debug/net6.0/perlang 
Perlang Interactive REPL Console (0.1.0-dev.215, built from git commit 4afdce4)
> 2 ** 32
4294967296
> 42 * 5 - 3
207
> print "hej hopp"
hej hopp
> quit

Running the tests

Seems to work just fine. Some tests are skipped, but that's expected.

[20:34:09] per@freebsd-test:~/git/perlang (master) $ make test
dotnet test --configuration Release
  Determining projects to restore...
  Restored /usr/home/per/git/perlang/src/Perlang.Parser/Perlang.Parser.csproj (in 420 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.Interpreter/Perlang.Interpreter.csproj (in 4 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.ConsoleApp/Perlang.ConsoleApp.csproj (in 11 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.Common/Perlang.Common.csproj (in 3 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.Tests.Integration/Perlang.Tests.Integration.csproj (in 49 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.Tests/Perlang.Tests.csproj (in 543 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.Stdlib/Perlang.Stdlib.csproj (in 2 ms).
  Restored /usr/home/per/git/perlang/src/Perlang.Tests.Architecture/Perlang.Tests.Architecture.csproj (in 38 ms).
  Perlang.Common -> /usr/home/per/git/perlang/src/Perlang.Common/bin/Release/net6.0/Perlang.Common.dll
  Perlang.Parser -> /usr/home/per/git/perlang/src/Perlang.Parser/bin/Release/net6.0/Perlang.Parser.dll
  Perlang.Tests.Architecture -> /usr/home/per/git/perlang/src/Perlang.Tests.Architecture/bin/Release/net6.0/Perlang.Tests.Architecture.dll
Test run for /usr/home/per/git/perlang/src/Perlang.Tests.Architecture/bin/Release/net6.0/Perlang.Tests.Architecture.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: < 1 ms - /usr/home/per/git/perlang/src/Perlang.Tests.Architecture/bin/Release/net6.0/Perlang.Tests.Architecture.dll (net6.0)
  Perlang.Stdlib -> /usr/home/per/git/perlang/src/Perlang.Stdlib/bin/Release/net6.0/Perlang.Stdlib.dll
  Perlang.Interpreter -> /usr/home/per/git/perlang/src/Perlang.Interpreter/bin/Release/net6.0/Perlang.Interpreter.dll
  Perlang.ConsoleApp -> /usr/home/per/git/perlang/src/Perlang.ConsoleApp/bin/Release/net6.0/perlang.dll
  Perlang.Tests.Integration -> /usr/home/per/git/perlang/src/Perlang.Tests.Integration/bin/Release/net6.0/Perlang.Tests.Integration.dll
Test run for /usr/home/per/git/perlang/src/Perlang.Tests.Integration/bin/Release/net6.0/Perlang.Tests.Integration.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:02.35]     Perlang.Tests.Integration.Return.in_method [SKIP]
  Skipped Perlang.Tests.Integration.Return.in_method [1 ms]
[xUnit.net 00:00:02.69]     Perlang.Tests.Integration.Assignment.AssignmentTests.this_is_not_a_valid_assignment_target [SKIP]
  Skipped Perlang.Tests.Integration.Assignment.AssignmentTests.this_is_not_a_valid_assignment_target [1 ms]
[xUnit.net 00:00:02.94]     Perlang.Tests.Integration.Assignment.AssignmentTests.assignment_on_right_hand_side_of_variable_is_right_associative [SKIP]
  Skipped Perlang.Tests.Integration.Assignment.AssignmentTests.assignment_on_right_hand_side_of_variable_is_right_associative [1 ms]
[xUnit.net 00:00:04.16]     Perlang.Tests.Integration.Classes.ClassesTests.duplicate_class_name_throws_expected_error [SKIP]
[xUnit.net 00:00:04.16]     Perlang.Tests.Integration.Classes.ClassesTests.class_name_clash_with_variable_throws_expected_error [SKIP]
  Skipped Perlang.Tests.Integration.Classes.ClassesTests.duplicate_class_name_throws_expected_error [1 ms]
  Skipped Perlang.Tests.Integration.Classes.ClassesTests.class_name_clash_with_variable_throws_expected_error [1 ms]
[xUnit.net 00:00:04.16]     Perlang.Tests.Integration.Classes.ClassesTests.class_name_clash_with_function_throws_expected_error [SKIP]
[xUnit.net 00:00:04.23]     Perlang.Tests.Integration.Classes.ClassesTests.empty_class_can_be_accessed_by_name [SKIP]
[xUnit.net 00:00:04.23]     Perlang.Tests.Integration.Classes.ClassesTests.can_chain_method_calls_for_static_method [SKIP]
[xUnit.net 00:00:04.23]     Perlang.Tests.Integration.Classes.ClassesTests.class_name_clash_with_native_class_throws_expected_error [SKIP]
[xUnit.net 00:00:04.23]     Perlang.Tests.Integration.Classes.ClassesTests.class_name_clash_with_native_object_throws_expected_error [SKIP]
  Skipped Perlang.Tests.Integration.Classes.ClassesTests.class_name_clash_with_function_throws_expected_error [1 ms]
  Skipped Perlang.Tests.Integration.Classes.ClassesTests.empty_class_can_be_accessed_by_name [1 ms]
  Skipped Perlang.Tests.Integration.Classes.ClassesTests.can_chain_method_calls_for_static_method [1 ms]
  Skipped Perlang.Tests.Integration.Classes.ClassesTests.class_name_clash_with_native_class_throws_expected_error [1 ms]
  Skipped Perlang.Tests.Integration.Classes.ClassesTests.class_name_clash_with_native_object_throws_expected_error [1 ms]
[xUnit.net 00:00:04.30]     Perlang.Tests.Integration.Classes.ClassesTests.can_call_static_method [SKIP]
[xUnit.net 00:00:04.30]     Perlang.Tests.Integration.Classes.ClassesTests.can_get_reference_to_static_method [SKIP]
  Skipped Perlang.Tests.Integration.Classes.ClassesTests.can_call_static_method [1 ms]
  Skipped Perlang.Tests.Integration.Classes.ClassesTests.can_get_reference_to_static_method [1 ms]
[xUnit.net 00:00:12.76]     Perlang.Tests.Integration.Var.VarTests.local_from_method [SKIP]
  Skipped Perlang.Tests.Integration.Var.VarTests.local_from_method [1 ms]

Passed!  - Failed:     0, Passed:   480, Skipped:    13, Total:   493, Duration: 13 s - /usr/home/per/git/perlang/src/Perlang.Tests.Integration/bin/Release/net6.0/Perlang.Tests.Integration.dll (net6.0)
  Perlang.Tests -> /usr/home/per/git/perlang/src/Perlang.Tests/bin/Release/net6.0/Perlang.Tests.dll
Test run for /usr/home/per/git/perlang/src/Perlang.Tests/bin/Release/net6.0/Perlang.Tests.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:    38, Skipped:     0, Total:    38, Duration: 1 s - /usr/home/per/git/perlang/src/Perlang.Tests/bin/Release/net6.0/Perlang.Tests.dll (net6.0)

Next steps

We should try cross-building this on Linux as the next step; I won't be looking into this right now so if you like, the task is up for grabs. Otherwise I'll probably look into it in the next few weeks. Should be roughly following these steps from your guide:

  1. Patch in the support for FreeBSD RID.
  2. Add the NuGet packages: Microsoft.NETCore.App.Runtime.freebsd-x64.VERSION.nupkg and/or Microsoft.NETCore.App.Host.freebsd-x64.VERSION.nupkg. (Question: should we just self-host these or is there some reliable (over time) URL where we could download them in CI?)
  3. Add CI scripts for the above.

The way this currently works for Linux/macOS/Windows is as follows:

#
# Build releases
#
- name: Build host-compatible release
run: dotnet build
- name: Build ${{ matrix.arch }} release
run: dotnet publish src/Perlang.ConsoleApp/Perlang.ConsoleApp.csproj -c Release -r ${{ matrix.arch }} --self-contained true /p:PublishReadyToRun=true /p:SolutionDir=$(pwd)/
#
# Create .tar.gz archives
#
- name: Create ${{ matrix.arch }} .tar.gz file
run: version=$(${GITHUB_WORKSPACE}/src/Perlang.ConsoleApp/bin/Debug/net6.0/perlang -v) && tar cvzf ../perlang-$version-${{ matrix.arch }}.tar.gz *
working-directory: src/Perlang.ConsoleApp/bin/Release/net6.0/${{ matrix.arch }}/publish

We use a build matrix for these, with which we can easily support both arm, arm64 and x64 on a few different platforms. Once FreeBSD support has landed in .NET SDK proper, we should be able to add it to the matrix just like all the others, but for now we probably have to do a bit of a manual hack for this. This is perfectly fine with me, we'll just remove the hack once we no longer need it. 👍

@perlun
Copy link
Collaborator Author

perlun commented Mar 12, 2022

@Thefrank From the top off your head, what are the odds that official support for FreeBSD will get merged into https://github.com/dotnet/runtime/ and released along with .NET 7? 🤔 I guess just waiting until there is the easiest way out here... once it's included in an official release it should be a trivial oneliner to support it from our POV (just adding it to the CI config and off we go). So if that's like to happen soon, I might just end up until .NET 7 gets released later this year to minimize my own effort.

@Thefrank
Copy link

@perlun chance of FreeBSD being officially supported is low to none for net7. It still has test failures and would need a good amount of effort put forth by Microsoft to add FreeBSD VMs to their CI system.

The advantage the FreeBSD community has from it NOT being officially supported is that we can drop older versions of FreeBSD from support as they move EOL and add in features from newer versions much faster than an officially supported platform would be able to.

@perlun
Copy link
Collaborator Author

perlun commented May 14, 2022

@Thefrank Sorry for the late reply. Understand. 👍 I can also understand why this can be an advantage for you and others in the FreeBSD community.

From my POV, things might be a bit different. I am thinking about ease of applying new .NET releases (.NET 7, .NET 8, .NET 9 and so forth). For all our current platforms (linux-arm, linux-arm64, linux-x64, osx-arm64, osx-x64, win-x64), we can cross-build from GitHub Actions standard runners (ubuntu-latest), and always expect things to "just work". The amount of supporting these targets (and potentially others in the future like win-arm64) is really quite minimal, given that the heavy lifting is already taken care of by the .NET team (of which I am very thankful. 🙏)

I think this is perhaps also why I'm a bit hesitant to bring in FreeBSD at a too-early stage, when the platform isn't officially supported from upstream. I might be willing to let myself be persuaded if there was a contributor I could trust willing to say "I'll take care of ensuring that it always work, at all times". But given the early stage of the language itself (there is basically not a single person in the world developing programs with Perlang at the moment. 😂 I haven't even myself yet gone further than the point of writing Perlang code in the Perlang-based integration tests, except for a few extremely trivial Perlang-based program(s) which I'm using sparsely) we don't really have that kind of contributors in the project yet.

So... "Later" is probably the correct milestone for this for the time being. 🙂

@perlun
Copy link
Collaborator Author

perlun commented Oct 16, 2023

Some more on this topic: since our current effort is focusing on #406, I think this will be delayed a bit. Once we have the compiled mode (first via intermediate C++ compilation, then potentially via a full LLVM backend) in place, supporting FreeBSD should be doable and not much more of an effort than "any other platform", where LLVM is supported.

In other words, spending time on getting this working in our current .NET implementation is pretty much a waste, and getting it done in the #406 world is "too early" until #409 is merged. Once that is in place, supporting FreeBSD is still not easy because the Perlang interpreter/compiler still requires the .NET runtime to be able to run.

We don't have an issue for "making Perlang be self-hosted" AFAIK, but we're reasonably talking about "years" rather than "months" before this can happen. Give me $1,000,000 and a research team and things might change... 😛

@perlun
Copy link
Collaborator Author

perlun commented Apr 11, 2024

We don't have an issue for "making Perlang be self-hosted" AFAIK, but we're reasonably talking about "years" rather than "months" before this can happen. Give me $1,000,000 and a research team and things might change... 😛

I'm not yet a millionaire 😉 but here's at least the issue now: #454.

@perlun perlun closed this as completed Aug 20, 2024
@perlang-org perlang-org locked as resolved and limited conversation to collaborators Aug 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request platform support Support for new operating systems and/or architectures
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants