dotnet / source-build

A repository to track efforts to produce a source tarball of the .NET Core SDK and all its components
MIT License
265 stars 130 forks source link

Building the .NET Core SDK on FreeBSD #1139

Closed joperator closed 7 months ago

joperator commented 5 years ago

I'm trying to build the .NET Core SDK on FreeBSD but I'm having trouble with the documentation. The documentation says I just have to initialize the submodules in the source-build repo and run ./build.sh. But this produces only the following output:

Unsupported OS 'FreeBSD' detected. Downloading linux-x64 tools.
Installing dotnet cli...
Installing dotnet 3.0 preview1 cli...
Restoring BuildTools version 3.0.0-preview4-04104-01...

Later in the documentation it says that

git submodule update --init --recursive [...] will initialize the submodules and clone the repos under the src folder if they haven't been initialized.

But after running this command, my src folder contains only the subfolders netcorecli-fsc and reference-assemblies, which are not all required repos I think. As the documentation says, I expected at least core-setup, standard, corefx and coreclr to be cloned into the src folder. This would also explain why there is no bin folder in my source-build repo after running ./build.sh as described in the documentation. If the scripts don't work under FreeBSD, I expect at least an error, otherwise I assume that everything has been built, which is not the case here.

So, am I doing something wrong or is the documentation incorrect or out of date?

wfurt commented 5 years ago

even source-build needs working SDK and that is problematic since lost build servers. I was planning to revisit the effort but closing on 3.0 prevented me from spending any reasonable time on it.

Aside from that, more cleanup may be needed to deal with OS differences.

joperator commented 5 years ago

I've already tried to use the old (December 2018) but working .NET Core SDK for FreeBSD as bootstrap CLI as described here. But when running ./init-tools.sh it produces the same output as above and doesn't finish even after several hours.

I could spend some time trying to re-enable .NET Core for FreeBSD, but I need to know where to start because the current documentations don't help me much if they don't work. For example, it would be helpful to know why the build servers were lost and how the .NET Core SDK for FreeBSD that I mentioned was created at that time.

wfurt commented 5 years ago

That is something source-build gurus should comment on. Published SDK was built by bootstrapping each needed repo separately and by publishing and consuming intermediate packages. As more repos moved to Arcade, lot of the build process was in flux. I would not be surprised in documentation or code is out of sync.

crummel commented 5 years ago

We've changed our process so that repos are cloned as part of the build process to ./bin/src. This lets us piggyback off other .NET infrastructure to keep source-build up to date more easily. netcorecli-fsc and reference-assemblies are both fake repos that live in source-build, so it's expected you'll have those in ./src. Your error from ./build.sh looks like init-tools is failing - could you post your init-tools.log from the root of the repo?

joperator commented 5 years ago

Yes, init-tools is indeed failing. The first error was a problem with the SSL certificate while restoring NuGet packages. I could fix it by setting the SSL_CERT_FILE environment variable to /usr/local/share/certs/ca-root-nss.crt as described here. But now there seems to be another problem with the SSL connection: init-tools.log The SSL certificate from https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json exists in my ca-root-nss.crt file. So I'm surprised that NuGet package restore still seems to have problems establishing an SSL connection.

joperator commented 5 years ago

It looks like dotnet has problems with the linux-c7-openssl-libs package. I installed it on my FreeBSD machine to ensure full Linux binary compatibility, because the first time I ran ./build.sh I got No usable version of libssl was found.

After removing this package, reinstalling the default OpenSSL package for FreeBSD, and creating the required symbolic links, running ./init-tools.sh using the .NET Core SDK for FreeBSD as bootstrap CLI succeeded. I can now tell build.sh to use .NET Core SDK version 3.0.100-preview-010021 via editing DotnetCLIVersion.txt, but running it still fails: error.txt

crummel commented 5 years ago

Ah, that looks like Darc (the tool we use to clone the source) doesn't build for BSD. I wonder if we can build that portable, I will take a look. Otherwise this is probably a fix in dotnet/arcade-services.

joperator commented 5 years ago

I was able to build Darc on FreeBSD using target framework netcoreapp3.0 instead of netcoreapp2.1. Cloning the repos now seems to work, but building them still fails. I have run ./build.sh and received the following output: arcade-error.txt arcade-build.binlog.txt arcade.log

I also ran ./build.sh /p:RootRepo=core-setup and received the following output: core-setup-error.txt core-setup-build.binlog.txt linker.log

So in both cases I get the error Segmentation fault (core dumped). I also receive linux: pid 1234 (dotnet): syscall membarrier not implemented in the terminal, which is not logged into the files.

crummel commented 5 years ago

I've seen similar errors with missing syscalls on ARM. At this point it's probably less of a source-build problem and more getting into bootstrapping the actual SDK on BSD - there's a couple related issues: https://github.com/dotnet/core-setup/issues/5083, https://github.com/dotnet/core-sdk/issues/248, https://github.com/dotnet/source-build/issues/724.

joperator commented 5 years ago

Looks like it is a bootstrapping problem, but probably not as you expected @crummel: Although I specified to use the .NET Core SDK for FreeBSD as bootstrap CLI, the build scripts also downloaded the .NET Core SDK 3.0.100-preview5-011568 for Linux and placed it in the source-build/Tools/dotnetcli3 folder. After replacing the folder with source-build/Tools/dotnetcli, which contains the .NET Core SDK for FreeBSD, the build continues. Now it tries to build Microsoft.DotNet.Arcade.csproj, but fails with error CS1617: Invalid option 'preview' for /langversion. Use '/langversion:?' to list supported values.

joperator commented 5 years ago

Replacing <langversion>preview</langversion> with <langversion>latest</langversion> in Microsoft.DotNet.Arcade.csproj fixes the above error. It looks like I'm now able to build the main parts of the .NET Core SDK on FreeBSD. I only get the following two errors after the build succeeded:

'common' failed during build.
See '/root/git/dotnet/source-build/bin/logs/common.log' for more information.
'known-good' failed during build.

I've already taken a look at the common.log, but there's nothing there that indicates an error. So does anyone know what's common and known-good? Are they required for the .NET Core SDK? And where is the .NET Core SDK stored after the build is complete? Or do I have to copy and paste the parts manually? Any help would be appreciated. Thanks in advance.

omajid commented 5 years ago

AFAIK known-good is the set of components that need to be built to assemble .NET Core itself. Right now, it's roughly analogous to the all target in other projects' makefiles.

If everything (including the cli) built succefully, the result should be a bin/x64/Release/dotnet-sdk-*tar.gz file. That's the .NET Core SDK itself. For fedora that's pretty much all we need. We extract it to /usr/lib64/dotnet.

wfurt commented 5 years ago

That is great progress @joperator. Do you have any outstanding changes or just something you need to set? With 3.0 under control now, I should have some cycles again to give FreeBSD another try. Just to confirm: You use FreeBSD bootstrap cli, not Linux under emulation, right?

joperator commented 5 years ago

@omajid: Then it looks like I have to build known-good as well because my bin/x64/Release folder only contains an empty netcorecli-fsc directory.

@wfurt: There are outstanding changes as well as some things you need to set to successfully run build.sh on FreeBSD. But these changes are only limited to a few files, where some of them are already described above. I will soon provide a complete list of these necessary changes. I'm using FreeBSD bootstrap CLI to build the .NET projects. While running build.sh it downloaded and tried to use the .NET Core SDK for Linux. But that didn't work, as I described above.

wfurt commented 5 years ago

Very good @joperator. I'm hoping to get newer version of the SDK published (closer to 3.0 final content) but I could not build some components again. If you get build working it would help me with that effort.

As far as the Linux SDK: I made changes in several components to recognize FreeBSD properly. I was on Linux path for a while until I realized that is dead-end path. Even if the binaries work under emulation it still uses many files from /proc and that will not work on FreeBSD. Getting source build working is best long-term option for FreeBSD. I would still like to build components using published sdk to avoid regressions.

joperator commented 5 years ago

I agree with you @wfurt:

Getting source build working is best long-term option for FreeBSD.

Therefore, here is a complete list of the necessary settings and changes to build the source-build repo on FreeBSD. I have built it using the current master (Aug 2, 2019) of the source-build repo and a VM with FreeBSD 12.0-RELEASE amd64 on a Windows 10 host.

Install and configure required packages

Install git

pkg install git

Install libunwind

pkg install libunwind

Install and configure bash (Building-.NET-Core-3.x-on-FreeBSD)

pkg install bash
ln -s /usr/local/bin/bash /bin/bash

Install and configure OpenSSL (dotnet/coreclr#22124)

pkg install openssl
ln -s /usr/local/lib/libssl.so.9 /usr/local/lib/libssl.so.8
ln -s /usr/local/lib/libcrypto.so.9 /usr/local/lib/libcrypto.so.8

Clone the source-build repo

git clone https://github.com/dotnet/source-build.git ~/git/dotnet/source-build

Set your environment variables

Prevent the dotnet CLI from freezing with no output (dotnet/coreclr#22124)

setenv LD_PRELOAD /usr/lib/libpthread.so

Set the path of the bootstrap CLI (Use the bootstrap CLI to build source-build). I have used dotnet-sdk-latest-freebsd-x64.tar.gz as bootstrap CLI.

setenv DotNetBootstrapCliTarPath $(DotNetBootstrapCliTarDir)/dotnet.tar

Build the source-build repo

cd ~/git/dotnet/source-build

./init-tools.sh
  ...
  Initializing BuildTools...
  ...
  Done initializing BuildTools.
  Initializing Arcade...
  Done initializing Arcade.
  Done initializing tools.

./build.sh
  ...
  warning: submodules tools-local/arcade-services does not appear to be initialized.
  Should I initialize it for you? [Y]es / [n]o / [a]ll / [q]uit] y
  ...
  Tools are already initialized
  ...
  No executable found matching command "dotnet-/root/git/dotnet/source-build/Tools/dotnetcli/sdk/2.2.300/MSBuild.dll". See https://aka.ms/missing-command for more information.

Fix dotnet CLI version

ee DotnetCLIVersion.txt

Replace 2.2.300 with 3.0.100-preview-010021.

Replace the downloaded dotnet CLI for Linux with the bootstrap CLI for FreeBSD

rm -r Tools/dotnetcli3
cp -r Tools/dotnetcli Tools/dotnetcli3

./build.sh
  ...
  /root/git/dotnet/source-build/tools-local/init-build.proj(153,5): error MSB3073: The command "/root/git/dotnet/source-build/Tools/dotnetcli/dotnet build -c Release /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Microsoft.DotNet.Darc.csproj" exited with code 1.

Change target framework netcoreapp2.1 to netcoreapp3.0 and commit your changes

cd tools-local/arcade-services
ee src/Microsoft.DotNet.Darc/src/Darc/Microsoft.DotNet.Darc.csproj

Replace <TargetFramework>netcoreapp2.1</TargetFramework> with <TargetFramework>netcoreapp3.0</TargetFramework>.

git commit -a -m "Change target framework of 'Microsoft.DotNet.Darc.csproj' from 'netcoreapp2.1' to 'netcoreapp3.0'."
cd ../..
git add tools-local/arcade-services
git commit -m "Update submodule 'tools-local/arcade-services'."

./build.sh
  ...
  No executable found matching command "dotnet-/root/git/dotnet/source-build/tools-local/arcade-services/artifacts/bin/Microsoft.DotNet.Darc/Release/netcoreapp2.1/Microsoft.DotNet.Darc.dll". See https://aka.ms/missing-command for more information.
  /root/git/dotnet/source-build/tools-local/init-build.proj(180,5): error MSB3073: The command "/root/git/dotnet/source-build/Tools/dotnetcli/dotnet /root/git/dotnet/source-build/tools-local/arcade-services/artifacts/bin/Microsoft.DotNet.Darc/Release/netcoreapp2.1/Microsoft.DotNet.Darc.dll clone --repos-folder /root/git/dotnet/source-build/bin/src/ --git-dir-folder /root/git/dotnet/source-build/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/dnceng/internal/_git/dotnet-core-setup" --azdev-pat bogus --github-pat bogus --depth 0 --debug" exited with code 1.

Copy the binaries to the expected directory because we changed the target framework from netcoreapp2.1 to netcoreapp3.0

rm -r tools-local/arcade-services/artifacts/bin/Microsoft.DotNet.Darc/Release/netcoreapp2.1
cp -r tools-local/arcade-services/artifacts/bin/Microsoft.DotNet.Darc/Release/netcoreapp3.0 tools-local/arcade-services/artifacts/bin/Microsoft.DotNet.Darc/Release/netcoreapp2.1

./build.sh
  ...
          Something failed while cloning.
    System.Exception: Something went wrong when cloning repo https://github.com/dotnet/arcade at <default branch> into /root/git/dotnet/source-build/bin/src/arcade ---> System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-572e4d8' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Shared object "libgit2-572e4d8" not found, required by "dotnet"
       at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
       at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
       at LibGit2Sharp.Core.NativeMethods..cctor()
       --- End of inner exception stack trace ---
       at LibGit2Sharp.Core.NativeMethods.git_clone(git_repository*& repo, String origin_url, FilePath workdir_path, GitCloneOptions& opts)
       at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)
       at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)
       at Microsoft.DotNet.DarcLib.RemoteRepoBase.Clone(String repoUri, String commit, String targetDirectory, ILogger _logger, String pat, String gitDirectory) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/RemoteRepoBase.cs:line 176
       --- End of inner exception stack trace ---
       at Microsoft.DotNet.DarcLib.RemoteRepoBase.Clone(String repoUri, String commit, String targetDirectory, ILogger _logger, String pat, String gitDirectory) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/RemoteRepoBase.cs:line 210
       at Microsoft.DotNet.DarcLib.GitHubClient.Clone(String repoUri, String commit, String targetDirectory, String gitDirectory) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/GitHubClient.cs:line 875
       at Microsoft.DotNet.DarcLib.Remote.Clone(String repoUri, String commit, String targetDirectory, String gitDirectory) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/Actions/Remote.cs:line 983
       at Microsoft.DotNet.Darc.Operations.CloneOperation.HandleMasterCopyAndCreateGitDir(RemoteFactory remoteFactory, String repoUrl, String masterGitRepoPath, String masterRepoGitDirPath, String gitDirRedirect, ILogger log) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 284
       at Microsoft.DotNet.Darc.Operations.CloneOperation.HandleMasterCopyWithGitDirPath(RemoteFactory remoteFactory, String repoUrl, String masterGitRepoPath, String masterRepoGitDirPath, ILogger log) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 272
       at Microsoft.DotNet.Darc.Operations.CloneOperation.HandleMasterCopy(RemoteFactory remoteFactory, String repoUrl, String masterGitRepoPath, String masterRepoGitDirPath, ILogger log) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 225
       at Microsoft.DotNet.Darc.Operations.CloneOperation.ExecuteAsync() in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 102
  /root/git/dotnet/source-build/tools-local/init-build.proj(180,5): error MSB3073: The command "/root/git/dotnet/source-build/Tools/dotnetcli/dotnet /root/git/dotnet/source-build/tools-local/arcade-services/artifacts/bin/Microsoft.DotNet.Darc/Release/netcoreapp2.1/Microsoft.DotNet.Darc.dll clone --repos-folder /root/git/dotnet/source-build/bin/src/ --git-dir-folder /root/git/dotnet/source-build/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/dnceng/internal/_git/dotnet-core-setup" --azdev-pat bogus --github-pat bogus --depth 0 --debug" exited with code 42.

Install missing libraries for LibGit2Sharp

pkg install libgit2
ln -s /usr/local/lib/libgit2.so /usr/local/lib/libgit2-572e4d8.so

./build.sh
  ...
          Something failed while cloning.
    System.Exception: Something went wrong when cloning repo https://github.com/mono/linker.git at refs/heads/master into /root/git/dotnet/source-build/bin/src/linker ---> LibGit2Sharp.LibGit2SharpException: failed to connect to github.com: Operation timed out
       at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
       at LibGit2Sharp.Core.Proxy.git_submodule_update(SubmoduleHandle submodule, Boolean init, GitSubmoduleUpdateOptions& options)
       at LibGit2Sharp.SubmoduleCollection.Update(String name, SubmoduleUpdateOptions options)
       at Microsoft.DotNet.DarcLib.RemoteRepoBase.CheckoutSubmodules(Repository repo, CloneOptions submoduleCloneOptions, String gitDirParentPath, ILogger log) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/RemoteRepoBase.cs:line 222
       at Microsoft.DotNet.DarcLib.RemoteRepoBase.Clone(String repoUri, String commit, String targetDirectory, ILogger _logger, String pat, String gitDirectory) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/RemoteRepoBase.cs:line 205
       --- End of inner exception stack trace ---
       at Microsoft.DotNet.DarcLib.RemoteRepoBase.Clone(String repoUri, String commit, String targetDirectory, ILogger _logger, String pat, String gitDirectory) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/RemoteRepoBase.cs:line 210
       at Microsoft.DotNet.DarcLib.GitHubClient.Clone(String repoUri, String commit, String targetDirectory, String gitDirectory) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/GitHubClient.cs:line 875
       at Microsoft.DotNet.DarcLib.Remote.Clone(String repoUri, String commit, String targetDirectory, String gitDirectory) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/Actions/Remote.cs:line 983
       at Microsoft.DotNet.Darc.Operations.CloneOperation.HandleMasterCopyAndCreateGitDir(RemoteFactory remoteFactory, String repoUrl, String masterGitRepoPath, String masterRepoGitDirPath, String gitDirRedirect, ILogger log) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 284
       at Microsoft.DotNet.Darc.Operations.CloneOperation.HandleMasterCopyWithGitDirPath(RemoteFactory remoteFactory, String repoUrl, String masterGitRepoPath, String masterRepoGitDirPath, ILogger log) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 272
       at Microsoft.DotNet.Darc.Operations.CloneOperation.HandleMasterCopy(RemoteFactory remoteFactory, String repoUrl, String masterGitRepoPath, String masterRepoGitDirPath, ILogger log) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 225
       at Microsoft.DotNet.Darc.Operations.CloneOperation.ExecuteAsync() in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 102
  /root/git/dotnet/source-build/tools-local/init-build.proj(180,5): error MSB3073: The command "/root/git/dotnet/source-build/Tools/dotnetcli/dotnet /root/git/dotnet/source-build/tools-local/arcade-services/artifacts/bin/Microsoft.DotNet.Darc/Release/netcoreapp2.1/Microsoft.DotNet.Darc.dll clone --repos-folder /root/git/dotnet/source-build/bin/src/ --git-dir-folder /root/git/dotnet/source-build/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/dnceng/internal/_git/dotnet-core-setup" --azdev-pat bogus --github-pat bogus --depth 0 --debug" exited with code 42.

./build.sh
  ...
          Something failed while cloning.
    System.Exception: Something went wrong when checking out $(GitCommitHash) in /root/git/dotnet/source-build/bin/src/linker.$(GitCommitHash) ---> System.InvalidOperationException: Sequence contains no matching element
       at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
       at Microsoft.DotNet.DarcLib.LocalGitClient.CleanRepoAndSubmodules(Repository repo, ILogger log) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/LocalGitClient.cs:line 427
       at Microsoft.DotNet.DarcLib.LocalGitClient.Checkout(String repoDir, String commit, Boolean force) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/LocalGitClient.cs:line 308
       --- End of inner exception stack trace ---
       at Microsoft.DotNet.DarcLib.LocalGitClient.Checkout(String repoDir, String commit, Boolean force) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/LocalGitClient.cs:line 347
       at Microsoft.DotNet.DarcLib.Local.Checkout(String commit, Boolean force) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/Actions/Local.cs:line 144
       at Microsoft.DotNet.Darc.Operations.CloneOperation.HandleRepoAtSpecificHash(String repoPath, String commit, String masterRepoGitDirPath, ILogger log) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 218
       at Microsoft.DotNet.Darc.Operations.CloneOperation.ExecuteAsync() in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/Darc/Operations/CloneOperation.cs:line 106
  /root/git/dotnet/source-build/tools-local/init-build.proj(180,5): error MSB3073: The command "/root/git/dotnet/source-build/Tools/dotnetcli/dotnet /root/git/dotnet/source-build/tools-local/arcade-services/artifacts/bin/Microsoft.DotNet.Darc/Release/netcoreapp2.1/Microsoft.DotNet.Darc.dll clone --repos-folder /root/git/dotnet/source-build/bin/src/ --git-dir-folder /root/git/dotnet/source-build/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/dnceng/internal/_git/dotnet-core-setup" --azdev-pat bogus --github-pat bogus --depth 0 --debug" exited with code 42.

Clone jbevain/cecil to the expected directory

rm -r bin/src/linker.$(GitCommitHash)/external/cecil
git clone https://github.com/jbevain/cecil.git bin/src/linker.$(GitCommitHash)/external/cecil

./build.sh
  ...
  /root/git/dotnet/source-build/repos/dir.targets(281,5): error MSB3073: The command "/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/build.sh  --pack --configuration Release --binaryLog  /p:DotNetPackageVersionPropsPath=/root/git/dotnet/source-build/bin/obj/x64/Release/PackageVersions.props /p:DotNetRestoreSourcePropsPath=/root/git/dotnet/source-build/bin/obj/x64/Release/RestoreSources.props >> /root/git/dotnet/source-build/bin/logs/sourcelink.log 2>&1" exited with code 145. [/root/git/dotnet/source-build/repos/sourcelink.proj]
    Found dotnet SDK, but did not find dotnet.dll at [/root/git/dotnet/source-build/Tools/dotnetcli3/sdk/3.0.100-preview6-012264/dotnet.dll]
    Build failed (exit code '145').

    'sourcelink' failed during build.
    See '/root/git/dotnet/source-build/bin/logs/sourcelink.log' for more information.
    'known-good' failed during build.

Copy the dotnet SDK to the expected directory because we replaced the dotnet CLI for Linux with the bootstrap CLI for FreeBSD

cp -r Tools/dotnetcli3/sdk/3.0.100-preview-010021/* Tools/dotnetcli3/sdk/3.0.100-preview6-012264

./build.sh
  ...
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.GitHub/Microsoft.SourceLink.GitHub.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Common/Microsoft.SourceLink.Common.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Vsts.Git/Microsoft.SourceLink.Vsts.Git.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/Microsoft.Build.Tasks.Git/Microsoft.Build.Tasks.Git.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.GitHub/Microsoft.SourceLink.GitHub.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Common/Microsoft.SourceLink.Common.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/Microsoft.Build.Tasks.Git/Microsoft.Build.Tasks.Git.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Vsts.Git/Microsoft.SourceLink.Vsts.Git.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Vsts.Tfvc/Microsoft.SourceLink.Vsts.Tfvc.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.GitLab/Microsoft.SourceLink.GitLab.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Vsts.Tfvc/Microsoft.SourceLink.Vsts.Tfvc.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Bitbucket.Git/Microsoft.SourceLink.Bitbucket.Git.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.GitLab/Microsoft.SourceLink.GitLab.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Tfs.Git/Microsoft.SourceLink.Tfs.Git.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Bitbucket.Git/Microsoft.SourceLink.Bitbucket.Git.csproj]
    CSC : error CS1617: Invalid option 'Preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/sourcelink.$(GitCommitHash)/src/SourceLink.Tfs.Git/Microsoft.SourceLink.Tfs.Git.csproj]
        0 Warning(s)
        16 Error(s)

    Time Elapsed 00:00:14.68
    Build failed (exit code '1').

    'sourcelink' failed during build.
    See '/root/git/dotnet/source-build/bin/logs/sourcelink.log' for more information.
    'known-good' failed during build.

Replace language version Preview with 8.0

ee bin/src/sourcelink.$(GitCommitHash)/src/Directory.Build.props

Replace <LangVersion>Preview</LangVersion> with <LangVersion>8.0</LangVersion>.

Remove modifier readonly from properties because it is not valid for these items

ee bin/src/sourcelink.$(GitCommitHash)/src/Microsoft.Build.Tasks.Git/GitDataReader/GitRepositoryLocation.cs

Remove modifier readonly from properties.

./build.sh
  ...
    CSC : error CS1617: Invalid option 'preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/src/Microsoft.DotNet.Arcade.Sdk/Microsoft.DotNet.Arcade.Sdk.csproj]
      Microsoft.DotNet.SignTool -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.SignTool/Release/netcoreapp2.0/Microsoft.DotNet.SignTool.dll
      Microsoft.DotNet.Deployment.Tasks.Links -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.Deployment.Tasks.Links/Release/net472/Microsoft.DotNet.Deployment.Tasks.Links.dll
      Microsoft.DotNet.Deployment.Tasks.Links -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.Deployment.Tasks.Links/Release/netcoreapp2.0/Microsoft.DotNet.Deployment.Tasks.Links.dll
      Microsoft.DotNet.GenFacades -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.GenFacades/Release/net472/Microsoft.DotNet.GenFacades.dll
    CSC : error CS1617: Invalid option 'preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/src/Microsoft.DotNet.Arcade.Sdk/Microsoft.DotNet.Arcade.Sdk.csproj]
      Microsoft.DotNet.GenFacades -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.GenFacades/Release/netcoreapp2.1/Microsoft.DotNet.GenFacades.dll
      Microsoft.DotNet.CoreFxTesting -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.CoreFxTesting/Release/netcoreapp2.1/Microsoft.DotNet.CoreFxTesting.dll
      Microsoft.DotNet.CoreFxTesting -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.CoreFxTesting/Release/net472/Microsoft.DotNet.CoreFxTesting.dll
      Microsoft.DotNet.Build.Tasks.Packaging -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.Build.Tasks.Packaging/Release/net472/Microsoft.DotNet.Build.Tasks.Packaging.dll
      Microsoft.DotNet.Build.Tasks.Packaging -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.Build.Tasks.Packaging/Release/netcoreapp2.1/Microsoft.DotNet.Build.Tasks.Packaging.dll
      Microsoft.DotNet.Build.Tasks.Configuration -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.Build.Tasks.Configuration/Release/netcoreapp2.1/Microsoft.DotNet.Build.Tasks.Configuration.dll
      Microsoft.DotNet.Build.Tasks.Configuration -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.Build.Tasks.Configuration/Release/net472/Microsoft.DotNet.Build.Tasks.Configuration.dll
      Microsoft.DotNet.CodeAnalysis -> /root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/artifacts/bin/Microsoft.DotNet.CodeAnalysis/Release/netstandard2.0/Microsoft.DotNet.CodeAnalysis.dll

    Build FAILED.

    CSC : error CS1617: Invalid option 'preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/src/Microsoft.DotNet.Arcade.Sdk/Microsoft.DotNet.Arcade.Sdk.csproj]
    CSC : error CS1617: Invalid option 'preview' for /langversion. Use '/langversion:?' to list supported values. [/root/git/dotnet/source-build/bin/src/arcade.$(GitCommitHash)/src/Microsoft.DotNet.Arcade.Sdk/Microsoft.DotNet.Arcade.Sdk.csproj]
        0 Warning(s)
        2 Error(s)

    Time Elapsed 00:00:24.02
    Build failed (exit code '1').

    'arcade' failed during build.
    See '/root/git/dotnet/source-build/bin/logs/arcade.log' for more information.
    'known-good' failed during build.

Replace language version preview with latest

ee bin/src/arcade.$(GitCommitHash)/src/Microsoft.DotNet.Arcade.Sdk/Microsoft.DotNet.Arcade.Sdk.csproj

Replace <LangVersion>preview</LangVersion> with <LangVersion>latest</LangVersion>.

Fix false positives

If you get messages like

/root/git/dotnet/source-build/repos/dir.targets(378,5): error : $(Repo) produced no new source-built package identities. Known possible causes: [/root/git/dotnet/source-build/repos/$(Repo).proj]
/root/git/dotnet/source-build/repos/dir.targets(378,5): error : ^ There may have been a silent failure in the submodule build. To confirm, check the build log file for undetected errors that may have prevented package creation: /root/git/dotnet/source-build/bin/logs/$(Repo).log [/root/git/dotnet/source-build/repos/$(Repo).proj]
/root/git/dotnet/source-build/repos/dir.targets(378,5): error : ^ This error might be a false positive if $(Repo) intentionally builds no nuget packages. If so, set the SkipEnsurePackagesCreated property to true in /root/git/dotnet/source-build/repos/$(Repo).proj [/root/git/dotnet/source-build/repos/$(Repo).proj]
/root/git/dotnet/source-build/repos/dir.targets(378,5): error : ^ The 'bin' directory might be dirty from a previous build and the package files already existed. If so, perform a clean build, or check which packages were already in 'bin' by opening /root/git/dotnet/source-build/bin/obj/x64/Release/PackageVersions.props.pre.$(Repo).xml [/root/git/dotnet/source-build/repos/$(Repo).proj]
/root/git/dotnet/source-build/repos/dir.targets(378,5): error : ^ The packages may have been written to an unexpected directory. For example, some repos used bin/ and changed to artifacts/ to match Arcade. Check PackagesOutput in /root/git/dotnet/source-build/repos/$(Repo).proj (currently '/root/git/dotnet/source-build/bin/src/$(Repo).$(GitCommitHash)/artifacts/packages/Release/NonShipping/') [/root/git/dotnet/source-build/repos/$(Repo).proj]

then make sure that there has not been a silent failure in the submodule builds, set the SkipEnsurePackagesCreated property as described and run ./build.sh again.

Fix missing app host freebsd-x64

If you get a message like

/root/git/dotnet/source-build/Tools/dotnetcli/sdk/3.0.100-preview-010021/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(220,5): error NETSDK1065: Cannot find app host for freebsd-x64. freebsd-x64 could be an invalid runtime identifier (RID). For more information about RID, see https://aka.ms/rid-catalog.

then just run ./build.sh again and the error will suddenly disappear.

Build completed successfully

After the build completed you should see the following output:

Executing: dotnet pack
  Successfully created package '/root/git/dotnet/source-build/bin/src/common.$(GitCommitHash)/artifacts/build/Microsoft.Extensions.CommandLineUtils.1.0.1.nupkg'.
Skipping tests because -NoTest was specified

Done

'common' failed during build.
See 'root/git/dotnet/source-build/bin/logs/common.log' for more information.
'known-good' failed during build.

A look at bin/logs/common.log indicates that common does not fail during build. If known-good is necessary to assemble the .NET Core SDK itself as described above, it looks like it really fails during build, because my bin/x64/Release folder only contains an empty netcorecli-fsc directory. It would be great if someone could figure out why known-good fails during build, because there is neither an error in the terminal nor a log file.

crummel commented 5 years ago

Known-good will fail if anything before it does, so that's probably what's happening. Could I get your whole bin/logs directory? And any *.binlog files under the repo root would be helpful, they get scattered in the individual bin/src directories.

joperator commented 5 years ago

Yes, of course. Here are the logs from the bin/logs directory: logs.zip

I had to split the *.binlog files into several zip archives so that each of them is smaller than the 10MB upload limit. The attached *.binlog files were located in these directories:

~/git/dotnet/source-build/src/netcorecli-fsc/msbuild.binlog
~/git/dotnet/source-build/build.binlog
~/git/dotnet/source-build/bin/src/arcade.8f3c22397990aeb20a88690b51dad4b33f21e7ff/artifacts/log/Release/ToolsetRestore.binlog
~/git/dotnet/source-build/bin/src/arcade.8f3c22397990aeb20a88690b51dad4b33f21e7ff/artifacts/log/Release/Build.binlog
~/git/dotnet/source-build/bin/src/sourcelink.51310e65e75010467993f793e1739d1a1dad50c5/artifacts/log/Release/ToolsetRestore.binlog
~/git/dotnet/source-build/bin/src/sourcelink.51310e65e75010467993f793e1739d1a1dad50c5/artifacts/log/Release/Build.binlog
~/git/dotnet/source-build/bin/src/xdt.c01a538851a8ab1a1fbeb2e6243f391fff7587b4/artifacts/log/Release/Build.binlog
~/git/dotnet/source-build/bin/src/standard.a9422da6ed91b413019ef93051613c5f03801d64/artifacts/log/Release/Build.binlog
~/git/dotnet/source-build/bin/src/roslyn.c91adff42c488aef2c2c532a7b053fb55e0c16ea/SourceBuild.binlog
~/git/dotnet/source-build/bin/src/roslyn.c91adff42c488aef2c2c532a7b053fb55e0c16ea/Microsoft.NETCore.Compilers.Package.binlog
~/git/dotnet/source-build/bin/src/cliCommandLineParser.0e89c2116ad28e404ba56c14d1c3f938caa25a01/artifacts/log/Release/Build.binlog
~/git/dotnet/source-build/bin/src/ApplicationInsights-dotnet.53b80940842204f78708a538628288ff5d741a1d/restore.binlog
~/git/dotnet/source-build/bin/src/ApplicationInsights-dotnet.53b80940842204f78708a538628288ff5d741a1d/build.binlog
~/git/dotnet/source-build/bin/src/ApplicationInsights-dotnet.53b80940842204f78708a538628288ff5d741a1d/pack.binlog
~/git/dotnet/source-build/bin/src/xliff-tasks.173ee3bd61c9549557eefa3cfb718bdef157cb87/msbuild.binlog
~/git/dotnet/source-build/bin/src/Newtonsoft.Json.cac0690ad133c5e166ce5642dc71175791404fad/restore.binlog
~/git/dotnet/source-build/bin/src/Newtonsoft.Json.cac0690ad133c5e166ce5642dc71175791404fad/build.binlog
~/git/dotnet/source-build/bin/src/Newtonsoft.Json.cac0690ad133c5e166ce5642dc71175791404fad/pack.binlog

And here are the attached *.binlog files: netcorecli-fsc.zip source-build.zip arcade.8f3c22397990aeb20a88690b51dad4b33f21e7ff.zip sourcelink.51310e65e75010467993f793e1739d1a1dad50c5.zip xdt.c01a538851a8ab1a1fbeb2e6243f391fff7587b4.zip standard.a9422da6ed91b413019ef93051613c5f03801d64.zip roslyn.c91adff42c488aef2c2c532a7b053fb55e0c16ea.zip cliCommandLineParser.0e89c2116ad28e404ba56c14d1c3f938caa25a01.zip ApplicationInsights-dotnet.53b80940842204f78708a538628288ff5d741a1d.zip xliff-tasks.173ee3bd61c9549557eefa3cfb718bdef157cb87.zip Newtonsoft.Json.cac0690ad133c5e166ce5642dc71175791404fad.zip

crummel commented 5 years ago

It looks like Roslyn is failing, possibly silently if you're not seeing it: error NETSDK1065: Cannot find app host for freebsd-x64. freebsd-x64 could be an invalid runtime identifier (RID). We don't have a declared dependency from common on Roslyn, so I'm not sure why that's coming up as the source repo, but I think it might have to do with rebuilding - incremental builds don't work very well for us right now (which is also why you're getting the no packages produced false positives), so we recommend doing a git clean -fxd between builds. I'm not sure if the RID error means we need to patch it in somewhere or if we're not picking up the BSD runtime correctly - any ideas @wfurt?

wfurt commented 5 years ago

We did not build Roslyn in official builds as that is same on all platforms and comes in from NuGet package. We will probably need to submit fixes there to recognize FreeBSD as platform.

BTW is there option @crummel to build just runtime instead of whole SDK? I know we want SDK eventually but getting at least runtime would be good milestone.

joperator commented 5 years ago

I can build SourceBuild.sln from the dotnet/roslyn repo after applying the following patches:

./build.sh from dotnet/source-build tries to build the Roslyn projects the same way, but as you've already mentioned @crummel, the incremental builds don't work very well and don't allow me to build the patched Roslyn projects, because after ./build.sh has cloned and failed to build the dotnet/roslyn repo, it won't try to rebuild the repo again when running ./build.sh the next time. The easiest way to fix building the Roslyn projects on FreeBSD, would be to send the above patches to dotnet/roslyn, I think.

wfurt commented 5 years ago

that would make sense. Why don't you create PR @joperator and mention me as well. Master branches should be now open for 5.0 work.

crummel commented 5 years ago

BTW is there option @crummel Chris Rummel FTE to build just runtime instead of whole SDK?

We can add /p:RootRepo=core-setup to the ./build.sh command, but this will still build Roslyn because the CoreFX build requires a more recent C# compiler than is in the preview6 SDK, as well as to support coherency.

crummel commented 5 years ago

after ./build.sh has cloned and failed to build the dotnet/roslyn repo, it won't try to rebuild the repo again when running ./build.sh the next time.

Yeah, our process here isn't great and it's why we're working to drive down the number of patches. Currently I go into the bin/src/<repo> directory (not bin/src/<repo>.<hash> as it's not an actual git directory), git am ../../../patches/<repo>/*, make my new change and commit it, git format-patch -o ../../../patches/<repo> <hash>, then git add the new patch, clean, and build.

joperator commented 5 years ago

It's more complicated than I thought @wfurt: Creating a PR with the above patches for the dotnet/roslyn repo would probably fix the FreeBSD build, but it would break the build for Windows and other platforms. The problem is that targeting netcoreapp2.1 and netcoreapp3.0 side-by-side is not possible everywhere in the project. So I would have to replace netcoreapp2.1 with netcoreapp3.0 in the whole project, which is a big change instead of a small patch. But I think it's going to be changed to netcoreapp3.0 in the future anyway. So maybe I can speed up this process a little bit...

wfurt commented 5 years ago

That make sense. I bump to something similar while back with coreclr. I can ask around what the plan is. As 3.0 is almost done, I would expect we would use it for building at some point.

daydrim commented 5 years ago

Hello!

I can get init-tools.sh work on FreeBSD 12 p9 Azure with DotNet3CLIVersion 3.0.100-preview7-012821 and BuildTools 3.0.0-preview7-27912-14 Additionally use the instructions above.

kldload linux.ko
kldload linux64
daydrim commented 5 years ago

Hello! I can get init-tools.sh work on FreeBSD 12 p9 Azure with DotNet3CLIVersion 3.0.100-preview7-012821 and BuildTools 3.0.0-preview4-04212-02 Additionally use the instructions above. kldload linux.ko kldload linux64

I've stuck on step

Install missing libraries for LibGit2Sharp

pkg install libgit2

/root/dot-net/source-build/packages/microsoft.dotnet.arcade.sdk/1.0.0-dev.18424.13/tools/Build.proj(63,5): error : Property 'Projects' must be specified

  Build FAILED.

  /root/dot-net/source-build/packages/microsoft.dotnet.arcade.sdk/1.0.0-dev.18424.13/tools/Build.proj(63,5): error : Property 'Projects' must be specified
      0 Warning(s)
      1 Error(s)

  Time Elapsed 00:00:00.57
  Build failed (exit code '1').

  'arcade' failed during build.
  See '/root/dot-net/source-build/bin/logs/arcade.log' for more information.
  'known-good' failed during build.
wfurt commented 5 years ago

running Linux runtime under emulation may work for simple app but I think it is dead end. It is not only about binaries but also some managed code is built from different sources. For example process management depends and some other functions do depend on Linux proc and that is incomplete under emulation.

Also note, that you cannot load FreeBSD libraries to Linux process. Using libgit2 from ports will not work wIth Linux SDK. You would need to get copy from Linux.

After all the long threads I'm wondering if we need to assemble new bootstrap cli. We may be able to keep runtime as it but drop new skd on top of it.

daydrim commented 5 years ago

Hello. Yeap. I've recreated FreeBSD 12.0 Azure VM linux compat is not enabled Using the FreeBSD-latest.tar.gz

So the process stuck on libgit2 with different error:

pkg install libgit2
ln -s /usr/local/lib/libgit2.so /usr/local/lib/libgit2-572e4d8.so

./build.sh
 fail: Microsoft.DotNet.Darc.Operations.Operation[0]
        Something failed while cloning.
  System.Exception: Something went wrong when cloning repo https://github.com/dotnet/arcade at <default branch> into /root/git/dotnet/source-build/bin/src/arcade ---> System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
at LibGit2Sharp.Core.Platform.get_OperatingSystem()
     at LibGit2Sharp.Core.NativeMethods..cctor()
     --- End of inner exception stack trace ---
     at LibGit2Sharp.Core.NativeMethods.git_clone(git_repository*& repo, String origin_url, FilePath workdir_path, GitCloneOptions& opts)
     at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)
     at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)
     at Microsoft.DotNet.DarcLib.RemoteRepoBase.Clone(String repoUri, String commit, String targetDirectory, ILogger _logger, String pat, String gitDirectory) in /root/git/dotnet/source-build/tools-local/arcade-services/src/Microsoft.DotNet.Darc/src/DarcLib/RemoteRepoBase.cs:line 176
     --- End of inner exception stack trace ---

I guess it would be ideal if we can just switch between Core 2 and Core 3 build.sh . As for now we are trying to build Dotnet 2.1 project with 3.0 environment

joperator commented 5 years ago

I guess it would be ideal if we can just switch between Core 2 and Core 3 build.sh.

Yeah, that would be great. But since this is not possible, you have to manually adjust the target framework in the project file. I may have encountered a similar error as you described @daydrim when experimenting with Linux compatibility on FreeBSD. But as @wfurt has already described, this was a dead end for me, too. However, what I noticed when installing and uninstalling various Linux compatibility packages on FreeBSD was that LibGit2Sharp also failed with different exceptions. Since the NativeMethods constructor seems to be very error-prone on FreeBSD, it would be a good idea if you could run the build process again on a fresh VM and only perform the steps I described above.

daydrim commented 5 years ago

Today it starts to fail on init-tools.sh I've redeploy FreeBSD 12.0 re-git and re-download dotnet-sdk-latest-freebsd.tar.gz Do we have an URL to concrete version of dotnet.tar instead of master ? Or we need new versions of BuildTools and Dotnet3CLIVersion How can we synchronize versions for builds ? If we can choose versions we can do different tests

Is this the instruction to build new dotnet.tar for bootstrap CLI ? https://github.com/dotnet/corefx/wiki/Building-.NET-Core--2.x-on-FreeBSD#building-freebsd-sdk

I agree with @wfurt that we we need to assemble new bootstrap cli

./init-tools.sh
Unsupported OS 'FreeBSD' detected. Downloading linux-x64 tools.
Installing dotnet cli...
Installing dotnet 3.0 preview1 cli...
Restoring BuildTools version 3.0.0-preview4-04104-01...
FailFast:
Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.

   at System.Environment.FailFast(System.String)
   at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
   at System.Globalization.GlobalizationMode..cctor()
   at System.Globalization.CultureData.CreateCultureWithInvariantData()
   at System.Globalization.CultureData.get_Invariant()
   at System.Globalization.CultureData.GetCultureData(System.String, Boolean)
   at System.Globalization.CultureInfo.InitializeFromName(System.String, Boolean)
   at System.Reflection.RuntimeAssembly.GetLocale()
   at System.Reflection.RuntimeAssembly.GetName(Boolean)
   at System.Diagnostics.Tracing.EventPipeController.GetAppName()
   at System.Diagnostics.Tracing.EventPipeController..ctor()
   at System.Diagnostics.Tracing.EventPipeController.Initialize()
   at System.StartupHookProvider.ProcessStartupHooks()
./init-tools.sh: line 200:  1709 Abort trap              (core dumped) "$__DOTNET_CMD" restore "$__INIT_TOOLS_RESTORE_PROJECT" --no-cache --packages "$__PACKAGES_DIR" --source "$__BUILDTOOLS_SOURCE" /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION /p:ToolsDir="$__TOOLRUNTIME_DIR" >> "$__init_tools_log"
ERROR: Could not restore build tools correctly.
Please check the detailed log that follows.
R
...
Using RID linux-x64 for BuildTools native tools
Initializing BuildTools...

./init-tools.sh: line 221: /root/git/dotnet/source-build/packages/microsoft.dotnet.buildtools/3.0.0-preview4-04104-01/lib/init-tools.sh: No such file or directory
ERROR: An error occurred when trying to initialize the tools.
joperator commented 5 years ago

Do we have an URL to concrete version of dotnet.tar instead of master?

The link that you posted is actually a concrete version of dotnet.tar. It's called master and latest but it hasn't changed since December 2018.

Is this the instruction to build new dotnet.tar for bootstrap CLI?

It's a part of the instructions. A starting point could be Build .NET Core from source. But most of the instructions (especially for FreeBSD and NetBSD) are out of date, I think.

wfurt commented 5 years ago

there is also https://github.com/dotnet/corefx/wiki/Building-.NET-Core--2.x-on-FreeBSD and https://github.com/dotnet/corefx/wiki/Building-.NET-Core-3.x-on-FreeBSD

Second ~6 month old. But even that is too old and out of sync as build changed a lot recently.

If there is interest we can probably come up with new instructions for 5.0 e.g. current master

daydrim commented 5 years ago

A starting point could be Build .NET Core from source. But most of the instructions (especially for FreeBSD and NetBSD) are out of date, I think.

Thanks! So @joperator @wfurt - what do you think? do we need new dotnet.tar for new test and experiments ? I guess that preview 7 far more stable than previous versions of .net core 3 preview. And the target patform is FreeBSD 12.0 for us.

joperator commented 5 years ago

So just to clarify @daydrim: You want to create a new .NET Core 3.0 SDK for FreeBSD with the current .NET Core 3.0 SDK preview 7 (for Linux) as bootstrap CLI?

daydrim commented 5 years ago

You want to create a new .NET Core 3.0 SDK for FreeBSD with the current .NET Core 3.0 SDK preview 7 (for Linux) as bootstrap CLI?

Exactly . If it helps. @wfurt, @joperator, @crummel What's your opinion?

this instrunction https://github.com/dotnet/corefx/wiki/Building-.NET-Core--2.x-on-FreeBSD is based on Linux_compat - so it's outdated. this instruction https://github.com/dotnet/corefx/wiki/Building-.NET-Core-3.x-on-FreeBSD - has the the link to dotnet.tar based on Linux_compat. And @joperator has more detailed instructions )))

@wfurt just to clarify: do you recommend switch from 3.0 to 5.0 ? Because there are more chances to make Native Build ? If so for 5.0 we need different thread ))

joperator commented 5 years ago

I don't know if this is possible @daydrim. I already accidentally tried to run ./build.sh with the .NET Core 3.0 SDK preview 6 for Linux as bootstrap CLI because the scripts decided to download and use that version instead of the .NET Core SDK for FreeBSD, which I specified as you can see above. The results were segmentation faults and core dumps even when running under Linux emulation, because as @wfurt pointed out:

I was on Linux path for a while until I realized that is dead-end path. Even if the binaries work under emulation it still uses many files from /proc and that will not work on FreeBSD.

So attempting to create a new .NET Core SDK for FreeBSD using the .NET Core SDK for Linux under emulation might be a solution - but I'm skeptical if it will work.

daydrim commented 5 years ago

So attempting to create a new .NET Core SDK for FreeBSD using the .NET Core SDK for Linux under emulation might be a solution - but I'm skeptical if it will work.

As far as I understand there is no need to enable linux emulation? or is this only in TBD? https://github.com/dotnet/coreclr/blob/master/Documentation/building/freebsd-instructions.md

joperator commented 5 years ago

You don't need to enable Linux emulation to build the native components of the dotnet/coreclr repo, because you don't need a bootstrap CLI for that. But there are also managed components spread across several repos that need to be built using a bootstrap CLI. See Adding support for a new OS for more information.

daydrim commented 5 years ago

default version of coreclr in GitHub

~/git/coreclr # ./build.sh
Commencing CoreCLR Repo build
__DistroRid: freebsd.12-x64
__RuntimeId: freebsd.12-x64
Setting up directories for build
Checking prerequisites...
dotnet_install: Error: Could not find/download: `.NET Core SDK` with version = 3.0.100-preview6-012264
dotnet_install: Error: Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support
Failed to install dotnet SDK (exit code '1').
Failed to get PGO data package version.

I've changed the version in gloval.json But the result is the same

 # ./build.sh
Commencing CoreCLR Repo build
__DistroRid: freebsd.12-x64
__RuntimeId: freebsd.12-x64
Setting up directories for build
Checking prerequisites...
dotnet_install: Error: Could not find/download: `.NET Core SDK` with version = 3.0.100-preview7-012821
dotnet_install: Error: Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support
Failed to install dotnet SDK (exit code '1').
Failed to get PGO data package version.

This is the first part of https://github.com/dotnet/coreclr/blob/master/Documentation/building/freebsd-instructions.md

Build the Runtime To build the runtime on FreeBSD, run build.sh from the root of the coreclr repository: janhenke@freebsd-frankfurt:~/git/coreclr % ./build.sh

But as far as I understand it depends on the native part ? https://github.com/dotnet/coreclr/blob/master/Documentation/building/freebsd-instructions.md#build-the-framework-native-components

Native part builds without problems.

 # ./build-native.sh
Setting up directories for build
Checking pre-requisites...
Commencing build of corefx native components for FreeBSD.x64.Debug
Invoking "/root/git/corefx/src/Native/Unix/gen-buildsys-clang.sh" "/root/git/corefx/src/Native/Unix" "3" "9" "x64" "DEBUG" " -DFEATURE_DISTRO_AGNOSTIC_SSL=0 -DCMAKE_STATIC_LIB_LINK=0"
-- Configuring done
-- Generating done
-- Build files have been written to: /root/git/corefx/artifacts/obj/native/FreeBSD-x64-Debug
Executing make install -j 1
[ 17%] Built target System.IO.Compression.Native-Static
…
[100%] Built target System.Security.Cryptography.Native.OpenSsl
Install the project...
-- Install configuration: "DEBUG"
-- Installing: /root/git/corefx/src/Native/../../artifacts/bin/native/FreeBSD-x64-Debug/./System.IO.Compression.Native.so
…
-- Installing: /root/git/corefx/src/Native/../../artifacts/bin/native/FreeBSD-x64-Debug/./System.Security.Cryptography.Native.OpenSsl.a
#:~/git/corefx/src/Native # 

So what should we do next ? And how to resolve: dotnet_install: Error: Could not find/download:.NET Core SDKwith version = 3.0.100-preview7-012821 as described and then build Managed part?

https://github.com/dotnet/coreclr/blob/master/Documentation/building/freebsd-instructions.md#build-the-framework-managed-components

And how to build the first part (Runtime) ?

joperator commented 5 years ago

These are the same problems I ran into a few weeks ago until I found the dotnet/source-build repo, from which I hope it will be able to build all the necessary components to create a new .NET Core SDK for FreeBSD by simply specifying an existing bootstrap CLI. But as you can see, it's not that easy.

daydrim commented 5 years ago

Probably @wfurt or @crummel can help us with new Bootstrap CLI instructions. Because it sems like there is a problem with downloading 3.0.100-preview6 and 7 SDK.

joperator commented 5 years ago

I think the problem with downloading .NET Core 3.0 SDK preview 6 and 7 on FreeBSD is the RID freebsd-x64. The download link, which you should see in the build log, contains this RID:

Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/3.0.100-preview7-012821/dotnet-sdk-3.0.100-preview7-012821-freebsd-x64.tar.gz

This download fails because the file does not exist. Valid download links are https://dotnetcli.azureedge.net/dotnet/Sdk/3.0.100-preview7-012821/dotnet-sdk-3.0.100-preview7-012821-linux-x64.tar.gz for the current preview of the .NET Core SDK for Linux and https://dotnetcli.azureedge.net/dotnet/Sdk/3.0.100-preview-010021/dotnet-sdk-3.0.100-preview-010021-freebsd-x64.tar.gz for the old preview of the .NET Core SDK for FreeBSD.

wfurt commented 5 years ago

Sorry for the late response. I had to squash few more 3.0 issues but now back to fun:

I think the bootstrap is certainly part of the problem. I made updates to bring it more recent and I can build coreclr and corefx again. As we lost build servers (long story) it is unlikely that any new version will come out any time soon.

My original suggestion to focus on master branch was because it is very unlikely we will get approval for any changes for 3.0.

However, with https://github.com/dotnet/announcements/issues/119 .net build as we know now will burn in flames. It will ultimately make it easier to build, but 5.0 changes will also bring lot of instability and changes.

I don't know what the motivation is @joperator and @daydrim but perhaps we could/should focus on recreating 3.x releases for FreeBSD. If source-build can take changes and patches, that can be viable path and it can provide some value. Maintaining patches instead of making code changes is tedious but hopefully release/3.0 branches will be pretty stable at this point.

If you agree, please let me know.

I'm in process of updating https://github.com/dotnet/corefx/wiki/Building-.NET-Core-3.x-on-FreeBSD to reflect current status as well as instructions how to update bootstrap cli.

I did not try source-build yet. I want to make sure important repos do build before trying to build everything together.

wfurt commented 5 years ago

As far as the core-setup @crummel: do you know what SDK version we would need to avoid building Roslyn? Updating that in bootstrap cli would be easy but I did bump to some issues as there are some JSON changes and Arcade cannot find proper types.

crummel commented 5 years ago

I actually thought we had gotten by the JSON changes around preview4 and 5. The more recent issues I've seen have been with nullable reference types, but I think those should be resolved as of preview7. If you want to try building the runtime without Roslyn you can remove the references in coreclr.proj and core-setup.proj and build with /p:RootRepo=core-setup, that should take Roslyn out of the tree completely and we should just use the bootstrap SDK instead. If you try that out and have specific issues I can take a look at the binlogs.

daydrim commented 5 years ago

I don't know what the motivation is @joperator and @daydrim but perhaps we could/should focus on recreating 3.x releases for FreeBSD. If source-build can take changes and patches, that can be viable path and it can provide some value. Maintaining patches instead of making code changes is tedious but hopefully release/3.0 branches will be pretty stable at this point.

Agree with that. As of me, my motivation is to commit and maintain netcore3.0 port for FreeBSD Community. I think it can provide some value and great experience.

I'm in process of updating https://github.com/dotnet/corefx/wiki/Building-.NET-Core-3.x-on-FreeBSD to reflect current status as well as instructions how to update bootstrap cli.

Thanks a lot! Can you mark which parts require Linux compatibilty and which do not. Because there are some links in the instruction such as:

Let's get SDK for supported OS. Sync code base to same version you are trying to build on FreeBSD.

./eng/common/build.sh --restore
Downloading 'https://dot.net/v1/dotnet-install.sh'
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/3.0.100-preview6-012264/dotnet-sdk-3.0.100-preview6-012264-linux-x64.tar.gz

And the result is (because linux compatibility is not enabled)

~/dotnet/sdk/source-build]$ ./eng/common/build.sh --restore
dotnet_install: Warning: Unable to locate libunwind. Probable prerequisite missing; install libunwind.
dotnet_install: Warning: Unable to locate libssl. Probable prerequisite missing; install libssl.
dotnet_install: Warning: Unable to locate libicu. Probable prerequisite missing; install libicu.
dotnet_install: Warning: Unable to locate libcurl. Probable prerequisite missing; install libcurl.
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/3.0.100-preview7-012821/dotnet-sdk-3.0.100-preview7-012821-linux-x64.tar.gz
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/3.0.100-preview7-012821/dotnet-sdk-3.0.100-preview7-012821-linux-x64.tar.gz
export UNAME_s=dotnet-install: Adding to current process PATH: `/usr/home/daydrim/dotnet/sdk/source-build/.dotnet`. Note: This change will be visible only when sourcing script.
dotnet-install: Installation finished successfully.
ELF binary type "0" not known.
/usr/home/daydrim/dotnet/sdk/source-build/eng/common/tools.sh: line 296: /usr/home/daydim/dotnet/sdk/source-build/.dotnet/dotnet: cannot execute binary file: Exec format error
Build failed (exit code '126').

Also we can switch the RID if needed: $ export UNAME_s=Linux and then check

$ uname -a
Linux bsd11 11.3-RELEASE-p2 FreeBSD 11.3-RELEASE-p2 #0: Tue Aug  6 05:07:20 UTC 2019     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
$ uname -s
Linux

One more issue:

Instructions were tested on plain FreeBSD 11.3 Azure image

There is no plain FreeBSD 11.3 Azure image in the Catalog available at the moment. We can only choose between plain FreeBSD 10.4 / 11.2 / 12.0 and if we use 11.2 we can update it manually to 11.3 according to FreeBSD Handbook

Or we can create new thread (issue) for the instruction ? and pull only the instructions as pull request if find some tiny fixes ? If 'yes' I'll do that

joperator commented 5 years ago

If you agree, please let me know.

I totally agree with you @wfurt. My motivation is to create applications and libraries that can run on different platforms like Windows, Linux and FreeBSD without having binaries for each platform and without needing Mono.

I made updates to bring it more recent and I can build coreclr and corefx again.

I'm in process of updating https://github.com/dotnet/corefx/wiki/Building-.NET-Core-3.x-on-FreeBSD to reflect current status as well as instructions how to update bootstrap cli.

Very nice to hear that there's some progress with these repos and the documentation. So if coreclr and corefx can be built again, is the next step to get source-build (without Roslyn) working again by creating patches for release/3.0?

wfurt commented 5 years ago

I did more updates to notes @joperator and @daydrim as well as I added link to download updated cli if somebody wants to skip all the steps for now. Building and running corefx tests is still a challenge.

I think getting source-build with or without Roslyn working is good milestone. As minimum it will outline gaps and we should get as much as possible changes to individual repos. Even if that will change in future, there is chance that changes will be carried forward. I think we should work with @crummel to get much as /p:RootRepo=coreclr, /p:RootRepo=corefx and /p:RootRepo=core-setup working.