From d39668a409bd4abf8206b93d8173f0f2584ed887 Mon Sep 17 00:00:00 2001 From: Gwyn Ciesla Date: Tue, 18 Feb 2020 20:06:29 +0000 Subject: [PATCH 01/19] Added the README --- README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d35adc1 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# dotnet3.1 + +The dotnet3.1 package \ No newline at end of file From b18622e4ac5651fd10701af3cb2ef6cdd933d32f Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Thu, 20 Feb 2020 20:23:21 -0500 Subject: [PATCH 02/19] Initial import (#1802803) --- .gitignore | 1 + build-dotnet-tarball | 117 ++++ check-debug-symbols.py | 136 +++++ cli-telemetry-optout.patch | 18 + core-setup-hardening-flags.patch | 11 + coreclr-hardening-flags.patch | 11 + corefx-39633-cgroupv2-mountpoints.patch | 46 ++ corefx-39686-cgroupv2-01.patch | 391 ++++++++++++++ corefx-39686-cgroupv2-02.patch | 129 +++++ corefx-optflags-support.patch | 39 ++ dotnet.sh.in | 14 + dotnet3.1.spec | 682 ++++++++++++++++++++++++ rename-tarball | 49 ++ sources | 1 + update-release | 62 +++ 15 files changed, 1707 insertions(+) create mode 100644 .gitignore create mode 100755 build-dotnet-tarball create mode 100755 check-debug-symbols.py create mode 100644 cli-telemetry-optout.patch create mode 100644 core-setup-hardening-flags.patch create mode 100644 coreclr-hardening-flags.patch create mode 100644 corefx-39633-cgroupv2-mountpoints.patch create mode 100644 corefx-39686-cgroupv2-01.patch create mode 100644 corefx-39686-cgroupv2-02.patch create mode 100644 corefx-optflags-support.patch create mode 100644 dotnet.sh.in create mode 100644 dotnet3.1.spec create mode 100755 rename-tarball create mode 100644 sources create mode 100755 update-release diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72735bd --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/dotnet-v3.1.101-SDK.tar.gz diff --git a/build-dotnet-tarball b/build-dotnet-tarball new file mode 100755 index 0000000..0923778 --- /dev/null +++ b/build-dotnet-tarball @@ -0,0 +1,117 @@ +#!/bin/bash + +# Usage: +# build-dotnet-tarball +# +# Creates a source archive from a tag (or commit) at github.com/dotnet/source-build + +# Source-build is a little strange, we need to clone it, check out the +# tag, build it and then create a tarball from the archive directory +# it creates. Also, it is likely that the source archive is only +# buildable on the OS it was initially created in. + +set -euo pipefail +IFS=$'\n\t' + +print_usage() { + echo "Usage:" + echo "$0 " + echo + echo "Creates a source archive from a tag at https://github.com/dotnet/source-build" +} + +clean_dotnet_cache() { + rm -rf ~/.aspnet ~/.dotnet/ ~/.nuget/ ~/.local/share/NuGet ~/.templateengine + rm -rf /tmp/NuGet /tmp/NuGetScratch /tmp/.NETCore* /tmp/.NETStandard* /tmp/.dotnet /tmp/dotnet.* /tmp/clr-debug-pipe* /tmp/Razor-Server /tmp/CoreFxPipe* /tmp/VBCSCompiler /tmp/.NETFramework* +} + +function runtime_id { + + declare -A archmap + archmap=( + ["aarch64"]="arm64" + ["amd64"]="x64" + ["armv8l"]="arm" + ["i686"]="x86" + ["i386"]="x86" + ["x86_64"]="x64" + ) + + arch=${archmap["$(uname -m)"]} + + source /etc/os-release + case "${ID}" in + # Remove the RHEL minor version + rhel) rid_version=${VERSION_ID%.*} ;; + + *) rid_version=${VERSION_ID} ;; + esac + + echo "${ID}.${rid_version}-${arch}" +} + +positional_args=() +while [[ "$#" -gt 0 ]]; do + arg="${1}" + case "${arg}" in + -h|--help) + print_usage + exit 0 + ;; + *) + positional_args+=("$1") + shift + ;; + esac +done + + +tag=${positional_args[0]:-} +if [[ -z ${tag} ]]; then + echo "error: missing tag to build" + exit 1 +fi + +set -x + +dir_name="dotnet-${tag}" +unmodified_tarball_name="${dir_name}-original" +tarball_name="${dir_name}" + +if [ -f "${tarball_name}.tar.gz" ]; then + echo "error: ${tarball_name}.tar.gz already exists" + exit 1 +fi + +if [ ! -f "${unmodified_tarball_name}.tar.gz" ]; then + temp_dir=$(mktemp -d -p "$(pwd)") + pushd "${temp_dir}" + git clone https://github.com/dotnet/source-build + pushd source-build + git checkout "${tag}" + git submodule update --init --recursive + clean_dotnet_cache + sed -i -e 's|cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE||' repos/coreclr.proj + ./build-source-tarball.sh "${unmodified_tarball_name}" + popd + popd + + tar czf "${unmodified_tarball_name}.tar.gz" -C "${temp_dir}/source-build" "${unmodified_tarball_name}" + + rm -rf "${temp_dir}" +fi + +rm -rf "${tarball_name}" +tar xf "${unmodified_tarball_name}.tar.gz" +mv "${unmodified_tarball_name}" "${tarball_name}" + +pushd "${tarball_name}" +# Remove files with funny licenses, crypto implementations and other +# not-very-useful artifacts to reduce tarball size +rm -r src/AspNetCore.*/src/SignalR/clients/java/signalr/gradle* +find src/AspNetCore.*/src -type d -name samples -print0 | xargs -0 rm -r +rm -r src/NuGet.Client.*/test/EndToEnd/ProjectTemplates/NetCoreWebApplication1.0.zip +find src/coreclr.*/ -depth -name tests -print0 | xargs -0 rm -r +popd + +tar czf "${tarball_name}.tar.gz" "${tarball_name}" diff --git a/check-debug-symbols.py b/check-debug-symbols.py new file mode 100755 index 0000000..be26d87 --- /dev/null +++ b/check-debug-symbols.py @@ -0,0 +1,136 @@ +#!/usr/bin/python3 + +""" +Check debug symbols are present in shared object and can identify +code. + +It starts scanning from a directory and recursively scans all ELF +files found in it for various symbols to ensure all debuginfo is +present and nothing has been stripped. + +Usage: + +./check-debug-symbols /path/of/dir/to/scan/ + + +Example: + +./check-debug-symbols /usr/lib64 +""" + +# This technique was explained to me by Mark Wielaard (mjw). + +import collections +import os +import re +import subprocess +import sys + +ScanResult = collections.namedtuple('ScanResult', + 'file_name debug_info debug_abbrev file_symbols gnu_debuglink') + + +def scan_file(file): + "Scan the provided file and return a ScanResult containing results of the scan." + + # Test for .debug_* sections in the shared object. This is the main test. + # Stripped objects will not contain these. + readelf_S_result = subprocess.run(['eu-readelf', '-S', file], + stdout=subprocess.PIPE, encoding='utf-8', check=True) + has_debug_info = any(line for line in readelf_S_result.stdout.split('\n') if '] .debug_info' in line) + + has_debug_abbrev = any(line for line in readelf_S_result.stdout.split('\n') if '] .debug_abbrev' in line) + + # Test FILE symbols. These will most likely be removed by anyting that + # manipulates symbol tables because it's generally useless. So a nice test + # that nothing has messed with symbols. + def contains_file_symbols(line): + parts = line.split() + if len(parts) < 8: + return False + return \ + parts[2] == '0' and parts[3] == 'FILE' and parts[4] == 'LOCAL' and parts[5] == 'DEFAULT' and \ + parts[6] == 'ABS' and re.match(r'((.*/)?[-_a-zA-Z0-9]+\.(c|cc|cpp|cxx))?', parts[7]) + + readelf_s_result = subprocess.run(["eu-readelf", '-s', file], + stdout=subprocess.PIPE, encoding='utf-8', check=True) + has_file_symbols = any(line for line in readelf_s_result.stdout.split('\n') if contains_file_symbols(line)) + + # Test that there are no .gnu_debuglink sections pointing to another + # debuginfo file. There shouldn't be any debuginfo files, so the link makes + # no sense either. + has_gnu_debuglink = any(line for line in readelf_s_result.stdout.split('\n') if '] .gnu_debuglink' in line) + + return ScanResult(file, has_debug_info, has_debug_abbrev, has_file_symbols, has_gnu_debuglink) + +def is_elf(file): + result = subprocess.run(['file', file], stdout=subprocess.PIPE, encoding='utf-8', check=True) + return re.search('ELF 64-bit LSB (?:executable|shared object)', result.stdout) + +def scan_file_if_sensible(file): + if is_elf(file): + # print(file) + return scan_file(file) + return None + +def scan_dir(dir): + results = [] + for root, _, files in os.walk(dir): + for name in files: + result = scan_file_if_sensible(os.path.join(root, name)) + if result: + results.append(result) + return results + +def scan(file): + file = os.path.abspath(file) + if os.path.isdir(file): + return scan_dir(file) + elif os.path.isfile(file): + return [scan_file_if_sensible(file)] + +def is_bad_result(result): + return not result.debug_info or not result.debug_abbrev or not result.file_symbols or result.gnu_debuglink + +def print_scan_results(results, verbose): + # print(results) + for result in results: + file_name = result.file_name + found_issue = False + if not result.debug_info: + found_issue = True + print('error: missing .debug_info section in', file_name) + if not result.debug_abbrev: + found_issue = True + print('error: missing .debug_abbrev section in', file_name) + if not result.file_symbols: + found_issue = True + print('error: missing FILE symbols in', file_name) + if result.gnu_debuglink: + found_issue = True + print('error: unexpected .gnu_debuglink section in', file_name) + if verbose and not found_issue: + print('OK: ', file_name) + +def main(args): + verbose = False + files = [] + for arg in args: + if arg == '--verbose' or arg == '-v': + verbose = True + else: + files.append(arg) + + results = [] + for file in files: + results.extend(scan(file)) + + print_scan_results(results, verbose) + + if any(is_bad_result(result) for result in results): + return 1 + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/cli-telemetry-optout.patch b/cli-telemetry-optout.patch new file mode 100644 index 0000000..9b01f13 --- /dev/null +++ b/cli-telemetry-optout.patch @@ -0,0 +1,18 @@ +diff --git a/src/dotnet/Program.cs b/src/dotnet/Program.cs +index de1ebb9e6..6bbf479de 100644 +--- a/src/dotnet/Program.cs ++++ b/src/dotnet/Program.cs +@@ -28,6 +28,13 @@ public class Program + + public static int Main(string[] args) + { ++ // opt out of telemetry by default if the env var is unset ++ string telemetryValue = Environment.GetEnvironmentVariable("DOTNET_CLI_TELEMETRY_OPTOUT"); ++ if (String.IsNullOrEmpty(telemetryValue)) ++ { ++ Environment.SetEnvironmentVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1"); ++ } ++ + DebugHelper.HandleDebugSwitch(ref args); + + new MulticoreJitActivator().TryActivateMulticoreJit(); diff --git a/core-setup-hardening-flags.patch b/core-setup-hardening-flags.patch new file mode 100644 index 0000000..3f6b91c --- /dev/null +++ b/core-setup-hardening-flags.patch @@ -0,0 +1,11 @@ +diff --git a/src/settings.cmake b/src/settings.cmake +--- a/src/settings.cmake ++++ b/src/settings.cmake +@@ -218,6 +218,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic -Bsymbolic-functions") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1") ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") + add_compile_options(-fstack-protector-strong) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + add_compile_options(-fstack-protector) diff --git a/coreclr-hardening-flags.patch b/coreclr-hardening-flags.patch new file mode 100644 index 0000000..d58d735 --- /dev/null +++ b/coreclr-hardening-flags.patch @@ -0,0 +1,11 @@ +diff --git a/src/debug/createdump/CMakeLists.txt b/src/debug/createdump/CMakeLists.txt +--- a/src/debug/createdump/CMakeLists.txt ++++ b/src/debug/createdump/CMakeLists.txt +@@ -21,6 +21,7 @@ include_directories(BEFORE ${VM_DIR}) + add_definitions(-DPAL_STDCPP_COMPAT) + + add_compile_options(-fPIE) ++add_link_options(-pie) + + set(CREATEDUMP_SOURCES + createdump.cpp diff --git a/corefx-39633-cgroupv2-mountpoints.patch b/corefx-39633-cgroupv2-mountpoints.patch new file mode 100644 index 0000000..34fbecb --- /dev/null +++ b/corefx-39633-cgroupv2-mountpoints.patch @@ -0,0 +1,46 @@ +From 1864630f762160e1cb439362cc0577471624192a Mon Sep 17 00:00:00 2001 +From: Omair Majid +Date: Fri, 19 Jul 2019 19:18:51 -0400 +Subject: [PATCH] Fix up cgroup2fs in Interop.MountPoints.FormatInfo + +`stat -fc %T /sys/fs/cgroup` calls this file system `cgroup2fs` + +Add the cgroup2fs file system magic number. Available from: + + - https://www.kernel.org/doc/Documentation/cgroup-v2.txt + - man 2 statfs + +Move cgroup2fs next to cgroupfs in the drive type list, since it is also +DriveType.Ram. +--- + .../Unix/System.Native/Interop.MountPoints.FormatInfo.cs | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs b/src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs +index af38a2285ba2..4240bd4853ab 100644 +--- a/src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs ++++ b/src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs +@@ -47,6 +47,7 @@ internal enum UnixFileSystemTypes : long + btrfs = 0x9123683E, + ceph = 0x00C36400, + cgroupfs = 0x0027E0EB, ++ cgroup2fs = 0x63677270, + cifs = 0xFF534D42, + coda = 0x73757245, + coherent = 0x012FF7B7, +@@ -231,7 +232,6 @@ private static DriveType GetDriveType(string fileSystemName) + case "bpf_fs": + case "btrfs": + case "btrfs_test": +- case "cgroup2fs": + case "coh": + case "daxfs": + case "drvfs": +@@ -384,6 +384,7 @@ private static DriveType GetDriveType(string fileSystemName) + case "binfmt_misc": + case "cgroup": + case "cgroupfs": ++ case "cgroup2fs": + case "configfs": + case "cramfs": + case "cramfs-wend": diff --git a/corefx-39686-cgroupv2-01.patch b/corefx-39686-cgroupv2-01.patch new file mode 100644 index 0000000..e7628e2 --- /dev/null +++ b/corefx-39686-cgroupv2-01.patch @@ -0,0 +1,391 @@ +From 2b2273ea4ea1c28472fa0d6ad2ffeb6374500550 Mon Sep 17 00:00:00 2001 +From: Omair Majid +Date: Wed, 23 Oct 2019 17:45:59 -0400 +Subject: [PATCH 1/2] Add cgroup v2 support to Interop.cgroups + +Fix up code to adjust cgroup v1 assumptions and check cgroup v2 paths, +locations and values. + +Continue using the older cgroup v1 terminology for APIs. +--- + .../Interop/Linux/cgroups/Interop.cgroups.cs | 116 ++++++++++++++---- + src/Common/tests/Common.Tests.csproj | 4 + + .../tests/Tests/Interop/cgroupsTests.cs | 107 ++++++++++++++++ + .../tests/DescriptionNameTests.cs | 2 +- + 4 files changed, 206 insertions(+), 23 deletions(-) + create mode 100644 src/Common/tests/Tests/Interop/cgroupsTests.cs + +diff --git a/src/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs b/src/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs +index 0ffd4d7b7c03..186fe0516c5b 100644 +--- a/src/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs ++++ b/src/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs +@@ -9,17 +9,22 @@ + + internal static partial class Interop + { ++ /// Provides access to some cgroup (v1 and v2) features + internal static partial class cgroups + { ++ // For cgroup v1, see https://www.kernel.org/doc/Documentation/cgroup-v1/ ++ // For cgroup v2, see https://www.kernel.org/doc/Documentation/cgroup-v2.txt ++ ++ /// The version of cgroup that's being used ++ internal enum CGroupVersion { None, CGroup1, CGroup2 }; ++ + /// Path to mountinfo file in procfs for the current process. + private const string ProcMountInfoFilePath = "/proc/self/mountinfo"; + /// Path to cgroup directory in procfs for the current process. + private const string ProcCGroupFilePath = "/proc/self/cgroup"; + +- /// Path to the found cgroup location, or null if it couldn't be found. +- internal static readonly string s_cgroupMemoryPath = FindCGroupPath("memory"); +- /// Path to the found cgroup memory limit_in_bytes path, or null if it couldn't be found. +- private static readonly string s_cgroupMemoryLimitPath = s_cgroupMemoryPath != null ? s_cgroupMemoryPath + "/memory.limit_in_bytes" : null; ++ /// Path to the found cgroup memory limit path, or null if it couldn't be found. ++ internal static readonly string s_cgroupMemoryLimitPath = FindCGroupMemoryLimitPath(); + + /// Tries to read the memory limit from the cgroup memory location. + /// The read limit, or 0 if it couldn't be read. +@@ -42,7 +47,7 @@ public static bool TryGetMemoryLimit(out ulong limit) + /// The path to the file to parse. + /// The parsed result, or 0 if it couldn't be parsed. + /// true if the value was read successfully; otherwise, false. +- private static bool TryReadMemoryValueFromFile(string path, out ulong result) ++ internal static bool TryReadMemoryValueFromFile(string path, out ulong result) + { + if (File.Exists(path)) + { +@@ -79,6 +84,11 @@ private static bool TryReadMemoryValueFromFile(string path, out ulong result) + result = checked(ulongValue * multiplier); + return true; + } ++ ++ // 'max' is also a possible valid value ++ // ++ // Treat this as 'no memory limit' and let the caller ++ // fallback to reading the real limit via other means + } + catch (Exception e) + { +@@ -90,12 +100,35 @@ private static bool TryReadMemoryValueFromFile(string path, out ulong result) + return false; + } + ++ /// Find the cgroup memory limit path. ++ /// The limit path if found; otherwise, null. ++ private static string FindCGroupMemoryLimitPath() ++ { ++ string cgroupMemoryPath = FindCGroupPath("memory", out CGroupVersion version); ++ if (cgroupMemoryPath != null) ++ { ++ if (version == CGroupVersion.CGroup1) ++ { ++ return cgroupMemoryPath + "/memory.limit_in_bytes"; ++ } ++ ++ if (version == CGroupVersion.CGroup2) ++ { ++ // 'memory.high' is a soft limit; the process may get throttled ++ // 'memory.max' is where OOM killer kicks in ++ return cgroupMemoryPath + "/memory.max"; ++ } ++ } ++ ++ return null; ++ } ++ + /// Find the cgroup path for the specified subsystem. + /// The subsystem, e.g. "memory". + /// The cgroup path if found; otherwise, null. +- private static string FindCGroupPath(string subsystem) ++ private static string FindCGroupPath(string subsystem, out CGroupVersion version) + { +- if (TryFindHierarchyMount(subsystem, out string hierarchyRoot, out string hierarchyMount) && ++ if (TryFindHierarchyMount(subsystem, out version, out string hierarchyRoot, out string hierarchyMount) && + TryFindCGroupPathForSubsystem(subsystem, out string cgroupPathRelativeToMount)) + { + // For a host cgroup, we need to append the relative path. +@@ -113,19 +146,24 @@ private static string FindCGroupPath(string subsystem) + /// The path of the directory in the filesystem which forms the root of this mount; null if not found. + /// The path of the mount point relative to the process's root directory; null if not found. + /// true if the mount was found; otherwise, null. +- private static bool TryFindHierarchyMount(string subsystem, out string root, out string path) ++ private static bool TryFindHierarchyMount(string subsystem, out CGroupVersion version, out string root, out string path) + { +- if (File.Exists(ProcMountInfoFilePath)) ++ return TryFindHierarchyMount(ProcMountInfoFilePath, subsystem, out version, out root, out path); ++ } ++ ++ internal static bool TryFindHierarchyMount(string mountInfoFilePath, string subsystem, out CGroupVersion version, out string root, out string path) ++ { ++ if (File.Exists(mountInfoFilePath)) + { + try + { +- using (var reader = new StreamReader(ProcMountInfoFilePath)) ++ using (var reader = new StreamReader(mountInfoFilePath)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + // Look for an entry that has cgroup as the "filesystem type" +- // and that has options containing the specified subsystem. ++ // and, for cgroup1, that has options containing the specified subsystem + // See man page for /proc/[pid]/mountinfo for details, e.g.: + // (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11) + // 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue +@@ -148,17 +186,35 @@ private static bool TryFindHierarchyMount(string subsystem, out string root, out + continue; + } + +- if (postSeparatorlineParts[0] != "cgroup" || +- Array.IndexOf(postSeparatorlineParts[2].Split(','), subsystem) < 0) ++ bool validCGroup1Entry = ((postSeparatorlineParts[0] == "cgroup") && ++ (Array.IndexOf(postSeparatorlineParts[2].Split(','), subsystem) >= 0)); ++ bool validCGroup2Entry = postSeparatorlineParts[0] == "cgroup2"; ++ ++ if (!validCGroup1Entry && !validCGroup2Entry) + { + // Not the relevant entry. + continue; + } + +- // Found the relevant entry. Extract the mount root and path. ++ // Found the relevant entry. Extract the cgroup version, mount root and path. ++ switch (postSeparatorlineParts[0]) ++ { ++ case "cgroup": ++ version = CGroupVersion.CGroup1; ++ break; ++ case "cgroup2": ++ version = CGroupVersion.CGroup2; ++ break; ++ default: ++ version = CGroupVersion.None; ++ Debug.Fail($"invalid value for CGroupVersion \"{postSeparatorlineParts[0]}\""); ++ break; ++ } ++ + string[] lineParts = line.Substring(0, endOfOptionalFields).Split(' '); + root = lineParts[3]; + path = lineParts[4]; ++ + return true; + } + } +@@ -169,6 +225,7 @@ private static bool TryFindHierarchyMount(string subsystem, out string root, out + } + } + ++ version = CGroupVersion.None; + root = null; + path = null; + return false; +@@ -180,27 +237,42 @@ private static bool TryFindHierarchyMount(string subsystem, out string root, out + /// + private static bool TryFindCGroupPathForSubsystem(string subsystem, out string path) + { +- if (File.Exists(ProcCGroupFilePath)) ++ return TryFindCGroupPathForSubsystem(ProcCGroupFilePath, subsystem, out path); ++ } ++ ++ internal static bool TryFindCGroupPathForSubsystem(string procCGroupFilePath, string subsystem, out string path) ++ { ++ if (File.Exists(procCGroupFilePath)) + { + try + { +- using (var reader = new StreamReader(ProcCGroupFilePath)) ++ using (var reader = new StreamReader(procCGroupFilePath)) + { + string line; + while ((line = reader.ReadLine()) != null) + { +- // Find the first entry that has the subsystem listed in its controller +- // list. See man page for cgroups for /proc/[pid]/cgroups format, e.g: +- // hierarchy-ID:controller-list:cgroup-path +- // 5:cpuacct,cpu,cpuset:/daemons +- + string[] lineParts = line.Split(':'); ++ + if (lineParts.Length != 3) + { + // Malformed line. + continue; + } + ++ // cgroup v2: Find the first entry that matches the cgroup v2 hierarchy: ++ // 0::$PATH ++ ++ if ((lineParts[0] == "0") && (string.Empty == lineParts[1])) ++ { ++ path = lineParts[2]; ++ return true; ++ } ++ ++ // cgroup v1: Find the first entry that has the subsystem listed in its controller ++ // list. See man page for cgroups for /proc/[pid]/cgroups format, e.g: ++ // hierarchy-ID:controller-list:cgroup-path ++ // 5:cpuacct,cpu,cpuset:/daemons ++ + if (Array.IndexOf(lineParts[1].Split(','), subsystem) < 0) + { + // Not the relevant entry. +@@ -214,7 +286,7 @@ private static bool TryFindCGroupPathForSubsystem(string subsystem, out string p + } + catch (Exception e) + { +- Debug.Fail($"Failed to read or parse \"{ProcMountInfoFilePath}\": {e}"); ++ Debug.Fail($"Failed to read or parse \"{procCGroupFilePath}\": {e}"); + } + } + +diff --git a/src/Common/tests/Common.Tests.csproj b/src/Common/tests/Common.Tests.csproj +index a189d856348b..979c8dd7fbe6 100644 +--- a/src/Common/tests/Common.Tests.csproj ++++ b/src/Common/tests/Common.Tests.csproj +@@ -12,6 +12,9 @@ + + Common\System\Security\Cryptography\ByteUtils.cs + ++ ++ Common\Interop\Linux\cgroups\Interop.cgroups.cs ++ + + Common\Interop\Linux\procfs\Interop.ProcFsStat.cs + +@@ -69,6 +72,7 @@ + + Common\CoreLib\System\PasteArguments.cs + ++ + + + +diff --git a/src/Common/tests/Tests/Interop/cgroupsTests.cs b/src/Common/tests/Tests/Interop/cgroupsTests.cs +new file mode 100644 +index 000000000000..f16d9242879c +--- /dev/null ++++ b/src/Common/tests/Tests/Interop/cgroupsTests.cs +@@ -0,0 +1,107 @@ ++// Licensed to the .NET Foundation under one or more agreements. ++// The .NET Foundation licenses this file to you under the MIT license. ++// See the LICENSE file in the project root for more information. ++ ++using System; ++using System.IO; ++using System.Text; ++using Xunit; ++ ++namespace Common.Tests ++{ ++ public class cgroupsTests ++ { ++ [Theory] ++ [InlineData(true, "0", 0)] ++ [InlineData(false, "max", 0)] ++ [InlineData(true, "1k", 1024)] ++ [InlineData(true, "1K", 1024)] ++ public static void ValidateTryReadMemoryValue(bool expectedResult, string valueText, ulong expectedValue) ++ { ++ string path = Path.GetTempFileName(); ++ try ++ { ++ File.WriteAllText(path, valueText); ++ ++ bool result = Interop.cgroups.TryReadMemoryValueFromFile(path, out ulong val); ++ ++ Assert.Equal(expectedResult, result); ++ if (result) ++ { ++ Assert.Equal(expectedValue, val); ++ } ++ } ++ finally ++ { ++ File.Delete(path); ++ } ++ } ++ ++ [Theory] ++ [InlineData(false, "0 0 0:0 / /foo ignore ignore - overlay overlay ignore", "ignore", 0, "/", "/")] ++ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup2 cgroup2 ignore", "ignore", 2, "/", "/foo")] ++ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup2 cgroup2 ignore", "memory", 2, "/", "/foo")] ++ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup2 cgroup2 ignore", "cpu", 2, "/", "/foo")] ++ [InlineData(true, "0 0 0:0 / /foo ignore - cgroup2 cgroup2 ignore", "cpu", 2, "/", "/foo")] ++ [InlineData(true, "0 0 0:0 / /foo ignore ignore ignore - cgroup2 cgroup2 ignore", "cpu", 2, "/", "/foo")] ++ [InlineData(true, "0 0 0:0 / /foo-with-dashes ignore ignore - cgroup2 cgroup2 ignore", "ignore", 2, "/", "/foo-with-dashes")] ++ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup memory", "memory", 1, "/", "/foo")] ++ [InlineData(true, "0 0 0:0 / /foo-with-dashes ignore ignore - cgroup cgroup memory", "memory", 1, "/", "/foo-with-dashes")] ++ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup cpu,memory", "memory", 1, "/", "/foo")] ++ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup memory,cpu", "memory", 1, "/", "/foo")] ++ [InlineData(false, "0 0 0:0 / /foo ignore ignore - cgroup cgroup cpu", "memory", 0, "/", "/foo")] ++ public static void ParseValidateMountInfo(bool found, string procSelfMountInfoText, string subsystem, int expectedVersion, string expectedRoot, string expectedMount) ++ { ++ string path = Path.GetTempFileName(); ++ try ++ { ++ File.WriteAllText(path, procSelfMountInfoText); ++ ++ bool result = Interop.cgroups.TryFindHierarchyMount(path, subsystem, out Interop.cgroups.CGroupVersion version, out string root, out string mount); ++ ++ Assert.Equal(found, result); ++ if (found) ++ { ++ Assert.Equal(expectedVersion, (int)version); ++ Assert.Equal(expectedRoot, root); ++ Assert.Equal(expectedMount, mount); ++ } ++ } ++ finally ++ { ++ File.Delete(path); ++ } ++ } ++ ++ [Theory] ++ [InlineData(true, "0::/foo", "ignore", "/foo")] ++ [InlineData(true, "0::/bar", "ignore", "/bar")] ++ [InlineData(true, "0::frob", "ignore", "frob")] ++ [InlineData(false, "1::frob", "ignore", "ignore")] ++ [InlineData(true, "1:foo:bar", "foo", "bar")] ++ [InlineData(true, "2:foo:bar", "foo", "bar")] ++ [InlineData(false, "2:foo:bar", "bar", "ignore")] ++ [InlineData(true, "1:foo:bar\n2:eggs:spam", "foo", "bar")] ++ [InlineData(true, "1:foo:bar\n2:eggs:spam", "eggs", "spam")] ++ public static void ParseValidateProcCGroup(bool found, string procSelfCgroupText, string subsystem, string expectedMountPath) ++ { ++ string path = Path.GetTempFileName(); ++ try ++ { ++ File.WriteAllText(path, procSelfCgroupText); ++ ++ bool result = Interop.cgroups.TryFindCGroupPathForSubsystem(path, subsystem, out string mountPath); ++ ++ Assert.Equal(found, result); ++ if (found) ++ { ++ Assert.Equal(expectedMountPath, mountPath); ++ } ++ } ++ finally ++ { ++ File.Delete(path); ++ } ++ } ++ } ++} +diff --git a/src/System.Runtime.InteropServices.RuntimeInformation/tests/DescriptionNameTests.cs b/src/System.Runtime.InteropServices.RuntimeInformation/tests/DescriptionNameTests.cs +index 910af2fd82b4..73f692898dbc 100644 +--- a/src/System.Runtime.InteropServices.RuntimeInformation/tests/DescriptionNameTests.cs ++++ b/src/System.Runtime.InteropServices.RuntimeInformation/tests/DescriptionNameTests.cs +@@ -40,7 +40,7 @@ public void DumpRuntimeInformationToConsole() + + Console.WriteLine($"### CURRENT DIRECTORY: {Environment.CurrentDirectory}"); + +- string cgroupsLocation = Interop.cgroups.s_cgroupMemoryPath; ++ string cgroupsLocation = Interop.cgroups.s_cgroupMemoryLimitPath; + if (cgroupsLocation != null) + { + Console.WriteLine($"### CGROUPS MEMORY: {cgroupsLocation}"); + diff --git a/corefx-39686-cgroupv2-02.patch b/corefx-39686-cgroupv2-02.patch new file mode 100644 index 0000000..88dcd99 --- /dev/null +++ b/corefx-39686-cgroupv2-02.patch @@ -0,0 +1,129 @@ +From 9a8c5e4014ffca8aff70808cc0e50a403d38c292 Mon Sep 17 00:00:00 2001 +From: Stephen Toub +Date: Wed, 23 Oct 2019 20:35:49 -0400 +Subject: [PATCH 2/2] Clean up new tests + +--- + .../tests/Tests/Interop/cgroupsTests.cs | 79 ++++++------------- + 1 file changed, 25 insertions(+), 54 deletions(-) + +diff --git a/src/Common/tests/Tests/Interop/cgroupsTests.cs b/src/Common/tests/Tests/Interop/cgroupsTests.cs +index f16d9242879c..fc6ab5c9753c 100644 +--- a/src/Common/tests/Tests/Interop/cgroupsTests.cs ++++ b/src/Common/tests/Tests/Interop/cgroupsTests.cs +@@ -2,38 +2,27 @@ + // The .NET Foundation licenses this file to you under the MIT license. + // See the LICENSE file in the project root for more information. + +-using System; + using System.IO; +-using System.Text; + using Xunit; + + namespace Common.Tests + { +- public class cgroupsTests ++ public class cgroupsTests : FileCleanupTestBase + { + [Theory] +- [InlineData(true, "0", 0)] +- [InlineData(false, "max", 0)] +- [InlineData(true, "1k", 1024)] +- [InlineData(true, "1K", 1024)] +- public static void ValidateTryReadMemoryValue(bool expectedResult, string valueText, ulong expectedValue) ++ [InlineData(true, "0", 0)] ++ [InlineData(false, "max", 0)] ++ [InlineData(true, "1k", 1024)] ++ [InlineData(true, "1K", 1024)] ++ public void ValidateTryReadMemoryValue(bool expectedResult, string valueText, ulong expectedValue) + { +- string path = Path.GetTempFileName(); +- try +- { +- File.WriteAllText(path, valueText); +- +- bool result = Interop.cgroups.TryReadMemoryValueFromFile(path, out ulong val); ++ string path = GetTestFilePath(); ++ File.WriteAllText(path, valueText); + +- Assert.Equal(expectedResult, result); +- if (result) +- { +- Assert.Equal(expectedValue, val); +- } +- } +- finally ++ Assert.Equal(expectedResult, Interop.cgroups.TryReadMemoryValueFromFile(path, out ulong val)); ++ if (expectedResult) + { +- File.Delete(path); ++ Assert.Equal(expectedValue, val); + } + } + +@@ -50,26 +39,17 @@ public static void ValidateTryReadMemoryValue(bool expectedResult, string valueT + [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup cpu,memory", "memory", 1, "/", "/foo")] + [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup memory,cpu", "memory", 1, "/", "/foo")] + [InlineData(false, "0 0 0:0 / /foo ignore ignore - cgroup cgroup cpu", "memory", 0, "/", "/foo")] +- public static void ParseValidateMountInfo(bool found, string procSelfMountInfoText, string subsystem, int expectedVersion, string expectedRoot, string expectedMount) ++ public void ParseValidateMountInfo(bool expectedFound, string procSelfMountInfoText, string subsystem, int expectedVersion, string expectedRoot, string expectedMount) + { +- string path = Path.GetTempFileName(); +- try +- { +- File.WriteAllText(path, procSelfMountInfoText); +- +- bool result = Interop.cgroups.TryFindHierarchyMount(path, subsystem, out Interop.cgroups.CGroupVersion version, out string root, out string mount); ++ string path = GetTestFilePath(); ++ File.WriteAllText(path, procSelfMountInfoText); + +- Assert.Equal(found, result); +- if (found) +- { +- Assert.Equal(expectedVersion, (int)version); +- Assert.Equal(expectedRoot, root); +- Assert.Equal(expectedMount, mount); +- } +- } +- finally ++ Assert.Equal(expectedFound, Interop.cgroups.TryFindHierarchyMount(path, subsystem, out Interop.cgroups.CGroupVersion version, out string root, out string mount)); ++ if (expectedFound) + { +- File.Delete(path); ++ Assert.Equal(expectedVersion, (int)version); ++ Assert.Equal(expectedRoot, root); ++ Assert.Equal(expectedMount, mount); + } + } + +@@ -83,24 +63,15 @@ public static void ParseValidateMountInfo(bool found, string procSelfMountInfoTe + [InlineData(false, "2:foo:bar", "bar", "ignore")] + [InlineData(true, "1:foo:bar\n2:eggs:spam", "foo", "bar")] + [InlineData(true, "1:foo:bar\n2:eggs:spam", "eggs", "spam")] +- public static void ParseValidateProcCGroup(bool found, string procSelfCgroupText, string subsystem, string expectedMountPath) ++ public void ParseValidateProcCGroup(bool expectedFound, string procSelfCgroupText, string subsystem, string expectedMountPath) + { +- string path = Path.GetTempFileName(); +- try +- { +- File.WriteAllText(path, procSelfCgroupText); ++ string path = GetTestFilePath(); ++ File.WriteAllText(path, procSelfCgroupText); + +- bool result = Interop.cgroups.TryFindCGroupPathForSubsystem(path, subsystem, out string mountPath); +- +- Assert.Equal(found, result); +- if (found) +- { +- Assert.Equal(expectedMountPath, mountPath); +- } +- } +- finally ++ Assert.Equal(expectedFound, Interop.cgroups.TryFindCGroupPathForSubsystem(path, subsystem, out string mountPath)); ++ if (expectedFound) + { +- File.Delete(path); ++ Assert.Equal(expectedMountPath, mountPath); + } + } + } diff --git a/corefx-optflags-support.patch b/corefx-optflags-support.patch new file mode 100644 index 0000000..6f76d7f --- /dev/null +++ b/corefx-optflags-support.patch @@ -0,0 +1,39 @@ +diff --git a/src/Native/Unix/CMakeLists.txt b/src/Native/Unix/CMakeLists.txt +index 7d804a1e54..717c2718d7 100644 +--- a/src/Native/Unix/CMakeLists.txt ++++ b/src/Native/Unix/CMakeLists.txt +@@ -25,7 +25,6 @@ add_compile_options(-fPIC) + add_compile_options(-Wthread-safety) + add_compile_options(-Wno-thread-safety-analysis) + endif() +-add_compile_options(-Werror) + + if(CMAKE_SYSTEM_NAME STREQUAL Emscripten) + set(CLR_CMAKE_PLATFORM_WASM 1) +diff --git a/src/Native/Unix/configure.cmake b/src/Native/Unix/configure.cmake +index f4a30ad6cb..f2db68402a 100644 +--- a/src/Native/Unix/configure.cmake ++++ b/src/Native/Unix/configure.cmake +@@ -27,6 +27,12 @@ else () + message(FATAL_ERROR "Unknown platform. Cannot define PAL_UNIX_NAME, used by RuntimeInformation.") + endif () + ++ ++set (PREVIOUS_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) ++set (CMAKE_CXX_FLAGS "-D_GNU_SOURCE") ++set (PREVIOUS_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) ++set (CMAKE_C_FLAGS "-D_GNU_SOURCE") ++ + # We compile with -Werror, so we need to make sure these code fragments compile without warnings. + # Older CMake versions (3.8) do not assign the result of their tests, causing unused-value errors + # which are not distinguished from the test failing. So no error for that one. +@@ -698,6 +704,9 @@ endif() + + set (CMAKE_REQUIRED_LIBRARIES) + ++set (CMAKE_CXX_FLAGS "${PREVIOUS_CMAKE_CXX_FLAGS}") ++set (CMAKE_C_FLAGS "${PREVIOUS_CMAKE_C_FLAGS}") ++ + check_c_source_compiles( + " + #include diff --git a/dotnet.sh.in b/dotnet.sh.in new file mode 100644 index 0000000..65b92a0 --- /dev/null +++ b/dotnet.sh.in @@ -0,0 +1,14 @@ + +# Set location for AppHost lookup +[ -z "$DOTNET_ROOT" ] && export DOTNET_ROOT=@LIBDIR@/dotnet + +# Add dotnet tools directory to PATH +DOTNET_TOOLS_PATH="$HOME/.dotnet/tools" +case "$PATH" in + *"$DOTNET_TOOLS_PATH"* ) true ;; + * ) PATH="$PATH:$DOTNET_TOOLS_PATH" ;; +esac + +# Extract self-contained executables under HOME +# to avoid multi-user issues from using the default '/var/tmp'. +[ -z "$DOTNET_BUNDLE_EXTRACT_BASE_DIR" ] && export DOTNET_BUNDLE_EXTRACT_BASE_DIR="${XDG_CACHE_HOME:-"$HOME"/.cache}/dotnet_bundle_extract" diff --git a/dotnet3.1.spec b/dotnet3.1.spec new file mode 100644 index 0000000..4536929 --- /dev/null +++ b/dotnet3.1.spec @@ -0,0 +1,682 @@ +%bcond_without bootstrap + +# Avoid provides/requires from private libraries +%global privlibs libhostfxr +%global privlibs %{privlibs}|libclrjit +%global privlibs %{privlibs}|libcoreclr +%global privlibs %{privlibs}|libcoreclrtraceptprovider +%global privlibs %{privlibs}|libdbgshim +%global privlibs %{privlibs}|libhostpolicy +%global privlibs %{privlibs}|libmscordaccore +%global privlibs %{privlibs}|libmscordbi +%global privlibs %{privlibs}|libsos +%global privlibs %{privlibs}|libsosplugin +%global __provides_exclude ^(%{privlibs})\\.so +%global __requires_exclude ^(%{privlibs})\\.so + +# Filter flags not supported by clang +# -fstack-clash-protection +# -specs= +%global dotnet_cflags %(echo %optflags | sed -e 's/-fstack-clash-protection//' | sed -re 's/-specs=[^ ]*//g') +%global dotnet_ldflags %(echo %{__global_ldflags} | sed -re 's/-specs=[^ ]*//g') + +%global host_version 3.1.1 +%global runtime_version 3.1.1 +%global aspnetcore_runtime_version %{runtime_version} +%global sdk_version 3.1.101 +%global templates_version %{runtime_version} + +%global host_rpm_version %{host_version} +%global aspnetcore_runtime_rpm_version %{aspnetcore_runtime_version} +%global runtime_rpm_version %{runtime_version} +%global sdk_rpm_version %{sdk_version} + +%if 0%{?fedora} || 0%{?rhel} < 8 +%global use_bundled_libunwind 0 +%else +%global use_bundled_libunwind 1 +%endif + +%ifarch x86_64 +%global runtime_arch x64 +%endif +%ifarch aarch64 +%global runtime_arch arm64 +%endif + +%if 0%{?fedora} +%global runtime_id fedora.%{fedora}-%{runtime_arch} +%else +%if 0%{?centos} +%global runtime_id centos.%{centos}-%{runtime_arch} +%else +%global runtime_id rhel.%{rhel}-%{runtime_arch} +%endif +%endif + +Name: dotnet3.1 +Version: %{sdk_rpm_version} +Release: 1%{?dist} +Summary: .NET Core Runtime and SDK +License: MIT and ASL 2.0 and BSD and LGPLv2+ and CC-BY and CC0 and MS-PL and EPL-1.0 and GPL+ and GPLv2 and ISC and OFL and zlib +URL: https://github.com/dotnet/ + +# The source is generated on a Fedora box via: +# ./build-dotnet-tarball v%%{sdk_version}-SDK +Source0: dotnet-v%{sdk_version}-SDK.tar.gz +Source1: check-debug-symbols.py +Source2: dotnet.sh.in + +# Fix building with our additional CFLAGS/CXXFLAGS/LDFLAGS +Patch100: corefx-optflags-support.patch + +# Add some support for cgroupv2 in corefx +# All these patches are upstreamed for 5.0 +Patch101: corefx-39686-cgroupv2-01.patch +Patch102: corefx-39686-cgroupv2-02.patch +Patch103: corefx-39633-cgroupv2-mountpoints.patch + +# Build with with hardening flags, including -pie +Patch200: coreclr-hardening-flags.patch + +# Build with with hardening flags, including -pie +Patch300: core-setup-hardening-flags.patch + +# Disable telemetry by default; make it opt-in +Patch500: cli-telemetry-optout.patch + +ExclusiveArch: x86_64 + +BuildRequires: clang +BuildRequires: cmake +BuildRequires: coreutils +%if %{without bootstrap} +BuildRequires: dotnet-build-reference-packages +BuildRequires: dotnet-sdk-3.1 +BuildRequires: dotnet-sdk-3.1-source-built-artifacts +%endif +BuildRequires: git +%if 0%{?fedora} || 0%{?rhel} > 7 +BuildRequires: glibc-langpack-en +%endif +BuildRequires: hostname +BuildRequires: krb5-devel +BuildRequires: libcurl-devel +BuildRequires: libicu-devel +%if ! %{use_bundled_libunwind} +BuildRequires: libunwind-devel +%endif +BuildRequires: lldb-devel +BuildRequires: llvm +BuildRequires: lttng-ust-devel +BuildRequires: make +BuildRequires: openssl-devel +BuildRequires: python3 +BuildRequires: tar +BuildRequires: zlib-devel + +%description +.NET Core is a fast, lightweight and modular platform for creating +cross platform applications that work on Linux, macOS and Windows. + +It particularly focuses on creating console applications, web +applications and micro-services. + +.NET Core contains a runtime conforming to .NET Standards a set of +framework libraries, an SDK containing compilers and a 'dotnet' +application to drive everything. + + +%package -n dotnet + +Version: %{sdk_rpm_version} +Summary: .NET Core CLI tools and runtime + +Requires: dotnet-sdk-3.1%{?_isa} >= %{sdk_rpm_version}-%{release} + +%description -n dotnet +.NET Core is a fast, lightweight and modular platform for creating +cross platform applications that work on Linux, macOS and Windows. + +It particularly focuses on creating console applications, web +applications and micro-services. + +.NET Core contains a runtime conforming to .NET Standards a set of +framework libraries, an SDK containing compilers and a 'dotnet' +application to drive everything. + + +%package -n dotnet-host + +Version: %{host_rpm_version} +Summary: .NET command line launcher + +%description -n dotnet-host +The .NET Core host is a command line program that runs a standalone +.NET core application or launches the SDK. + +.NET Core is a fast, lightweight and modular platform for creating +cross platform applications that work on Linux, Mac and Windows. + +It particularly focuses on creating console applications, web +applications and micro-services. + + +%package -n dotnet-hostfxr-3.1 + +Version: %{host_rpm_version} +Summary: .NET Core command line host resolver + +# Theoretically any version of the host should work. But lets aim for the one +# provided by this package, or from a newer version of .NET Core +Requires: dotnet-host%{?_isa} >= %{host_rpm_version}-%{release} + +%description -n dotnet-hostfxr-3.1 +The .NET Core host resolver contains the logic to resolve and select +the right version of the .NET Core SDK or runtime to use. + +.NET Core is a fast, lightweight and modular platform for creating +cross platform applications that work on Linux, Mac and Windows. + +It particularly focuses on creating console applications, web +applications and micro-services. + + +%package -n dotnet-runtime-3.1 + +Version: %{runtime_rpm_version} +Summary: NET Core 3.1 runtime + +Requires: dotnet-hostfxr-3.1%{?_isa} >= %{host_rpm_version}-%{release} + +# libicu is dlopen()ed +Requires: libicu%{?_isa} + +%if %{use_bundled_libunwind} +Provides: bundled(libunwind) = 1.3 +%endif + +%description -n dotnet-runtime-3.1 +The .NET Core runtime contains everything needed to run .NET Core applications. +It includes a high performance Virtual Machine as well as the framework +libraries used by .NET Core applications. + +.NET Core is a fast, lightweight and modular platform for creating +cross platform applications that work on Linux, Mac and Windows. + +It particularly focuses on creating console applications, web +applications and micro-services. + + +%package -n aspnetcore-runtime-3.1 + +Version: %{aspnetcore_runtime_rpm_version} +Summary: ASP.NET Core 3.1 runtime + +Requires: dotnet-runtime-3.1%{?_isa} >= %{runtime_rpm_version}-%{release} + +%description -n aspnetcore-runtime-3.1 +The ASP.NET Core runtime contains everything needed to run .NET Core +web applications. It includes a high performance Virtual Machine as +well as the framework libraries used by .NET Core applications. + +ASP.NET Core is a fast, lightweight and modular platform for creating +cross platform web applications that work on Linux, Mac and Windows. + +It particularly focuses on creating console applications, web +applications and micro-services. + + +%package -n dotnet-templates-3.1 + +Version: %{sdk_rpm_version} +Summary: .NET Core 3.1 templates + +# Theoretically any version of the host should work. But lets aim for the one +# provided by this package, or from a newer version of .NET Core +Requires: dotnet-host%{?_isa} >= %{host_rpm_version}-%{release} + +%description -n dotnet-templates-3.1 +This package contains templates used by the .NET Core SDK. + +ASP.NET Core is a fast, lightweight and modular platform for creating +cross platform web applications that work on Linux, Mac and Windows. + +It particularly focuses on creating console applications, web +applications and micro-services. + + +%package -n dotnet-sdk-3.1 + +Version: %{sdk_rpm_version} +Summary: .NET Core 3.1 Software Development Kit + +Provides: bundled(js-jquery) +Provides: bundled(npm) + +Requires: dotnet-runtime-3.1%{?_isa} >= %{runtime_rpm_version}-%{release} +Requires: aspnetcore-runtime-3.1%{?_isa} >= %{aspnetcore_runtime_rpm_version}-%{release} + +Requires: dotnet-apphost-pack-3.1%{?_isa} >= %{runtime_rpm_version}-%{release} +Requires: dotnet-targeting-pack-3.1%{?_isa} >= %{runtime_rpm_version}-%{release} +Requires: aspnetcore-targeting-pack-3.1%{?_isa} >= %{aspnetcore_runtime_rpm_version}-%{release} +Requires: netstandard-targeting-pack-2.1%{?_isa} >= %{sdk_rpm_version}-%{release} + +Requires: dotnet-templates-3.1%{?_isa} >= %{sdk_rpm_version}-%{release} + +%description -n dotnet-sdk-3.1 +The .NET Core SDK is a collection of command line applications to +create, build, publish and run .NET Core applications. + +.NET Core is a fast, lightweight and modular platform for creating +cross platform applications that work on Linux, Mac and Windows. + +It particularly focuses on creating console applications, web +applications and micro-services. + + +%global dotnet_targeting_pack() %{expand: +%package -n %{1} + +Version: %{2} +Summary: Targeting Pack for %{3} %{4} + +Requires: dotnet-host%{?_isa} + +%description -n %{1} +This package provides a targeting pack for %{3} %{4} +that allows developers to compile against and target %{3} %{4} +applications using the .NET Core SDK. + +%files -n %{1} +%dir %{_libdir}/dotnet/packs +%{_libdir}/dotnet/packs/%{5} +} + +%dotnet_targeting_pack dotnet-apphost-pack-3.1 %{runtime_rpm_version} Microsoft.NETCore.App 3.1 Microsoft.NETCore.App.Host.%{runtime_id} +%dotnet_targeting_pack dotnet-targeting-pack-3.1 %{runtime_rpm_version} Microsoft.NETCore.App 3.1 Microsoft.NETCore.App.Ref +%dotnet_targeting_pack aspnetcore-targeting-pack-3.1 %{aspnetcore_runtime_rpm_version} Microsoft.AspNetCore.App 3.1 Microsoft.AspNetCore.App.Ref +%dotnet_targeting_pack netstandard-targeting-pack-2.1 %{sdk_rpm_version} NETStandard.Library 2.1 NETStandard.Library.Ref + + +%package -n dotnet-sdk-3.1-source-built-artifacts + +Version: %{sdk_rpm_version} +Summary: Internal package for building .NET Core 3.1 Software Development Kit + +%description -n dotnet-sdk-3.1-source-built-artifacts +The .NET Core source-built archive is a collection of packages needed +to build the .NET Core SDK itself. + +These are not meant for general use. + + +%prep +%setup -q -n dotnet-v%{sdk_version}-SDK + +%if %{without bootstrap} +# Remove all prebuilts +find -iname '*.dll' -type f -delete +find -iname '*.so' -type f -delete +find -iname '*.tar.gz' -type f -delete +find -iname '*.nupkg' -type f -delete +find -iname '*.zip' -type f -delete +rm -r .dotnet/ +rm -r packages/source-built +%endif + +%if %{without bootstrap} +sed -i -e 's|3.1.100-preview1-014459|3.1.101|' global.json +mkdir -p packages/archive +ln -s %{_libdir}/dotnet/source-built-artifacts/*.tar.gz packages/archive/ +ln -s %{_libdir}/dotnet/reference-packages/Private.SourceBuild.ReferencePackages*.tar.gz packages/archive +%endif + +# Fix bad hardcoded path in build +sed -i 's|/usr/share/dotnet|%{_libdir}/dotnet|' src/dotnet-core-setup.*/src/corehost/common/pal.unix.cpp + +# Disable warnings +sed -i 's|skiptests|skiptests ignorewarnings|' repos/coreclr.proj + +pushd src/corefx.* +%patch100 -p1 +%patch101 -p1 +%patch102 -p1 +%patch103 -p1 +popd + +pushd src/coreclr.* +%patch200 -p1 +popd + +pushd src/dotnet-core-setup.* +%patch300 -p1 +popd + +pushd src/dotnet-cli.* +%patch500 -p1 +popd + +# If CLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE is misisng, add it back +grep CLR_CMAKE_USE_SYSTEM_LIBUNWIND repos/coreclr.proj || \ + sed -i 's|\$(BuildArguments) |$(BuildArguments) cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE|' repos/coreclr.proj + +%if %{use_bundled_libunwind} +sed -i 's|-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE|-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=FALSE|' repos/coreclr.proj +%endif + +cat source-build-info.txt + +find -iname 'nuget.config' -exec echo {}: \; -exec cat {} \; -exec echo \; + + +%build +cat /etc/os-release + +%if %{without bootstrap} +cp -a %{_libdir}/dotnet .dotnet +%endif + +export CFLAGS="%{dotnet_cflags}" +export CXXFLAGS="%{dotnet_cflags}" +export LDFLAGS="%{dotnet_ldflags}" + +VERBOSE=1 ./build.sh \ + /v:n \ + /p:LogVerbosity=n \ + /p:MinimalConsoleLogOutput=false \ + /p:ContinueOnPrebuiltBaselineError=true \ + + +sed -e 's|[@]LIBDIR[@]|%{_libdir}|g' %{SOURCE2} > dotnet.sh + + +%install +install -dm 0755 %{buildroot}%{_libdir}/dotnet +ls bin/%{runtime_arch}/Release +tar xf bin/%{runtime_arch}/Release/dotnet-sdk-%{sdk_version}-%{runtime_id}.tar.gz -C %{buildroot}%{_libdir}/dotnet/ + +# Install managed symbols +tar xf bin/%{runtime_arch}/Release/runtime/dotnet-runtime-symbols-%{runtime_version}-%{runtime_id}.tar.gz \ + -C %{buildroot}/%{_libdir}/dotnet/shared/Microsoft.NETCore.App/%{runtime_version}/ + +# Fix executable permissions on files +find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.dll' -exec chmod -x {} \; +find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.pdb' -exec chmod -x {} \; +find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.props' -exec chmod -x {} \; +find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.pubxml' -exec chmod -x {} \; +find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.targets' -exec chmod -x {} \; +chmod 0755 %{buildroot}/%{_libdir}/dotnet/sdk/%{sdk_version}/AppHostTemplate/apphost +chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/libnethost.so +chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/apphost +chmod 0644 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/nethost.h +chmod 0644 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.AspNetCore.App.Ref/3.1.0/obj/Microsoft.AspNetCore.App.Ref.csproj.nuget.cache +chmod 0644 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.AspNetCore.App.Ref/3.1.0/Microsoft.AspNetCore.App.Ref/3.1.0/Debug/netstandard2.0/Microsoft.AspNetCore.App.Ref.assets.cache + +install -dm 0755 %{buildroot}%{_sysconfdir}/profile.d/ +install dotnet.sh %{buildroot}%{_sysconfdir}/profile.d/ + +install -dm 0755 %{buildroot}/%{_datadir}/bash-completion/completions +# dynamic completion needs the file to be named the same as the base command +install src/dotnet-cli.*/scripts/register-completions.bash %{buildroot}/%{_datadir}/bash-completion/completions/dotnet + +# TODO: the zsh completion script needs to be ported to use #compdef +#install -dm 755 %%{buildroot}/%%{_datadir}/zsh/site-functions +#install src/cli/scripts/register-completions.zsh %%{buildroot}/%%{_datadir}/zsh/site-functions/_dotnet + +install -dm 0755 %{buildroot}%{_bindir} +ln -s ../../%{_libdir}/dotnet/dotnet %{buildroot}%{_bindir}/ + +install -dm 0755 %{buildroot}%{_mandir}/man1/ +find -iname 'dotnet*.1' -type f -exec cp {} %{buildroot}%{_mandir}/man1/ \; + +echo "%{_libdir}/dotnet" >> install_location +install -dm 0755 %{buildroot}%{_sysconfdir}/dotnet +install install_location %{buildroot}%{_sysconfdir}/dotnet/ + +install -dm 0755 %{buildroot}%{_libdir}/dotnet/source-built-artifacts +install bin/%{runtime_arch}/Release/Private.SourceBuilt.Artifacts.*.tar.gz %{buildroot}/%{_libdir}/dotnet/source-built-artifacts/ + +# Check debug symbols in all elf objects. This is not in %%check +# because native binaries are stripped by rpm-build after %%install. +# So we need to do this check earlier. +echo "Testing build results for debug symbols..." +%{SOURCE1} -v %{buildroot}%{_libdir}/dotnet/ + + +%check +%{buildroot}%{_libdir}/dotnet/dotnet --info + + +%files -n dotnet +# empty package useful for dependencies + +%files -n dotnet-host +%dir %{_libdir}/dotnet +%{_libdir}/dotnet/dotnet +%dir %{_libdir}/dotnet/host +%dir %{_libdir}/dotnet/host/fxr +%{_bindir}/dotnet +%license %{_libdir}/dotnet/LICENSE.txt +%license %{_libdir}/dotnet/ThirdPartyNotices.txt +%doc %{_mandir}/man1/dotnet*.1.gz +%{_sysconfdir}/profile.d/dotnet.sh +%{_sysconfdir}/dotnet +%dir %{_datadir}/bash-completion +%dir %{_datadir}/bash-completion/completions +%{_datadir}/bash-completion/completions/dotnet + +%files -n dotnet-hostfxr-3.1 +%dir %{_libdir}/dotnet/host/fxr +%{_libdir}/dotnet/host/fxr/%{host_version} + +%files -n dotnet-runtime-3.1 +%dir %{_libdir}/dotnet/shared +%dir %{_libdir}/dotnet/shared/Microsoft.NETCore.App +%{_libdir}/dotnet/shared/Microsoft.NETCore.App/%{runtime_version} + +%files -n aspnetcore-runtime-3.1 +%dir %{_libdir}/dotnet/shared +%dir %{_libdir}/dotnet/shared/Microsoft.AspNetCore.App +%{_libdir}/dotnet/shared/Microsoft.AspNetCore.App/%{aspnetcore_runtime_version} + +%files -n dotnet-templates-3.1 +%dir %{_libdir}/dotnet/templates +%{_libdir}/dotnet/templates/%{templates_version} + +%files -n dotnet-sdk-3.1 +%dir %{_libdir}/dotnet/sdk +%{_libdir}/dotnet/sdk/%{sdk_version} +%dir %{_libdir}/dotnet/packs + +%files -n dotnet-sdk-3.1-source-built-artifacts +%dir %{_libdir}/dotnet +%{_libdir}/dotnet/source-built-artifacts + + +%changelog +* Tue Jan 21 2020 Omair Majid - 3.1.101-1 +- Update to .NET Core Runtime 3.1.1 and SDK 3.1.101 + +* Thu Dec 05 2019 Omair Majid - 3.1.100-1 +- Update to .NET Core Runtime 3.1.0 and SDK 3.1.100 + +* Mon Nov 18 2019 Omair Majid - 3.1.100-0.4.preview3 +- Fix apphost permissions + +* Fri Nov 15 2019 Omair Majid - 3.1.100-0.3.preview3 +- Update to .NET Core Runtime 3.1.0-preview3.19553.2 and SDK + 3.1.100-preview3-014645 + +* Wed Nov 06 2019 Omair Majid - 3.1.100-0.2 +- Update to .NET Core 3.1 Preview 2 + +* Wed Oct 30 2019 Omair Majid - 3.1.100-0.1 +- Update to .NET Core 3.1 Preview 1 + +* Thu Oct 24 2019 Omair Majid - 3.0.100-5 +- Add cgroupv2 support to .NET Core + +* Wed Oct 16 2019 Omair Majid - 3.0.100-4 +- Include fix from coreclr for building on Fedora 32 + +* Wed Oct 16 2019 Omair Majid - 3.0.100-3 +- Harden built binaries to pass annocheck + +* Fri Oct 11 2019 Omair Majid - 3.0.100-2 +- Export DOTNET_ROOT in profile to make apphost lookup work + +* Fri Sep 27 2019 Omair Majid - 3.0.100-1 +- Update to .NET Core Runtime 3.0.0 and SDK 3.0.100 + +* Wed Sep 25 2019 Omair Majid - 3.0.100-0.18.rc1 +- Update to .NET Core Runtime 3.0.0-rc1-19456-20 and SDK 3.0.100-rc1-014190 + +* Tue Sep 17 2019 Omair Majid - 3.0.100-0.16.preview9 +- Fix files duplicated between dotnet-apphost-pack-3.0 and dotnet-targeting-pack-3.0 +- Fix dependencies between .NET SDK and the targeting packs + +* Mon Sep 16 2019 Omair Majid - 3.0.100-0.15.preview9 +- Update to .NET Core Runtime 3.0.0-preview 9 and SDK 3.0.100-preview9 + +* Mon Aug 19 2019 Omair Majid - 3.0.100-0.11.preview8 +- Update to .NET Core Runtime 3.0.0-preview8-28405-07 and SDK + 3.0.100-preview8-013656 + +* Tue Jul 30 2019 Omair Majid - 3.0.100-0.9.preview7 +- Update to .NET Core Runtime 3.0.0-preview7-27912-14 and SDK + 3.0.100-preview7-012821 + +* Fri Jul 26 2019 Omair Majid - 3.0.100-0.8.preview7 +- Update to .NET Core Runtime 3.0.0-preview7-27902-19 and SDK + 3.0.100-preview7-012802 + +* Wed Jun 26 2019 Omair Majid - 3.0.0-0.7.preview6 +- Obsolete dotnet-sdk-3.0.1xx +- Add supackages for targeting packs +- Add -fcf-protection to CFLAGS + +* Wed Jun 26 2019 Omair Majid - 3.0.0-0.6.preview6 +- Update to .NET Core Runtime 3.0.0-preview6-27804-01 and SDK 3.0.100-preview6-012264 +- Set dotnet installation location in /etc/dotnet/install_location +- Update targeting packs +- Install managed symbols +- Completely conditionalize libunwind bundling + +* Tue May 07 2019 Omair Majid - 3.0.0-0.3.preview4 +- Update to .NET Core 3.0 preview 4 + +* Tue Dec 18 2018 Omair Majid - 3.0.0-0.1.preview1 +- Update to .NET Core 3.0 preview 1 + +* Fri Dec 07 2018 Omair Majid - 2.2.100 +- Update to .NET Core 2.2.0 + +* Wed Nov 07 2018 Omair Majid - 2.2.100-0.2.preview3 +- Update to .NET Core 2.2.0-preview3 + +* Fri Nov 02 2018 Omair Majid - 2.1.403-3 +- Add host-fxr-2.1 subpackage + +* Mon Oct 15 2018 Omair Majid - 2.1.403-2 +- Disable telemetry by default +- Users have to manually export DOTNET_CLI_TELEMETRY_OPTOUT=0 to enable + +* Tue Oct 02 2018 Omair Majid - 2.1.403-1 +- Update to .NET Core Runtime 2.1.5 and SDK 2.1.403 + +* Wed Sep 26 2018 Omair Majid - 2.1.402-2 +- Add ~/.dotnet/tools to $PATH to make it easier to use dotnet tools + +* Thu Sep 13 2018 Omair Majid - 2.1.402-1 +- Update to .NET Core Runtime 2.1.4 and SDK 2.1.402 + +* Wed Sep 05 2018 Omair Majid - 2.1.401-2 +- Use distro-standard flags when building .NET Core + +* Tue Aug 21 2018 Omair Majid - 2.1.401-1 +- Update to .NET Core Runtime 2.1.3 and SDK 2.1.401 + +* Mon Aug 20 2018 Omair Majid - 2.1.302-1 +- Update to .NET Core Runtime 2.1.2 and SDK 2.1.302 + +* Fri Jul 20 2018 Omair Majid - 2.1.301-1 +- Update to .NET Core 2.1 + +* Thu May 03 2018 Omair Majid - 2.0.7-1 +- Update to .NET Core 2.0.7 + +* Wed Mar 28 2018 Omair Majid - 2.0.6-2 +- Enable bash completion for dotnet +- Remove redundant buildrequires and requires + +* Wed Mar 14 2018 Omair Majid - 2.0.6-1 +- Update to .NET Core 2.0.6 + +* Fri Feb 23 2018 Omair Majid - 2.0.5-1 +- Update to .NET Core 2.0.5 + +* Wed Jan 24 2018 Omair Majid - 2.0.3-5 +- Don't apply corefx clang warnings fix on clang < 5 + +* Fri Jan 19 2018 Omair Majid - 2.0.3-4 +- Add a test script to sanity check debug and symbol info. +- Build with clang 5.0 +- Make main package real instead of using a virtual provides (see RHBZ 1519325) + +* Wed Nov 29 2017 Omair Majid - 2.0.3-3 +- Add a Provides for 'dotnet' +- Fix conditional macro + +* Tue Nov 28 2017 Omair Majid - 2.0.3-2 +- Fix build on Fedora 27 + +* Fri Nov 17 2017 Omair Majid - 2.0.3-1 +- Update to .NET Core 2.0.3 + +* Thu Oct 19 2017 Omair Majid - 2.0.0-4 +- Add a hack to let omnisharp work + +* Wed Aug 30 2017 Omair Majid - 2.0.0-3 +- Add a patch for building coreclr and core-setup correctly on Fedora >= 27 + +* Fri Aug 25 2017 Omair Majid - 2.0.0-2 +- Move libicu/libcurl/libunwind requires to runtime package +- Make sdk depend on the exact version of the runtime package + +* Thu Aug 24 2017 Omair Majid - 2.0.0-1 +- Update to 2.0.0 final release + +* Wed Jul 26 2017 Omair Majid - 2.0.0-0.3.preview2 +- Add man pages + +* Tue Jul 25 2017 Omair Majid - 2.0.0-0.2.preview2 +- Add Requires on libicu +- Split into multiple packages +- Do not repeat first-run message + +* Fri Jul 21 2017 Omair Majid - 2.0.0-0.1.preview2 +- Update to .NET Core 2.0 Preview 2 + +* Thu Mar 16 2017 Nemanja Milošević - 1.1.0-7 +- rebuilt with latest libldb +* Wed Feb 22 2017 Nemanja Milosevic - 1.1.0-6 +- compat-openssl 1.0 for F26 for now +* Sun Feb 19 2017 Nemanja Milosevic - 1.1.0-5 +- Fix wrong commit id's +* Sat Feb 18 2017 Nemanja Milosevic - 1.1.0-4 +- Use commit id's instead of branch names +* Sat Feb 18 2017 Nemanja Milosevic - 1.1.0-3 +- Improper patch5 fix +* Sat Feb 18 2017 Nemanja Milosevic - 1.1.0-2 +- SPEC cleanup +- git removal (using all tarballs for reproducible builds) +- more reasonable versioning +* Thu Feb 09 2017 Nemanja Milosevic - 1.1.0-1 +- Fixed debuginfo going to separate package (Patch1) +- Added F25/F26 RIL and fixed the version info (Patch2) +- Added F25/F26 RIL in Microsoft.NETCore.App suported runtime graph (Patch3) +- SPEC file cleanup +* Wed Jan 11 2017 Nemanja Milosevic - 1.1.0-0 +- Initial RPM for Fedora 25/26. + diff --git a/rename-tarball b/rename-tarball new file mode 100755 index 0000000..b6b6086 --- /dev/null +++ b/rename-tarball @@ -0,0 +1,49 @@ +#!/bin/bash + +# Usage: +# ./rename-tarball original-name.tar.gz new-name.tar.gz + +set -euo pipefail +IFS=$'\n\t' + +positional_args=() +while [[ "$#" -gt 0 ]]; do + arg="${1}" + case "${arg}" in + -h|--help) + print_usage + exit 0 + ;; + *) + positional_args+=("$1") + shift + ;; + esac +done + +original_name=${positional_args[0]:-} +if [[ -z ${original_name} ]]; then + echo "error: missing original tarball name" + exit 1 +fi + +new_name=${positional_args[1]:-} +if [[ -z ${new_name} ]]; then + echo "error: missing new tarball name" + exit 1 +fi + +original_name=${original_name/%.tar.gz} +new_name=${new_name/.tar.gz} + +echo "Original: ${original_name}.tar.gz" +echo "New name: ${new_name}.tar.gz" + +mkdir "temp-${new_name}" +pushd "temp-${new_name}" +tar xf "../${original_name}.tar.gz" +mv "${original_name}" "${new_name}" +tar czf ../"${new_name}.tar.gz" "${new_name}" +rm -rf "${new_name}" +popd +rmdir "temp-${new_name}" diff --git a/sources b/sources new file mode 100644 index 0000000..e5c1d68 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (dotnet-v3.1.101-SDK.tar.gz) = b2eb9df091186e793e82ac7560496c9ac3478e41efa94e58300606e2883d9bdb187f588a48a7bd9cf7f10f3d8f641d0867eb013de9b159e3d471a71dd823278c diff --git a/update-release b/update-release new file mode 100755 index 0000000..09eb509 --- /dev/null +++ b/update-release @@ -0,0 +1,62 @@ +#!/bin/bash + +# Usage: +# ./update-release runtime-version sdk-version + +set -euo pipefail +IFS=$'\n\t' + +print_usage() { + echo " Usage:" + echo " ./update-release runtime-version sdk-version" +} + +positional_args=() +while [[ "$#" -gt 0 ]]; do + arg="${1}" + case "${arg}" in + -h|--help) + print_usage + exit 0 + ;; + *) + positional_args+=("$1") + shift + ;; + esac +done + +spec_file=dotnet3.1.spec + +runtime_version=${positional_args[0]:-} +if [[ -z ${runtime_version} ]]; then + echo "error: missing runtime version" + exit 1 +fi +host_version="$runtime_version" + +sdk_version=${positional_args[1]:-} +if [[ -z ${sdk_version} ]]; then + echo "error: missing sdk version" + exit 1 +fi + +if [[ ! -f "dotnet-v${sdk_version}-SDK.tar.gz" ]]; then + ./build-dotnet-tarball "v${sdk_version}-SDK" +fi + +set -x + +sed -i -E "s|^%global host_version [[:digit:]]\.[[:digit:]]\.[[:digit:]]+|%global host_version ${host_version}|" "$spec_file" +sed -i -E "s|^%global runtime_version [[:digit:]]\.[[:digit:]]\.[[:digit:]]+|%global runtime_version ${runtime_version}|" "$spec_file" +sed -i -E "s|^%global sdk_version [[:digit:]]\.[[:digit:]]\.[[:digit:]][[:digit:]][[:digit:]]|%global sdk_version ${sdk_version}|" "$spec_file" + +comment="Update to .NET Core Runtime ${runtime_version} and SDK ${sdk_version}" + +rpmdev-bumpspec --comment="$comment" $spec_file + +# Reset release to 1 in 'Release' tag +sed -i -E 's|^Release: [[:digit:]]+%|Release: 1%|' $spec_file +# Reset Release in changelog comment +# See https://stackoverflow.com/questions/18620153/find-matching-text-and-replace-next-line +sed -i -E '/^%changelog$/!b;n;s/-[[:digit:]]+$/-1/' $spec_file From 39697ab889857504725b0798acddec3d7848bad7 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Wed, 26 Feb 2020 21:56:12 -0500 Subject: [PATCH 03/19] Fix build with clang 10 --- coreclr-clang10.patch | 54 +++++++++++++++++++++++++++++++++++++++++++ dotnet3.1.spec | 4 ++++ 2 files changed, 58 insertions(+) create mode 100644 coreclr-clang10.patch diff --git a/coreclr-clang10.patch b/coreclr-clang10.patch new file mode 100644 index 0000000..3b13cb1 --- /dev/null +++ b/coreclr-clang10.patch @@ -0,0 +1,54 @@ +diff --git a/configurecompiler.cmake b/configurecompiler.cmake +index d769e82f57..4936c8b00d 100644 +--- a/configurecompiler.cmake ++++ b/configurecompiler.cmake +@@ -474,6 +474,7 @@ if (CLR_CMAKE_PLATFORM_UNIX) + add_compile_options(-Wno-unused-variable) + add_compile_options(-Wno-unused-value) + add_compile_options(-Wno-unused-function) ++ add_compile_options(-Wno-error=misleading-indentation) + + #These seem to indicate real issues + add_compile_options($<$:-Wno-invalid-offsetof>) +diff --git a/src/inc/slist.h b/src/inc/slist.h +index f05d763dc6..abebe04d47 100644 +--- a/src/inc/slist.h ++++ b/src/inc/slist.h +@@ -160,13 +160,13 @@ public: + void Init() + { + LIMITED_METHOD_CONTRACT; +- m_pHead = &m_link; ++ m_pHead = PTR_SLink(&m_link); + // NOTE :: fHead variable is template argument + // the following code is a compiled in, only if the fHead flag + // is set to false, + if (!fHead) + { +- m_pTail = &m_link; ++ m_pTail = PTR_SLink(&m_link); + } + } + +@@ -274,7 +274,7 @@ public: + SLink *ret = SLink::FindAndRemove(m_pHead, GetLink(pObj), &prior); + + if (ret == m_pTail) +- m_pTail = prior; ++ m_pTail = PTR_SLink(prior); + + return GetObject(ret); + } +diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h +index 08a35c8f62..43eb648a14 100644 +--- a/src/pal/inc/pal.h ++++ b/src/pal/inc/pal.h +@@ -145,7 +145,7 @@ typedef PVOID NATIVE_LIBRARY_HANDLE; + + /******************* Compiler-specific glue *******************************/ + #ifndef THROW_DECL +-#if defined(_MSC_VER) || defined(__llvm__) || !defined(__cplusplus) ++#if defined(_MSC_VER) || !defined(__cplusplus) + #define THROW_DECL + #else + #define THROW_DECL throw() diff --git a/dotnet3.1.spec b/dotnet3.1.spec index 4536929..32d18ba 100644 --- a/dotnet3.1.spec +++ b/dotnet3.1.spec @@ -78,6 +78,8 @@ Patch103: corefx-39633-cgroupv2-mountpoints.patch # Build with with hardening flags, including -pie Patch200: coreclr-hardening-flags.patch +# Fix build with clang 10 +Patch201: coreclr-clang10.patch # Build with with hardening flags, including -pie Patch300: core-setup-hardening-flags.patch @@ -112,6 +114,7 @@ BuildRequires: lttng-ust-devel BuildRequires: make BuildRequires: openssl-devel BuildRequires: python3 +BuildRequires: systemtap-sdt-devel BuildRequires: tar BuildRequires: zlib-devel @@ -347,6 +350,7 @@ popd pushd src/coreclr.* %patch200 -p1 +%patch201 -p1 popd pushd src/dotnet-core-setup.* From b909e7156775b1d8c8ea7198c41f11eda135636a Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Thu, 27 Feb 2020 17:57:48 -0500 Subject: [PATCH 04/19] Disable bootstrap --- dotnet3.1.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dotnet3.1.spec b/dotnet3.1.spec index 32d18ba..7f89d4b 100644 --- a/dotnet3.1.spec +++ b/dotnet3.1.spec @@ -1,4 +1,4 @@ -%bcond_without bootstrap +%bcond_with bootstrap # Avoid provides/requires from private libraries %global privlibs libhostfxr @@ -56,7 +56,7 @@ Name: dotnet3.1 Version: %{sdk_rpm_version} -Release: 1%{?dist} +Release: 2%{?dist} Summary: .NET Core Runtime and SDK License: MIT and ASL 2.0 and BSD and LGPLv2+ and CC-BY and CC0 and MS-PL and EPL-1.0 and GPL+ and GPLv2 and ISC and OFL and zlib URL: https://github.com/dotnet/ @@ -499,6 +499,9 @@ echo "Testing build results for debug symbols..." %changelog +* Thu Feb 27 2020 Omair Majid - 3.1.101-2 +- Disable bootstrap + * Tue Jan 21 2020 Omair Majid - 3.1.101-1 - Update to .NET Core Runtime 3.1.1 and SDK 3.1.101 From 5a4961b806dc1de340a2b640d4a406d36fb00554 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Fri, 28 Feb 2020 10:22:16 -0500 Subject: [PATCH 05/19] Enable bootstrap and add Fedora 33 runtime ids --- corefx-42871-fedora-33-rid.patch | 124 +++++++++++++++++++++++++++++++ dotnet3.1.spec | 15 +++- sdk-rid.patch | 33 ++++++++ 3 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 corefx-42871-fedora-33-rid.patch create mode 100644 sdk-rid.patch diff --git a/corefx-42871-fedora-33-rid.patch b/corefx-42871-fedora-33-rid.patch new file mode 100644 index 0000000..2802dcd --- /dev/null +++ b/corefx-42871-fedora-33-rid.patch @@ -0,0 +1,124 @@ +From 6cf4ff086875eaf29381cf406ea85846d9f66178 Mon Sep 17 00:00:00 2001 +From: Omair Majid +Date: Mon, 24 Feb 2020 14:11:03 -0500 +Subject: [PATCH] Add Fedora 33 runtime ids + +Fedora 32 is gearing up for release[1], and in-development version of +Fedora has been offically labelled as being Fedora 33: + + $ podman run -it fedora:33 cat /etc/os-release + NAME=Fedora + VERSION="33 (Container Image)" + ID=fedora + VERSION_ID=33 + VERSION_CODENAME="" + PLATFORM_ID="platform:f33" + PRETTY_NAME="Fedora 33 (Container Image)" + ANSI_COLOR="0;34" + LOGO=fedora-logo-icon + CPE_NAME="cpe:/o:fedoraproject:fedora:33" + HOME_URL="https://fedoraproject.org/" + DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/rawhide/system-administrators-guide/" + SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help" + BUG_REPORT_URL="https://bugzilla.redhat.com/" + REDHAT_BUGZILLA_PRODUCT="Fedora" + REDHAT_BUGZILLA_PRODUCT_VERSION=rawhide + REDHAT_SUPPORT_PRODUCT="Fedora" + REDHAT_SUPPORT_PRODUCT_VERSION=rawhide + PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" + VARIANT="Container Image" + VARIANT_ID=container + +[1] https://fedorapeople.org/groups/schedule/f-32/f-32-key-tasks.html +--- + eng/Packaging.props | 2 +- + .../runtime.compatibility.json | 32 +++++++++++++++++++ + pkg/Microsoft.NETCore.Platforms/runtime.json | 17 ++++++++++ + .../runtimeGroups.props | 2 +- + src/packages.builds | 3 ++ + 5 files changed, 54 insertions(+), 2 deletions(-) + +diff --git a/pkg/Microsoft.NETCore.Platforms/runtime.compatibility.json b/pkg/Microsoft.NETCore.Platforms/runtime.compatibility.json +index 1e5c380a7a6a..c20e35394d6b 100644 +--- a/pkg/Microsoft.NETCore.Platforms/runtime.compatibility.json ++++ b/pkg/Microsoft.NETCore.Platforms/runtime.compatibility.json +@@ -953,6 +953,38 @@ + "any", + "base" + ], ++ "fedora.33": [ ++ "fedora.33", ++ "fedora", ++ "linux", ++ "unix", ++ "any", ++ "base" ++ ], ++ "fedora.33-arm64": [ ++ "fedora.33-arm64", ++ "fedora.33", ++ "fedora-arm64", ++ "fedora", ++ "linux-arm64", ++ "linux", ++ "unix-arm64", ++ "unix", ++ "any", ++ "base" ++ ], ++ "fedora.33-x64": [ ++ "fedora.33-x64", ++ "fedora.33", ++ "fedora-x64", ++ "fedora", ++ "linux-x64", ++ "linux", ++ "unix-x64", ++ "unix", ++ "any", ++ "base" ++ ], + "freebsd": [ + "freebsd", + "unix", +diff --git a/pkg/Microsoft.NETCore.Platforms/runtime.json b/pkg/Microsoft.NETCore.Platforms/runtime.json +index b2f286ea2479..b3380ecbbef3 100644 +--- a/pkg/Microsoft.NETCore.Platforms/runtime.json ++++ b/pkg/Microsoft.NETCore.Platforms/runtime.json +@@ -488,6 +488,23 @@ + "fedora-x64" + ] + }, ++ "fedora.33": { ++ "#import": [ ++ "fedora" ++ ] ++ }, ++ "fedora.33-arm64": { ++ "#import": [ ++ "fedora.33", ++ "fedora-arm64" ++ ] ++ }, ++ "fedora.33-x64": { ++ "#import": [ ++ "fedora.33", ++ "fedora-x64" ++ ] ++ }, + "freebsd": { + "#import": [ + "unix" +diff --git a/pkg/Microsoft.NETCore.Platforms/runtimeGroups.props b/pkg/Microsoft.NETCore.Platforms/runtimeGroups.props +index eeb8130b54fb..da48e5f9d09f 100644 +--- a/pkg/Microsoft.NETCore.Platforms/runtimeGroups.props ++++ b/pkg/Microsoft.NETCore.Platforms/runtimeGroups.props +@@ -43,7 +43,7 @@ + + linux + x64;arm64 +- 23;24;25;26;27;28;29;30;31;32 ++ 23;24;25;26;27;28;29;30;31;32;33 + false + + diff --git a/dotnet3.1.spec b/dotnet3.1.spec index 7f89d4b..7fc1ded 100644 --- a/dotnet3.1.spec +++ b/dotnet3.1.spec @@ -1,4 +1,4 @@ -%bcond_with bootstrap +%bcond_without bootstrap # Avoid provides/requires from private libraries %global privlibs libhostfxr @@ -56,7 +56,7 @@ Name: dotnet3.1 Version: %{sdk_rpm_version} -Release: 2%{?dist} +Release: 3%{?dist} Summary: .NET Core Runtime and SDK License: MIT and ASL 2.0 and BSD and LGPLv2+ and CC-BY and CC0 and MS-PL and EPL-1.0 and GPL+ and GPLv2 and ISC and OFL and zlib URL: https://github.com/dotnet/ @@ -67,6 +67,8 @@ Source0: dotnet-v%{sdk_version}-SDK.tar.gz Source1: check-debug-symbols.py Source2: dotnet.sh.in +Patch1: sdk-rid.patch + # Fix building with our additional CFLAGS/CXXFLAGS/LDFLAGS Patch100: corefx-optflags-support.patch @@ -76,6 +78,9 @@ Patch101: corefx-39686-cgroupv2-01.patch Patch102: corefx-39686-cgroupv2-02.patch Patch103: corefx-39633-cgroupv2-mountpoints.patch +# Add Fedora 33 RID to corefx +Patch104: corefx-42871-fedora-33-rid.patch + # Build with with hardening flags, including -pie Patch200: coreclr-hardening-flags.patch # Fix build with clang 10 @@ -346,6 +351,7 @@ pushd src/corefx.* %patch101 -p1 %patch102 -p1 %patch103 -p1 +%patch104 -p1 popd pushd src/coreclr.* @@ -379,6 +385,7 @@ cat /etc/os-release %if %{without bootstrap} cp -a %{_libdir}/dotnet .dotnet +patch -p0 -i %{PATCH1} %endif export CFLAGS="%{dotnet_cflags}" @@ -499,6 +506,10 @@ echo "Testing build results for debug symbols..." %changelog +* Fri Feb 28 2020 Omair Majid - 3.1.101-3 +- Enable bootstrap +- Add Fedora 33 runtime ids + * Thu Feb 27 2020 Omair Majid - 3.1.101-2 - Disable bootstrap diff --git a/sdk-rid.patch b/sdk-rid.patch new file mode 100644 index 0000000..85e97b5 --- /dev/null +++ b/sdk-rid.patch @@ -0,0 +1,33 @@ +--- .dotnet/sdk/3.1.101/RuntimeIdentifierGraph.json.orig 2020-02-27 19:48:57.286692828 -0500 ++++ .dotnet/sdk/3.1.101/RuntimeIdentifierGraph.json 2020-02-27 19:49:17.185262594 -0500 +@@ -488,6 +488,23 @@ + "fedora-x64" + ] + }, ++ "fedora.33": { ++ "#import": [ ++ "fedora" ++ ] ++ }, ++ "fedora.33-arm64": { ++ "#import": [ ++ "fedora.33", ++ "fedora-arm64" ++ ] ++ }, ++ "fedora.33-x64": { ++ "#import": [ ++ "fedora.33", ++ "fedora-x64" ++ ] ++ }, + "freebsd": { + "#import": [ + "unix" +@@ -2042,4 +2059,4 @@ + ] + } + } +-} +\ No newline at end of file ++} From 87d13ef02a3e031d50160e2fcc635465169b581f Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Fri, 28 Feb 2020 14:26:16 -0500 Subject: [PATCH 06/19] Disable bootstrap --- dotnet3.1.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dotnet3.1.spec b/dotnet3.1.spec index 7fc1ded..fe50a53 100644 --- a/dotnet3.1.spec +++ b/dotnet3.1.spec @@ -1,4 +1,4 @@ -%bcond_without bootstrap +%bcond_with bootstrap # Avoid provides/requires from private libraries %global privlibs libhostfxr @@ -56,7 +56,7 @@ Name: dotnet3.1 Version: %{sdk_rpm_version} -Release: 3%{?dist} +Release: 4%{?dist} Summary: .NET Core Runtime and SDK License: MIT and ASL 2.0 and BSD and LGPLv2+ and CC-BY and CC0 and MS-PL and EPL-1.0 and GPL+ and GPLv2 and ISC and OFL and zlib URL: https://github.com/dotnet/ @@ -506,6 +506,9 @@ echo "Testing build results for debug symbols..." %changelog +* Fri Feb 28 2020 Omair Majid - 3.1.101-4 +- Disable bootstrap + * Fri Feb 28 2020 Omair Majid - 3.1.101-3 - Enable bootstrap - Add Fedora 33 runtime ids From afa7f9a38cd8368e41e41309d6bd4fae20a0e3a5 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 16 Mar 2020 12:30:04 -0400 Subject: [PATCH 07/19] Update to .NET Core Runtime 3.1.2 and SDK 3.1.102 --- ...ang10.patch => build-coreclr-clang10.patch | 0 build-dotnet-tarball | 3 ++ dotnet3.1.spec | 37 ++++++++++++------- sdk-rid.patch | 4 +- update-release | 21 ++++++----- 5 files changed, 39 insertions(+), 26 deletions(-) rename coreclr-clang10.patch => build-coreclr-clang10.patch (100%) diff --git a/coreclr-clang10.patch b/build-coreclr-clang10.patch similarity index 100% rename from coreclr-clang10.patch rename to build-coreclr-clang10.patch diff --git a/build-dotnet-tarball b/build-dotnet-tarball index 0923778..ef7f742 100755 --- a/build-dotnet-tarball +++ b/build-dotnet-tarball @@ -92,6 +92,8 @@ if [ ! -f "${unmodified_tarball_name}.tar.gz" ]; then git submodule update --init --recursive clean_dotnet_cache sed -i -e 's|cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE||' repos/coreclr.proj + mkdir -p patches/coreclr/ + cp ../../build-coreclr-clang10.patch patches/coreclr ./build-source-tarball.sh "${unmodified_tarball_name}" popd popd @@ -108,6 +110,7 @@ mv "${unmodified_tarball_name}" "${tarball_name}" pushd "${tarball_name}" # Remove files with funny licenses, crypto implementations and other # not-very-useful artifacts to reduce tarball size +find -type f -iname '*.tar.gz' -delete rm -r src/AspNetCore.*/src/SignalR/clients/java/signalr/gradle* find src/AspNetCore.*/src -type d -name samples -print0 | xargs -0 rm -r rm -r src/NuGet.Client.*/test/EndToEnd/ProjectTemplates/NetCoreWebApplication1.0.zip diff --git a/dotnet3.1.spec b/dotnet3.1.spec index fe50a53..76a64b6 100644 --- a/dotnet3.1.spec +++ b/dotnet3.1.spec @@ -20,11 +20,11 @@ %global dotnet_cflags %(echo %optflags | sed -e 's/-fstack-clash-protection//' | sed -re 's/-specs=[^ ]*//g') %global dotnet_ldflags %(echo %{__global_ldflags} | sed -re 's/-specs=[^ ]*//g') -%global host_version 3.1.1 -%global runtime_version 3.1.1 +%global host_version 3.1.2 +%global runtime_version 3.1.2 %global aspnetcore_runtime_version %{runtime_version} -%global sdk_version 3.1.101 -%global templates_version %{runtime_version} +%global sdk_version 3.1.102 +%global templates_version %(echo %{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }') %global host_rpm_version %{host_version} %global aspnetcore_runtime_rpm_version %{aspnetcore_runtime_version} @@ -56,7 +56,7 @@ Name: dotnet3.1 Version: %{sdk_rpm_version} -Release: 4%{?dist} +Release: 1%{?dist} Summary: .NET Core Runtime and SDK License: MIT and ASL 2.0 and BSD and LGPLv2+ and CC-BY and CC0 and MS-PL and EPL-1.0 and GPL+ and GPLv2 and ISC and OFL and zlib URL: https://github.com/dotnet/ @@ -83,8 +83,8 @@ Patch104: corefx-42871-fedora-33-rid.patch # Build with with hardening flags, including -pie Patch200: coreclr-hardening-flags.patch -# Fix build with clang 10 -Patch201: coreclr-clang10.patch +# Fix build with clang 10; Already applied at tarball-build time +# Patch201: coreclr-clang10.patch # Build with with hardening flags, including -pie Patch300: core-setup-hardening-flags.patch @@ -341,7 +341,7 @@ ln -s %{_libdir}/dotnet/reference-packages/Private.SourceBuild.ReferencePackages %endif # Fix bad hardcoded path in build -sed -i 's|/usr/share/dotnet|%{_libdir}/dotnet|' src/dotnet-core-setup.*/src/corehost/common/pal.unix.cpp +sed -i 's|/usr/share/dotnet|%{_libdir}/dotnet|' src/core-setup.*/src/corehost/common/pal.unix.cpp # Disable warnings sed -i 's|skiptests|skiptests ignorewarnings|' repos/coreclr.proj @@ -356,14 +356,14 @@ popd pushd src/coreclr.* %patch200 -p1 -%patch201 -p1 +#%%patch201 -p1 popd -pushd src/dotnet-core-setup.* +pushd src/core-setup.* %patch300 -p1 popd -pushd src/dotnet-cli.* +pushd src/cli.* %patch500 -p1 popd @@ -392,8 +392,16 @@ export CFLAGS="%{dotnet_cflags}" export CXXFLAGS="%{dotnet_cflags}" export LDFLAGS="%{dotnet_ldflags}" +#%%if %%{without bootstrap} +# --with-ref-packages %%{_libdir}/dotnet/reference-packages/ \ +# --with-packages %%{_libdir}/dotnet/source-built-artifacts/*.tar.gz \ +# --with-sdk %%{_libdir}/dotnet \ +#%%endif + VERBOSE=1 ./build.sh \ + -- \ /v:n \ + /p:SkipPortableRuntimeBuild=true \ /p:LogVerbosity=n \ /p:MinimalConsoleLogOutput=false \ /p:ContinueOnPrebuiltBaselineError=true \ @@ -421,15 +429,13 @@ chmod 0755 %{buildroot}/%{_libdir}/dotnet/sdk/%{sdk_version}/AppHostTemplate/app chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/libnethost.so chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/apphost chmod 0644 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/nethost.h -chmod 0644 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.AspNetCore.App.Ref/3.1.0/obj/Microsoft.AspNetCore.App.Ref.csproj.nuget.cache -chmod 0644 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.AspNetCore.App.Ref/3.1.0/Microsoft.AspNetCore.App.Ref/3.1.0/Debug/netstandard2.0/Microsoft.AspNetCore.App.Ref.assets.cache install -dm 0755 %{buildroot}%{_sysconfdir}/profile.d/ install dotnet.sh %{buildroot}%{_sysconfdir}/profile.d/ install -dm 0755 %{buildroot}/%{_datadir}/bash-completion/completions # dynamic completion needs the file to be named the same as the base command -install src/dotnet-cli.*/scripts/register-completions.bash %{buildroot}/%{_datadir}/bash-completion/completions/dotnet +install src/cli.*/scripts/register-completions.bash %{buildroot}/%{_datadir}/bash-completion/completions/dotnet # TODO: the zsh completion script needs to be ported to use #compdef #install -dm 755 %%{buildroot}/%%{_datadir}/zsh/site-functions @@ -506,6 +512,9 @@ echo "Testing build results for debug symbols..." %changelog +* Mon Mar 16 2020 Omair Majid - 3.1.102-1 +- Update to .NET Core Runtime 3.1.2 and SDK 3.1.102 + * Fri Feb 28 2020 Omair Majid - 3.1.101-4 - Disable bootstrap diff --git a/sdk-rid.patch b/sdk-rid.patch index 85e97b5..99dda5b 100644 --- a/sdk-rid.patch +++ b/sdk-rid.patch @@ -1,5 +1,5 @@ ---- .dotnet/sdk/3.1.101/RuntimeIdentifierGraph.json.orig 2020-02-27 19:48:57.286692828 -0500 -+++ .dotnet/sdk/3.1.101/RuntimeIdentifierGraph.json 2020-02-27 19:49:17.185262594 -0500 +--- .dotnet/sdk/3.1.101/RuntimeIdentifierGraph.json ++++ .dotnet/sdk/3.1.101/RuntimeIdentifierGraph.json @@ -488,6 +488,23 @@ "fedora-x64" ] diff --git a/update-release b/update-release index 09eb509..d8bcde7 100755 --- a/update-release +++ b/update-release @@ -1,14 +1,14 @@ #!/bin/bash # Usage: -# ./update-release runtime-version sdk-version +# ./update-release sdk-version runtime-version set -euo pipefail IFS=$'\n\t' print_usage() { echo " Usage:" - echo " ./update-release runtime-version sdk-version" + echo " ./update-release sdk-version runtime-version" } positional_args=() @@ -28,19 +28,20 @@ done spec_file=dotnet3.1.spec -runtime_version=${positional_args[0]:-} -if [[ -z ${runtime_version} ]]; then - echo "error: missing runtime version" - exit 1 -fi -host_version="$runtime_version" - -sdk_version=${positional_args[1]:-} +sdk_version=${positional_args[0]:-} if [[ -z ${sdk_version} ]]; then echo "error: missing sdk version" exit 1 fi +runtime_version=${positional_args[1]:-} +if [[ -z ${runtime_version} ]]; then + echo "error: missing runtime version" + exit 1 +fi + +host_version="$runtime_version" + if [[ ! -f "dotnet-v${sdk_version}-SDK.tar.gz" ]]; then ./build-dotnet-tarball "v${sdk_version}-SDK" fi From 942e8b4298a91cc9da6eac84967cdffb5da062cd Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 16 Mar 2020 12:46:48 -0400 Subject: [PATCH 08/19] Upload sources --- .gitignore | 1 + sources | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 72735bd..1337900 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /dotnet-v3.1.101-SDK.tar.gz +/dotnet-v3.1.102-SDK.tar.gz diff --git a/sources b/sources index e5c1d68..9bc51e2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (dotnet-v3.1.101-SDK.tar.gz) = b2eb9df091186e793e82ac7560496c9ac3478e41efa94e58300606e2883d9bdb187f588a48a7bd9cf7f10f3d8f641d0867eb013de9b159e3d471a71dd823278c +SHA512 (dotnet-v3.1.102-SDK.tar.gz) = f46f54b996883ecced44d377e2052b59461781bd2a0c8453a31e90e6822998ca5e97957a4b16a2aa00f7e803c17ce68c2128b8aad9aa2e0a399b7b15ea5af168 From 115e095157e2dbe9e52bdba77dbffd7b9c262fa6 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Tue, 17 Mar 2020 10:08:19 -0400 Subject: [PATCH 09/19] Add testing and enable gating And enable building against itself. --- dotnet3.1.spec | 22 ++++++++++++---------- gating.yaml | 7 +++++++ sdk-rid.patch | 33 --------------------------------- tests/.fmf/version | 1 + tests/provision.fmf | 6 ++++++ tests/tests.yml | 38 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 64 insertions(+), 43 deletions(-) create mode 100644 gating.yaml delete mode 100644 sdk-rid.patch create mode 100644 tests/.fmf/version create mode 100644 tests/provision.fmf create mode 100644 tests/tests.yml diff --git a/dotnet3.1.spec b/dotnet3.1.spec index 76a64b6..c08312f 100644 --- a/dotnet3.1.spec +++ b/dotnet3.1.spec @@ -67,8 +67,6 @@ Source0: dotnet-v%{sdk_version}-SDK.tar.gz Source1: check-debug-symbols.py Source2: dotnet.sh.in -Patch1: sdk-rid.patch - # Fix building with our additional CFLAGS/CXXFLAGS/LDFLAGS Patch100: corefx-optflags-support.patch @@ -102,6 +100,7 @@ BuildRequires: dotnet-build-reference-packages BuildRequires: dotnet-sdk-3.1 BuildRequires: dotnet-sdk-3.1-source-built-artifacts %endif +BuildRequires: findutils BuildRequires: git %if 0%{?fedora} || 0%{?rhel} > 7 BuildRequires: glibc-langpack-en @@ -384,8 +383,8 @@ find -iname 'nuget.config' -exec echo {}: \; -exec cat {} \; -exec echo \; cat /etc/os-release %if %{without bootstrap} -cp -a %{_libdir}/dotnet .dotnet -patch -p0 -i %{PATCH1} +# We need to create a copy because we will mutate this +cp -a %{_libdir}/dotnet previously-built-dotnet %endif export CFLAGS="%{dotnet_cflags}" @@ -399,12 +398,15 @@ export LDFLAGS="%{dotnet_ldflags}" #%%endif VERBOSE=1 ./build.sh \ - -- \ - /v:n \ - /p:SkipPortableRuntimeBuild=true \ - /p:LogVerbosity=n \ - /p:MinimalConsoleLogOutput=false \ - /p:ContinueOnPrebuiltBaselineError=true \ +%if %{without bootstrap} + --with-sdk previously-built-dotnet \ +%endif + -- \ + /v:n \ + /p:SkipPortableRuntimeBuild=true \ + /p:LogVerbosity=n \ + /p:MinimalConsoleLogOutput=false \ + /p:ContinueOnPrebuiltBaselineError=true \ sed -e 's|[@]LIBDIR[@]|%{_libdir}|g' %{SOURCE2} > dotnet.sh diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..0d881de --- /dev/null +++ b/gating.yaml @@ -0,0 +1,7 @@ +--- !Policy +product_versions: + - fedora-* +decision_context: bodhi_update_push_testing +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} diff --git a/sdk-rid.patch b/sdk-rid.patch deleted file mode 100644 index 99dda5b..0000000 --- a/sdk-rid.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- .dotnet/sdk/3.1.101/RuntimeIdentifierGraph.json -+++ .dotnet/sdk/3.1.101/RuntimeIdentifierGraph.json -@@ -488,6 +488,23 @@ - "fedora-x64" - ] - }, -+ "fedora.33": { -+ "#import": [ -+ "fedora" -+ ] -+ }, -+ "fedora.33-arm64": { -+ "#import": [ -+ "fedora.33", -+ "fedora-arm64" -+ ] -+ }, -+ "fedora.33-x64": { -+ "#import": [ -+ "fedora.33", -+ "fedora-x64" -+ ] -+ }, - "freebsd": { - "#import": [ - "unix" -@@ -2042,4 +2059,4 @@ - ] - } - } --} -\ No newline at end of file -+} diff --git a/tests/.fmf/version b/tests/.fmf/version new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/.fmf/version @@ -0,0 +1 @@ +2 diff --git a/tests/provision.fmf b/tests/provision.fmf new file mode 100644 index 0000000..87b3807 --- /dev/null +++ b/tests/provision.fmf @@ -0,0 +1,6 @@ +--- + +standard-inventory-qcow2: + qemu: + m: 5G + diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..ede9095 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,38 @@ +--- +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + - container + - atomic + repositories: + - repo: "https://github.com/redhat-developer/dotnet-bunny.git" + dest: "dotnet-bunny" + - repo: "https://github.com/redhat-developer/dotnet-regular-tests.git" + dest: "dotnet-regular-tests" + tests: + - build_test_suite: + dir: dotnet-bunny + run: make + - print_test_suite_version: + dir: dotnet-bunny + run: bin/turkey --version + - run_regular_tests: + dir: dotnet-regular-tests + run: ../dotnet-bunny/bin/turkey -l={{ remote_artifacts }} + required_packages: + - babeltrace + - bash-completion + - binutils + - expect + - git + - jq + - lldb + - lttng-tools + - make + - npm + - python3 + - strace + - wget + - which From 835f5d753d45c6e638dc1519cd108a0a97bfa545 Mon Sep 17 00:00:00 2001 From: Chris Rummel Date: Thu, 9 Apr 2020 18:40:42 -0500 Subject: [PATCH 10/19] Update to 3.1.103 SDK and 3.1.3 runtime. - Update version numbers and sources. - Add CoreFx patch from PR#42900 to fix clang10 build. --- .gitignore | 1 + build-dotnet-tarball | 10 +++-- corefx-42900-clang-10.patch | 70 +++++++++++++++++++++++++++++++++++ corefx-optflags-support.patch | 3 +- dotnet3.1.spec | 21 +++++++---- sources | 2 +- 6 files changed, 94 insertions(+), 13 deletions(-) create mode 100644 corefx-42900-clang-10.patch diff --git a/.gitignore b/.gitignore index 1337900..6fa687b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /dotnet-v3.1.101-SDK.tar.gz /dotnet-v3.1.102-SDK.tar.gz +/dotnet-v3.1.103.2-SDK.tar.gz diff --git a/build-dotnet-tarball b/build-dotnet-tarball index ef7f742..3314c7e 100755 --- a/build-dotnet-tarball +++ b/build-dotnet-tarball @@ -94,7 +94,11 @@ if [ ! -f "${unmodified_tarball_name}.tar.gz" ]; then sed -i -e 's|cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE||' repos/coreclr.proj mkdir -p patches/coreclr/ cp ../../build-coreclr-clang10.patch patches/coreclr - ./build-source-tarball.sh "${unmodified_tarball_name}" + mkdir -p patches/corefx/ + cp ../../corefx-42900-clang-10.patch patches/corefx + cp -r /usr/lib64/dotnet "${temp_dir}" + ./build.sh --with-sdk ../dotnet /p:ArchiveDownloadedPackages=true + ./build-source-tarball.sh "${unmodified_tarball_name}" --skip-build --with-sdk ../dotnet popd popd @@ -111,8 +115,8 @@ pushd "${tarball_name}" # Remove files with funny licenses, crypto implementations and other # not-very-useful artifacts to reduce tarball size find -type f -iname '*.tar.gz' -delete -rm -r src/AspNetCore.*/src/SignalR/clients/java/signalr/gradle* -find src/AspNetCore.*/src -type d -name samples -print0 | xargs -0 rm -r +rm -r src/aspnetcore.*/src/SignalR/clients/java/signalr/gradle* +find src/aspnetcore.*/src -type d -name samples -print0 | xargs -0 rm -r rm -r src/NuGet.Client.*/test/EndToEnd/ProjectTemplates/NetCoreWebApplication1.0.zip find src/coreclr.*/ -depth -name tests -print0 | xargs -0 rm -r popd diff --git a/corefx-42900-clang-10.patch b/corefx-42900-clang-10.patch new file mode 100644 index 0000000..b898f34 --- /dev/null +++ b/corefx-42900-clang-10.patch @@ -0,0 +1,70 @@ +From 58d6cd09bd2d5b1085c6572c1d97b8533cf8294b Mon Sep 17 00:00:00 2001 +From: Omair Majid +Date: Fri, 3 Apr 2020 13:53:09 -0400 +Subject: [PATCH] Fix corefx to build on clang 10 + +Clang 10 adds/enables new warnings, some of which is affecting +the corefx code. + +Clang 10 has added -Walloca to warn about uses of alloca. This commit +replaces the only non-compliant use of that with a single fixed +stack-allocated buffer. + +Clang 10 has also added -Wimplicit-int-float-conversion. This commit +uses explicit casts to double to avoid the warnings. + +This is a backport of dotnet/runtime#33734 to corefx. + +After this commit, I can build all of corefx with Clang 10. +--- + src/Native/Unix/System.Native/pal_io.c | 20 +++++++++++--------- + src/Native/Unix/System.Native/pal_time.c | 2 +- + 2 files changed, 12 insertions(+), 10 deletions(-) + +diff --git a/src/Native/Unix/System.Native/pal_io.c b/src/Native/Unix/System.Native/pal_io.c +index 2d51edacf5ee..c7c42eb3e72b 100644 +--- a/src/Native/Unix/System.Native/pal_io.c ++++ b/src/Native/Unix/System.Native/pal_io.c +@@ -906,18 +906,20 @@ int32_t SystemNative_Poll(PollEvent* pollEvents, uint32_t eventCount, int32_t mi + return Error_EINVAL; + } + +- size_t bufferSize; +- if (!multiply_s(sizeof(struct pollfd), (size_t)eventCount, &bufferSize)) ++ struct pollfd stackBuffer[(uint32_t)(2048/sizeof(struct pollfd))]; ++ int useStackBuffer = eventCount <= (sizeof(stackBuffer)/sizeof(stackBuffer[0])); ++ struct pollfd* pollfds = NULL; ++ if (useStackBuffer) + { +- return SystemNative_ConvertErrorPlatformToPal(EOVERFLOW); ++ pollfds = (struct pollfd*)&stackBuffer[0]; + } +- +- +- int useStackBuffer = bufferSize <= 2048; +- struct pollfd* pollfds = (struct pollfd*)(useStackBuffer ? alloca(bufferSize) : malloc(bufferSize)); +- if (pollfds == NULL) ++ else + { +- return Error_ENOMEM; ++ pollfds = (struct pollfd*)calloc(eventCount, sizeof(*pollfds)); ++ if (pollfds == NULL) ++ { ++ return Error_ENOMEM; ++ } + } + + for (uint32_t i = 0; i < eventCount; i++) +diff --git a/src/Native/Unix/System.Native/pal_time.c b/src/Native/Unix/System.Native/pal_time.c +index 1a7c862749d1..54ebde60a83b 100644 +--- a/src/Native/Unix/System.Native/pal_time.c ++++ b/src/Native/Unix/System.Native/pal_time.c +@@ -169,7 +169,7 @@ int32_t SystemNative_GetCpuUtilization(ProcessCpuInformation* previousCpuInfo) + uint64_t resolution = SystemNative_GetTimestampResolution(); + uint64_t timestamp = SystemNative_GetTimestamp(); + +- uint64_t currentTime = (uint64_t)(timestamp * ((double)SecondsToNanoSeconds / resolution)); ++ uint64_t currentTime = (uint64_t)((double)timestamp * ((double)SecondsToNanoSeconds / (double)resolution)); + + uint64_t lastRecordedCurrentTime = previousCpuInfo->lastRecordedCurrentTime; + uint64_t lastRecordedKernelTime = previousCpuInfo->lastRecordedKernelTime; diff --git a/corefx-optflags-support.patch b/corefx-optflags-support.patch index 6f76d7f..9b08f1f 100644 --- a/corefx-optflags-support.patch +++ b/corefx-optflags-support.patch @@ -2,9 +2,10 @@ diff --git a/src/Native/Unix/CMakeLists.txt b/src/Native/Unix/CMakeLists.txt index 7d804a1e54..717c2718d7 100644 --- a/src/Native/Unix/CMakeLists.txt +++ b/src/Native/Unix/CMakeLists.txt -@@ -25,7 +25,6 @@ add_compile_options(-fPIC) +@@ -25,7 +25,7 @@ add_compile_options(-fPIC) add_compile_options(-Wthread-safety) add_compile_options(-Wno-thread-safety-analysis) ++ add_compile_options(-Wno-alloca) endif() -add_compile_options(-Werror) diff --git a/dotnet3.1.spec b/dotnet3.1.spec index c08312f..44ff8fb 100644 --- a/dotnet3.1.spec +++ b/dotnet3.1.spec @@ -20,10 +20,12 @@ %global dotnet_cflags %(echo %optflags | sed -e 's/-fstack-clash-protection//' | sed -re 's/-specs=[^ ]*//g') %global dotnet_ldflags %(echo %{__global_ldflags} | sed -re 's/-specs=[^ ]*//g') -%global host_version 3.1.2 -%global runtime_version 3.1.2 +%global host_version 3.1.3 +%global runtime_version 3.1.3 %global aspnetcore_runtime_version %{runtime_version} -%global sdk_version 3.1.102 +%global sdk_version 3.1.103 +# upstream respun this release, so the tag doesn't exactly match +%global src_version %{sdk_version}.2 %global templates_version %(echo %{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }') %global host_rpm_version %{host_version} @@ -62,8 +64,8 @@ License: MIT and ASL 2.0 and BSD and LGPLv2+ and CC-BY and CC0 and MS-PL URL: https://github.com/dotnet/ # The source is generated on a Fedora box via: -# ./build-dotnet-tarball v%%{sdk_version}-SDK -Source0: dotnet-v%{sdk_version}-SDK.tar.gz +# ./build-dotnet-tarball v%%{src_version}-SDK +Source0: dotnet-v%{src_version}-SDK.tar.gz Source1: check-debug-symbols.py Source2: dotnet.sh.in @@ -319,7 +321,7 @@ These are not meant for general use. %prep -%setup -q -n dotnet-v%{sdk_version}-SDK +%setup -q -n dotnet-v%{src_version}-SDK %if %{without bootstrap} # Remove all prebuilts @@ -328,12 +330,12 @@ find -iname '*.so' -type f -delete find -iname '*.tar.gz' -type f -delete find -iname '*.nupkg' -type f -delete find -iname '*.zip' -type f -delete -rm -r .dotnet/ +rm -rf .dotnet/ rm -r packages/source-built %endif %if %{without bootstrap} -sed -i -e 's|3.1.100-preview1-014459|3.1.101|' global.json +sed -i -e 's|3.1.100-preview1-014459|3.1.102|' global.json mkdir -p packages/archive ln -s %{_libdir}/dotnet/source-built-artifacts/*.tar.gz packages/archive/ ln -s %{_libdir}/dotnet/reference-packages/Private.SourceBuild.ReferencePackages*.tar.gz packages/archive @@ -514,6 +516,9 @@ echo "Testing build results for debug symbols..." %changelog +* Thu Apr 09 2020 Chris Rummel - 3.1.103-1 +- Update to .NET Core Runtime 3.1.3 and SDK 3.1.103 + * Mon Mar 16 2020 Omair Majid - 3.1.102-1 - Update to .NET Core Runtime 3.1.2 and SDK 3.1.102 diff --git a/sources b/sources index 9bc51e2..6762903 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (dotnet-v3.1.102-SDK.tar.gz) = f46f54b996883ecced44d377e2052b59461781bd2a0c8453a31e90e6822998ca5e97957a4b16a2aa00f7e803c17ce68c2128b8aad9aa2e0a399b7b15ea5af168 +SHA512 (dotnet-v3.1.103.2-SDK.tar.gz) = 6c4de4914f6d107e59300efb43fae24fffdbb983a5ffeb36fbe26c8071a87e76162ebde0f0aa270ab7cbb666b4ee0ab65cfab98f1dbba2ea9d48809372417ec2 From 2236128d3ef9488a2c9fd503322a1d7910ef28f0 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Fri, 10 Apr 2020 12:29:37 -0400 Subject: [PATCH 11/19] Add some documentation to the empty README --- README.md | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d35adc1..816aba3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,133 @@ -# dotnet3.1 +# Overview -The dotnet3.1 package \ No newline at end of file +This is the .NET Core 3.1 package for Fedora. + +This package is maintained by the Fedora DotNet SIG (Special Interest +Group). You can find out more about the DotNet SIG at: + +- https://fedoraproject.org/wiki/SIGs/DotNet +- https://fedoraproject.org/wiki/DotNet +- https://lists.fedoraproject.org/archives/list/dotnet-sig@lists.fedoraproject.org/ + +Please report any issues [using +bugzilla](https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=dotnet3.1). + +# Specification + +This package follows [package naming and contents suggested by +upstream](https://docs.microsoft.com/en-us/dotnet/core/build/distribution-packaging), +with one exception. It installs dotnet to `/usr/lib64/dotnet` (aka +`%{_libdir}`). + +# Contributing + +## General Changes + +1. Fork the repo. + +2. Checkout the forked repository. + + - `git clone ssh://$USER@pkgs.fedoraproject.org/forks/$USER/rpms/dotnet3.1.git` + - `cd dotnet3.1` + +3. Make your changes. Don't forget to add a changelog. + +4. Do local builds. + + - `fedpkg local` + +5. Fix any errors that come up and rebuild until it works locally. + +6. Do builds in koji. + + - `fedpkg scratch-build --srpm` + +8. Commit the changes to the git repo. + + - `git add` any new patches + - `git remove` any now-unnecessary patches + - `git commit -a` + - `git push` + +9. Create a pull request with your changes. + +10. Once the tests in the pull-request pass, and reviewers are happy, do a real + build. + + - `fedpkg build` + +11. For non-rawhide releases, file updates using bodhi to ship the just-built + package out to users. + + - https://bodhi.fedoraproject.org/updates/new + + OR + + - `fedpkg update` + +## Updating to an new upstream release + +1. Fork the repo. + +2. Checkout the forked repository. + + - `git clone ssh://$USER@pkgs.fedoraproject.org/forks/$USER/rpms/dotnet3.1.git` + - `cd dotnet3.1` + +3. Build the new upstream source tarball. Update the versions in the + spec file. Add a changelog. This is generally automated by the + following. + + - `./update-release ` + + If this fails because of compiler errors, you might have to figure + out a fix, then add the patch in `build-dotnet-tarball` script + rather than the spec file. + +4. Do local builds. + + - `fedpkg local` + +5. Fix any errors that come up and rebuild until it works locally. Any + patches that are needed at this point should be added to the spec file. + +6. Do builds in koji. + + - `fedpkg scratch-build --srpm` + +7. Upload the source archive to the Fedora look-aside cache. + + - `fedpkg new-sources path-to-generated-dotnet-source-tarball.tar.gz` + +8. Commit the changes to the git repo. + + - `git add` any new patches + - `git remove` any now-unnecessary patches + - `git commit -a` + - `git push` + +9. Create a pull request with your changes. + +10. Once the tests in the pull-request pass, and reviewers are happy, do a real + build. + + - `fedpkg build` + +11. For non-rawhide releases, file updates using bodhi to ship the just-built + package out to users. + + - https://bodhi.fedoraproject.org/updates/new + + OR + + - `fedpkg update` + +# Testing + +This package uses CI tests as defined in `tests/test.yml`. Creating a +pull-request or running a build will fire off tests and flag any issues. We have +enabled gating (via `gating.yaml`) on the tests. That prevents a build +that fails any test from being released until the failures are waived. + +The tests themselves are contained in this external repository: +https://github.com/redhat-developer/dotnet-regular-tests/ From ccec65f6fac2e9f96e34068fe4f31bf72648e1af Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 10 Aug 2020 11:10:29 -0400 Subject: [PATCH 12/19] Iniitial update to .NET 5.0 --- README.md | 12 +- build-bootstrap-tarball | 50 + build-coreclr-clang10.patch | 54 - build-dotnet-tarball | 19 +- copr-build | 11 + core-setup-hardening-flags.patch | 11 - coreclr-hardening-flags.patch | 11 - corefx-39633-cgroupv2-mountpoints.patch | 46 - corefx-39686-cgroupv2-01.patch | 391 ------ corefx-39686-cgroupv2-02.patch | 129 -- corefx-42871-fedora-33-rid.patch | 124 -- corefx-42900-clang-10.patch | 70 - corefx-optflags-support.patch | 40 - dotnet3.1.spec => dotnet5.0.spec | 224 ++-- runtime-39044-cmake-downgrade.patch | 1158 +++++++++++++++++ runtime-dont-strip.patch | 47 + runtime-flags-support.patch | 30 + ...optout.patch => sdk-telemetry-optout.patch | 6 +- sources | 1 - tests/tests.yml | 20 +- update-release | 2 +- 21 files changed, 1443 insertions(+), 1013 deletions(-) create mode 100755 build-bootstrap-tarball delete mode 100644 build-coreclr-clang10.patch create mode 100755 copr-build delete mode 100644 core-setup-hardening-flags.patch delete mode 100644 coreclr-hardening-flags.patch delete mode 100644 corefx-39633-cgroupv2-mountpoints.patch delete mode 100644 corefx-39686-cgroupv2-01.patch delete mode 100644 corefx-39686-cgroupv2-02.patch delete mode 100644 corefx-42871-fedora-33-rid.patch delete mode 100644 corefx-42900-clang-10.patch delete mode 100644 corefx-optflags-support.patch rename dotnet3.1.spec => dotnet5.0.spec (79%) create mode 100644 runtime-39044-cmake-downgrade.patch create mode 100644 runtime-dont-strip.patch create mode 100644 runtime-flags-support.patch rename cli-telemetry-optout.patch => sdk-telemetry-optout.patch (82%) delete mode 100644 sources diff --git a/README.md b/README.md index 816aba3..4d4fb58 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Overview -This is the .NET Core 3.1 package for Fedora. +This is the .NET Core 5.0 package for Fedora. This package is maintained by the Fedora DotNet SIG (Special Interest Group). You can find out more about the DotNet SIG at: @@ -10,7 +10,7 @@ Group). You can find out more about the DotNet SIG at: - https://lists.fedoraproject.org/archives/list/dotnet-sig@lists.fedoraproject.org/ Please report any issues [using -bugzilla](https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=dotnet3.1). +bugzilla](https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=dotnet5.0). # Specification @@ -27,8 +27,8 @@ with one exception. It installs dotnet to `/usr/lib64/dotnet` (aka 2. Checkout the forked repository. - - `git clone ssh://$USER@pkgs.fedoraproject.org/forks/$USER/rpms/dotnet3.1.git` - - `cd dotnet3.1` + - `git clone ssh://$USER@pkgs.fedoraproject.org/forks/$USER/rpms/dotnet5.0.git` + - `cd dotnet5.0` 3. Make your changes. Don't forget to add a changelog. @@ -71,8 +71,8 @@ with one exception. It installs dotnet to `/usr/lib64/dotnet` (aka 2. Checkout the forked repository. - - `git clone ssh://$USER@pkgs.fedoraproject.org/forks/$USER/rpms/dotnet3.1.git` - - `cd dotnet3.1` + - `git clone ssh://$USER@pkgs.fedoraproject.org/forks/$USER/rpms/dotnet5.0.git` + - `cd dotnet5.0` 3. Build the new upstream source tarball. Update the versions in the spec file. Add a changelog. This is generally automated by the diff --git a/build-bootstrap-tarball b/build-bootstrap-tarball new file mode 100755 index 0000000..d3f3547 --- /dev/null +++ b/build-bootstrap-tarball @@ -0,0 +1,50 @@ +#!/bin/bash + +set -euo pipefail + +set -x + +sdk_version=3.1.105 + +arch=$(uname -m) +if [[ $arch == "x86_64" ]]; then + arch=x64 +elif [[ $arch == "aarch64" ]]; then + arch=arm64 +fi + +if rpm -qa | grep libunwind; then + echo "error: libunwind is installed. Not a good idea for bootstrapping." + exit 1 +fi +if rpm -qa | grep dotnet ; then + echo "error: dotnet is installed. Not a good idea for bootstrapping." + exit 1 +fi +if [ -d /usr/lib/dotnet ] || [ -d /usr/lib64/dotnet ] || [ -d /usr/share/dotnet ] ; then + echo "error: one of /usr/lib/dotnet /usr/lib64/dotnet or /usr/share/dotnet/ exists. Not a good idea for bootstrapping." + exit 1 +fi +if command -v dotnet ; then + echo "error: dotnet is in $PATH. Not a good idea for bootstrapping." + exit 1 +fi + +if [ ! -d dotnet-source-build-tarball ]; then + if [ ! -d source-build ]; then + git clone https://github.com/dotnet/source-build + fi + pushd source-build + sed -i -e 's|cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE||' repos/coreclr.common.props + git clean -xdf + ./build-source-tarball.sh ../dotnet-source-build-tarball/ -- -p:DownloadSourceBuildReferencePackagesTimeoutSeconds=100000 + popd +fi + +rm -rf dotnet-v${sdk_version}-SDK dotnet-v${sdk_version}-SDK.tar.gz + +cp -a dotnet-source-build-tarball dotnet-v${sdk_version}-SDK +cp -a source-build/artifacts/$arch/Release/Private.SourceBuilt.Artifacts.*.tar.gz dotnet-v${sdk_version}-SDK/packages/archive/Private.SourceBuilt.Artifacts.*.tar.gz + +tar czf dotnet-v${sdk_version}-SDK-$arch.tar.gz dotnet-v${sdk_version}-SDK + diff --git a/build-coreclr-clang10.patch b/build-coreclr-clang10.patch deleted file mode 100644 index 3b13cb1..0000000 --- a/build-coreclr-clang10.patch +++ /dev/null @@ -1,54 +0,0 @@ -diff --git a/configurecompiler.cmake b/configurecompiler.cmake -index d769e82f57..4936c8b00d 100644 ---- a/configurecompiler.cmake -+++ b/configurecompiler.cmake -@@ -474,6 +474,7 @@ if (CLR_CMAKE_PLATFORM_UNIX) - add_compile_options(-Wno-unused-variable) - add_compile_options(-Wno-unused-value) - add_compile_options(-Wno-unused-function) -+ add_compile_options(-Wno-error=misleading-indentation) - - #These seem to indicate real issues - add_compile_options($<$:-Wno-invalid-offsetof>) -diff --git a/src/inc/slist.h b/src/inc/slist.h -index f05d763dc6..abebe04d47 100644 ---- a/src/inc/slist.h -+++ b/src/inc/slist.h -@@ -160,13 +160,13 @@ public: - void Init() - { - LIMITED_METHOD_CONTRACT; -- m_pHead = &m_link; -+ m_pHead = PTR_SLink(&m_link); - // NOTE :: fHead variable is template argument - // the following code is a compiled in, only if the fHead flag - // is set to false, - if (!fHead) - { -- m_pTail = &m_link; -+ m_pTail = PTR_SLink(&m_link); - } - } - -@@ -274,7 +274,7 @@ public: - SLink *ret = SLink::FindAndRemove(m_pHead, GetLink(pObj), &prior); - - if (ret == m_pTail) -- m_pTail = prior; -+ m_pTail = PTR_SLink(prior); - - return GetObject(ret); - } -diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h -index 08a35c8f62..43eb648a14 100644 ---- a/src/pal/inc/pal.h -+++ b/src/pal/inc/pal.h -@@ -145,7 +145,7 @@ typedef PVOID NATIVE_LIBRARY_HANDLE; - - /******************* Compiler-specific glue *******************************/ - #ifndef THROW_DECL --#if defined(_MSC_VER) || defined(__llvm__) || !defined(__cplusplus) -+#if defined(_MSC_VER) || !defined(__cplusplus) - #define THROW_DECL - #else - #define THROW_DECL throw() diff --git a/build-dotnet-tarball b/build-dotnet-tarball index 3314c7e..f32d847 100755 --- a/build-dotnet-tarball +++ b/build-dotnet-tarball @@ -91,14 +91,10 @@ if [ ! -f "${unmodified_tarball_name}.tar.gz" ]; then git checkout "${tag}" git submodule update --init --recursive clean_dotnet_cache - sed -i -e 's|cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE||' repos/coreclr.proj - mkdir -p patches/coreclr/ - cp ../../build-coreclr-clang10.patch patches/coreclr - mkdir -p patches/corefx/ - cp ../../corefx-42900-clang-10.patch patches/corefx - cp -r /usr/lib64/dotnet "${temp_dir}" - ./build.sh --with-sdk ../dotnet /p:ArchiveDownloadedPackages=true - ./build-source-tarball.sh "${unmodified_tarball_name}" --skip-build --with-sdk ../dotnet + sed -i -e 's|cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE||' repos/runtime.common.props + # FIXME remove contineuonprebuilterror + ./build.sh -p:SkipPrebuiltEnforcement=true -p:ContinueOnPrebuiltBaselineError=true -p:ArchiveDownloadedPackages=true + ./build-source-tarball.sh "${unmodified_tarball_name}" --skip-build -- -p:ContinueOnPrebuiltBaselineError=true -p:SkipPrebuiltEnforcement=true popd popd @@ -114,11 +110,12 @@ mv "${unmodified_tarball_name}" "${tarball_name}" pushd "${tarball_name}" # Remove files with funny licenses, crypto implementations and other # not-very-useful artifacts to reduce tarball size +rm -rf .dotnet find -type f -iname '*.tar.gz' -delete -rm -r src/aspnetcore.*/src/SignalR/clients/java/signalr/gradle* -find src/aspnetcore.*/src -type d -name samples -print0 | xargs -0 rm -r +rm -r src/AspNetCore.*/src/SignalR/clients/java/signalr/gradle* +find src/AspNetCore.*/src -type d -name samples -print0 | xargs -0 rm -r rm -r src/NuGet.Client.*/test/EndToEnd/ProjectTemplates/NetCoreWebApplication1.0.zip -find src/coreclr.*/ -depth -name tests -print0 | xargs -0 rm -r +find src/runtime.*/ -depth -name tests -print0 | xargs -0 rm -r popd tar czf "${tarball_name}.tar.gz" "${tarball_name}" diff --git a/copr-build b/copr-build new file mode 100755 index 0000000..8a7cf46 --- /dev/null +++ b/copr-build @@ -0,0 +1,11 @@ +#!/bin/bash + +set -euo pipefail + +set -x + +fedpkg --release f32 srpm 2>&1 | tee fedpkg.output + +srpm_name=$(grep 'Wrote: ' fedpkg.output | cut -d' ' -f 2) + +copr-cli build @dotnet-sig/dotnet-preview "${srpm_name}" diff --git a/core-setup-hardening-flags.patch b/core-setup-hardening-flags.patch deleted file mode 100644 index 3f6b91c..0000000 --- a/core-setup-hardening-flags.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff --git a/src/settings.cmake b/src/settings.cmake ---- a/src/settings.cmake -+++ b/src/settings.cmake -@@ -218,6 +218,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic -Bsymbolic-functions") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1") -+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") - add_compile_options(-fstack-protector-strong) - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - add_compile_options(-fstack-protector) diff --git a/coreclr-hardening-flags.patch b/coreclr-hardening-flags.patch deleted file mode 100644 index d58d735..0000000 --- a/coreclr-hardening-flags.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff --git a/src/debug/createdump/CMakeLists.txt b/src/debug/createdump/CMakeLists.txt ---- a/src/debug/createdump/CMakeLists.txt -+++ b/src/debug/createdump/CMakeLists.txt -@@ -21,6 +21,7 @@ include_directories(BEFORE ${VM_DIR}) - add_definitions(-DPAL_STDCPP_COMPAT) - - add_compile_options(-fPIE) -+add_link_options(-pie) - - set(CREATEDUMP_SOURCES - createdump.cpp diff --git a/corefx-39633-cgroupv2-mountpoints.patch b/corefx-39633-cgroupv2-mountpoints.patch deleted file mode 100644 index 34fbecb..0000000 --- a/corefx-39633-cgroupv2-mountpoints.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 1864630f762160e1cb439362cc0577471624192a Mon Sep 17 00:00:00 2001 -From: Omair Majid -Date: Fri, 19 Jul 2019 19:18:51 -0400 -Subject: [PATCH] Fix up cgroup2fs in Interop.MountPoints.FormatInfo - -`stat -fc %T /sys/fs/cgroup` calls this file system `cgroup2fs` - -Add the cgroup2fs file system magic number. Available from: - - - https://www.kernel.org/doc/Documentation/cgroup-v2.txt - - man 2 statfs - -Move cgroup2fs next to cgroupfs in the drive type list, since it is also -DriveType.Ram. ---- - .../Unix/System.Native/Interop.MountPoints.FormatInfo.cs | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs b/src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs -index af38a2285ba2..4240bd4853ab 100644 ---- a/src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs -+++ b/src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs -@@ -47,6 +47,7 @@ internal enum UnixFileSystemTypes : long - btrfs = 0x9123683E, - ceph = 0x00C36400, - cgroupfs = 0x0027E0EB, -+ cgroup2fs = 0x63677270, - cifs = 0xFF534D42, - coda = 0x73757245, - coherent = 0x012FF7B7, -@@ -231,7 +232,6 @@ private static DriveType GetDriveType(string fileSystemName) - case "bpf_fs": - case "btrfs": - case "btrfs_test": -- case "cgroup2fs": - case "coh": - case "daxfs": - case "drvfs": -@@ -384,6 +384,7 @@ private static DriveType GetDriveType(string fileSystemName) - case "binfmt_misc": - case "cgroup": - case "cgroupfs": -+ case "cgroup2fs": - case "configfs": - case "cramfs": - case "cramfs-wend": diff --git a/corefx-39686-cgroupv2-01.patch b/corefx-39686-cgroupv2-01.patch deleted file mode 100644 index e7628e2..0000000 --- a/corefx-39686-cgroupv2-01.patch +++ /dev/null @@ -1,391 +0,0 @@ -From 2b2273ea4ea1c28472fa0d6ad2ffeb6374500550 Mon Sep 17 00:00:00 2001 -From: Omair Majid -Date: Wed, 23 Oct 2019 17:45:59 -0400 -Subject: [PATCH 1/2] Add cgroup v2 support to Interop.cgroups - -Fix up code to adjust cgroup v1 assumptions and check cgroup v2 paths, -locations and values. - -Continue using the older cgroup v1 terminology for APIs. ---- - .../Interop/Linux/cgroups/Interop.cgroups.cs | 116 ++++++++++++++---- - src/Common/tests/Common.Tests.csproj | 4 + - .../tests/Tests/Interop/cgroupsTests.cs | 107 ++++++++++++++++ - .../tests/DescriptionNameTests.cs | 2 +- - 4 files changed, 206 insertions(+), 23 deletions(-) - create mode 100644 src/Common/tests/Tests/Interop/cgroupsTests.cs - -diff --git a/src/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs b/src/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs -index 0ffd4d7b7c03..186fe0516c5b 100644 ---- a/src/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs -+++ b/src/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs -@@ -9,17 +9,22 @@ - - internal static partial class Interop - { -+ /// Provides access to some cgroup (v1 and v2) features - internal static partial class cgroups - { -+ // For cgroup v1, see https://www.kernel.org/doc/Documentation/cgroup-v1/ -+ // For cgroup v2, see https://www.kernel.org/doc/Documentation/cgroup-v2.txt -+ -+ /// The version of cgroup that's being used -+ internal enum CGroupVersion { None, CGroup1, CGroup2 }; -+ - /// Path to mountinfo file in procfs for the current process. - private const string ProcMountInfoFilePath = "/proc/self/mountinfo"; - /// Path to cgroup directory in procfs for the current process. - private const string ProcCGroupFilePath = "/proc/self/cgroup"; - -- /// Path to the found cgroup location, or null if it couldn't be found. -- internal static readonly string s_cgroupMemoryPath = FindCGroupPath("memory"); -- /// Path to the found cgroup memory limit_in_bytes path, or null if it couldn't be found. -- private static readonly string s_cgroupMemoryLimitPath = s_cgroupMemoryPath != null ? s_cgroupMemoryPath + "/memory.limit_in_bytes" : null; -+ /// Path to the found cgroup memory limit path, or null if it couldn't be found. -+ internal static readonly string s_cgroupMemoryLimitPath = FindCGroupMemoryLimitPath(); - - /// Tries to read the memory limit from the cgroup memory location. - /// The read limit, or 0 if it couldn't be read. -@@ -42,7 +47,7 @@ public static bool TryGetMemoryLimit(out ulong limit) - /// The path to the file to parse. - /// The parsed result, or 0 if it couldn't be parsed. - /// true if the value was read successfully; otherwise, false. -- private static bool TryReadMemoryValueFromFile(string path, out ulong result) -+ internal static bool TryReadMemoryValueFromFile(string path, out ulong result) - { - if (File.Exists(path)) - { -@@ -79,6 +84,11 @@ private static bool TryReadMemoryValueFromFile(string path, out ulong result) - result = checked(ulongValue * multiplier); - return true; - } -+ -+ // 'max' is also a possible valid value -+ // -+ // Treat this as 'no memory limit' and let the caller -+ // fallback to reading the real limit via other means - } - catch (Exception e) - { -@@ -90,12 +100,35 @@ private static bool TryReadMemoryValueFromFile(string path, out ulong result) - return false; - } - -+ /// Find the cgroup memory limit path. -+ /// The limit path if found; otherwise, null. -+ private static string FindCGroupMemoryLimitPath() -+ { -+ string cgroupMemoryPath = FindCGroupPath("memory", out CGroupVersion version); -+ if (cgroupMemoryPath != null) -+ { -+ if (version == CGroupVersion.CGroup1) -+ { -+ return cgroupMemoryPath + "/memory.limit_in_bytes"; -+ } -+ -+ if (version == CGroupVersion.CGroup2) -+ { -+ // 'memory.high' is a soft limit; the process may get throttled -+ // 'memory.max' is where OOM killer kicks in -+ return cgroupMemoryPath + "/memory.max"; -+ } -+ } -+ -+ return null; -+ } -+ - /// Find the cgroup path for the specified subsystem. - /// The subsystem, e.g. "memory". - /// The cgroup path if found; otherwise, null. -- private static string FindCGroupPath(string subsystem) -+ private static string FindCGroupPath(string subsystem, out CGroupVersion version) - { -- if (TryFindHierarchyMount(subsystem, out string hierarchyRoot, out string hierarchyMount) && -+ if (TryFindHierarchyMount(subsystem, out version, out string hierarchyRoot, out string hierarchyMount) && - TryFindCGroupPathForSubsystem(subsystem, out string cgroupPathRelativeToMount)) - { - // For a host cgroup, we need to append the relative path. -@@ -113,19 +146,24 @@ private static string FindCGroupPath(string subsystem) - /// The path of the directory in the filesystem which forms the root of this mount; null if not found. - /// The path of the mount point relative to the process's root directory; null if not found. - /// true if the mount was found; otherwise, null. -- private static bool TryFindHierarchyMount(string subsystem, out string root, out string path) -+ private static bool TryFindHierarchyMount(string subsystem, out CGroupVersion version, out string root, out string path) - { -- if (File.Exists(ProcMountInfoFilePath)) -+ return TryFindHierarchyMount(ProcMountInfoFilePath, subsystem, out version, out root, out path); -+ } -+ -+ internal static bool TryFindHierarchyMount(string mountInfoFilePath, string subsystem, out CGroupVersion version, out string root, out string path) -+ { -+ if (File.Exists(mountInfoFilePath)) - { - try - { -- using (var reader = new StreamReader(ProcMountInfoFilePath)) -+ using (var reader = new StreamReader(mountInfoFilePath)) - { - string line; - while ((line = reader.ReadLine()) != null) - { - // Look for an entry that has cgroup as the "filesystem type" -- // and that has options containing the specified subsystem. -+ // and, for cgroup1, that has options containing the specified subsystem - // See man page for /proc/[pid]/mountinfo for details, e.g.: - // (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11) - // 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue -@@ -148,17 +186,35 @@ private static bool TryFindHierarchyMount(string subsystem, out string root, out - continue; - } - -- if (postSeparatorlineParts[0] != "cgroup" || -- Array.IndexOf(postSeparatorlineParts[2].Split(','), subsystem) < 0) -+ bool validCGroup1Entry = ((postSeparatorlineParts[0] == "cgroup") && -+ (Array.IndexOf(postSeparatorlineParts[2].Split(','), subsystem) >= 0)); -+ bool validCGroup2Entry = postSeparatorlineParts[0] == "cgroup2"; -+ -+ if (!validCGroup1Entry && !validCGroup2Entry) - { - // Not the relevant entry. - continue; - } - -- // Found the relevant entry. Extract the mount root and path. -+ // Found the relevant entry. Extract the cgroup version, mount root and path. -+ switch (postSeparatorlineParts[0]) -+ { -+ case "cgroup": -+ version = CGroupVersion.CGroup1; -+ break; -+ case "cgroup2": -+ version = CGroupVersion.CGroup2; -+ break; -+ default: -+ version = CGroupVersion.None; -+ Debug.Fail($"invalid value for CGroupVersion \"{postSeparatorlineParts[0]}\""); -+ break; -+ } -+ - string[] lineParts = line.Substring(0, endOfOptionalFields).Split(' '); - root = lineParts[3]; - path = lineParts[4]; -+ - return true; - } - } -@@ -169,6 +225,7 @@ private static bool TryFindHierarchyMount(string subsystem, out string root, out - } - } - -+ version = CGroupVersion.None; - root = null; - path = null; - return false; -@@ -180,27 +237,42 @@ private static bool TryFindHierarchyMount(string subsystem, out string root, out - /// - private static bool TryFindCGroupPathForSubsystem(string subsystem, out string path) - { -- if (File.Exists(ProcCGroupFilePath)) -+ return TryFindCGroupPathForSubsystem(ProcCGroupFilePath, subsystem, out path); -+ } -+ -+ internal static bool TryFindCGroupPathForSubsystem(string procCGroupFilePath, string subsystem, out string path) -+ { -+ if (File.Exists(procCGroupFilePath)) - { - try - { -- using (var reader = new StreamReader(ProcCGroupFilePath)) -+ using (var reader = new StreamReader(procCGroupFilePath)) - { - string line; - while ((line = reader.ReadLine()) != null) - { -- // Find the first entry that has the subsystem listed in its controller -- // list. See man page for cgroups for /proc/[pid]/cgroups format, e.g: -- // hierarchy-ID:controller-list:cgroup-path -- // 5:cpuacct,cpu,cpuset:/daemons -- - string[] lineParts = line.Split(':'); -+ - if (lineParts.Length != 3) - { - // Malformed line. - continue; - } - -+ // cgroup v2: Find the first entry that matches the cgroup v2 hierarchy: -+ // 0::$PATH -+ -+ if ((lineParts[0] == "0") && (string.Empty == lineParts[1])) -+ { -+ path = lineParts[2]; -+ return true; -+ } -+ -+ // cgroup v1: Find the first entry that has the subsystem listed in its controller -+ // list. See man page for cgroups for /proc/[pid]/cgroups format, e.g: -+ // hierarchy-ID:controller-list:cgroup-path -+ // 5:cpuacct,cpu,cpuset:/daemons -+ - if (Array.IndexOf(lineParts[1].Split(','), subsystem) < 0) - { - // Not the relevant entry. -@@ -214,7 +286,7 @@ private static bool TryFindCGroupPathForSubsystem(string subsystem, out string p - } - catch (Exception e) - { -- Debug.Fail($"Failed to read or parse \"{ProcMountInfoFilePath}\": {e}"); -+ Debug.Fail($"Failed to read or parse \"{procCGroupFilePath}\": {e}"); - } - } - -diff --git a/src/Common/tests/Common.Tests.csproj b/src/Common/tests/Common.Tests.csproj -index a189d856348b..979c8dd7fbe6 100644 ---- a/src/Common/tests/Common.Tests.csproj -+++ b/src/Common/tests/Common.Tests.csproj -@@ -12,6 +12,9 @@ - - Common\System\Security\Cryptography\ByteUtils.cs - -+ -+ Common\Interop\Linux\cgroups\Interop.cgroups.cs -+ - - Common\Interop\Linux\procfs\Interop.ProcFsStat.cs - -@@ -69,6 +72,7 @@ - - Common\CoreLib\System\PasteArguments.cs - -+ - - - -diff --git a/src/Common/tests/Tests/Interop/cgroupsTests.cs b/src/Common/tests/Tests/Interop/cgroupsTests.cs -new file mode 100644 -index 000000000000..f16d9242879c ---- /dev/null -+++ b/src/Common/tests/Tests/Interop/cgroupsTests.cs -@@ -0,0 +1,107 @@ -+// Licensed to the .NET Foundation under one or more agreements. -+// The .NET Foundation licenses this file to you under the MIT license. -+// See the LICENSE file in the project root for more information. -+ -+using System; -+using System.IO; -+using System.Text; -+using Xunit; -+ -+namespace Common.Tests -+{ -+ public class cgroupsTests -+ { -+ [Theory] -+ [InlineData(true, "0", 0)] -+ [InlineData(false, "max", 0)] -+ [InlineData(true, "1k", 1024)] -+ [InlineData(true, "1K", 1024)] -+ public static void ValidateTryReadMemoryValue(bool expectedResult, string valueText, ulong expectedValue) -+ { -+ string path = Path.GetTempFileName(); -+ try -+ { -+ File.WriteAllText(path, valueText); -+ -+ bool result = Interop.cgroups.TryReadMemoryValueFromFile(path, out ulong val); -+ -+ Assert.Equal(expectedResult, result); -+ if (result) -+ { -+ Assert.Equal(expectedValue, val); -+ } -+ } -+ finally -+ { -+ File.Delete(path); -+ } -+ } -+ -+ [Theory] -+ [InlineData(false, "0 0 0:0 / /foo ignore ignore - overlay overlay ignore", "ignore", 0, "/", "/")] -+ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup2 cgroup2 ignore", "ignore", 2, "/", "/foo")] -+ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup2 cgroup2 ignore", "memory", 2, "/", "/foo")] -+ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup2 cgroup2 ignore", "cpu", 2, "/", "/foo")] -+ [InlineData(true, "0 0 0:0 / /foo ignore - cgroup2 cgroup2 ignore", "cpu", 2, "/", "/foo")] -+ [InlineData(true, "0 0 0:0 / /foo ignore ignore ignore - cgroup2 cgroup2 ignore", "cpu", 2, "/", "/foo")] -+ [InlineData(true, "0 0 0:0 / /foo-with-dashes ignore ignore - cgroup2 cgroup2 ignore", "ignore", 2, "/", "/foo-with-dashes")] -+ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup memory", "memory", 1, "/", "/foo")] -+ [InlineData(true, "0 0 0:0 / /foo-with-dashes ignore ignore - cgroup cgroup memory", "memory", 1, "/", "/foo-with-dashes")] -+ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup cpu,memory", "memory", 1, "/", "/foo")] -+ [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup memory,cpu", "memory", 1, "/", "/foo")] -+ [InlineData(false, "0 0 0:0 / /foo ignore ignore - cgroup cgroup cpu", "memory", 0, "/", "/foo")] -+ public static void ParseValidateMountInfo(bool found, string procSelfMountInfoText, string subsystem, int expectedVersion, string expectedRoot, string expectedMount) -+ { -+ string path = Path.GetTempFileName(); -+ try -+ { -+ File.WriteAllText(path, procSelfMountInfoText); -+ -+ bool result = Interop.cgroups.TryFindHierarchyMount(path, subsystem, out Interop.cgroups.CGroupVersion version, out string root, out string mount); -+ -+ Assert.Equal(found, result); -+ if (found) -+ { -+ Assert.Equal(expectedVersion, (int)version); -+ Assert.Equal(expectedRoot, root); -+ Assert.Equal(expectedMount, mount); -+ } -+ } -+ finally -+ { -+ File.Delete(path); -+ } -+ } -+ -+ [Theory] -+ [InlineData(true, "0::/foo", "ignore", "/foo")] -+ [InlineData(true, "0::/bar", "ignore", "/bar")] -+ [InlineData(true, "0::frob", "ignore", "frob")] -+ [InlineData(false, "1::frob", "ignore", "ignore")] -+ [InlineData(true, "1:foo:bar", "foo", "bar")] -+ [InlineData(true, "2:foo:bar", "foo", "bar")] -+ [InlineData(false, "2:foo:bar", "bar", "ignore")] -+ [InlineData(true, "1:foo:bar\n2:eggs:spam", "foo", "bar")] -+ [InlineData(true, "1:foo:bar\n2:eggs:spam", "eggs", "spam")] -+ public static void ParseValidateProcCGroup(bool found, string procSelfCgroupText, string subsystem, string expectedMountPath) -+ { -+ string path = Path.GetTempFileName(); -+ try -+ { -+ File.WriteAllText(path, procSelfCgroupText); -+ -+ bool result = Interop.cgroups.TryFindCGroupPathForSubsystem(path, subsystem, out string mountPath); -+ -+ Assert.Equal(found, result); -+ if (found) -+ { -+ Assert.Equal(expectedMountPath, mountPath); -+ } -+ } -+ finally -+ { -+ File.Delete(path); -+ } -+ } -+ } -+} -diff --git a/src/System.Runtime.InteropServices.RuntimeInformation/tests/DescriptionNameTests.cs b/src/System.Runtime.InteropServices.RuntimeInformation/tests/DescriptionNameTests.cs -index 910af2fd82b4..73f692898dbc 100644 ---- a/src/System.Runtime.InteropServices.RuntimeInformation/tests/DescriptionNameTests.cs -+++ b/src/System.Runtime.InteropServices.RuntimeInformation/tests/DescriptionNameTests.cs -@@ -40,7 +40,7 @@ public void DumpRuntimeInformationToConsole() - - Console.WriteLine($"### CURRENT DIRECTORY: {Environment.CurrentDirectory}"); - -- string cgroupsLocation = Interop.cgroups.s_cgroupMemoryPath; -+ string cgroupsLocation = Interop.cgroups.s_cgroupMemoryLimitPath; - if (cgroupsLocation != null) - { - Console.WriteLine($"### CGROUPS MEMORY: {cgroupsLocation}"); - diff --git a/corefx-39686-cgroupv2-02.patch b/corefx-39686-cgroupv2-02.patch deleted file mode 100644 index 88dcd99..0000000 --- a/corefx-39686-cgroupv2-02.patch +++ /dev/null @@ -1,129 +0,0 @@ -From 9a8c5e4014ffca8aff70808cc0e50a403d38c292 Mon Sep 17 00:00:00 2001 -From: Stephen Toub -Date: Wed, 23 Oct 2019 20:35:49 -0400 -Subject: [PATCH 2/2] Clean up new tests - ---- - .../tests/Tests/Interop/cgroupsTests.cs | 79 ++++++------------- - 1 file changed, 25 insertions(+), 54 deletions(-) - -diff --git a/src/Common/tests/Tests/Interop/cgroupsTests.cs b/src/Common/tests/Tests/Interop/cgroupsTests.cs -index f16d9242879c..fc6ab5c9753c 100644 ---- a/src/Common/tests/Tests/Interop/cgroupsTests.cs -+++ b/src/Common/tests/Tests/Interop/cgroupsTests.cs -@@ -2,38 +2,27 @@ - // The .NET Foundation licenses this file to you under the MIT license. - // See the LICENSE file in the project root for more information. - --using System; - using System.IO; --using System.Text; - using Xunit; - - namespace Common.Tests - { -- public class cgroupsTests -+ public class cgroupsTests : FileCleanupTestBase - { - [Theory] -- [InlineData(true, "0", 0)] -- [InlineData(false, "max", 0)] -- [InlineData(true, "1k", 1024)] -- [InlineData(true, "1K", 1024)] -- public static void ValidateTryReadMemoryValue(bool expectedResult, string valueText, ulong expectedValue) -+ [InlineData(true, "0", 0)] -+ [InlineData(false, "max", 0)] -+ [InlineData(true, "1k", 1024)] -+ [InlineData(true, "1K", 1024)] -+ public void ValidateTryReadMemoryValue(bool expectedResult, string valueText, ulong expectedValue) - { -- string path = Path.GetTempFileName(); -- try -- { -- File.WriteAllText(path, valueText); -- -- bool result = Interop.cgroups.TryReadMemoryValueFromFile(path, out ulong val); -+ string path = GetTestFilePath(); -+ File.WriteAllText(path, valueText); - -- Assert.Equal(expectedResult, result); -- if (result) -- { -- Assert.Equal(expectedValue, val); -- } -- } -- finally -+ Assert.Equal(expectedResult, Interop.cgroups.TryReadMemoryValueFromFile(path, out ulong val)); -+ if (expectedResult) - { -- File.Delete(path); -+ Assert.Equal(expectedValue, val); - } - } - -@@ -50,26 +39,17 @@ public static void ValidateTryReadMemoryValue(bool expectedResult, string valueT - [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup cpu,memory", "memory", 1, "/", "/foo")] - [InlineData(true, "0 0 0:0 / /foo ignore ignore - cgroup cgroup memory,cpu", "memory", 1, "/", "/foo")] - [InlineData(false, "0 0 0:0 / /foo ignore ignore - cgroup cgroup cpu", "memory", 0, "/", "/foo")] -- public static void ParseValidateMountInfo(bool found, string procSelfMountInfoText, string subsystem, int expectedVersion, string expectedRoot, string expectedMount) -+ public void ParseValidateMountInfo(bool expectedFound, string procSelfMountInfoText, string subsystem, int expectedVersion, string expectedRoot, string expectedMount) - { -- string path = Path.GetTempFileName(); -- try -- { -- File.WriteAllText(path, procSelfMountInfoText); -- -- bool result = Interop.cgroups.TryFindHierarchyMount(path, subsystem, out Interop.cgroups.CGroupVersion version, out string root, out string mount); -+ string path = GetTestFilePath(); -+ File.WriteAllText(path, procSelfMountInfoText); - -- Assert.Equal(found, result); -- if (found) -- { -- Assert.Equal(expectedVersion, (int)version); -- Assert.Equal(expectedRoot, root); -- Assert.Equal(expectedMount, mount); -- } -- } -- finally -+ Assert.Equal(expectedFound, Interop.cgroups.TryFindHierarchyMount(path, subsystem, out Interop.cgroups.CGroupVersion version, out string root, out string mount)); -+ if (expectedFound) - { -- File.Delete(path); -+ Assert.Equal(expectedVersion, (int)version); -+ Assert.Equal(expectedRoot, root); -+ Assert.Equal(expectedMount, mount); - } - } - -@@ -83,24 +63,15 @@ public static void ParseValidateMountInfo(bool found, string procSelfMountInfoTe - [InlineData(false, "2:foo:bar", "bar", "ignore")] - [InlineData(true, "1:foo:bar\n2:eggs:spam", "foo", "bar")] - [InlineData(true, "1:foo:bar\n2:eggs:spam", "eggs", "spam")] -- public static void ParseValidateProcCGroup(bool found, string procSelfCgroupText, string subsystem, string expectedMountPath) -+ public void ParseValidateProcCGroup(bool expectedFound, string procSelfCgroupText, string subsystem, string expectedMountPath) - { -- string path = Path.GetTempFileName(); -- try -- { -- File.WriteAllText(path, procSelfCgroupText); -+ string path = GetTestFilePath(); -+ File.WriteAllText(path, procSelfCgroupText); - -- bool result = Interop.cgroups.TryFindCGroupPathForSubsystem(path, subsystem, out string mountPath); -- -- Assert.Equal(found, result); -- if (found) -- { -- Assert.Equal(expectedMountPath, mountPath); -- } -- } -- finally -+ Assert.Equal(expectedFound, Interop.cgroups.TryFindCGroupPathForSubsystem(path, subsystem, out string mountPath)); -+ if (expectedFound) - { -- File.Delete(path); -+ Assert.Equal(expectedMountPath, mountPath); - } - } - } diff --git a/corefx-42871-fedora-33-rid.patch b/corefx-42871-fedora-33-rid.patch deleted file mode 100644 index 2802dcd..0000000 --- a/corefx-42871-fedora-33-rid.patch +++ /dev/null @@ -1,124 +0,0 @@ -From 6cf4ff086875eaf29381cf406ea85846d9f66178 Mon Sep 17 00:00:00 2001 -From: Omair Majid -Date: Mon, 24 Feb 2020 14:11:03 -0500 -Subject: [PATCH] Add Fedora 33 runtime ids - -Fedora 32 is gearing up for release[1], and in-development version of -Fedora has been offically labelled as being Fedora 33: - - $ podman run -it fedora:33 cat /etc/os-release - NAME=Fedora - VERSION="33 (Container Image)" - ID=fedora - VERSION_ID=33 - VERSION_CODENAME="" - PLATFORM_ID="platform:f33" - PRETTY_NAME="Fedora 33 (Container Image)" - ANSI_COLOR="0;34" - LOGO=fedora-logo-icon - CPE_NAME="cpe:/o:fedoraproject:fedora:33" - HOME_URL="https://fedoraproject.org/" - DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/rawhide/system-administrators-guide/" - SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help" - BUG_REPORT_URL="https://bugzilla.redhat.com/" - REDHAT_BUGZILLA_PRODUCT="Fedora" - REDHAT_BUGZILLA_PRODUCT_VERSION=rawhide - REDHAT_SUPPORT_PRODUCT="Fedora" - REDHAT_SUPPORT_PRODUCT_VERSION=rawhide - PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" - VARIANT="Container Image" - VARIANT_ID=container - -[1] https://fedorapeople.org/groups/schedule/f-32/f-32-key-tasks.html ---- - eng/Packaging.props | 2 +- - .../runtime.compatibility.json | 32 +++++++++++++++++++ - pkg/Microsoft.NETCore.Platforms/runtime.json | 17 ++++++++++ - .../runtimeGroups.props | 2 +- - src/packages.builds | 3 ++ - 5 files changed, 54 insertions(+), 2 deletions(-) - -diff --git a/pkg/Microsoft.NETCore.Platforms/runtime.compatibility.json b/pkg/Microsoft.NETCore.Platforms/runtime.compatibility.json -index 1e5c380a7a6a..c20e35394d6b 100644 ---- a/pkg/Microsoft.NETCore.Platforms/runtime.compatibility.json -+++ b/pkg/Microsoft.NETCore.Platforms/runtime.compatibility.json -@@ -953,6 +953,38 @@ - "any", - "base" - ], -+ "fedora.33": [ -+ "fedora.33", -+ "fedora", -+ "linux", -+ "unix", -+ "any", -+ "base" -+ ], -+ "fedora.33-arm64": [ -+ "fedora.33-arm64", -+ "fedora.33", -+ "fedora-arm64", -+ "fedora", -+ "linux-arm64", -+ "linux", -+ "unix-arm64", -+ "unix", -+ "any", -+ "base" -+ ], -+ "fedora.33-x64": [ -+ "fedora.33-x64", -+ "fedora.33", -+ "fedora-x64", -+ "fedora", -+ "linux-x64", -+ "linux", -+ "unix-x64", -+ "unix", -+ "any", -+ "base" -+ ], - "freebsd": [ - "freebsd", - "unix", -diff --git a/pkg/Microsoft.NETCore.Platforms/runtime.json b/pkg/Microsoft.NETCore.Platforms/runtime.json -index b2f286ea2479..b3380ecbbef3 100644 ---- a/pkg/Microsoft.NETCore.Platforms/runtime.json -+++ b/pkg/Microsoft.NETCore.Platforms/runtime.json -@@ -488,6 +488,23 @@ - "fedora-x64" - ] - }, -+ "fedora.33": { -+ "#import": [ -+ "fedora" -+ ] -+ }, -+ "fedora.33-arm64": { -+ "#import": [ -+ "fedora.33", -+ "fedora-arm64" -+ ] -+ }, -+ "fedora.33-x64": { -+ "#import": [ -+ "fedora.33", -+ "fedora-x64" -+ ] -+ }, - "freebsd": { - "#import": [ - "unix" -diff --git a/pkg/Microsoft.NETCore.Platforms/runtimeGroups.props b/pkg/Microsoft.NETCore.Platforms/runtimeGroups.props -index eeb8130b54fb..da48e5f9d09f 100644 ---- a/pkg/Microsoft.NETCore.Platforms/runtimeGroups.props -+++ b/pkg/Microsoft.NETCore.Platforms/runtimeGroups.props -@@ -43,7 +43,7 @@ - - linux - x64;arm64 -- 23;24;25;26;27;28;29;30;31;32 -+ 23;24;25;26;27;28;29;30;31;32;33 - false - - diff --git a/corefx-42900-clang-10.patch b/corefx-42900-clang-10.patch deleted file mode 100644 index b898f34..0000000 --- a/corefx-42900-clang-10.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 58d6cd09bd2d5b1085c6572c1d97b8533cf8294b Mon Sep 17 00:00:00 2001 -From: Omair Majid -Date: Fri, 3 Apr 2020 13:53:09 -0400 -Subject: [PATCH] Fix corefx to build on clang 10 - -Clang 10 adds/enables new warnings, some of which is affecting -the corefx code. - -Clang 10 has added -Walloca to warn about uses of alloca. This commit -replaces the only non-compliant use of that with a single fixed -stack-allocated buffer. - -Clang 10 has also added -Wimplicit-int-float-conversion. This commit -uses explicit casts to double to avoid the warnings. - -This is a backport of dotnet/runtime#33734 to corefx. - -After this commit, I can build all of corefx with Clang 10. ---- - src/Native/Unix/System.Native/pal_io.c | 20 +++++++++++--------- - src/Native/Unix/System.Native/pal_time.c | 2 +- - 2 files changed, 12 insertions(+), 10 deletions(-) - -diff --git a/src/Native/Unix/System.Native/pal_io.c b/src/Native/Unix/System.Native/pal_io.c -index 2d51edacf5ee..c7c42eb3e72b 100644 ---- a/src/Native/Unix/System.Native/pal_io.c -+++ b/src/Native/Unix/System.Native/pal_io.c -@@ -906,18 +906,20 @@ int32_t SystemNative_Poll(PollEvent* pollEvents, uint32_t eventCount, int32_t mi - return Error_EINVAL; - } - -- size_t bufferSize; -- if (!multiply_s(sizeof(struct pollfd), (size_t)eventCount, &bufferSize)) -+ struct pollfd stackBuffer[(uint32_t)(2048/sizeof(struct pollfd))]; -+ int useStackBuffer = eventCount <= (sizeof(stackBuffer)/sizeof(stackBuffer[0])); -+ struct pollfd* pollfds = NULL; -+ if (useStackBuffer) - { -- return SystemNative_ConvertErrorPlatformToPal(EOVERFLOW); -+ pollfds = (struct pollfd*)&stackBuffer[0]; - } -- -- -- int useStackBuffer = bufferSize <= 2048; -- struct pollfd* pollfds = (struct pollfd*)(useStackBuffer ? alloca(bufferSize) : malloc(bufferSize)); -- if (pollfds == NULL) -+ else - { -- return Error_ENOMEM; -+ pollfds = (struct pollfd*)calloc(eventCount, sizeof(*pollfds)); -+ if (pollfds == NULL) -+ { -+ return Error_ENOMEM; -+ } - } - - for (uint32_t i = 0; i < eventCount; i++) -diff --git a/src/Native/Unix/System.Native/pal_time.c b/src/Native/Unix/System.Native/pal_time.c -index 1a7c862749d1..54ebde60a83b 100644 ---- a/src/Native/Unix/System.Native/pal_time.c -+++ b/src/Native/Unix/System.Native/pal_time.c -@@ -169,7 +169,7 @@ int32_t SystemNative_GetCpuUtilization(ProcessCpuInformation* previousCpuInfo) - uint64_t resolution = SystemNative_GetTimestampResolution(); - uint64_t timestamp = SystemNative_GetTimestamp(); - -- uint64_t currentTime = (uint64_t)(timestamp * ((double)SecondsToNanoSeconds / resolution)); -+ uint64_t currentTime = (uint64_t)((double)timestamp * ((double)SecondsToNanoSeconds / (double)resolution)); - - uint64_t lastRecordedCurrentTime = previousCpuInfo->lastRecordedCurrentTime; - uint64_t lastRecordedKernelTime = previousCpuInfo->lastRecordedKernelTime; diff --git a/corefx-optflags-support.patch b/corefx-optflags-support.patch deleted file mode 100644 index 9b08f1f..0000000 --- a/corefx-optflags-support.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/src/Native/Unix/CMakeLists.txt b/src/Native/Unix/CMakeLists.txt -index 7d804a1e54..717c2718d7 100644 ---- a/src/Native/Unix/CMakeLists.txt -+++ b/src/Native/Unix/CMakeLists.txt -@@ -25,7 +25,7 @@ add_compile_options(-fPIC) - add_compile_options(-Wthread-safety) - add_compile_options(-Wno-thread-safety-analysis) -+ add_compile_options(-Wno-alloca) - endif() --add_compile_options(-Werror) - - if(CMAKE_SYSTEM_NAME STREQUAL Emscripten) - set(CLR_CMAKE_PLATFORM_WASM 1) -diff --git a/src/Native/Unix/configure.cmake b/src/Native/Unix/configure.cmake -index f4a30ad6cb..f2db68402a 100644 ---- a/src/Native/Unix/configure.cmake -+++ b/src/Native/Unix/configure.cmake -@@ -27,6 +27,12 @@ else () - message(FATAL_ERROR "Unknown platform. Cannot define PAL_UNIX_NAME, used by RuntimeInformation.") - endif () - -+ -+set (PREVIOUS_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) -+set (CMAKE_CXX_FLAGS "-D_GNU_SOURCE") -+set (PREVIOUS_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) -+set (CMAKE_C_FLAGS "-D_GNU_SOURCE") -+ - # We compile with -Werror, so we need to make sure these code fragments compile without warnings. - # Older CMake versions (3.8) do not assign the result of their tests, causing unused-value errors - # which are not distinguished from the test failing. So no error for that one. -@@ -698,6 +704,9 @@ endif() - - set (CMAKE_REQUIRED_LIBRARIES) - -+set (CMAKE_CXX_FLAGS "${PREVIOUS_CMAKE_CXX_FLAGS}") -+set (CMAKE_C_FLAGS "${PREVIOUS_CMAKE_C_FLAGS}") -+ - check_c_source_compiles( - " - #include diff --git a/dotnet3.1.spec b/dotnet5.0.spec similarity index 79% rename from dotnet3.1.spec rename to dotnet5.0.spec index 44ff8fb..49221a4 100644 --- a/dotnet3.1.spec +++ b/dotnet5.0.spec @@ -1,4 +1,4 @@ -%bcond_with bootstrap +%bcond_without bootstrap # Avoid provides/requires from private libraries %global privlibs libhostfxr @@ -20,18 +20,20 @@ %global dotnet_cflags %(echo %optflags | sed -e 's/-fstack-clash-protection//' | sed -re 's/-specs=[^ ]*//g') %global dotnet_ldflags %(echo %{__global_ldflags} | sed -re 's/-specs=[^ ]*//g') -%global host_version 3.1.3 -%global runtime_version 3.1.3 -%global aspnetcore_runtime_version %{runtime_version} -%global sdk_version 3.1.103 -# upstream respun this release, so the tag doesn't exactly match -%global src_version %{sdk_version}.2 -%global templates_version %(echo %{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }') +%global host_version 5.0.0-preview.4.20251.6 +%global runtime_version 5.0.0-preview.4.20251.6 +%global aspnetcore_runtime_version 5.0.0-preview.4.20257.10 +%global sdk_version 5.0.100-preview.4.20161.13 +%global templates_version 5.0.0-preview.4.20161.13 +#%%global templates_version %%(echo %%{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }') -%global host_rpm_version %{host_version} -%global aspnetcore_runtime_rpm_version %{aspnetcore_runtime_version} -%global runtime_rpm_version %{runtime_version} -%global sdk_rpm_version %{sdk_version} +%global host_rpm_version 5.0.0 +%global aspnetcore_runtime_rpm_version 5.0.0 +%global runtime_rpm_version 5.0.0 +%global sdk_rpm_version 5.0.100 + +# upstream can update releases without revving the SDK version so these don't always match +%global src_version %{sdk_rpm_version} %if 0%{?fedora} || 0%{?rhel} < 8 %global use_bundled_libunwind 0 @@ -39,6 +41,10 @@ %global use_bundled_libunwind 1 %endif +%ifarch aarch64 +%global use_bundled_libunwind 1 +%endif + %ifarch x86_64 %global runtime_arch x64 %endif @@ -56,42 +62,34 @@ %endif %endif -Name: dotnet3.1 +Name: dotnet5.0 Version: %{sdk_rpm_version} -Release: 1%{?dist} +Release: 0.2.preview4%{?dist} Summary: .NET Core Runtime and SDK License: MIT and ASL 2.0 and BSD and LGPLv2+ and CC-BY and CC0 and MS-PL and EPL-1.0 and GPL+ and GPLv2 and ISC and OFL and zlib URL: https://github.com/dotnet/ # The source is generated on a Fedora box via: # ./build-dotnet-tarball v%%{src_version}-SDK -Source0: dotnet-v%{src_version}-SDK.tar.gz +Source0: dotnet-v%{src_version}-preview4-SDK.tar.gz Source1: check-debug-symbols.py Source2: dotnet.sh.in +# dotnet/runtime PR 39044 +Patch100: runtime-39044-cmake-downgrade.patch + +# TODO: upstream this patch +# Do not strip debuginfo from (native/unmanaged) binaries +Patch101: runtime-dont-strip.patch + +# TODO: upstream this patch # Fix building with our additional CFLAGS/CXXFLAGS/LDFLAGS -Patch100: corefx-optflags-support.patch - -# Add some support for cgroupv2 in corefx -# All these patches are upstreamed for 5.0 -Patch101: corefx-39686-cgroupv2-01.patch -Patch102: corefx-39686-cgroupv2-02.patch -Patch103: corefx-39633-cgroupv2-mountpoints.patch - -# Add Fedora 33 RID to corefx -Patch104: corefx-42871-fedora-33-rid.patch - -# Build with with hardening flags, including -pie -Patch200: coreclr-hardening-flags.patch -# Fix build with clang 10; Already applied at tarball-build time -# Patch201: coreclr-clang10.patch - -# Build with with hardening flags, including -pie -Patch300: core-setup-hardening-flags.patch +Patch102: runtime-flags-support.patch # Disable telemetry by default; make it opt-in -Patch500: cli-telemetry-optout.patch +Patch500: sdk-telemetry-optout.patch +# ExclusiveArch: aarch64 x86_64 ExclusiveArch: x86_64 BuildRequires: clang @@ -99,8 +97,8 @@ BuildRequires: cmake BuildRequires: coreutils %if %{without bootstrap} BuildRequires: dotnet-build-reference-packages -BuildRequires: dotnet-sdk-3.1 -BuildRequires: dotnet-sdk-3.1-source-built-artifacts +BuildRequires: dotnet-sdk-5.0 +BuildRequires: dotnet-sdk-5.0-source-built-artifacts %endif BuildRequires: findutils BuildRequires: git @@ -141,7 +139,7 @@ application to drive everything. Version: %{sdk_rpm_version} Summary: .NET Core CLI tools and runtime -Requires: dotnet-sdk-3.1%{?_isa} >= %{sdk_rpm_version}-%{release} +Requires: dotnet-sdk-5.0%{?_isa} >= %{sdk_rpm_version}-%{release} %description -n dotnet .NET Core is a fast, lightweight and modular platform for creating @@ -171,7 +169,7 @@ It particularly focuses on creating console applications, web applications and micro-services. -%package -n dotnet-hostfxr-3.1 +%package -n dotnet-hostfxr-5.0 Version: %{host_rpm_version} Summary: .NET Core command line host resolver @@ -180,7 +178,7 @@ Summary: .NET Core command line host resolver # provided by this package, or from a newer version of .NET Core Requires: dotnet-host%{?_isa} >= %{host_rpm_version}-%{release} -%description -n dotnet-hostfxr-3.1 +%description -n dotnet-hostfxr-5.0 The .NET Core host resolver contains the logic to resolve and select the right version of the .NET Core SDK or runtime to use. @@ -191,12 +189,12 @@ It particularly focuses on creating console applications, web applications and micro-services. -%package -n dotnet-runtime-3.1 +%package -n dotnet-runtime-5.0 Version: %{runtime_rpm_version} -Summary: NET Core 3.1 runtime +Summary: NET Core 5.0 runtime -Requires: dotnet-hostfxr-3.1%{?_isa} >= %{host_rpm_version}-%{release} +Requires: dotnet-hostfxr-5.0%{?_isa} >= %{host_rpm_version}-%{release} # libicu is dlopen()ed Requires: libicu%{?_isa} @@ -205,7 +203,7 @@ Requires: libicu%{?_isa} Provides: bundled(libunwind) = 1.3 %endif -%description -n dotnet-runtime-3.1 +%description -n dotnet-runtime-5.0 The .NET Core runtime contains everything needed to run .NET Core applications. It includes a high performance Virtual Machine as well as the framework libraries used by .NET Core applications. @@ -217,14 +215,14 @@ It particularly focuses on creating console applications, web applications and micro-services. -%package -n aspnetcore-runtime-3.1 +%package -n aspnetcore-runtime-5.0 Version: %{aspnetcore_runtime_rpm_version} -Summary: ASP.NET Core 3.1 runtime +Summary: ASP.NET Core 5.0 runtime -Requires: dotnet-runtime-3.1%{?_isa} >= %{runtime_rpm_version}-%{release} +Requires: dotnet-runtime-5.0%{?_isa} >= %{runtime_rpm_version}-%{release} -%description -n aspnetcore-runtime-3.1 +%description -n aspnetcore-runtime-5.0 The ASP.NET Core runtime contains everything needed to run .NET Core web applications. It includes a high performance Virtual Machine as well as the framework libraries used by .NET Core applications. @@ -236,16 +234,16 @@ It particularly focuses on creating console applications, web applications and micro-services. -%package -n dotnet-templates-3.1 +%package -n dotnet-templates-5.0 Version: %{sdk_rpm_version} -Summary: .NET Core 3.1 templates +Summary: .NET Core 5.0 templates # Theoretically any version of the host should work. But lets aim for the one # provided by this package, or from a newer version of .NET Core Requires: dotnet-host%{?_isa} >= %{host_rpm_version}-%{release} -%description -n dotnet-templates-3.1 +%description -n dotnet-templates-5.0 This package contains templates used by the .NET Core SDK. ASP.NET Core is a fast, lightweight and modular platform for creating @@ -255,25 +253,25 @@ It particularly focuses on creating console applications, web applications and micro-services. -%package -n dotnet-sdk-3.1 +%package -n dotnet-sdk-5.0 Version: %{sdk_rpm_version} -Summary: .NET Core 3.1 Software Development Kit +Summary: .NET Core 5.0 Software Development Kit Provides: bundled(js-jquery) Provides: bundled(npm) -Requires: dotnet-runtime-3.1%{?_isa} >= %{runtime_rpm_version}-%{release} -Requires: aspnetcore-runtime-3.1%{?_isa} >= %{aspnetcore_runtime_rpm_version}-%{release} +Requires: dotnet-runtime-5.0%{?_isa} >= %{runtime_rpm_version}-%{release} +Requires: aspnetcore-runtime-5.0%{?_isa} >= %{aspnetcore_runtime_rpm_version}-%{release} -Requires: dotnet-apphost-pack-3.1%{?_isa} >= %{runtime_rpm_version}-%{release} -Requires: dotnet-targeting-pack-3.1%{?_isa} >= %{runtime_rpm_version}-%{release} -Requires: aspnetcore-targeting-pack-3.1%{?_isa} >= %{aspnetcore_runtime_rpm_version}-%{release} +Requires: dotnet-apphost-pack-5.0%{?_isa} >= %{runtime_rpm_version}-%{release} +Requires: dotnet-targeting-pack-5.0%{?_isa} >= %{runtime_rpm_version}-%{release} +Requires: aspnetcore-targeting-pack-5.0%{?_isa} >= %{aspnetcore_runtime_rpm_version}-%{release} Requires: netstandard-targeting-pack-2.1%{?_isa} >= %{sdk_rpm_version}-%{release} -Requires: dotnet-templates-3.1%{?_isa} >= %{sdk_rpm_version}-%{release} +Requires: dotnet-templates-5.0%{?_isa} >= %{sdk_rpm_version}-%{release} -%description -n dotnet-sdk-3.1 +%description -n dotnet-sdk-5.0 The .NET Core SDK is a collection of command line applications to create, build, publish and run .NET Core applications. @@ -302,18 +300,18 @@ applications using the .NET Core SDK. %{_libdir}/dotnet/packs/%{5} } -%dotnet_targeting_pack dotnet-apphost-pack-3.1 %{runtime_rpm_version} Microsoft.NETCore.App 3.1 Microsoft.NETCore.App.Host.%{runtime_id} -%dotnet_targeting_pack dotnet-targeting-pack-3.1 %{runtime_rpm_version} Microsoft.NETCore.App 3.1 Microsoft.NETCore.App.Ref -%dotnet_targeting_pack aspnetcore-targeting-pack-3.1 %{aspnetcore_runtime_rpm_version} Microsoft.AspNetCore.App 3.1 Microsoft.AspNetCore.App.Ref +%dotnet_targeting_pack dotnet-apphost-pack-5.0 %{runtime_rpm_version} Microsoft.NETCore.App 5.0 Microsoft.NETCore.App.Host.%{runtime_id} +%dotnet_targeting_pack dotnet-targeting-pack-5.0 %{runtime_rpm_version} Microsoft.NETCore.App 5.0 Microsoft.NETCore.App.Ref +%dotnet_targeting_pack aspnetcore-targeting-pack-5.0 %{aspnetcore_runtime_rpm_version} Microsoft.AspNetCore.App 5.0 Microsoft.AspNetCore.App.Ref %dotnet_targeting_pack netstandard-targeting-pack-2.1 %{sdk_rpm_version} NETStandard.Library 2.1 NETStandard.Library.Ref -%package -n dotnet-sdk-3.1-source-built-artifacts +%package -n dotnet-sdk-5.0-source-built-artifacts Version: %{sdk_rpm_version} -Summary: Internal package for building .NET Core 3.1 Software Development Kit +Summary: Internal package for building .NET Core 5.0 Software Development Kit -%description -n dotnet-sdk-3.1-source-built-artifacts +%description -n dotnet-sdk-5.0-source-built-artifacts The .NET Core source-built archive is a collection of packages needed to build the .NET Core SDK itself. @@ -321,7 +319,7 @@ These are not meant for general use. %prep -%setup -q -n dotnet-v%{src_version}-SDK +%setup -q -n dotnet-v%{src_version}-preview4-SDK %if %{without bootstrap} # Remove all prebuilts @@ -331,49 +329,43 @@ find -iname '*.tar.gz' -type f -delete find -iname '*.nupkg' -type f -delete find -iname '*.zip' -type f -delete rm -rf .dotnet/ -rm -r packages/source-built +rm -rf packages/source-built %endif %if %{without bootstrap} -sed -i -e 's|3.1.100-preview1-014459|3.1.102|' global.json +sed -i -e 's|5.0.100-preview1-014459|5.0.103|' global.json mkdir -p packages/archive ln -s %{_libdir}/dotnet/source-built-artifacts/*.tar.gz packages/archive/ ln -s %{_libdir}/dotnet/reference-packages/Private.SourceBuild.ReferencePackages*.tar.gz packages/archive %endif # Fix bad hardcoded path in build -sed -i 's|/usr/share/dotnet|%{_libdir}/dotnet|' src/core-setup.*/src/corehost/common/pal.unix.cpp +sed -i 's|/usr/share/dotnet|%{_libdir}/dotnet|' src/runtime.*/src/installer/corehost/cli/hostmisc/pal.unix.cpp # Disable warnings -sed -i 's|skiptests|skiptests ignorewarnings|' repos/coreclr.proj +sed -i 's|skiptests|skiptests ignorewarnings|' repos/runtime.common.props -pushd src/corefx.* +pushd src/runtime.* %patch100 -p1 %patch101 -p1 %patch102 -p1 -%patch103 -p1 -%patch104 -p1 popd -pushd src/coreclr.* -%patch200 -p1 -#%%patch201 -p1 -popd - -pushd src/core-setup.* -%patch300 -p1 -popd - -pushd src/cli.* +pushd src/sdk.* %patch500 -p1 popd # If CLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE is misisng, add it back -grep CLR_CMAKE_USE_SYSTEM_LIBUNWIND repos/coreclr.proj || \ - sed -i 's|\$(BuildArguments) |$(BuildArguments) cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE|' repos/coreclr.proj +grep CLR_CMAKE_USE_SYSTEM_LIBUNWIND repos/runtime.common.props || \ + sed -i 's|\$(BuildArguments) |$(BuildArguments) cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE|' repos/runtime.common.props %if %{use_bundled_libunwind} -sed -i 's|-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE|-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=FALSE|' repos/coreclr.proj +sed -i 's|-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE|-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=FALSE|' repos/runtime.common.props +%endif + +%ifnarch x86_64 +mkdir -p artifacts/obj/%{runtime_arch}/Release +cp artifacts/obj/x64/Release/PackageVersions.props artifacts/obj/%{runtime_arch}/Release/PackageVersions.props %endif cat source-build-info.txt @@ -389,9 +381,9 @@ cat /etc/os-release cp -a %{_libdir}/dotnet previously-built-dotnet %endif -export CFLAGS="%{dotnet_cflags}" -export CXXFLAGS="%{dotnet_cflags}" -export LDFLAGS="%{dotnet_ldflags}" +export EXTRA_CFLAGS="%{dotnet_cflags}" +export EXTRA_CXXFLAGS="%{dotnet_cflags}" +export EXTRA_LDFLAGS="%%{dotnet_ldflags}" #%%if %%{without bootstrap} # --with-ref-packages %%{_libdir}/dotnet/reference-packages/ \ @@ -416,11 +408,11 @@ sed -e 's|[@]LIBDIR[@]|%{_libdir}|g' %{SOURCE2} > dotnet.sh %install install -dm 0755 %{buildroot}%{_libdir}/dotnet -ls bin/%{runtime_arch}/Release -tar xf bin/%{runtime_arch}/Release/dotnet-sdk-%{sdk_version}-%{runtime_id}.tar.gz -C %{buildroot}%{_libdir}/dotnet/ +ls artifacts/%{runtime_arch}/Release +tar xf artifacts/%{runtime_arch}/Release/dotnet-sdk-%{sdk_rpm_version}-preview.4.20161.13-%{runtime_id}.tar.gz -C %{buildroot}%{_libdir}/dotnet/ # Install managed symbols -tar xf bin/%{runtime_arch}/Release/runtime/dotnet-runtime-symbols-%{runtime_version}-%{runtime_id}.tar.gz \ +tar xf artifacts/%{runtime_arch}/Release/runtime/dotnet-runtime-symbols-%{runtime_version}-%{runtime_id}.tar.gz \ -C %{buildroot}/%{_libdir}/dotnet/shared/Microsoft.NETCore.App/%{runtime_version}/ # Fix executable permissions on files @@ -439,7 +431,7 @@ install dotnet.sh %{buildroot}%{_sysconfdir}/profile.d/ install -dm 0755 %{buildroot}/%{_datadir}/bash-completion/completions # dynamic completion needs the file to be named the same as the base command -install src/cli.*/scripts/register-completions.bash %{buildroot}/%{_datadir}/bash-completion/completions/dotnet +install src/sdk.*/scripts/register-completions.bash %{buildroot}/%{_datadir}/bash-completion/completions/dotnet # TODO: the zsh completion script needs to be ported to use #compdef #install -dm 755 %%{buildroot}/%%{_datadir}/zsh/site-functions @@ -455,8 +447,8 @@ echo "%{_libdir}/dotnet" >> install_location install -dm 0755 %{buildroot}%{_sysconfdir}/dotnet install install_location %{buildroot}%{_sysconfdir}/dotnet/ -install -dm 0755 %{buildroot}%{_libdir}/dotnet/source-built-artifacts -install bin/%{runtime_arch}/Release/Private.SourceBuilt.Artifacts.*.tar.gz %{buildroot}/%{_libdir}/dotnet/source-built-artifacts/ +#install -dm 0755 %%{buildroot}%%{_libdir}/dotnet/source-built-artifacts +#install artifacts/%%{runtime_arch}/Release/Private.SourceBuilt.Artifacts.*.tar.gz %%{buildroot}/%%{_libdir}/dotnet/source-built-artifacts/ # Check debug symbols in all elf objects. This is not in %%check # because native binaries are stripped by rpm-build after %%install. @@ -487,35 +479,60 @@ echo "Testing build results for debug symbols..." %dir %{_datadir}/bash-completion/completions %{_datadir}/bash-completion/completions/dotnet -%files -n dotnet-hostfxr-3.1 +%files -n dotnet-hostfxr-5.0 %dir %{_libdir}/dotnet/host/fxr %{_libdir}/dotnet/host/fxr/%{host_version} -%files -n dotnet-runtime-3.1 +%files -n dotnet-runtime-5.0 %dir %{_libdir}/dotnet/shared %dir %{_libdir}/dotnet/shared/Microsoft.NETCore.App %{_libdir}/dotnet/shared/Microsoft.NETCore.App/%{runtime_version} -%files -n aspnetcore-runtime-3.1 +%files -n aspnetcore-runtime-5.0 %dir %{_libdir}/dotnet/shared %dir %{_libdir}/dotnet/shared/Microsoft.AspNetCore.App %{_libdir}/dotnet/shared/Microsoft.AspNetCore.App/%{aspnetcore_runtime_version} -%files -n dotnet-templates-3.1 +%files -n dotnet-templates-5.0 %dir %{_libdir}/dotnet/templates %{_libdir}/dotnet/templates/%{templates_version} -%files -n dotnet-sdk-3.1 +%files -n dotnet-sdk-5.0 %dir %{_libdir}/dotnet/sdk %{_libdir}/dotnet/sdk/%{sdk_version} %dir %{_libdir}/dotnet/packs -%files -n dotnet-sdk-3.1-source-built-artifacts -%dir %{_libdir}/dotnet -%{_libdir}/dotnet/source-built-artifacts +#%%files -n dotnet-sdk-5.0-source-built-artifacts +#%%dir %%{_libdir}/dotnet +#%%{_libdir}/dotnet/source-built-artifacts %changelog +* Fri Jul 10 2020 Omair Majid - 5.0.100-0.2.preview4 +- Fix building with custom CFLAGS/CXXFLAGS/LDFLAGS +- Clean up patches + +* Mon Jul 06 2020 Omair Majid - 5.0.100-0.1.preview4 +- Initial build + +* Sat Jun 27 2020 Omair Majid - 3.1.105-4 +- Disable bootstrap + +* Fri Jun 26 2020 Omair Majid - 3.1.105-3 +- Re-bootstrap aarch64 + +* Fri Jun 19 2020 Omair Majid - 3.1.105-3 +- Disable bootstrap + +* Thu Jun 18 2020 Omair Majid - 3.1.105-1 +- Bootstrap aarch64 + +* Tue Jun 16 2020 Chris Rummel - 3.1.105-1 +- Update to .NET Core Runtime 3.1.5 and SDK 3.1.105 + +* Fri Jun 05 2020 Chris Rummel - 3.1.104-1 +- Update to .NET Core Runtime 3.1.4 and SDK 3.1.104 + * Thu Apr 09 2020 Chris Rummel - 3.1.103-1 - Update to .NET Core Runtime 3.1.3 and SDK 3.1.103 @@ -716,4 +733,3 @@ echo "Testing build results for debug symbols..." - SPEC file cleanup * Wed Jan 11 2017 Nemanja Milosevic - 1.1.0-0 - Initial RPM for Fedora 25/26. - diff --git a/runtime-39044-cmake-downgrade.patch b/runtime-39044-cmake-downgrade.patch new file mode 100644 index 0000000..71938d0 --- /dev/null +++ b/runtime-39044-cmake-downgrade.patch @@ -0,0 +1,1158 @@ +diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake +index 534f1d19de6..50d81842274 100644 +--- a/eng/common/cross/toolchain.cmake ++++ b/eng/common/cross/toolchain.cmake +@@ -83,15 +83,26 @@ endif() + + # Specify link flags + ++function(add_toolchain_linker_flag Flag) ++ set(Config "${ARGV1}") ++ set(CONFIG_SUFFIX "") ++ if (NOT Config STREQUAL "") ++ set(CONFIG_SUFFIX "_${Config}") ++ endif() ++ set("CMAKE_EXE_LINKER_FLAGS${CONFIG_SUFFIX}" "${CMAKE_EXE_LINKER_FLAGS${CONFIG_SUFFIX}} ${Flag}" PARENT_SCOPE) ++ set("CMAKE_SHARED_LINKER_FLAGS${CONFIG_SUFFIX}" "${CMAKE_SHARED_LINKER_FLAGS${CONFIG_SUFFIX}} ${Flag}" PARENT_SCOPE) ++endfunction() ++ ++ + if(TARGET_ARCH_NAME STREQUAL "armel") + if(DEFINED TIZEN_TOOLCHAIN) # For Tizen only +- add_link_options("-B${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") +- add_link_options("-L${CROSS_ROOTFS}/lib") +- add_link_options("-L${CROSS_ROOTFS}/usr/lib") +- add_link_options("-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") ++ add_toolchain_linker_flag("-B${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") ++ add_toolchain_linker_flag("-L${CROSS_ROOTFS}/lib") ++ add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib") ++ add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") + endif() + elseif(TARGET_ARCH_NAME STREQUAL "x86") +- add_link_options(-m32) ++ add_toolchain_linker_flag(-m32) + endif() + + # Specify compile options +diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh +index a1a975ce177..9a0c296ff66 100755 +--- a/eng/native/build-commons.sh ++++ b/eng/native/build-commons.sh +@@ -51,12 +51,9 @@ check_prereqs() + # Check presence of CMake on the path + command -v cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; } + +- function version { echo "$@" | awk -F. '{ printf("%d%02d%02d\n", $1,$2,$3); }'; } +- +- local cmake_version="$(cmake --version | awk '/^cmake version [0-9]+\.[0-9]+\.[0-9]+$/ {print $3}')" +- +- if [[ "$(version "$cmake_version")" -lt "$(version 3.14.2)" ]]; then +- echo "Please install CMake 3.14.2 or newer from http://www.cmake.org/download/ or https://apt.kitware.com and ensure it is on your path."; exit 1; ++ if [[ "$__HostOS" == "OSX" ]]; then ++ # Check presence of pkg-config on the path ++ command -v pkg-config 2>/dev/null || { echo >&2 "Please install pkg-config before running this script, see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/macos-requirements.md"; exit 1; } + fi + + if [[ "$__UseNinja" == 1 ]]; then +@@ -156,8 +153,8 @@ build_native() + cmake_command="emcmake $cmake_command" + fi + +- echo "Executing $cmake_command --build \"$intermediatesDir\" --target install -j $__NumProc" +- $cmake_command --build "$intermediatesDir" --target install -j "$__NumProc" ++ echo "Executing $cmake_command --build \"$intermediatesDir\" --target install -- -j $__NumProc" ++ $cmake_command --build "$intermediatesDir" --target install -- -j "$__NumProc" + fi + + local exit_code="$?" +diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake +index 2937916ced9..07fd6f75f6f 100644 +--- a/eng/native/configurecompiler.cmake ++++ b/eng/native/configurecompiler.cmake +@@ -8,8 +8,6 @@ set(CMAKE_C_STANDARD_REQUIRED ON) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + +-cmake_policy(SET CMP0083 NEW) +- + include(CheckCXXCompilerFlag) + + # "configureoptimization.cmake" must be included after CLR_CMAKE_HOST_UNIX has been set. +@@ -40,11 +38,18 @@ set(CMAKE_CXX_FLAGS_CHECKED "") + set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") + set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") + ++set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "") ++set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "") ++set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "") ++set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") ++set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") ++set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "") ++ + add_compile_definitions("$<$,$>:DEBUG;_DEBUG;_DBG;URTBLDENV_FRIENDLY=Checked;BUILDENV_CHECKED=1>") + add_compile_definitions("$<$,$>:NDEBUG;URTBLDENV_FRIENDLY=Retail>") + + if (MSVC) +- add_link_options(/GUARD:CF) ++ add_linker_flag(/GUARD:CF) + + # Linker flags + # +@@ -57,48 +62,51 @@ if (MSVC) + endif () + + #Do not create Side-by-Side Assembly Manifest +- add_link_options($<$,SHARED_LIBRARY>:/MANIFEST:NO>) ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") + # can handle addresses larger than 2 gigabytes +- add_link_options($<$,SHARED_LIBRARY>:/LARGEADDRESSAWARE>) ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") + #Compatible with Data Execution Prevention +- add_link_options($<$,SHARED_LIBRARY>:/NXCOMPAT>) ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NXCOMPAT") + #Use address space layout randomization +- add_link_options($<$,SHARED_LIBRARY>:/DYNAMICBASE>) ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE") + #shrink pdb size +- add_link_options($<$,SHARED_LIBRARY>:/PDBCOMPRESS>) ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /PDBCOMPRESS") + +- add_link_options($<$,SHARED_LIBRARY>:/DEBUG>) +- add_link_options($<$,SHARED_LIBRARY>:/IGNORE:4197,4013,4254,4070,4221>) +- add_link_options($<$,SHARED_LIBRARY>:/SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}>) ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG") ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4197,4013,4254,4070,4221") ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}") + + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221") + +- add_link_options($<$,EXECUTABLE>:/DEBUG>) +- add_link_options($<$,EXECUTABLE>:/PDBCOMPRESS>) +- add_link_options($<$,EXECUTABLE>:/STACK:1572864>) ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG") ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /PDBCOMPRESS") ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864") + + # Debug build specific flags +- add_link_options($<$,$>,$,SHARED_LIBRARY>>:/NOVCFEATURE>) ++ set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NOVCFEATURE") ++ set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_CHECKED} /NOVCFEATURE") + + # Checked build specific flags +- add_link_options($<$:/INCREMENTAL:NO>) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification" +- add_link_options($<$:/OPT:REF>) +- add_link_options($<$:/OPT:NOICF>) ++ add_linker_flag(/INCREMENTAL:NO CHECKED) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification" ++ add_linker_flag(/OPT:REF CHECKED) ++ add_linker_flag(/OPT:NOICF CHECKED) + + # Release build specific flags +- add_link_options($<$:/LTCG>) +- add_link_options($<$:/OPT:REF>) +- add_link_options($<$:/OPT:ICF>) ++ add_linker_flag(/LTCG RELEASE) ++ add_linker_flag(/OPT:REF RELEASE) ++ add_linker_flag(/OPT:ICF RELEASE) ++ add_linker_flag(/INCREMENTAL:NO RELEASE) + set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG") + + # ReleaseWithDebugInfo build specific flags +- add_link_options($<$:/LTCG>) +- add_link_options($<$:/OPT:REF>) +- add_link_options($<$:/OPT:ICF>) ++ add_linker_flag(/LTCG RELWITHDEBINFO) ++ add_linker_flag(/OPT:REF RELWITHDEBINFO) ++ add_linker_flag(/OPT:ICF RELWITHDEBINFO) + set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") + + # Force uCRT to be dynamically linked for Release build +- add_link_options("$<$:/NODEFAULTLIB:libucrt.lib;/DEFAULTLIB:ucrt.lib>") ++ add_linker_flag(/NODEFAULTLIB:libucrt.lib RELEASE) ++ add_linker_flag(/DEFAULTLIB:ucrt.lib RELEASE) + + elseif (CLR_CMAKE_HOST_UNIX) + # Set the values to display when interactively configuring CMAKE_BUILD_TYPE +@@ -157,11 +165,10 @@ elseif (CLR_CMAKE_HOST_UNIX) + + # -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections) + # -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint" +- add_compile_definitions("$<$,$>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>") +- add_link_options($<$,$>,$,EXECUTABLE>>:${CLR_SANITIZE_LINK_OPTIONS}>) +- ++ add_compile_options("$<$,$>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>") ++ add_linker_flag("${CLR_SANITIZE_LINK_OPTIONS}" DEBUG CHECKED) + # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking) +- add_link_options("$<$,$>,$,SHARED_LIBRARY>>:${CLR_SANITIZE_LINK_OPTIONS};-Wl,--gc-sections>") ++ add_linker_flag("-Wl,--gc-sections" DEBUG CHECKED) + endif () + endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED) + endif(MSVC) +@@ -173,15 +180,18 @@ endif(MSVC) + # ./build-native.sh cmakeargs "-DCLR_ADDITIONAL_COMPILER_OPTIONS=<...>" cmakeargs "-DCLR_ADDITIONAL_LINKER_FLAGS=<...>" + # + if(CLR_CMAKE_HOST_UNIX) +- add_link_options(${CLR_ADDITIONAL_LINKER_FLAGS}) ++ foreach(ADDTL_LINKER_FLAG ${CLR_ADDITIONAL_LINKER_FLAGS}) ++ add_linker_flag(${ADDTL_LINKER_FLAG}) ++ endforeach() + endif(CLR_CMAKE_HOST_UNIX) + + if(CLR_CMAKE_HOST_LINUX) + add_compile_options($<$:-Wa,--noexecstack>) +- add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now) ++ add_linker_flag(-Wl,--build-id=sha1) ++ add_linker_flag(-Wl,-z,relro,-z,now) + elseif(CLR_CMAKE_HOST_FREEBSD) + add_compile_options($<$:-Wa,--noexecstack>) +- add_link_options(LINKER:--build-id=sha1) ++ add_linker_flag("-Wl,--build-id=sha1") + elseif(CLR_CMAKE_HOST_SUNOS) + set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include) + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib) +@@ -357,7 +367,7 @@ if (CLR_CMAKE_HOST_UNIX) + if(CLR_CMAKE_HOST_OSX) + set(MACOS_VERSION_MIN_FLAGS -mmacosx-version-min=10.12) + add_compile_options(${MACOS_VERSION_MIN_FLAGS}) +- add_link_options(${MACOS_VERSION_MIN_FLAGS}) ++ add_linker_flag(${MACOS_VERSION_MIN_FLAGS}) + endif(CLR_CMAKE_HOST_OSX) + endif(CLR_CMAKE_HOST_UNIX) + +@@ -514,7 +524,7 @@ if(CLR_CMAKE_ENABLE_CODE_COVERAGE) + + add_compile_options(-fprofile-arcs) + add_compile_options(-ftest-coverage) +- add_link_options(--coverage) ++ add_linker_flag(--coverage) + else() + message(FATAL_ERROR "Code coverage builds not supported on current platform") + endif(CLR_CMAKE_HOST_UNIX) +diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake +index 1c5254d8496..4a4131cb05d 100644 +--- a/eng/native/configureplatform.cmake ++++ b/eng/native/configureplatform.cmake +@@ -1,4 +1,3 @@ +-include(CheckPIESupported) + include(${CMAKE_CURRENT_LIST_DIR}/functions.cmake) + + # If set, indicates that this is not an officially supported release +@@ -363,19 +362,10 @@ if(NOT CLR_CMAKE_TARGET_EMSCRIPTEN) + # but since we know that PIE is supported, we can safely skip this redundant check). + # + # The default linker on Solaris also does not support PIE. +- if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS) +- # All code we build should be compiled as position independent +- get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) +- if("CXX" IN_LIST languages) +- set(CLR_PIE_LANGUAGE CXX) +- else() +- set(CLR_PIE_LANGUAGE C) +- endif() +- check_pie_supported(OUTPUT_VARIABLE PIE_SUPPORT_OUTPUT LANGUAGES ${CLR_PIE_LANGUAGE}) +- if(NOT MSVC AND NOT CMAKE_${CLR_PIE_LANGUAGE}_LINK_PIE_SUPPORTED) +- message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n" +- "PIE link options will not be passed to linker.") +- endif() ++ if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_IOS AND NOT MSVC) ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") ++ add_compile_options($<$,EXECUTABLE>:-fPIE>) ++ add_compile_options($<$,SHARED_LIBRARY>:-fPIC>) + endif() + + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake +index b7f8f463804..f4a96cbe35e 100644 +--- a/eng/native/functions.cmake ++++ b/eng/native/functions.cmake +@@ -123,7 +123,7 @@ function(preprocess_compile_asm) + set(options "") + set(oneValueArgs OUTPUT_OBJECTS) + set(multiValueArgs ASM_FILES) +- cmake_parse_arguments(PARSE_ARGV 0 COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}") ++ cmake_parse_arguments(COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) + + get_include_directories_asm(ASM_INCLUDE_DIRECTORIES) + +@@ -209,7 +209,7 @@ function(target_precompile_header) + set(options "") + set(oneValueArgs TARGET HEADER) + set(multiValueArgs ADDITIONAL_INCLUDE_DIRECTORIES) +- cmake_parse_arguments(PARSE_ARGV 0 PRECOMPILE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}") ++ cmake_parse_arguments(PRECOMPILE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) + + if ("${PRECOMPILE_HEADERS_TARGET}" STREQUAL "") + message(SEND_ERROR "No target supplied to target_precompile_header.") +@@ -321,7 +321,7 @@ endfunction() + function(install_clr) + set(oneValueArgs ADDITIONAL_DESTINATION) + set(multiValueArgs TARGETS) +- cmake_parse_arguments(PARSE_ARGV 0 INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}") ++ cmake_parse_arguments(INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) + + if ("${INSTALL_CLR_TARGETS}" STREQUAL "") + message(FATAL_ERROR "At least one target must be passed to install_clr(TARGETS )") +@@ -377,6 +377,15 @@ function(disable_pax_mprotect targetName) + endif() + endfunction() + ++if (CMAKE_VERSION VERSION_LESS "3.12") ++ # Polyfill add_compile_definitions when it is unavailable ++ function(add_compile_definitions) ++ get_directory_property(DIR_COMPILE_DEFINITIONS COMPILE_DEFINITIONS) ++ list(APPEND DIR_COMPILE_DEFINITIONS ${ARGV}) ++ set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${DIR_COMPILE_DEFINITIONS}") ++ endfunction() ++endif() ++ + function(_add_executable) + if(NOT WIN32) + add_executable(${ARGV} ${VERSION_FILE_PATH}) +@@ -415,3 +424,16 @@ endfunction() + function(add_executable_clr) + _add_executable(${ARGV}) + endfunction() ++ ++# add_linker_flag(Flag [Config1 Config2 ...]) ++function(add_linker_flag Flag) ++ if (ARGN STREQUAL "") ++ set("CMAKE_EXE_LINKER_FLAGS" "${CMAKE_EXE_LINKER_FLAGS} ${Flag}" PARENT_SCOPE) ++ set("CMAKE_SHARED_LINKER_FLAGS" "${CMAKE_SHARED_LINKER_FLAGS} ${Flag}" PARENT_SCOPE) ++ else() ++ foreach(Config ${ARGN}) ++ set("CMAKE_EXE_LINKER_FLAGS_${Config}" "${CMAKE_EXE_LINKER_FLAGS_${Config}} ${Flag}" PARENT_SCOPE) ++ set("CMAKE_SHARED_LINKER_FLAGS_${Config}" "${CMAKE_SHARED_LINKER_FLAGS_${Config}} ${Flag}" PARENT_SCOPE) ++ endforeach() ++ endif() ++endfunction() +diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh +index f27bb33e357..1b4c2e02c59 100755 +--- a/eng/native/gen-buildsys.sh ++++ b/eng/native/gen-buildsys.sh +@@ -91,6 +91,9 @@ if [[ "$build_arch" == "wasm" ]]; then + cmake_command="emcmake $cmake_command" + fi + ++# We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options ++pushd "$3" ++ + # Include CMAKE_USER_MAKE_RULES_OVERRIDE as uninitialized since it will hold its value in the CMake cache otherwise can cause issues when branch switching + $cmake_command \ + -G "$generator" \ +@@ -98,5 +101,6 @@ $cmake_command \ + "-DCMAKE_INSTALL_PREFIX=$__CMakeBinDir" \ + $cmake_extra_defines \ + $__UnprocessedCMakeArgs \ +- -S "$1" \ +- -B "$3" ++ "$1" ++ ++popd +diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt +index 5fa572c4fcd..071ac2cf5fa 100644 +--- a/src/coreclr/CMakeLists.txt ++++ b/src/coreclr/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.14.2) ++cmake_minimum_required(VERSION 3.6.2) + + cmake_policy(SET CMP0042 NEW) + +diff --git a/src/coreclr/pgosupport.cmake b/src/coreclr/pgosupport.cmake +index 4b119809017..04bde2bc20b 100644 +--- a/src/coreclr/pgosupport.cmake ++++ b/src/coreclr/pgosupport.cmake +@@ -1,5 +1,18 @@ +-include(CheckIPOSupported) +-check_ipo_supported(RESULT HAVE_LTO) ++include(CheckCXXSourceCompiles) ++include(CheckCXXCompilerFlag) ++ ++# VC++ guarantees support for LTCG (LTO's equivalent) ++if(NOT WIN32) ++ # Function required to give CMAKE_REQUIRED_* local scope ++ function(check_have_lto) ++ set(CMAKE_REQUIRED_FLAGS -flto) ++ set(CMAKE_REQUIRED_LIBRARIES -flto -fuse-ld=gold) ++ check_cxx_source_compiles("int main() { return 0; }" HAVE_LTO) ++ endfunction(check_have_lto) ++ check_have_lto() ++ ++ check_cxx_compiler_flag(-faligned-new COMPILER_SUPPORTS_F_ALIGNED_NEW) ++endif(NOT WIN32) + + # Adds Profile Guided Optimization (PGO) flags to the current target + function(add_pgo TargetName) +diff --git a/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt b/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt +index dcd39e346c9..7b471d53726 100644 +--- a/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt ++++ b/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt +@@ -1,3 +1,4 @@ ++cmake_minimum_required(VERSION 3.8) + # Quick note: The CMake C# support is using the CSC bundled with the MSBuild that the native build runs on, not the one supplied by the local .NET SDK. + + project(DacTableGen LANGUAGES CSharp) +diff --git a/src/coreclr/src/binder/CMakeLists.txt b/src/coreclr/src/binder/CMakeLists.txt +index 3a66c81e10e..208f1214dd0 100644 +--- a/src/coreclr/src/binder/CMakeLists.txt ++++ b/src/coreclr/src/binder/CMakeLists.txt +@@ -82,11 +82,13 @@ endif(CLR_CMAKE_TARGET_WIN32) + convert_to_absolute_path(BINDER_SOURCES ${BINDER_SOURCES}) + convert_to_absolute_path(BINDER_CROSSGEN_SOURCES ${BINDER_CROSSGEN_SOURCES}) + +-add_library_clr(v3binder +- STATIC ++add_library_clr(v3binder_obj ++ OBJECT + ${BINDER_SOURCES} + ) +-add_dependencies(v3binder eventing_headers) ++add_dependencies(v3binder_obj eventing_headers) ++add_library(v3binder INTERFACE) ++target_sources(v3binder INTERFACE $) + + add_library_clr(v3binder_crossgen + STATIC +diff --git a/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt b/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt +index 391f70eff43..fdcf344c16a 100644 +--- a/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt ++++ b/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt +@@ -10,9 +10,11 @@ set(BCLTYPE_SOURCES + variant.cpp + ) + +-add_library_clr(bcltype +- STATIC ++add_library_clr(bcltype_obj ++ OBJECT + ${BCLTYPE_SOURCES} + ) + +-add_dependencies(bcltype eventing_headers) ++add_dependencies(bcltype_obj eventing_headers) ++add_library(bcltype INTERFACE) ++target_sources(bcltype INTERFACE $) +diff --git a/src/coreclr/src/classlibnative/float/CMakeLists.txt b/src/coreclr/src/classlibnative/float/CMakeLists.txt +index 44d40c92592..3c066620f76 100644 +--- a/src/coreclr/src/classlibnative/float/CMakeLists.txt ++++ b/src/coreclr/src/classlibnative/float/CMakeLists.txt +@@ -7,9 +7,12 @@ set(FLOAT_SOURCES + floatsingle.cpp + ) + +-add_library_clr(comfloat_wks +- STATIC ++add_library_clr(comfloat_wks_obj ++ OBJECT + ${FLOAT_SOURCES} + ) + +-add_dependencies(comfloat_wks eventing_headers) ++add_dependencies(comfloat_wks_obj eventing_headers) ++ ++add_library(comfloat_wks INTERFACE) ++target_sources(comfloat_wks INTERFACE $) +diff --git a/src/coreclr/src/debug/debug-pal/CMakeLists.txt b/src/coreclr/src/debug/debug-pal/CMakeLists.txt +index ac1e48fb5fb..213fa59e784 100644 +--- a/src/coreclr/src/debug/debug-pal/CMakeLists.txt ++++ b/src/coreclr/src/debug/debug-pal/CMakeLists.txt +@@ -34,4 +34,6 @@ if(CLR_CMAKE_HOST_UNIX) + + endif(CLR_CMAKE_HOST_UNIX) + +-_add_library(debug-pal STATIC ${TWO_WAY_PIPE_SOURCES}) ++_add_library(debug-pal_obj OBJECT ${TWO_WAY_PIPE_SOURCES}) ++add_library(debug-pal INTERFACE) ++target_sources(debug-pal INTERFACE $) +diff --git a/src/coreclr/src/debug/ee/wks/CMakeLists.txt b/src/coreclr/src/debug/ee/wks/CMakeLists.txt +index ee6c482ce76..3dd5e3612df 100644 +--- a/src/coreclr/src/debug/ee/wks/CMakeLists.txt ++++ b/src/coreclr/src/debug/ee/wks/CMakeLists.txt +@@ -9,9 +9,9 @@ if (CLR_CMAKE_TARGET_WIN32) + + if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64) + +- preprocess_compile_asm(ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS) ++ preprocess_compile_asm(TARGET cordbee_wks_obj ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS) + +- add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ${ASM_OBJECTS}) ++ add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE} ${ASM_OBJECTS}) + + else () + +@@ -23,19 +23,21 @@ if (CLR_CMAKE_TARGET_WIN32) + + set_source_files_properties(${ASM_FILE} PROPERTIES COMPILE_OPTIONS "${ASM_OPTIONS}") + +- add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ${ASM_FILE}) ++ add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE}) + + endif() + + else () + + if(CLR_CMAKE_HOST_ARCH_AMD64 OR CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64 OR CLR_CMAKE_HOST_ARCH_I386) +- add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ../${ARCH_SOURCES_DIR}/dbghelpers.S) ++ add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ../${ARCH_SOURCES_DIR}/dbghelpers.S) + else() + message(FATAL_ERROR "Unknown platform") + endif() + + endif (CLR_CMAKE_TARGET_WIN32) + +-target_precompile_header(TARGET cordbee_wks HEADER stdafx.h) +-add_dependencies(cordbee_wks eventing_headers) ++target_precompile_header(TARGET cordbee_wks_obj HEADER stdafx.h) ++add_dependencies(cordbee_wks_obj eventing_headers) ++add_library(cordbee_wks INTERFACE) ++target_sources(cordbee_wks INTERFACE $) +diff --git a/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt b/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt +index 88364658f11..362da1f6483 100644 +--- a/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt ++++ b/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt +@@ -10,5 +10,6 @@ set( ILDBSYMLIB_SOURCES + symwrite.cpp + ) + +-add_library_clr(ildbsymlib ${ILDBSYMLIB_SOURCES}) +- ++add_library_clr(ildbsymlib_obj OBJECT ${ILDBSYMLIB_SOURCES}) ++add_library(ildbsymlib INTERFACE) ++target_sources(ildbsymlib INTERFACE $) +diff --git a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt +index 777a2869e4f..066b75ab01f 100644 +--- a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt ++++ b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt +@@ -9,20 +9,20 @@ if (CLR_CMAKE_HOST_WIN32) + + list(APPEND CLR_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def) + +- add_link_options(/ENTRY:CoreDllMain) ++ add_linker_flag("/ENTRY:CoreDllMain") + + # Incremental linking results in the linker inserting extra padding and routing function calls via thunks that can break the + # invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page). +- add_link_options(/INCREMENTAL:NO) ++ add_linker_flag("/INCREMENTAL:NO") + + # Delay load libraries required for WinRT as that is not supported on all platforms +- add_link_options("/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll") +- add_link_options("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") +- add_link_options("/DELAYLOAD:api-ms-win-core-winrt-roparameterizediid-l1-1-0.dll") +- add_link_options("/DELAYLOAD:api-ms-win-ro-typeresolution-l1-1-0.dll") ++ add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll") ++ add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") ++ add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-roparameterizediid-l1-1-0.dll") ++ add_linker_flag("/DELAYLOAD:api-ms-win-ro-typeresolution-l1-1-0.dll") + + # Delay load version.dll so that we can specify how to search when loading it as it is not part of Windows' known DLLs +- add_link_options("/DELAYLOAD:version.dll") ++ add_linker_flag("/DELAYLOAD:version.dll") + + # No library groups for Win32 + set(START_LIBRARY_GROUP) +@@ -35,7 +35,7 @@ else(CLR_CMAKE_HOST_WIN32) + if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD) + # This option is necessary to ensure that the overloaded delete operator defined inside + # of the utilcode will be used instead of the standard library delete operator. +- add_link_options("LINKER:-Bsymbolic") ++ add_linker_flag("-Wl,-Bsymbolic") + + # The following linked options can be inserted into the linker libraries list to + # ensure proper resolving of circular references between a subset of the libraries. +@@ -110,7 +110,7 @@ set(CORECLR_LIBRARIES + utilcode + v3binder + libraries-native +- System.Globalization.Native-Static ++ System.Globalization.Native-static + interop + ) + +@@ -162,7 +162,12 @@ if(FEATURE_EVENT_TRACE) + endif(CLR_CMAKE_HOST_UNIX) + endif(FEATURE_EVENT_TRACE) + +-target_link_libraries(coreclr ${CORECLR_LIBRARIES}) ++if(FEATURE_MERGE_JIT_AND_ENGINE) ++ set(CLRJIT_STATIC clrjit_static) ++endif(FEATURE_MERGE_JIT_AND_ENGINE) ++ ++target_sources(coreclr PUBLIC $) ++target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} cee_wks) + + # Create the runtime module index header file containing the coreclr build id + # for xplat and the timestamp/size on Windows. +diff --git a/src/coreclr/src/dlls/mscorrc/CMakeLists.txt b/src/coreclr/src/dlls/mscorrc/CMakeLists.txt +index 08cf27aaf80..e114ec19cea 100644 +--- a/src/coreclr/src/dlls/mscorrc/CMakeLists.txt ++++ b/src/coreclr/src/dlls/mscorrc/CMakeLists.txt +@@ -19,7 +19,9 @@ if(CLR_CMAKE_HOST_WIN32) + else() + build_resources(${CMAKE_CURRENT_SOURCE_DIR}/include.rc mscorrc TARGET_CPP_FILE) + +- add_library_clr(mscorrc STATIC ++ add_library_clr(mscorrc_obj OBJECT + ${TARGET_CPP_FILE} + ) ++ add_library(mscorrc INTERFACE) ++ target_sources(mscorrc INTERFACE $) + endif(CLR_CMAKE_HOST_WIN32) +diff --git a/src/coreclr/src/gcinfo/CMakeLists.txt b/src/coreclr/src/gcinfo/CMakeLists.txt +index b0b67462562..50a1722a8ea 100644 +--- a/src/coreclr/src/gcinfo/CMakeLists.txt ++++ b/src/coreclr/src/gcinfo/CMakeLists.txt +@@ -16,11 +16,14 @@ endif(CLR_CMAKE_TARGET_ARCH_I386) + + convert_to_absolute_path(GCINFO_SOURCES ${GCINFO_SOURCES}) + +-add_library_clr(gcinfo +- STATIC ++add_library_clr(gcinfo_obj ++ OBJECT + ${GCINFO_SOURCES} + ) + ++add_library(gcinfo INTERFACE) ++target_sources(gcinfo INTERFACE $) ++ + add_library_clr(gcinfo_crossgen + STATIC + ${GCINFO_SOURCES} +diff --git a/src/coreclr/src/inc/CMakeLists.txt b/src/coreclr/src/inc/CMakeLists.txt +index 60fad88e77d..4f75d3a882d 100644 +--- a/src/coreclr/src/inc/CMakeLists.txt ++++ b/src/coreclr/src/inc/CMakeLists.txt +@@ -58,7 +58,9 @@ if(FEATURE_JIT_PITCHING) + endif(FEATURE_JIT_PITCHING) + + # Compile *_i.cpp to lib +-_add_library(corguids ${CORGUIDS_SOURCES}) ++_add_library(corguids_obj OBJECT ${CORGUIDS_SOURCES}) ++add_library(corguids INTERFACE) ++target_sources(corguids INTERFACE $) + + # Binplace the inc files for packaging later. + +@@ -75,4 +77,3 @@ _install (FILES cfi.h + gcinfoencoder.h + gcinfotypes.h + DESTINATION inc) +-_install (TARGETS corguids DESTINATION lib) +diff --git a/src/coreclr/src/interop/CMakeLists.txt b/src/coreclr/src/interop/CMakeLists.txt +index d7eaa1b04ae..3924b4fdbb4 100644 +--- a/src/coreclr/src/interop/CMakeLists.txt ++++ b/src/coreclr/src/interop/CMakeLists.txt +@@ -30,7 +30,10 @@ endif(WIN32) + + convert_to_absolute_path(INTEROP_SOURCES ${INTEROP_SOURCES}) + +-add_library_clr(interop +- STATIC ++add_library_clr(interop_obj ++ OBJECT + ${INTEROP_SOURCES} + ) ++ ++add_library(interop INTERFACE) ++target_sources(interop INTERFACE $) +diff --git a/src/coreclr/src/jit/dll/CMakeLists.txt b/src/coreclr/src/jit/dll/CMakeLists.txt +index ec7cddc78ed..01bdbf5a731 100644 +--- a/src/coreclr/src/jit/dll/CMakeLists.txt ++++ b/src/coreclr/src/jit/dll/CMakeLists.txt +@@ -2,17 +2,17 @@ project(ClrJit) + + set_source_files_properties(${JIT_EXPORTS_FILE} PROPERTIES GENERATED TRUE) + ++add_library_clr(clrjit_obj ++ OBJECT ++ ${JIT_CORE_SOURCES} ++ ${JIT_ARCH_SOURCES} ++) ++ + if(CLR_CMAKE_HOST_UNIX) +- add_library_clr(clrjit_static +- STATIC +- ${SHARED_LIB_SOURCES} +- ${JIT_ARCH_SOURCES} +- ) +- add_dependencies(clrjit_static coreclrpal gcinfo) +-else() +- add_library_clr(clrjit_static +- ${SHARED_LIB_SOURCES} +- ${JIT_ARCH_SOURCES} +- ) ++ add_dependencies(clrjit_obj coreclrpal gcinfo) + endif(CLR_CMAKE_HOST_UNIX) +-target_precompile_header(TARGET clrjit_static HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR}) ++ ++target_precompile_header(TARGET clrjit_obj HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR}) ++ ++add_library(clrjit_static INTERFACE) ++target_sources(clrjit_static INTERFACE $) +diff --git a/src/coreclr/src/md/ceefilegen/CMakeLists.txt b/src/coreclr/src/md/ceefilegen/CMakeLists.txt +index 90749c806b2..fd0f8424d97 100644 +--- a/src/coreclr/src/md/ceefilegen/CMakeLists.txt ++++ b/src/coreclr/src/md/ceefilegen/CMakeLists.txt +@@ -25,8 +25,11 @@ if (CLR_CMAKE_TARGET_WIN32) + list(APPEND CEEFILEGEN_SOURCES ${CEEFILEGEN_HEADERS}) + endif (CLR_CMAKE_TARGET_WIN32) + +-add_library_clr(ceefgen +- STATIC ++add_library_clr(ceefgen_obj ++ OBJECT + ${CEEFILEGEN_SOURCES} + ) +-target_precompile_header(TARGET ceefgen HEADER stdafx.h) ++target_precompile_header(TARGET ceefgen_obj HEADER stdafx.h) ++ ++add_library(ceefgen INTERFACE) ++target_sources(ceefgen INTERFACE $) +diff --git a/src/coreclr/src/md/compiler/CMakeLists.txt b/src/coreclr/src/md/compiler/CMakeLists.txt +index 3b916cdc9fe..f9f80db2500 100644 +--- a/src/coreclr/src/md/compiler/CMakeLists.txt ++++ b/src/coreclr/src/md/compiler/CMakeLists.txt +@@ -58,9 +58,11 @@ add_library_clr(mdcompiler_dac ${MDCOMPILER_SOURCES}) + set_target_properties(mdcompiler_dac PROPERTIES DAC_COMPONENT TRUE) + target_precompile_header(TARGET mdcompiler_dac HEADER stdafx.h) + +-add_library_clr(mdcompiler_wks ${MDCOMPILER_SOURCES}) +-target_compile_definitions(mdcompiler_wks PRIVATE FEATURE_METADATA_EMIT_ALL) +-target_precompile_header(TARGET mdcompiler_wks HEADER stdafx.h) ++add_library_clr(mdcompiler_wks_obj OBJECT ${MDCOMPILER_SOURCES}) ++target_compile_definitions(mdcompiler_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL) ++target_precompile_header(TARGET mdcompiler_wks_obj HEADER stdafx.h) ++add_library(mdcompiler_wks INTERFACE) ++target_sources(mdcompiler_wks INTERFACE $) + + add_library_clr(mdcompiler-dbi ${MDCOMPILER_SOURCES}) + set_target_properties(mdcompiler-dbi PROPERTIES DBI_COMPONENT TRUE) +diff --git a/src/coreclr/src/md/enc/CMakeLists.txt b/src/coreclr/src/md/enc/CMakeLists.txt +index 7220736b9ca..82af8434296 100644 +--- a/src/coreclr/src/md/enc/CMakeLists.txt ++++ b/src/coreclr/src/md/enc/CMakeLists.txt +@@ -48,9 +48,11 @@ add_library_clr(mdruntimerw_dac ${MDRUNTIMERW_SOURCES}) + set_target_properties(mdruntimerw_dac PROPERTIES DAC_COMPONENT TRUE) + target_precompile_header(TARGET mdruntimerw_dac HEADER stdafx.h) + +-add_library_clr(mdruntimerw_wks ${MDRUNTIMERW_SOURCES}) +-target_compile_definitions(mdruntimerw_wks PRIVATE FEATURE_METADATA_EMIT_ALL) +-target_precompile_header(TARGET mdruntimerw_wks HEADER stdafx.h) ++add_library_clr(mdruntimerw_wks_obj OBJECT ${MDRUNTIMERW_SOURCES}) ++target_compile_definitions(mdruntimerw_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL) ++target_precompile_header(TARGET mdruntimerw_wks_obj HEADER stdafx.h) ++add_library(mdruntimerw_wks INTERFACE) ++target_sources(mdruntimerw_wks INTERFACE $) + + add_library_clr(mdruntimerw-dbi ${MDRUNTIMERW_SOURCES}) + set_target_properties(mdruntimerw-dbi PROPERTIES DBI_COMPONENT TRUE) +diff --git a/src/coreclr/src/md/hotdata/CMakeLists.txt b/src/coreclr/src/md/hotdata/CMakeLists.txt +index c6168d2a4b0..88475cb72f4 100644 +--- a/src/coreclr/src/md/hotdata/CMakeLists.txt ++++ b/src/coreclr/src/md/hotdata/CMakeLists.txt +@@ -33,8 +33,10 @@ add_library_clr(mdhotdata_dac ${MDHOTDATA_SOURCES}) + set_target_properties(mdhotdata_dac PROPERTIES DAC_COMPONENT TRUE) + target_precompile_header(TARGET mdhotdata_dac HEADER external.h) + +-add_library_clr(mdhotdata_full ${MDHOTDATA_SOURCES}) +-target_precompile_header(TARGET mdhotdata_full HEADER external.h) ++add_library_clr(mdhotdata_full_obj OBJECT ${MDHOTDATA_SOURCES}) ++target_precompile_header(TARGET mdhotdata_full_obj HEADER external.h) ++add_library(mdhotdata_full INTERFACE) ++target_sources(mdhotdata_full INTERFACE $) + + add_library_clr(mdhotdata_crossgen ${MDHOTDATA_SOURCES}) + set_target_properties(mdhotdata_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) +diff --git a/src/coreclr/src/md/runtime/CMakeLists.txt b/src/coreclr/src/md/runtime/CMakeLists.txt +index 6dc193e14a7..7e0e83f1114 100644 +--- a/src/coreclr/src/md/runtime/CMakeLists.txt ++++ b/src/coreclr/src/md/runtime/CMakeLists.txt +@@ -47,9 +47,11 @@ add_library_clr(mdruntime_dac ${MDRUNTIME_SOURCES}) + set_target_properties(mdruntime_dac PROPERTIES DAC_COMPONENT TRUE) + target_precompile_header(TARGET mdruntime_dac HEADER stdafx.h) + +-add_library_clr(mdruntime_wks ${MDRUNTIME_SOURCES}) +-target_compile_definitions(mdruntime_wks PRIVATE FEATURE_METADATA_EMIT_ALL) +-target_precompile_header(TARGET mdruntime_wks HEADER stdafx.h) ++add_library_clr(mdruntime_wks_obj OBJECT ${MDRUNTIME_SOURCES}) ++target_compile_definitions(mdruntime_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL) ++target_precompile_header(TARGET mdruntime_wks_obj HEADER stdafx.h) ++add_library(mdruntime_wks INTERFACE) ++target_sources(mdruntime_wks INTERFACE $) + + add_library_clr(mdruntime-dbi ${MDRUNTIME_SOURCES}) + set_target_properties(mdruntime-dbi PROPERTIES DBI_COMPONENT TRUE) +diff --git a/src/coreclr/src/pal/src/CMakeLists.txt b/src/coreclr/src/pal/src/CMakeLists.txt +index e7c1629d5b2..7818deef050 100644 +--- a/src/coreclr/src/pal/src/CMakeLists.txt ++++ b/src/coreclr/src/pal/src/CMakeLists.txt +@@ -256,10 +256,12 @@ add_library(coreclrpal + # > warning for library: libtracepointprovider.a the table of contents is empty (no object file members in the library define global symbols) + # + if(CLR_CMAKE_TARGET_LINUX) +- add_library(tracepointprovider +- STATIC ++ add_library(tracepointprovider_obj ++ OBJECT + misc/tracepointprovider.cpp + ) ++ add_library(tracepointprovider INTERFACE) ++ target_sources(tracepointprovider INTERFACE $) + endif(CLR_CMAKE_TARGET_LINUX) + + if(CLR_CMAKE_TARGET_OSX) +diff --git a/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt b/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt +index 39b9826d1ab..8e6968cf783 100644 +--- a/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt ++++ b/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt +@@ -1,8 +1,8 @@ +-include(FindPython) ++include(FindPythonInterp) + + set (GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genDummyProvider.py) + +-set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) ++set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) + + execute_process( + COMMAND ${GENERATE_COMMAND} --dry-run +diff --git a/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt b/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt +index 234dea19b75..d55dab3557f 100644 +--- a/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt ++++ b/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt +@@ -1,7 +1,7 @@ +-include(FindPython) ++include(FindPythonInterp) + set (GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genLttngProvider.py) + +-set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) ++set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) + + execute_process( + COMMAND ${GENERATE_COMMAND} --dry-run +diff --git a/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt b/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt +index 000ee2d2fb0..845fae656be 100644 +--- a/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt ++++ b/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt +@@ -5,10 +5,10 @@ set(SOURCES + set(EVENT_MANIFEST ${VM_DIR}/ClrEtwAll.man) + set(TEST_GENERATOR ${CLR_DIR}/src/scripts/genEventingTests.py) + +-include(FindPython) ++include(FindPythonInterp) + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clralltestevents.cpp +- COMMAND ${Python_EXECUTABLE} ${TEST_GENERATOR} --testdir "${CMAKE_CURRENT_BINARY_DIR}" --man "${EVENT_MANIFEST}" ++ COMMAND ${PYTHON_EXECUTABLE} ${TEST_GENERATOR} --testdir "${CMAKE_CURRENT_BINARY_DIR}" --man "${EVENT_MANIFEST}" + DEPENDS ${EVENT_MANIFEST} ${TEST_GENERATOR} + COMMENT "Updating clralltestevents.cpp" + ) +diff --git a/src/coreclr/src/unwinder/CMakeLists.txt b/src/coreclr/src/unwinder/CMakeLists.txt +index 4421ea9f6f6..41a0219bbf7 100644 +--- a/src/coreclr/src/unwinder/CMakeLists.txt ++++ b/src/coreclr/src/unwinder/CMakeLists.txt +@@ -20,8 +20,10 @@ list(APPEND UNWINDER_SOURCES + convert_to_absolute_path(UNWINDER_SOURCES ${UNWINDER_SOURCES}) + + if(CLR_CMAKE_HOST_UNIX) +- add_library_clr(unwinder_wks ${UNWINDER_SOURCES}) +- add_dependencies(unwinder_wks eventing_headers) ++ add_library_clr(unwinder_wks_obj OBJECT ${UNWINDER_SOURCES}) ++ add_dependencies(unwinder_wks_obj eventing_headers) ++ add_library(unwinder_wks INTERFACE) ++ target_sources(unwinder_wks INTERFACE $) + endif(CLR_CMAKE_HOST_UNIX) + + add_library_clr(unwinder_dac ${UNWINDER_SOURCES}) +diff --git a/src/coreclr/src/utilcode/CMakeLists.txt b/src/coreclr/src/utilcode/CMakeLists.txt +index aa28b2db603..f8082fc9076 100644 +--- a/src/coreclr/src/utilcode/CMakeLists.txt ++++ b/src/coreclr/src/utilcode/CMakeLists.txt +@@ -98,7 +98,9 @@ convert_to_absolute_path(UTILCODE_CROSSGEN_SOURCES ${UTILCODE_CROSSGEN_SOURCES}) + convert_to_absolute_path(UTILCODE_STATICNOHOST_SOURCES ${UTILCODE_STATICNOHOST_SOURCES}) + + add_library_clr(utilcode_dac STATIC ${UTILCODE_DAC_SOURCES}) +-add_library_clr(utilcode STATIC ${UTILCODE_SOURCES}) ++add_library_clr(utilcode_obj OBJECT ${UTILCODE_SOURCES}) ++add_library(utilcode INTERFACE) ++target_sources(utilcode INTERFACE $) + add_library_clr(utilcodestaticnohost STATIC ${UTILCODE_STATICNOHOST_SOURCES}) + add_library_clr(utilcode_crossgen STATIC ${UTILCODE_CROSSGEN_SOURCES}) + +@@ -106,9 +108,9 @@ if(CLR_CMAKE_HOST_UNIX) + target_link_libraries(utilcodestaticnohost nativeresourcestring) + target_link_libraries(utilcode_crossgen nativeresourcestring) + target_link_libraries(utilcode_dac nativeresourcestring) +- target_link_libraries(utilcode nativeresourcestring) ++ target_link_libraries(utilcode INTERFACE nativeresourcestring) + add_dependencies(utilcode_dac coreclrpal) +- add_dependencies(utilcode coreclrpal) ++ add_dependencies(utilcode_obj coreclrpal) + endif(CLR_CMAKE_HOST_UNIX) + + +@@ -121,10 +123,10 @@ set_target_properties(utilcode_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) + target_compile_definitions(utilcode_dac PRIVATE SELF_NO_HOST) + target_compile_definitions(utilcodestaticnohost PRIVATE SELF_NO_HOST) + add_dependencies(utilcode_dac ${UTILCODE_DEPENDENCIES}) +-add_dependencies(utilcode ${UTILCODE_DEPENDENCIES}) ++add_dependencies(utilcode_obj ${UTILCODE_DEPENDENCIES}) + add_dependencies(utilcode_crossgen ${UTILCODE_DEPENDENCIES}) + add_dependencies(utilcodestaticnohost ${UTILCODE_DEPENDENCIES}) + target_precompile_header(TARGET utilcode_dac HEADER stdafx.h) +-target_precompile_header(TARGET utilcode HEADER stdafx.h) ++target_precompile_header(TARGET utilcode_obj HEADER stdafx.h) + target_precompile_header(TARGET utilcode_crossgen HEADER stdafx.h) + target_precompile_header(TARGET utilcodestaticnohost HEADER stdafx.h) +diff --git a/src/coreclr/src/vm/CMakeLists.txt b/src/coreclr/src/vm/CMakeLists.txt +index 3e37cebdc10..2b20d7d910a 100644 +--- a/src/coreclr/src/vm/CMakeLists.txt ++++ b/src/coreclr/src/vm/CMakeLists.txt +@@ -923,7 +923,7 @@ list(APPEND VM_HEADERS_DAC + + if (CLR_CMAKE_TARGET_WIN32) + list(APPEND VM_SOURCES_WKS ${VM_HEADERS_WKS}) +- list(APPEND VM_SOURCES_WKS_ARCH_ASM ${VM_HEADERS_WKS_ARCH_ASM}) ++ list(APPEND VM_SOURCES_WKS ${VM_HEADERS_WKS_ARCH_ASM}) + list(APPEND VM_SOURCES_DAC ${VM_HEADERS_DAC}) + endif(CLR_CMAKE_TARGET_WIN32) + +diff --git a/src/coreclr/src/vm/eventing/CMakeLists.txt b/src/coreclr/src/vm/eventing/CMakeLists.txt +index 98dd158df54..e2bf024fc59 100644 +--- a/src/coreclr/src/vm/eventing/CMakeLists.txt ++++ b/src/coreclr/src/vm/eventing/CMakeLists.txt +@@ -8,12 +8,13 @@ else() + set(NEED_XPLAT_HEADER ON) + endif() + +-include(FindPython) ++include(FindPythonInterp) + + set (EventingHeaders + ${GENERATED_INCLUDE_DIR}/etmdummy.h + ${GENERATED_INCLUDE_DIR}/clretwallmain.h + ${GENERATED_INCLUDE_DIR}/clreventpipewriteevents.h ++ ${GENERATED_INCLUDE_DIR}/clrproviders.h + ) + + if (NEED_XPLAT_HEADER) +@@ -24,7 +25,7 @@ endif() + set(GENEVENTING_SCRIPT ${CLR_DIR}/src/scripts/genEventing.py) + + add_custom_target(eventing_headers +- ${Python_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --inc ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG} ++ ${PYTHON_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --inc ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG} + DEPENDS ${EVENT_MANIFEST} ${GENEVENTING_SCRIPT} + VERBATIM + ) +diff --git a/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt b/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt +index 34a067e1ec5..4c7df2fbb3c 100644 +--- a/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt ++++ b/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt +@@ -1,4 +1,4 @@ +-include(FindPython) ++include(FindPythonInterp) + + set(ETW_PROVIDER_SCRIPT ${CLR_DIR}/src/scripts/genEtwProvider.py) + +@@ -14,5 +14,5 @@ set (ETW_PROVIDER_OUTPUTS + set_source_files_properties(${ETW_PROVIDER_OUTPUTS} PROPERTIES GENERATED TRUE) + + add_custom_target(eventprovider +- ${Python_EXECUTABLE} ${ETW_PROVIDER_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${GENERATED_INCLUDE_DIR} ++ ${PYTHON_EXECUTABLE} ${ETW_PROVIDER_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${GENERATED_INCLUDE_DIR} + DEPENDS ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS} ${ETW_PROVIDER_SCRIPT}) +diff --git a/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt +index 00b3f6f386f..00d79737e54 100644 +--- a/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt ++++ b/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt +@@ -1,9 +1,9 @@ +-include(FindPython) ++include(FindPythonInterp) + + set(CMAKE_INCLUDE_CURRENT_DIR ON) + + set(GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genEventPipe.py) +-set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${CMAKE_CURRENT_BINARY_DIR} ${NONEXTERN_ARG}) ++set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${CMAKE_CURRENT_BINARY_DIR} ${NONEXTERN_ARG}) + + execute_process( + COMMAND ${GENERATE_COMMAND} --dry-run +@@ -28,10 +28,8 @@ add_custom_command(OUTPUT ${EVENTPIPE_SOURCES} + COMMAND ${GENERATE_COMMAND} + DEPENDS ${GENERATE_SCRIPT} ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS}) + +-add_library_clr(eventpipe STATIC ${EVENTPIPE_SOURCES}) +-set_target_properties(eventpipe PROPERTIES LINKER_LANGUAGE CXX) +-add_dependencies(eventpipe eventing_headers) +- +-if (NOT CLR_CMAKE_TARGET_WIN32) +- _install(TARGETS eventpipe DESTINATION lib) +-endif() ++add_library_clr(eventpipe_obj OBJECT ${EVENTPIPE_SOURCES}) ++set_target_properties(eventpipe_obj PROPERTIES LINKER_LANGUAGE CXX) ++add_dependencies(eventpipe_obj eventing_headers) ++add_library(eventpipe INTERFACE) ++target_sources(eventpipe INTERFACE $) +diff --git a/src/coreclr/src/vm/wks/CMakeLists.txt b/src/coreclr/src/vm/wks/CMakeLists.txt +index 1e94b575fd6..5d355f6adcb 100644 +--- a/src/coreclr/src/vm/wks/CMakeLists.txt ++++ b/src/coreclr/src/vm/wks/CMakeLists.txt +@@ -7,13 +7,19 @@ if (CLR_CMAKE_TARGET_WIN32) + + endif (CLR_CMAKE_TARGET_WIN32) + +-add_library_clr(cee_wks ${VM_SOURCES_WKS} ${VM_SOURCES_WKS_ARCH_ASM}) +-target_precompile_header(TARGET cee_wks HEADER common.h) ++add_library_clr(cee_wks_core OBJECT ${VM_SOURCES_WKS} ${VM_SOURCES_WKS_ARCH_ASM}) ++add_library_clr(cee_wks_obj OBJECT ${VM_SOURCES_WKS_SPECIAL}) ++ ++target_precompile_header(TARGET cee_wks_core HEADER common.h) ++target_precompile_header(TARGET cee_wks_obj HEADER common.h) ++ + if (MSVC) + # mscorlib.cpp does not compile with precompiled header file + set_source_files_properties(../mscorlib.cpp PROPERTIES COMPILE_FLAGS "/Y-") + endif() +-add_dependencies(cee_wks eventing_headers) ++ ++add_dependencies(cee_wks_core eventing_headers) ++add_dependencies(cee_wks_obj eventing_headers) + + if (CLR_CMAKE_TARGET_WIN32) + +@@ -45,8 +51,16 @@ if (CLR_CMAKE_TARGET_WIN32) + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.inc + ) + +- add_dependencies(cee_wks asmconstants_inc) ++ add_dependencies(cee_wks_core asmconstants_inc) ++ add_dependencies(cee_wks_obj asmconstants_inc) + + endif(NOT CLR_CMAKE_HOST_ARCH_ARM AND NOT CLR_CMAKE_HOST_ARCH_ARM64) + + endif (CLR_CMAKE_TARGET_WIN32) ++ ++add_custom_target(preprocessd_asm DEPENDS ${VM_WKS_ARCH_ASM_OBJECTS}) ++add_dependencies(cee_wks_core preprocessd_asm) ++add_dependencies(cee_wks_obj preprocessd_asm) ++ ++add_library(cee_wks INTERFACE) ++target_sources(cee_wks INTERFACE $ ${VM_WKS_ARCH_ASM_OBJECTS}) +diff --git a/src/coreclr/tests/CMakeLists.txt b/src/coreclr/tests/CMakeLists.txt +index 53dbb85a58b..c5417cba7d0 100644 +--- a/src/coreclr/tests/CMakeLists.txt ++++ b/src/coreclr/tests/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.14.2) ++cmake_minimum_required(VERSION 3.6.2) + + cmake_policy(SET CMP0042 NEW) + project(Tests) +diff --git a/src/installer/corehost/CMakeLists.txt b/src/installer/corehost/CMakeLists.txt +index 43a59a1a695..dff0496cdd8 100644 +--- a/src/installer/corehost/CMakeLists.txt ++++ b/src/installer/corehost/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.14.2) ++cmake_minimum_required(VERSION 3.6.2) + + project(corehost) + +diff --git a/src/installer/corehost/cli/exe.cmake b/src/installer/corehost/cli/exe.cmake +index de8cd49396b..732faf97ff9 100644 +--- a/src/installer/corehost/cli/exe.cmake ++++ b/src/installer/corehost/cli/exe.cmake +@@ -5,7 +5,6 @@ + project (${DOTNET_PROJECT_NAME}) + + cmake_policy(SET CMP0011 NEW) +-cmake_policy(SET CMP0083 NEW) + + include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) + +diff --git a/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt b/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt +index bcf6a051229..8572a6318ec 100644 +--- a/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt ++++ b/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt +@@ -2,7 +2,6 @@ + # The .NET Foundation licenses this file to you under the MIT license. + # See the LICENSE file in the project root for more information. + +-cmake_minimum_required (VERSION 2.6) + project(mockhostfxr_2_2) + + set(DOTNET_PROJECT_NAME "mockhostfxr_2_2") +diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt +index f14ada69fee..cb174fe5013 100644 +--- a/src/libraries/Native/Unix/CMakeLists.txt ++++ b/src/libraries/Native/Unix/CMakeLists.txt +@@ -1,19 +1,14 @@ +-cmake_minimum_required(VERSION 3.14.2) ++cmake_minimum_required(VERSION 3.6.2) ++if(CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) ++ # CMake 3.14.5 contains bug fixes for iOS ++ cmake_minimum_required(VERSION 3.14.5) ++ endif() + cmake_policy(SET CMP0042 NEW) + + project(CoreFX C) + + include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake) + +-if(CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +- # CMake 3.14.5 contains bug fixes for iOS +- cmake_minimum_required(VERSION 3.14.5) +-endif() +- +-if(NOT CLR_CMAKE_TARGET_ARCH_WASM) +- cmake_policy(SET CMP0083 NEW) +-endif(NOT CLR_CMAKE_TARGET_ARCH_WASM) +- + set(CMAKE_MACOSX_RPATH ON) + set(CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir}) + set(CMAKE_INCLUDE_CURRENT_DIR ON) +@@ -167,7 +162,8 @@ if(CLR_CMAKE_TARGET_UNIX) + if(NOT CLR_CMAKE_TARGET_ARCH_WASM AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + if(CLR_CMAKE_TARGET_OSX) + add_definitions(-DTARGET_OSX) +- add_link_options(-Wl,-bind_at_load) ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-bind_at_load") ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-bind_at_load" ) + else() + add_compile_options($<$:-Wa,--noexecstack>) + if(CLR_CMAKE_TARGET_SUNOS) +@@ -175,7 +171,8 @@ if(CLR_CMAKE_TARGET_UNIX) + else() + # -z,now is required for full relro. + # see https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro +- add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now) ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now") ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now" ) + endif() + endif() + endif() +diff --git a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt +index bcfc5dd106a..ebcb5a02b3f 100644 +--- a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt ++++ b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt +@@ -79,14 +79,15 @@ if (GEN_SHARED_LIB) + install_with_stripped_symbols (System.Globalization.Native PROGRAMS .) + endif() + +-add_library(System.Globalization.Native-Static +- STATIC ++add_library(System.Globalization.Native-obj ++ OBJECT + ${NATIVEGLOBALIZATION_SOURCES} + ) + +-set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) ++set_target_properties(System.Globalization.Native-obj PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) + +-install (TARGETS System.Globalization.Native-Static DESTINATION .) ++add_library(System.Globalization.Native-static INTERFACE) ++target_sources(System.Globalization.Native-static INTERFACE $) + + if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID) + if (GEN_SHARED_LIB) diff --git a/runtime-dont-strip.patch b/runtime-dont-strip.patch new file mode 100644 index 0000000..694face --- /dev/null +++ b/runtime-dont-strip.patch @@ -0,0 +1,47 @@ +Do not strip native/unmanaged symbols from binaries + +This is a hack. It rips out the calls to strip directly. + +The correct/upstreamable fix is to add a configure/build option to +keep symbols for some builds, such as those needed by upstream. + +diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake +index 8b73581ed14..7697908425e 100644 +--- a/eng/native/functions.cmake ++++ b/eng/native/functions.cmake +@@ -282,7 +282,7 @@ function(target_precompile_header) + endif(MSVC) + endfunction() + +-function(strip_symbols targetName outputFilename) ++function(strip_symbols_renamed targetName outputFilename) + if (CLR_CMAKE_HOST_UNIX) + set(strip_source_file $) + +@@ -336,8 +336,8 @@ function(strip_symbols targetName outputFilename) + endfunction() + + function(install_with_stripped_symbols targetName kind destination) +- strip_symbols(${targetName} symbol_file) +- install_symbols(${symbol_file} ${destination}) ++ # strip_symbols_renamed(${targetName} symbol_file) ++ # install_symbols(${symbol_file} ${destination}) + if ("${kind}" STREQUAL "TARGETS") + set(install_source ${targetName}) + elseif("${kind}" STREQUAL "PROGRAMS") +@@ -375,13 +375,13 @@ function(install_clr) + foreach(targetName ${INSTALL_CLR_TARGETS}) + list(FIND CLR_CROSS_COMPONENTS_LIST ${targetName} INDEX) + if (NOT DEFINED CLR_CROSS_COMPONENTS_LIST OR NOT ${INDEX} EQUAL -1) +- strip_symbols(${targetName} symbol_file) ++ # strip_symbols_renamed(${targetName} symbol_file) + + foreach(destination ${destinations}) + # We don't need to install the export libraries for our DLLs + # since they won't be directly linked against. + install(PROGRAMS $ DESTINATION ${destination}) +- install_symbols(${symbol_file} ${destination}) ++ # install_symbols(${symbol_file} ${destination}) + + if(CLR_CMAKE_PGO_INSTRUMENT) + if(WIN32) diff --git a/runtime-flags-support.patch b/runtime-flags-support.patch new file mode 100644 index 0000000..921e483 --- /dev/null +++ b/runtime-flags-support.patch @@ -0,0 +1,30 @@ +diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh +index b976f5fdc6c..853580b1c7a 100755 +--- a/eng/native/build-commons.sh ++++ b/eng/native/build-commons.sh +@@ -163,6 +163,14 @@ EOF + return + fi + ++ SAVED_CFLAGS="${CFLAGS}" ++ SAVED_CXXFLAGS="${CXXFLAGS}" ++ SAVED_LDFLAGS="${LDFLAGS}" ++ ++ export CFLAGS="${CFLAGS} ${EXTRA_CFLAGS}" ++ export CXXFLAGS="${CXXFLAGS} ${EXTRA_CXXFLAGS}" ++ export LDFLAGS="${LDFLAGS} ${EXTRA_LDFLAGS}" ++ + if [[ "$__StaticAnalyzer" == 1 ]]; then + pushd "$intermediatesDir" + +@@ -181,6 +189,10 @@ EOF + $cmake_command --build "$intermediatesDir" --target install -- -j "$__NumProc" + fi + ++ CFLAGS="${SAVED_CFLAGS}" ++ CXXFLAGS="${SAVED_CXXFLAGS}" ++ LDFLAGS="${SAVED_LDFLAGS}" ++ + local exit_code="$?" + if [[ "$exit_code" != 0 ]]; then + echo "${__ErrMsgPrefix}Failed to build \"$message\"." diff --git a/cli-telemetry-optout.patch b/sdk-telemetry-optout.patch similarity index 82% rename from cli-telemetry-optout.patch rename to sdk-telemetry-optout.patch index 9b01f13..9b92f33 100644 --- a/cli-telemetry-optout.patch +++ b/sdk-telemetry-optout.patch @@ -1,7 +1,7 @@ -diff --git a/src/dotnet/Program.cs b/src/dotnet/Program.cs +diff --git a/src/Cli/dotnet/Program.cs b/src/Cli/dotnet/Program.cs index de1ebb9e6..6bbf479de 100644 ---- a/src/dotnet/Program.cs -+++ b/src/dotnet/Program.cs +--- a/src/Cli/dotnet/Program.cs ++++ b/src/Cli/dotnet/Program.cs @@ -28,6 +28,13 @@ public class Program public static int Main(string[] args) diff --git a/sources b/sources deleted file mode 100644 index 6762903..0000000 --- a/sources +++ /dev/null @@ -1 +0,0 @@ -SHA512 (dotnet-v3.1.103.2-SDK.tar.gz) = 6c4de4914f6d107e59300efb43fae24fffdbb983a5ffeb36fbe26c8071a87e76162ebde0f0aa270ab7cbb666b4ee0ab65cfab98f1dbba2ea9d48809372417ec2 diff --git a/tests/tests.yml b/tests/tests.yml index ede9095..f3825cf 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -7,20 +7,18 @@ - container - atomic repositories: - - repo: "https://github.com/redhat-developer/dotnet-bunny.git" - dest: "dotnet-bunny" - repo: "https://github.com/redhat-developer/dotnet-regular-tests.git" dest: "dotnet-regular-tests" tests: - - build_test_suite: - dir: dotnet-bunny - run: make - - print_test_suite_version: - dir: dotnet-bunny - run: bin/turkey --version - - run_regular_tests: - dir: dotnet-regular-tests - run: ../dotnet-bunny/bin/turkey -l={{ remote_artifacts }} + - download_test_runner: + dir: ./ + run: wget --no-verbose https://github.com/redhat-developer/dotnet-bunny/releases/latest/download/turkey-$(uname -m) -O turkey && chmod +x ./turkey + - print_test_runner_version: + dir: ./ + run: ./turkey --version + - regular: + dir: ./ + run: ./turkey -l={{ remote_artifacts }} -s=$(pwd)/nuget-prerelease dotnet-regular-tests required_packages: - babeltrace - bash-completion diff --git a/update-release b/update-release index d8bcde7..da87262 100755 --- a/update-release +++ b/update-release @@ -26,7 +26,7 @@ while [[ "$#" -gt 0 ]]; do esac done -spec_file=dotnet3.1.spec +spec_file=dotnet5.0.spec sdk_version=${positional_args[0]:-} if [[ -z ${sdk_version} ]]; then From 260d2eab645885b86643a9c6da358d3b38941f56 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 14 Sep 2020 11:29:00 -0400 Subject: [PATCH 13/19] Update to Preview 8 --- build-additional-rids.patch | 24 + build-dotnet-tarball | 7 +- dotnet5.0.spec | 108 +-- runtime-39044-cmake-downgrade.patch | 1158 --------------------------- runtime-linker-order.patch | 20 + 5 files changed, 103 insertions(+), 1214 deletions(-) create mode 100644 build-additional-rids.patch delete mode 100644 runtime-39044-cmake-downgrade.patch create mode 100644 runtime-linker-order.patch diff --git a/build-additional-rids.patch b/build-additional-rids.patch new file mode 100644 index 0000000..5bfba35 --- /dev/null +++ b/build-additional-rids.patch @@ -0,0 +1,24 @@ +diff --git a/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/PublishCoreSetupBinaries.cs b/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/PublishCoreSetupBinaries.cs +index 4394a8b..e32d338 100644 +--- a/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/PublishCoreSetupBinaries.cs ++++ b/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/PublishCoreSetupBinaries.cs +@@ -36,12 +36,15 @@ namespace Microsoft.DotNet.Build.Tasks + // should include the delimiter immediately before the RID, arch, or extension. + protected string[] BadAtoms = new[] { "-x64", ".x64", + ".tar", ".gz", +- "-rhel.7", "-rhel.8", +- ".rhel.7", ".rhel.8", +- "-centos.7", "-centos.8", +- ".centos.7", ".centos.8", ++ "-rhel.7", "-rhel.8", "-rhel.9", ++ ".rhel.7", ".rhel.8", ".rhel.9", ++ "-centos.7", "-centos.8", "-centos.9", ++ ".centos.7", ".centos.8", ".centos.9", + ".fedora.30", "-fedora.30", + ".fedora.31", "-fedora.31", ++ ".fedora.32", "-fedora.32", ++ ".fedora.33", "-fedora.33", ++ ".fedora.34", "-fedora.34", + "-linux", ".linux", + "-osx", ".osx", + "-OSX", ".OSX", diff --git a/build-dotnet-tarball b/build-dotnet-tarball index f32d847..fbaea55 100755 --- a/build-dotnet-tarball +++ b/build-dotnet-tarball @@ -93,6 +93,7 @@ if [ ! -f "${unmodified_tarball_name}.tar.gz" ]; then clean_dotnet_cache sed -i -e 's|cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE||' repos/runtime.common.props # FIXME remove contineuonprebuilterror + patch -p1 -i ../../build-additional-rids.patch ./build.sh -p:SkipPrebuiltEnforcement=true -p:ContinueOnPrebuiltBaselineError=true -p:ArchiveDownloadedPackages=true ./build-source-tarball.sh "${unmodified_tarball_name}" --skip-build -- -p:ContinueOnPrebuiltBaselineError=true -p:SkipPrebuiltEnforcement=true popd @@ -110,10 +111,8 @@ mv "${unmodified_tarball_name}" "${tarball_name}" pushd "${tarball_name}" # Remove files with funny licenses, crypto implementations and other # not-very-useful artifacts to reduce tarball size -rm -rf .dotnet -find -type f -iname '*.tar.gz' -delete -rm -r src/AspNetCore.*/src/SignalR/clients/java/signalr/gradle* -find src/AspNetCore.*/src -type d -name samples -print0 | xargs -0 rm -r +rm -r src/aspnetcore.*/src/SignalR/clients/java/signalr/gradle* +find src/aspnetcore.*/src -type d -name samples -print0 | xargs -0 rm -r rm -r src/NuGet.Client.*/test/EndToEnd/ProjectTemplates/NetCoreWebApplication1.0.zip find src/runtime.*/ -depth -name tests -print0 | xargs -0 rm -r popd diff --git a/dotnet5.0.spec b/dotnet5.0.spec index 49221a4..8305ab1 100644 --- a/dotnet5.0.spec +++ b/dotnet5.0.spec @@ -20,11 +20,11 @@ %global dotnet_cflags %(echo %optflags | sed -e 's/-fstack-clash-protection//' | sed -re 's/-specs=[^ ]*//g') %global dotnet_ldflags %(echo %{__global_ldflags} | sed -re 's/-specs=[^ ]*//g') -%global host_version 5.0.0-preview.4.20251.6 -%global runtime_version 5.0.0-preview.4.20251.6 -%global aspnetcore_runtime_version 5.0.0-preview.4.20257.10 -%global sdk_version 5.0.100-preview.4.20161.13 -%global templates_version 5.0.0-preview.4.20161.13 +%global host_version 5.0.0-preview.8.20407.11 +%global runtime_version 5.0.0-preview.8.20407.11 +%global aspnetcore_runtime_version 5.0.0-preview.8.20414.8 +%global sdk_version 5.0.100-preview.8.20417.9 +%global templates_version 5.0.0-preview.8.20417.9 #%%global templates_version %%(echo %%{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }') %global host_rpm_version 5.0.0 @@ -33,7 +33,7 @@ %global sdk_rpm_version 5.0.100 # upstream can update releases without revving the SDK version so these don't always match -%global src_version %{sdk_rpm_version} +%global src_version %{sdk_version} %if 0%{?fedora} || 0%{?rhel} < 8 %global use_bundled_libunwind 0 @@ -64,25 +64,24 @@ Name: dotnet5.0 Version: %{sdk_rpm_version} -Release: 0.2.preview4%{?dist} -Summary: .NET Core Runtime and SDK +Release: 0.3.preview8%{?dist} +Summary: .NET Runtime and SDK License: MIT and ASL 2.0 and BSD and LGPLv2+ and CC-BY and CC0 and MS-PL and EPL-1.0 and GPL+ and GPLv2 and ISC and OFL and zlib URL: https://github.com/dotnet/ # The source is generated on a Fedora box via: # ./build-dotnet-tarball v%%{src_version}-SDK -Source0: dotnet-v%{src_version}-preview4-SDK.tar.gz +Source0: dotnet-v%{src_version}-SDK.tar.gz Source1: check-debug-symbols.py Source2: dotnet.sh.in -# dotnet/runtime PR 39044 -Patch100: runtime-39044-cmake-downgrade.patch - -# TODO: upstream this patch +# https://github.com/dotnet/runtime/pull/39203 # Do not strip debuginfo from (native/unmanaged) binaries -Patch101: runtime-dont-strip.patch - -# TODO: upstream this patch +Patch100: runtime-dont-strip.patch +# https://github.com/dotnet/runtime/pull/42094 +# Fix linker order when linking with --as-needed +Patch101: runtime-linker-order.patch +# https://github.com/dotnet/runtime/pull/39191 # Fix building with our additional CFLAGS/CXXFLAGS/LDFLAGS Patch102: runtime-flags-support.patch @@ -123,13 +122,13 @@ BuildRequires: tar BuildRequires: zlib-devel %description -.NET Core is a fast, lightweight and modular platform for creating +.NET is a fast, lightweight and modular platform for creating cross platform applications that work on Linux, macOS and Windows. It particularly focuses on creating console applications, web applications and micro-services. -.NET Core contains a runtime conforming to .NET Standards a set of +.NET contains a runtime conforming to .NET Standards a set of framework libraries, an SDK containing compilers and a 'dotnet' application to drive everything. @@ -137,18 +136,18 @@ application to drive everything. %package -n dotnet Version: %{sdk_rpm_version} -Summary: .NET Core CLI tools and runtime +Summary: .NET CLI tools and runtime Requires: dotnet-sdk-5.0%{?_isa} >= %{sdk_rpm_version}-%{release} %description -n dotnet -.NET Core is a fast, lightweight and modular platform for creating +.NET is a fast, lightweight and modular platform for creating cross platform applications that work on Linux, macOS and Windows. It particularly focuses on creating console applications, web applications and micro-services. -.NET Core contains a runtime conforming to .NET Standards a set of +.NET contains a runtime conforming to .NET Standards a set of framework libraries, an SDK containing compilers and a 'dotnet' application to drive everything. @@ -159,10 +158,10 @@ Version: %{host_rpm_version} Summary: .NET command line launcher %description -n dotnet-host -The .NET Core host is a command line program that runs a standalone -.NET core application or launches the SDK. +The .NET host is a command line program that runs a standalone +.NET application or launches the SDK. -.NET Core is a fast, lightweight and modular platform for creating +.NET is a fast, lightweight and modular platform for creating cross platform applications that work on Linux, Mac and Windows. It particularly focuses on creating console applications, web @@ -172,17 +171,17 @@ applications and micro-services. %package -n dotnet-hostfxr-5.0 Version: %{host_rpm_version} -Summary: .NET Core command line host resolver +Summary: .NET command line host resolver # Theoretically any version of the host should work. But lets aim for the one -# provided by this package, or from a newer version of .NET Core +# provided by this package, or from a newer version of .NET Requires: dotnet-host%{?_isa} >= %{host_rpm_version}-%{release} %description -n dotnet-hostfxr-5.0 -The .NET Core host resolver contains the logic to resolve and select -the right version of the .NET Core SDK or runtime to use. +The .NET host resolver contains the logic to resolve and select +the right version of the .NET SDK or runtime to use. -.NET Core is a fast, lightweight and modular platform for creating +.NET is a fast, lightweight and modular platform for creating cross platform applications that work on Linux, Mac and Windows. It particularly focuses on creating console applications, web @@ -192,7 +191,7 @@ applications and micro-services. %package -n dotnet-runtime-5.0 Version: %{runtime_rpm_version} -Summary: NET Core 5.0 runtime +Summary: NET 5.0 runtime Requires: dotnet-hostfxr-5.0%{?_isa} >= %{host_rpm_version}-%{release} @@ -204,11 +203,11 @@ Provides: bundled(libunwind) = 1.3 %endif %description -n dotnet-runtime-5.0 -The .NET Core runtime contains everything needed to run .NET Core applications. +The .NET runtime contains everything needed to run .NET applications. It includes a high performance Virtual Machine as well as the framework -libraries used by .NET Core applications. +libraries used by .NET applications. -.NET Core is a fast, lightweight and modular platform for creating +.NET is a fast, lightweight and modular platform for creating cross platform applications that work on Linux, Mac and Windows. It particularly focuses on creating console applications, web @@ -223,9 +222,9 @@ Summary: ASP.NET Core 5.0 runtime Requires: dotnet-runtime-5.0%{?_isa} >= %{runtime_rpm_version}-%{release} %description -n aspnetcore-runtime-5.0 -The ASP.NET Core runtime contains everything needed to run .NET Core +The ASP.NET Core runtime contains everything needed to run .NET web applications. It includes a high performance Virtual Machine as -well as the framework libraries used by .NET Core applications. +well as the framework libraries used by .NET applications. ASP.NET Core is a fast, lightweight and modular platform for creating cross platform web applications that work on Linux, Mac and Windows. @@ -237,17 +236,17 @@ applications and micro-services. %package -n dotnet-templates-5.0 Version: %{sdk_rpm_version} -Summary: .NET Core 5.0 templates +Summary: .NET 5.0 templates # Theoretically any version of the host should work. But lets aim for the one -# provided by this package, or from a newer version of .NET Core +# provided by this package, or from a newer version of .NET Requires: dotnet-host%{?_isa} >= %{host_rpm_version}-%{release} %description -n dotnet-templates-5.0 -This package contains templates used by the .NET Core SDK. +This package contains templates used by the .NET SDK. -ASP.NET Core is a fast, lightweight and modular platform for creating -cross platform web applications that work on Linux, Mac and Windows. +.NET is a fast, lightweight and modular platform for creating +cross platform applications that work on Linux, Mac and Windows. It particularly focuses on creating console applications, web applications and micro-services. @@ -256,7 +255,7 @@ applications and micro-services. %package -n dotnet-sdk-5.0 Version: %{sdk_rpm_version} -Summary: .NET Core 5.0 Software Development Kit +Summary: .NET 5.0 Software Development Kit Provides: bundled(js-jquery) Provides: bundled(npm) @@ -272,10 +271,10 @@ Requires: netstandard-targeting-pack-2.1%{?_isa} >= %{sdk_rpm_version}-%{r Requires: dotnet-templates-5.0%{?_isa} >= %{sdk_rpm_version}-%{release} %description -n dotnet-sdk-5.0 -The .NET Core SDK is a collection of command line applications to -create, build, publish and run .NET Core applications. +The .NET SDK is a collection of command line applications to +create, build, publish and run .NET applications. -.NET Core is a fast, lightweight and modular platform for creating +.NET is a fast, lightweight and modular platform for creating cross platform applications that work on Linux, Mac and Windows. It particularly focuses on creating console applications, web @@ -293,7 +292,7 @@ Requires: dotnet-host%{?_isa} %description -n %{1} This package provides a targeting pack for %{3} %{4} that allows developers to compile against and target %{3} %{4} -applications using the .NET Core SDK. +applications using the .NET SDK. %files -n %{1} %dir %{_libdir}/dotnet/packs @@ -309,17 +308,17 @@ applications using the .NET Core SDK. %package -n dotnet-sdk-5.0-source-built-artifacts Version: %{sdk_rpm_version} -Summary: Internal package for building .NET Core 5.0 Software Development Kit +Summary: Internal package for building .NET 5.0 Software Development Kit %description -n dotnet-sdk-5.0-source-built-artifacts -The .NET Core source-built archive is a collection of packages needed -to build the .NET Core SDK itself. +The .NET source-built archive is a collection of packages needed +to build the .NET SDK itself. These are not meant for general use. %prep -%setup -q -n dotnet-v%{src_version}-preview4-SDK +%setup -q -n dotnet-v%{src_version}-SDK %if %{without bootstrap} # Remove all prebuilts @@ -383,7 +382,7 @@ cp -a %{_libdir}/dotnet previously-built-dotnet export EXTRA_CFLAGS="%{dotnet_cflags}" export EXTRA_CXXFLAGS="%{dotnet_cflags}" -export EXTRA_LDFLAGS="%%{dotnet_ldflags}" +export EXTRA_LDFLAGS="%{dotnet_ldflags}" #%%if %%{without bootstrap} # --with-ref-packages %%{_libdir}/dotnet/reference-packages/ \ @@ -409,7 +408,7 @@ sed -e 's|[@]LIBDIR[@]|%{_libdir}|g' %{SOURCE2} > dotnet.sh %install install -dm 0755 %{buildroot}%{_libdir}/dotnet ls artifacts/%{runtime_arch}/Release -tar xf artifacts/%{runtime_arch}/Release/dotnet-sdk-%{sdk_rpm_version}-preview.4.20161.13-%{runtime_id}.tar.gz -C %{buildroot}%{_libdir}/dotnet/ +tar xf artifacts/%{runtime_arch}/Release/dotnet-sdk-%{sdk_version}-%{runtime_id}.tar.gz -C %{buildroot}%{_libdir}/dotnet/ # Install managed symbols tar xf artifacts/%{runtime_arch}/Release/runtime/dotnet-runtime-symbols-%{runtime_version}-%{runtime_id}.tar.gz \ @@ -421,10 +420,12 @@ find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.pdb' -exec chmod -x {} \; find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.props' -exec chmod -x {} \; find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.pubxml' -exec chmod -x {} \; find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.targets' -exec chmod -x {} \; +find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.a' -exec chmod -x {} \; chmod 0755 %{buildroot}/%{_libdir}/dotnet/sdk/%{sdk_version}/AppHostTemplate/apphost -chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/libnethost.so chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/apphost +chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/libnethost.so chmod 0644 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/nethost.h +chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/singlefilehost install -dm 0755 %{buildroot}%{_sysconfdir}/profile.d/ install dotnet.sh %{buildroot}%{_sysconfdir}/profile.d/ @@ -508,6 +509,9 @@ echo "Testing build results for debug symbols..." %changelog +* Mon Sep 14 2020 Omair Majid - 5.0.100-0.3.preview8 +- Update to Preview 8 + * Fri Jul 10 2020 Omair Majid - 5.0.100-0.2.preview4 - Fix building with custom CFLAGS/CXXFLAGS/LDFLAGS - Clean up patches diff --git a/runtime-39044-cmake-downgrade.patch b/runtime-39044-cmake-downgrade.patch deleted file mode 100644 index 71938d0..0000000 --- a/runtime-39044-cmake-downgrade.patch +++ /dev/null @@ -1,1158 +0,0 @@ -diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake -index 534f1d19de6..50d81842274 100644 ---- a/eng/common/cross/toolchain.cmake -+++ b/eng/common/cross/toolchain.cmake -@@ -83,15 +83,26 @@ endif() - - # Specify link flags - -+function(add_toolchain_linker_flag Flag) -+ set(Config "${ARGV1}") -+ set(CONFIG_SUFFIX "") -+ if (NOT Config STREQUAL "") -+ set(CONFIG_SUFFIX "_${Config}") -+ endif() -+ set("CMAKE_EXE_LINKER_FLAGS${CONFIG_SUFFIX}" "${CMAKE_EXE_LINKER_FLAGS${CONFIG_SUFFIX}} ${Flag}" PARENT_SCOPE) -+ set("CMAKE_SHARED_LINKER_FLAGS${CONFIG_SUFFIX}" "${CMAKE_SHARED_LINKER_FLAGS${CONFIG_SUFFIX}} ${Flag}" PARENT_SCOPE) -+endfunction() -+ -+ - if(TARGET_ARCH_NAME STREQUAL "armel") - if(DEFINED TIZEN_TOOLCHAIN) # For Tizen only -- add_link_options("-B${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") -- add_link_options("-L${CROSS_ROOTFS}/lib") -- add_link_options("-L${CROSS_ROOTFS}/usr/lib") -- add_link_options("-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") -+ add_toolchain_linker_flag("-B${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") -+ add_toolchain_linker_flag("-L${CROSS_ROOTFS}/lib") -+ add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib") -+ add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") - endif() - elseif(TARGET_ARCH_NAME STREQUAL "x86") -- add_link_options(-m32) -+ add_toolchain_linker_flag(-m32) - endif() - - # Specify compile options -diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh -index a1a975ce177..9a0c296ff66 100755 ---- a/eng/native/build-commons.sh -+++ b/eng/native/build-commons.sh -@@ -51,12 +51,9 @@ check_prereqs() - # Check presence of CMake on the path - command -v cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; } - -- function version { echo "$@" | awk -F. '{ printf("%d%02d%02d\n", $1,$2,$3); }'; } -- -- local cmake_version="$(cmake --version | awk '/^cmake version [0-9]+\.[0-9]+\.[0-9]+$/ {print $3}')" -- -- if [[ "$(version "$cmake_version")" -lt "$(version 3.14.2)" ]]; then -- echo "Please install CMake 3.14.2 or newer from http://www.cmake.org/download/ or https://apt.kitware.com and ensure it is on your path."; exit 1; -+ if [[ "$__HostOS" == "OSX" ]]; then -+ # Check presence of pkg-config on the path -+ command -v pkg-config 2>/dev/null || { echo >&2 "Please install pkg-config before running this script, see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/macos-requirements.md"; exit 1; } - fi - - if [[ "$__UseNinja" == 1 ]]; then -@@ -156,8 +153,8 @@ build_native() - cmake_command="emcmake $cmake_command" - fi - -- echo "Executing $cmake_command --build \"$intermediatesDir\" --target install -j $__NumProc" -- $cmake_command --build "$intermediatesDir" --target install -j "$__NumProc" -+ echo "Executing $cmake_command --build \"$intermediatesDir\" --target install -- -j $__NumProc" -+ $cmake_command --build "$intermediatesDir" --target install -- -j "$__NumProc" - fi - - local exit_code="$?" -diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake -index 2937916ced9..07fd6f75f6f 100644 ---- a/eng/native/configurecompiler.cmake -+++ b/eng/native/configurecompiler.cmake -@@ -8,8 +8,6 @@ set(CMAKE_C_STANDARD_REQUIRED ON) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - --cmake_policy(SET CMP0083 NEW) -- - include(CheckCXXCompilerFlag) - - # "configureoptimization.cmake" must be included after CLR_CMAKE_HOST_UNIX has been set. -@@ -40,11 +38,18 @@ set(CMAKE_CXX_FLAGS_CHECKED "") - set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") - set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") - -+set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "") -+set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "") -+set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "") -+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") -+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") -+set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "") -+ - add_compile_definitions("$<$,$>:DEBUG;_DEBUG;_DBG;URTBLDENV_FRIENDLY=Checked;BUILDENV_CHECKED=1>") - add_compile_definitions("$<$,$>:NDEBUG;URTBLDENV_FRIENDLY=Retail>") - - if (MSVC) -- add_link_options(/GUARD:CF) -+ add_linker_flag(/GUARD:CF) - - # Linker flags - # -@@ -57,48 +62,51 @@ if (MSVC) - endif () - - #Do not create Side-by-Side Assembly Manifest -- add_link_options($<$,SHARED_LIBRARY>:/MANIFEST:NO>) -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") - # can handle addresses larger than 2 gigabytes -- add_link_options($<$,SHARED_LIBRARY>:/LARGEADDRESSAWARE>) -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") - #Compatible with Data Execution Prevention -- add_link_options($<$,SHARED_LIBRARY>:/NXCOMPAT>) -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NXCOMPAT") - #Use address space layout randomization -- add_link_options($<$,SHARED_LIBRARY>:/DYNAMICBASE>) -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE") - #shrink pdb size -- add_link_options($<$,SHARED_LIBRARY>:/PDBCOMPRESS>) -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /PDBCOMPRESS") - -- add_link_options($<$,SHARED_LIBRARY>:/DEBUG>) -- add_link_options($<$,SHARED_LIBRARY>:/IGNORE:4197,4013,4254,4070,4221>) -- add_link_options($<$,SHARED_LIBRARY>:/SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}>) -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG") -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4197,4013,4254,4070,4221") -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,${WINDOWS_SUBSYSTEM_VERSION}") - - set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221") - -- add_link_options($<$,EXECUTABLE>:/DEBUG>) -- add_link_options($<$,EXECUTABLE>:/PDBCOMPRESS>) -- add_link_options($<$,EXECUTABLE>:/STACK:1572864>) -+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG") -+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /PDBCOMPRESS") -+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864") - - # Debug build specific flags -- add_link_options($<$,$>,$,SHARED_LIBRARY>>:/NOVCFEATURE>) -+ set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NOVCFEATURE") -+ set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "${CMAKE_SHARED_LINKER_FLAGS_CHECKED} /NOVCFEATURE") - - # Checked build specific flags -- add_link_options($<$:/INCREMENTAL:NO>) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification" -- add_link_options($<$:/OPT:REF>) -- add_link_options($<$:/OPT:NOICF>) -+ add_linker_flag(/INCREMENTAL:NO CHECKED) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification" -+ add_linker_flag(/OPT:REF CHECKED) -+ add_linker_flag(/OPT:NOICF CHECKED) - - # Release build specific flags -- add_link_options($<$:/LTCG>) -- add_link_options($<$:/OPT:REF>) -- add_link_options($<$:/OPT:ICF>) -+ add_linker_flag(/LTCG RELEASE) -+ add_linker_flag(/OPT:REF RELEASE) -+ add_linker_flag(/OPT:ICF RELEASE) -+ add_linker_flag(/INCREMENTAL:NO RELEASE) - set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG") - - # ReleaseWithDebugInfo build specific flags -- add_link_options($<$:/LTCG>) -- add_link_options($<$:/OPT:REF>) -- add_link_options($<$:/OPT:ICF>) -+ add_linker_flag(/LTCG RELWITHDEBINFO) -+ add_linker_flag(/OPT:REF RELWITHDEBINFO) -+ add_linker_flag(/OPT:ICF RELWITHDEBINFO) - set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") - - # Force uCRT to be dynamically linked for Release build -- add_link_options("$<$:/NODEFAULTLIB:libucrt.lib;/DEFAULTLIB:ucrt.lib>") -+ add_linker_flag(/NODEFAULTLIB:libucrt.lib RELEASE) -+ add_linker_flag(/DEFAULTLIB:ucrt.lib RELEASE) - - elseif (CLR_CMAKE_HOST_UNIX) - # Set the values to display when interactively configuring CMAKE_BUILD_TYPE -@@ -157,11 +165,10 @@ elseif (CLR_CMAKE_HOST_UNIX) - - # -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections) - # -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint" -- add_compile_definitions("$<$,$>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>") -- add_link_options($<$,$>,$,EXECUTABLE>>:${CLR_SANITIZE_LINK_OPTIONS}>) -- -+ add_compile_options("$<$,$>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>") -+ add_linker_flag("${CLR_SANITIZE_LINK_OPTIONS}" DEBUG CHECKED) - # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking) -- add_link_options("$<$,$>,$,SHARED_LIBRARY>>:${CLR_SANITIZE_LINK_OPTIONS};-Wl,--gc-sections>") -+ add_linker_flag("-Wl,--gc-sections" DEBUG CHECKED) - endif () - endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED) - endif(MSVC) -@@ -173,15 +180,18 @@ endif(MSVC) - # ./build-native.sh cmakeargs "-DCLR_ADDITIONAL_COMPILER_OPTIONS=<...>" cmakeargs "-DCLR_ADDITIONAL_LINKER_FLAGS=<...>" - # - if(CLR_CMAKE_HOST_UNIX) -- add_link_options(${CLR_ADDITIONAL_LINKER_FLAGS}) -+ foreach(ADDTL_LINKER_FLAG ${CLR_ADDITIONAL_LINKER_FLAGS}) -+ add_linker_flag(${ADDTL_LINKER_FLAG}) -+ endforeach() - endif(CLR_CMAKE_HOST_UNIX) - - if(CLR_CMAKE_HOST_LINUX) - add_compile_options($<$:-Wa,--noexecstack>) -- add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now) -+ add_linker_flag(-Wl,--build-id=sha1) -+ add_linker_flag(-Wl,-z,relro,-z,now) - elseif(CLR_CMAKE_HOST_FREEBSD) - add_compile_options($<$:-Wa,--noexecstack>) -- add_link_options(LINKER:--build-id=sha1) -+ add_linker_flag("-Wl,--build-id=sha1") - elseif(CLR_CMAKE_HOST_SUNOS) - set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include) - set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib) -@@ -357,7 +367,7 @@ if (CLR_CMAKE_HOST_UNIX) - if(CLR_CMAKE_HOST_OSX) - set(MACOS_VERSION_MIN_FLAGS -mmacosx-version-min=10.12) - add_compile_options(${MACOS_VERSION_MIN_FLAGS}) -- add_link_options(${MACOS_VERSION_MIN_FLAGS}) -+ add_linker_flag(${MACOS_VERSION_MIN_FLAGS}) - endif(CLR_CMAKE_HOST_OSX) - endif(CLR_CMAKE_HOST_UNIX) - -@@ -514,7 +524,7 @@ if(CLR_CMAKE_ENABLE_CODE_COVERAGE) - - add_compile_options(-fprofile-arcs) - add_compile_options(-ftest-coverage) -- add_link_options(--coverage) -+ add_linker_flag(--coverage) - else() - message(FATAL_ERROR "Code coverage builds not supported on current platform") - endif(CLR_CMAKE_HOST_UNIX) -diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake -index 1c5254d8496..4a4131cb05d 100644 ---- a/eng/native/configureplatform.cmake -+++ b/eng/native/configureplatform.cmake -@@ -1,4 +1,3 @@ --include(CheckPIESupported) - include(${CMAKE_CURRENT_LIST_DIR}/functions.cmake) - - # If set, indicates that this is not an officially supported release -@@ -363,19 +362,10 @@ if(NOT CLR_CMAKE_TARGET_EMSCRIPTEN) - # but since we know that PIE is supported, we can safely skip this redundant check). - # - # The default linker on Solaris also does not support PIE. -- if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS) -- # All code we build should be compiled as position independent -- get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) -- if("CXX" IN_LIST languages) -- set(CLR_PIE_LANGUAGE CXX) -- else() -- set(CLR_PIE_LANGUAGE C) -- endif() -- check_pie_supported(OUTPUT_VARIABLE PIE_SUPPORT_OUTPUT LANGUAGES ${CLR_PIE_LANGUAGE}) -- if(NOT MSVC AND NOT CMAKE_${CLR_PIE_LANGUAGE}_LINK_PIE_SUPPORTED) -- message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n" -- "PIE link options will not be passed to linker.") -- endif() -+ if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_IOS AND NOT MSVC) -+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") -+ add_compile_options($<$,EXECUTABLE>:-fPIE>) -+ add_compile_options($<$,SHARED_LIBRARY>:-fPIC>) - endif() - - set(CMAKE_POSITION_INDEPENDENT_CODE ON) -diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake -index b7f8f463804..f4a96cbe35e 100644 ---- a/eng/native/functions.cmake -+++ b/eng/native/functions.cmake -@@ -123,7 +123,7 @@ function(preprocess_compile_asm) - set(options "") - set(oneValueArgs OUTPUT_OBJECTS) - set(multiValueArgs ASM_FILES) -- cmake_parse_arguments(PARSE_ARGV 0 COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}") -+ cmake_parse_arguments(COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) - - get_include_directories_asm(ASM_INCLUDE_DIRECTORIES) - -@@ -209,7 +209,7 @@ function(target_precompile_header) - set(options "") - set(oneValueArgs TARGET HEADER) - set(multiValueArgs ADDITIONAL_INCLUDE_DIRECTORIES) -- cmake_parse_arguments(PARSE_ARGV 0 PRECOMPILE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}") -+ cmake_parse_arguments(PRECOMPILE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) - - if ("${PRECOMPILE_HEADERS_TARGET}" STREQUAL "") - message(SEND_ERROR "No target supplied to target_precompile_header.") -@@ -321,7 +321,7 @@ endfunction() - function(install_clr) - set(oneValueArgs ADDITIONAL_DESTINATION) - set(multiValueArgs TARGETS) -- cmake_parse_arguments(PARSE_ARGV 0 INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}") -+ cmake_parse_arguments(INSTALL_CLR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) - - if ("${INSTALL_CLR_TARGETS}" STREQUAL "") - message(FATAL_ERROR "At least one target must be passed to install_clr(TARGETS )") -@@ -377,6 +377,15 @@ function(disable_pax_mprotect targetName) - endif() - endfunction() - -+if (CMAKE_VERSION VERSION_LESS "3.12") -+ # Polyfill add_compile_definitions when it is unavailable -+ function(add_compile_definitions) -+ get_directory_property(DIR_COMPILE_DEFINITIONS COMPILE_DEFINITIONS) -+ list(APPEND DIR_COMPILE_DEFINITIONS ${ARGV}) -+ set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${DIR_COMPILE_DEFINITIONS}") -+ endfunction() -+endif() -+ - function(_add_executable) - if(NOT WIN32) - add_executable(${ARGV} ${VERSION_FILE_PATH}) -@@ -415,3 +424,16 @@ endfunction() - function(add_executable_clr) - _add_executable(${ARGV}) - endfunction() -+ -+# add_linker_flag(Flag [Config1 Config2 ...]) -+function(add_linker_flag Flag) -+ if (ARGN STREQUAL "") -+ set("CMAKE_EXE_LINKER_FLAGS" "${CMAKE_EXE_LINKER_FLAGS} ${Flag}" PARENT_SCOPE) -+ set("CMAKE_SHARED_LINKER_FLAGS" "${CMAKE_SHARED_LINKER_FLAGS} ${Flag}" PARENT_SCOPE) -+ else() -+ foreach(Config ${ARGN}) -+ set("CMAKE_EXE_LINKER_FLAGS_${Config}" "${CMAKE_EXE_LINKER_FLAGS_${Config}} ${Flag}" PARENT_SCOPE) -+ set("CMAKE_SHARED_LINKER_FLAGS_${Config}" "${CMAKE_SHARED_LINKER_FLAGS_${Config}} ${Flag}" PARENT_SCOPE) -+ endforeach() -+ endif() -+endfunction() -diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh -index f27bb33e357..1b4c2e02c59 100755 ---- a/eng/native/gen-buildsys.sh -+++ b/eng/native/gen-buildsys.sh -@@ -91,6 +91,9 @@ if [[ "$build_arch" == "wasm" ]]; then - cmake_command="emcmake $cmake_command" - fi - -+# We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options -+pushd "$3" -+ - # Include CMAKE_USER_MAKE_RULES_OVERRIDE as uninitialized since it will hold its value in the CMake cache otherwise can cause issues when branch switching - $cmake_command \ - -G "$generator" \ -@@ -98,5 +101,6 @@ $cmake_command \ - "-DCMAKE_INSTALL_PREFIX=$__CMakeBinDir" \ - $cmake_extra_defines \ - $__UnprocessedCMakeArgs \ -- -S "$1" \ -- -B "$3" -+ "$1" -+ -+popd -diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt -index 5fa572c4fcd..071ac2cf5fa 100644 ---- a/src/coreclr/CMakeLists.txt -+++ b/src/coreclr/CMakeLists.txt -@@ -1,4 +1,4 @@ --cmake_minimum_required(VERSION 3.14.2) -+cmake_minimum_required(VERSION 3.6.2) - - cmake_policy(SET CMP0042 NEW) - -diff --git a/src/coreclr/pgosupport.cmake b/src/coreclr/pgosupport.cmake -index 4b119809017..04bde2bc20b 100644 ---- a/src/coreclr/pgosupport.cmake -+++ b/src/coreclr/pgosupport.cmake -@@ -1,5 +1,18 @@ --include(CheckIPOSupported) --check_ipo_supported(RESULT HAVE_LTO) -+include(CheckCXXSourceCompiles) -+include(CheckCXXCompilerFlag) -+ -+# VC++ guarantees support for LTCG (LTO's equivalent) -+if(NOT WIN32) -+ # Function required to give CMAKE_REQUIRED_* local scope -+ function(check_have_lto) -+ set(CMAKE_REQUIRED_FLAGS -flto) -+ set(CMAKE_REQUIRED_LIBRARIES -flto -fuse-ld=gold) -+ check_cxx_source_compiles("int main() { return 0; }" HAVE_LTO) -+ endfunction(check_have_lto) -+ check_have_lto() -+ -+ check_cxx_compiler_flag(-faligned-new COMPILER_SUPPORTS_F_ALIGNED_NEW) -+endif(NOT WIN32) - - # Adds Profile Guided Optimization (PGO) flags to the current target - function(add_pgo TargetName) -diff --git a/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt b/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt -index dcd39e346c9..7b471d53726 100644 ---- a/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt -+++ b/src/coreclr/src/ToolBox/SOS/DacTableGen/CMakeLists.txt -@@ -1,3 +1,4 @@ -+cmake_minimum_required(VERSION 3.8) - # Quick note: The CMake C# support is using the CSC bundled with the MSBuild that the native build runs on, not the one supplied by the local .NET SDK. - - project(DacTableGen LANGUAGES CSharp) -diff --git a/src/coreclr/src/binder/CMakeLists.txt b/src/coreclr/src/binder/CMakeLists.txt -index 3a66c81e10e..208f1214dd0 100644 ---- a/src/coreclr/src/binder/CMakeLists.txt -+++ b/src/coreclr/src/binder/CMakeLists.txt -@@ -82,11 +82,13 @@ endif(CLR_CMAKE_TARGET_WIN32) - convert_to_absolute_path(BINDER_SOURCES ${BINDER_SOURCES}) - convert_to_absolute_path(BINDER_CROSSGEN_SOURCES ${BINDER_CROSSGEN_SOURCES}) - --add_library_clr(v3binder -- STATIC -+add_library_clr(v3binder_obj -+ OBJECT - ${BINDER_SOURCES} - ) --add_dependencies(v3binder eventing_headers) -+add_dependencies(v3binder_obj eventing_headers) -+add_library(v3binder INTERFACE) -+target_sources(v3binder INTERFACE $) - - add_library_clr(v3binder_crossgen - STATIC -diff --git a/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt b/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt -index 391f70eff43..fdcf344c16a 100644 ---- a/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt -+++ b/src/coreclr/src/classlibnative/bcltype/CMakeLists.txt -@@ -10,9 +10,11 @@ set(BCLTYPE_SOURCES - variant.cpp - ) - --add_library_clr(bcltype -- STATIC -+add_library_clr(bcltype_obj -+ OBJECT - ${BCLTYPE_SOURCES} - ) - --add_dependencies(bcltype eventing_headers) -+add_dependencies(bcltype_obj eventing_headers) -+add_library(bcltype INTERFACE) -+target_sources(bcltype INTERFACE $) -diff --git a/src/coreclr/src/classlibnative/float/CMakeLists.txt b/src/coreclr/src/classlibnative/float/CMakeLists.txt -index 44d40c92592..3c066620f76 100644 ---- a/src/coreclr/src/classlibnative/float/CMakeLists.txt -+++ b/src/coreclr/src/classlibnative/float/CMakeLists.txt -@@ -7,9 +7,12 @@ set(FLOAT_SOURCES - floatsingle.cpp - ) - --add_library_clr(comfloat_wks -- STATIC -+add_library_clr(comfloat_wks_obj -+ OBJECT - ${FLOAT_SOURCES} - ) - --add_dependencies(comfloat_wks eventing_headers) -+add_dependencies(comfloat_wks_obj eventing_headers) -+ -+add_library(comfloat_wks INTERFACE) -+target_sources(comfloat_wks INTERFACE $) -diff --git a/src/coreclr/src/debug/debug-pal/CMakeLists.txt b/src/coreclr/src/debug/debug-pal/CMakeLists.txt -index ac1e48fb5fb..213fa59e784 100644 ---- a/src/coreclr/src/debug/debug-pal/CMakeLists.txt -+++ b/src/coreclr/src/debug/debug-pal/CMakeLists.txt -@@ -34,4 +34,6 @@ if(CLR_CMAKE_HOST_UNIX) - - endif(CLR_CMAKE_HOST_UNIX) - --_add_library(debug-pal STATIC ${TWO_WAY_PIPE_SOURCES}) -+_add_library(debug-pal_obj OBJECT ${TWO_WAY_PIPE_SOURCES}) -+add_library(debug-pal INTERFACE) -+target_sources(debug-pal INTERFACE $) -diff --git a/src/coreclr/src/debug/ee/wks/CMakeLists.txt b/src/coreclr/src/debug/ee/wks/CMakeLists.txt -index ee6c482ce76..3dd5e3612df 100644 ---- a/src/coreclr/src/debug/ee/wks/CMakeLists.txt -+++ b/src/coreclr/src/debug/ee/wks/CMakeLists.txt -@@ -9,9 +9,9 @@ if (CLR_CMAKE_TARGET_WIN32) - - if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64) - -- preprocess_compile_asm(ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS) -+ preprocess_compile_asm(TARGET cordbee_wks_obj ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS) - -- add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ${ASM_OBJECTS}) -+ add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE} ${ASM_OBJECTS}) - - else () - -@@ -23,19 +23,21 @@ if (CLR_CMAKE_TARGET_WIN32) - - set_source_files_properties(${ASM_FILE} PROPERTIES COMPILE_OPTIONS "${ASM_OPTIONS}") - -- add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ${ASM_FILE}) -+ add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE}) - - endif() - - else () - - if(CLR_CMAKE_HOST_ARCH_AMD64 OR CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64 OR CLR_CMAKE_HOST_ARCH_I386) -- add_library_clr(cordbee_wks ${CORDBEE_SOURCES_WKS} ../${ARCH_SOURCES_DIR}/dbghelpers.S) -+ add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ../${ARCH_SOURCES_DIR}/dbghelpers.S) - else() - message(FATAL_ERROR "Unknown platform") - endif() - - endif (CLR_CMAKE_TARGET_WIN32) - --target_precompile_header(TARGET cordbee_wks HEADER stdafx.h) --add_dependencies(cordbee_wks eventing_headers) -+target_precompile_header(TARGET cordbee_wks_obj HEADER stdafx.h) -+add_dependencies(cordbee_wks_obj eventing_headers) -+add_library(cordbee_wks INTERFACE) -+target_sources(cordbee_wks INTERFACE $) -diff --git a/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt b/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt -index 88364658f11..362da1f6483 100644 ---- a/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt -+++ b/src/coreclr/src/debug/ildbsymlib/CMakeLists.txt -@@ -10,5 +10,6 @@ set( ILDBSYMLIB_SOURCES - symwrite.cpp - ) - --add_library_clr(ildbsymlib ${ILDBSYMLIB_SOURCES}) -- -+add_library_clr(ildbsymlib_obj OBJECT ${ILDBSYMLIB_SOURCES}) -+add_library(ildbsymlib INTERFACE) -+target_sources(ildbsymlib INTERFACE $) -diff --git a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt -index 777a2869e4f..066b75ab01f 100644 ---- a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt -+++ b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt -@@ -9,20 +9,20 @@ if (CLR_CMAKE_HOST_WIN32) - - list(APPEND CLR_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def) - -- add_link_options(/ENTRY:CoreDllMain) -+ add_linker_flag("/ENTRY:CoreDllMain") - - # Incremental linking results in the linker inserting extra padding and routing function calls via thunks that can break the - # invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page). -- add_link_options(/INCREMENTAL:NO) -+ add_linker_flag("/INCREMENTAL:NO") - - # Delay load libraries required for WinRT as that is not supported on all platforms -- add_link_options("/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll") -- add_link_options("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") -- add_link_options("/DELAYLOAD:api-ms-win-core-winrt-roparameterizediid-l1-1-0.dll") -- add_link_options("/DELAYLOAD:api-ms-win-ro-typeresolution-l1-1-0.dll") -+ add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll") -+ add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") -+ add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-roparameterizediid-l1-1-0.dll") -+ add_linker_flag("/DELAYLOAD:api-ms-win-ro-typeresolution-l1-1-0.dll") - - # Delay load version.dll so that we can specify how to search when loading it as it is not part of Windows' known DLLs -- add_link_options("/DELAYLOAD:version.dll") -+ add_linker_flag("/DELAYLOAD:version.dll") - - # No library groups for Win32 - set(START_LIBRARY_GROUP) -@@ -35,7 +35,7 @@ else(CLR_CMAKE_HOST_WIN32) - if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD) - # This option is necessary to ensure that the overloaded delete operator defined inside - # of the utilcode will be used instead of the standard library delete operator. -- add_link_options("LINKER:-Bsymbolic") -+ add_linker_flag("-Wl,-Bsymbolic") - - # The following linked options can be inserted into the linker libraries list to - # ensure proper resolving of circular references between a subset of the libraries. -@@ -110,7 +110,7 @@ set(CORECLR_LIBRARIES - utilcode - v3binder - libraries-native -- System.Globalization.Native-Static -+ System.Globalization.Native-static - interop - ) - -@@ -162,7 +162,12 @@ if(FEATURE_EVENT_TRACE) - endif(CLR_CMAKE_HOST_UNIX) - endif(FEATURE_EVENT_TRACE) - --target_link_libraries(coreclr ${CORECLR_LIBRARIES}) -+if(FEATURE_MERGE_JIT_AND_ENGINE) -+ set(CLRJIT_STATIC clrjit_static) -+endif(FEATURE_MERGE_JIT_AND_ENGINE) -+ -+target_sources(coreclr PUBLIC $) -+target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} cee_wks) - - # Create the runtime module index header file containing the coreclr build id - # for xplat and the timestamp/size on Windows. -diff --git a/src/coreclr/src/dlls/mscorrc/CMakeLists.txt b/src/coreclr/src/dlls/mscorrc/CMakeLists.txt -index 08cf27aaf80..e114ec19cea 100644 ---- a/src/coreclr/src/dlls/mscorrc/CMakeLists.txt -+++ b/src/coreclr/src/dlls/mscorrc/CMakeLists.txt -@@ -19,7 +19,9 @@ if(CLR_CMAKE_HOST_WIN32) - else() - build_resources(${CMAKE_CURRENT_SOURCE_DIR}/include.rc mscorrc TARGET_CPP_FILE) - -- add_library_clr(mscorrc STATIC -+ add_library_clr(mscorrc_obj OBJECT - ${TARGET_CPP_FILE} - ) -+ add_library(mscorrc INTERFACE) -+ target_sources(mscorrc INTERFACE $) - endif(CLR_CMAKE_HOST_WIN32) -diff --git a/src/coreclr/src/gcinfo/CMakeLists.txt b/src/coreclr/src/gcinfo/CMakeLists.txt -index b0b67462562..50a1722a8ea 100644 ---- a/src/coreclr/src/gcinfo/CMakeLists.txt -+++ b/src/coreclr/src/gcinfo/CMakeLists.txt -@@ -16,11 +16,14 @@ endif(CLR_CMAKE_TARGET_ARCH_I386) - - convert_to_absolute_path(GCINFO_SOURCES ${GCINFO_SOURCES}) - --add_library_clr(gcinfo -- STATIC -+add_library_clr(gcinfo_obj -+ OBJECT - ${GCINFO_SOURCES} - ) - -+add_library(gcinfo INTERFACE) -+target_sources(gcinfo INTERFACE $) -+ - add_library_clr(gcinfo_crossgen - STATIC - ${GCINFO_SOURCES} -diff --git a/src/coreclr/src/inc/CMakeLists.txt b/src/coreclr/src/inc/CMakeLists.txt -index 60fad88e77d..4f75d3a882d 100644 ---- a/src/coreclr/src/inc/CMakeLists.txt -+++ b/src/coreclr/src/inc/CMakeLists.txt -@@ -58,7 +58,9 @@ if(FEATURE_JIT_PITCHING) - endif(FEATURE_JIT_PITCHING) - - # Compile *_i.cpp to lib --_add_library(corguids ${CORGUIDS_SOURCES}) -+_add_library(corguids_obj OBJECT ${CORGUIDS_SOURCES}) -+add_library(corguids INTERFACE) -+target_sources(corguids INTERFACE $) - - # Binplace the inc files for packaging later. - -@@ -75,4 +77,3 @@ _install (FILES cfi.h - gcinfoencoder.h - gcinfotypes.h - DESTINATION inc) --_install (TARGETS corguids DESTINATION lib) -diff --git a/src/coreclr/src/interop/CMakeLists.txt b/src/coreclr/src/interop/CMakeLists.txt -index d7eaa1b04ae..3924b4fdbb4 100644 ---- a/src/coreclr/src/interop/CMakeLists.txt -+++ b/src/coreclr/src/interop/CMakeLists.txt -@@ -30,7 +30,10 @@ endif(WIN32) - - convert_to_absolute_path(INTEROP_SOURCES ${INTEROP_SOURCES}) - --add_library_clr(interop -- STATIC -+add_library_clr(interop_obj -+ OBJECT - ${INTEROP_SOURCES} - ) -+ -+add_library(interop INTERFACE) -+target_sources(interop INTERFACE $) -diff --git a/src/coreclr/src/jit/dll/CMakeLists.txt b/src/coreclr/src/jit/dll/CMakeLists.txt -index ec7cddc78ed..01bdbf5a731 100644 ---- a/src/coreclr/src/jit/dll/CMakeLists.txt -+++ b/src/coreclr/src/jit/dll/CMakeLists.txt -@@ -2,17 +2,17 @@ project(ClrJit) - - set_source_files_properties(${JIT_EXPORTS_FILE} PROPERTIES GENERATED TRUE) - -+add_library_clr(clrjit_obj -+ OBJECT -+ ${JIT_CORE_SOURCES} -+ ${JIT_ARCH_SOURCES} -+) -+ - if(CLR_CMAKE_HOST_UNIX) -- add_library_clr(clrjit_static -- STATIC -- ${SHARED_LIB_SOURCES} -- ${JIT_ARCH_SOURCES} -- ) -- add_dependencies(clrjit_static coreclrpal gcinfo) --else() -- add_library_clr(clrjit_static -- ${SHARED_LIB_SOURCES} -- ${JIT_ARCH_SOURCES} -- ) -+ add_dependencies(clrjit_obj coreclrpal gcinfo) - endif(CLR_CMAKE_HOST_UNIX) --target_precompile_header(TARGET clrjit_static HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR}) -+ -+target_precompile_header(TARGET clrjit_obj HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR}) -+ -+add_library(clrjit_static INTERFACE) -+target_sources(clrjit_static INTERFACE $) -diff --git a/src/coreclr/src/md/ceefilegen/CMakeLists.txt b/src/coreclr/src/md/ceefilegen/CMakeLists.txt -index 90749c806b2..fd0f8424d97 100644 ---- a/src/coreclr/src/md/ceefilegen/CMakeLists.txt -+++ b/src/coreclr/src/md/ceefilegen/CMakeLists.txt -@@ -25,8 +25,11 @@ if (CLR_CMAKE_TARGET_WIN32) - list(APPEND CEEFILEGEN_SOURCES ${CEEFILEGEN_HEADERS}) - endif (CLR_CMAKE_TARGET_WIN32) - --add_library_clr(ceefgen -- STATIC -+add_library_clr(ceefgen_obj -+ OBJECT - ${CEEFILEGEN_SOURCES} - ) --target_precompile_header(TARGET ceefgen HEADER stdafx.h) -+target_precompile_header(TARGET ceefgen_obj HEADER stdafx.h) -+ -+add_library(ceefgen INTERFACE) -+target_sources(ceefgen INTERFACE $) -diff --git a/src/coreclr/src/md/compiler/CMakeLists.txt b/src/coreclr/src/md/compiler/CMakeLists.txt -index 3b916cdc9fe..f9f80db2500 100644 ---- a/src/coreclr/src/md/compiler/CMakeLists.txt -+++ b/src/coreclr/src/md/compiler/CMakeLists.txt -@@ -58,9 +58,11 @@ add_library_clr(mdcompiler_dac ${MDCOMPILER_SOURCES}) - set_target_properties(mdcompiler_dac PROPERTIES DAC_COMPONENT TRUE) - target_precompile_header(TARGET mdcompiler_dac HEADER stdafx.h) - --add_library_clr(mdcompiler_wks ${MDCOMPILER_SOURCES}) --target_compile_definitions(mdcompiler_wks PRIVATE FEATURE_METADATA_EMIT_ALL) --target_precompile_header(TARGET mdcompiler_wks HEADER stdafx.h) -+add_library_clr(mdcompiler_wks_obj OBJECT ${MDCOMPILER_SOURCES}) -+target_compile_definitions(mdcompiler_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL) -+target_precompile_header(TARGET mdcompiler_wks_obj HEADER stdafx.h) -+add_library(mdcompiler_wks INTERFACE) -+target_sources(mdcompiler_wks INTERFACE $) - - add_library_clr(mdcompiler-dbi ${MDCOMPILER_SOURCES}) - set_target_properties(mdcompiler-dbi PROPERTIES DBI_COMPONENT TRUE) -diff --git a/src/coreclr/src/md/enc/CMakeLists.txt b/src/coreclr/src/md/enc/CMakeLists.txt -index 7220736b9ca..82af8434296 100644 ---- a/src/coreclr/src/md/enc/CMakeLists.txt -+++ b/src/coreclr/src/md/enc/CMakeLists.txt -@@ -48,9 +48,11 @@ add_library_clr(mdruntimerw_dac ${MDRUNTIMERW_SOURCES}) - set_target_properties(mdruntimerw_dac PROPERTIES DAC_COMPONENT TRUE) - target_precompile_header(TARGET mdruntimerw_dac HEADER stdafx.h) - --add_library_clr(mdruntimerw_wks ${MDRUNTIMERW_SOURCES}) --target_compile_definitions(mdruntimerw_wks PRIVATE FEATURE_METADATA_EMIT_ALL) --target_precompile_header(TARGET mdruntimerw_wks HEADER stdafx.h) -+add_library_clr(mdruntimerw_wks_obj OBJECT ${MDRUNTIMERW_SOURCES}) -+target_compile_definitions(mdruntimerw_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL) -+target_precompile_header(TARGET mdruntimerw_wks_obj HEADER stdafx.h) -+add_library(mdruntimerw_wks INTERFACE) -+target_sources(mdruntimerw_wks INTERFACE $) - - add_library_clr(mdruntimerw-dbi ${MDRUNTIMERW_SOURCES}) - set_target_properties(mdruntimerw-dbi PROPERTIES DBI_COMPONENT TRUE) -diff --git a/src/coreclr/src/md/hotdata/CMakeLists.txt b/src/coreclr/src/md/hotdata/CMakeLists.txt -index c6168d2a4b0..88475cb72f4 100644 ---- a/src/coreclr/src/md/hotdata/CMakeLists.txt -+++ b/src/coreclr/src/md/hotdata/CMakeLists.txt -@@ -33,8 +33,10 @@ add_library_clr(mdhotdata_dac ${MDHOTDATA_SOURCES}) - set_target_properties(mdhotdata_dac PROPERTIES DAC_COMPONENT TRUE) - target_precompile_header(TARGET mdhotdata_dac HEADER external.h) - --add_library_clr(mdhotdata_full ${MDHOTDATA_SOURCES}) --target_precompile_header(TARGET mdhotdata_full HEADER external.h) -+add_library_clr(mdhotdata_full_obj OBJECT ${MDHOTDATA_SOURCES}) -+target_precompile_header(TARGET mdhotdata_full_obj HEADER external.h) -+add_library(mdhotdata_full INTERFACE) -+target_sources(mdhotdata_full INTERFACE $) - - add_library_clr(mdhotdata_crossgen ${MDHOTDATA_SOURCES}) - set_target_properties(mdhotdata_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) -diff --git a/src/coreclr/src/md/runtime/CMakeLists.txt b/src/coreclr/src/md/runtime/CMakeLists.txt -index 6dc193e14a7..7e0e83f1114 100644 ---- a/src/coreclr/src/md/runtime/CMakeLists.txt -+++ b/src/coreclr/src/md/runtime/CMakeLists.txt -@@ -47,9 +47,11 @@ add_library_clr(mdruntime_dac ${MDRUNTIME_SOURCES}) - set_target_properties(mdruntime_dac PROPERTIES DAC_COMPONENT TRUE) - target_precompile_header(TARGET mdruntime_dac HEADER stdafx.h) - --add_library_clr(mdruntime_wks ${MDRUNTIME_SOURCES}) --target_compile_definitions(mdruntime_wks PRIVATE FEATURE_METADATA_EMIT_ALL) --target_precompile_header(TARGET mdruntime_wks HEADER stdafx.h) -+add_library_clr(mdruntime_wks_obj OBJECT ${MDRUNTIME_SOURCES}) -+target_compile_definitions(mdruntime_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL) -+target_precompile_header(TARGET mdruntime_wks_obj HEADER stdafx.h) -+add_library(mdruntime_wks INTERFACE) -+target_sources(mdruntime_wks INTERFACE $) - - add_library_clr(mdruntime-dbi ${MDRUNTIME_SOURCES}) - set_target_properties(mdruntime-dbi PROPERTIES DBI_COMPONENT TRUE) -diff --git a/src/coreclr/src/pal/src/CMakeLists.txt b/src/coreclr/src/pal/src/CMakeLists.txt -index e7c1629d5b2..7818deef050 100644 ---- a/src/coreclr/src/pal/src/CMakeLists.txt -+++ b/src/coreclr/src/pal/src/CMakeLists.txt -@@ -256,10 +256,12 @@ add_library(coreclrpal - # > warning for library: libtracepointprovider.a the table of contents is empty (no object file members in the library define global symbols) - # - if(CLR_CMAKE_TARGET_LINUX) -- add_library(tracepointprovider -- STATIC -+ add_library(tracepointprovider_obj -+ OBJECT - misc/tracepointprovider.cpp - ) -+ add_library(tracepointprovider INTERFACE) -+ target_sources(tracepointprovider INTERFACE $) - endif(CLR_CMAKE_TARGET_LINUX) - - if(CLR_CMAKE_TARGET_OSX) -diff --git a/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt b/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt -index 39b9826d1ab..8e6968cf783 100644 ---- a/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt -+++ b/src/coreclr/src/pal/src/eventprovider/dummyprovider/CMakeLists.txt -@@ -1,8 +1,8 @@ --include(FindPython) -+include(FindPythonInterp) - - set (GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genDummyProvider.py) - --set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) -+set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) - - execute_process( - COMMAND ${GENERATE_COMMAND} --dry-run -diff --git a/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt b/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt -index 234dea19b75..d55dab3557f 100644 ---- a/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt -+++ b/src/coreclr/src/pal/src/eventprovider/lttngprovider/CMakeLists.txt -@@ -1,7 +1,7 @@ --include(FindPython) -+include(FindPythonInterp) - set (GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genLttngProvider.py) - --set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) -+set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --intermediate ${CMAKE_CURRENT_BINARY_DIR}) - - execute_process( - COMMAND ${GENERATE_COMMAND} --dry-run -diff --git a/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt b/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt -index 000ee2d2fb0..845fae656be 100644 ---- a/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt -+++ b/src/coreclr/src/pal/tests/palsuite/eventprovider/CMakeLists.txt -@@ -5,10 +5,10 @@ set(SOURCES - set(EVENT_MANIFEST ${VM_DIR}/ClrEtwAll.man) - set(TEST_GENERATOR ${CLR_DIR}/src/scripts/genEventingTests.py) - --include(FindPython) -+include(FindPythonInterp) - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clralltestevents.cpp -- COMMAND ${Python_EXECUTABLE} ${TEST_GENERATOR} --testdir "${CMAKE_CURRENT_BINARY_DIR}" --man "${EVENT_MANIFEST}" -+ COMMAND ${PYTHON_EXECUTABLE} ${TEST_GENERATOR} --testdir "${CMAKE_CURRENT_BINARY_DIR}" --man "${EVENT_MANIFEST}" - DEPENDS ${EVENT_MANIFEST} ${TEST_GENERATOR} - COMMENT "Updating clralltestevents.cpp" - ) -diff --git a/src/coreclr/src/unwinder/CMakeLists.txt b/src/coreclr/src/unwinder/CMakeLists.txt -index 4421ea9f6f6..41a0219bbf7 100644 ---- a/src/coreclr/src/unwinder/CMakeLists.txt -+++ b/src/coreclr/src/unwinder/CMakeLists.txt -@@ -20,8 +20,10 @@ list(APPEND UNWINDER_SOURCES - convert_to_absolute_path(UNWINDER_SOURCES ${UNWINDER_SOURCES}) - - if(CLR_CMAKE_HOST_UNIX) -- add_library_clr(unwinder_wks ${UNWINDER_SOURCES}) -- add_dependencies(unwinder_wks eventing_headers) -+ add_library_clr(unwinder_wks_obj OBJECT ${UNWINDER_SOURCES}) -+ add_dependencies(unwinder_wks_obj eventing_headers) -+ add_library(unwinder_wks INTERFACE) -+ target_sources(unwinder_wks INTERFACE $) - endif(CLR_CMAKE_HOST_UNIX) - - add_library_clr(unwinder_dac ${UNWINDER_SOURCES}) -diff --git a/src/coreclr/src/utilcode/CMakeLists.txt b/src/coreclr/src/utilcode/CMakeLists.txt -index aa28b2db603..f8082fc9076 100644 ---- a/src/coreclr/src/utilcode/CMakeLists.txt -+++ b/src/coreclr/src/utilcode/CMakeLists.txt -@@ -98,7 +98,9 @@ convert_to_absolute_path(UTILCODE_CROSSGEN_SOURCES ${UTILCODE_CROSSGEN_SOURCES}) - convert_to_absolute_path(UTILCODE_STATICNOHOST_SOURCES ${UTILCODE_STATICNOHOST_SOURCES}) - - add_library_clr(utilcode_dac STATIC ${UTILCODE_DAC_SOURCES}) --add_library_clr(utilcode STATIC ${UTILCODE_SOURCES}) -+add_library_clr(utilcode_obj OBJECT ${UTILCODE_SOURCES}) -+add_library(utilcode INTERFACE) -+target_sources(utilcode INTERFACE $) - add_library_clr(utilcodestaticnohost STATIC ${UTILCODE_STATICNOHOST_SOURCES}) - add_library_clr(utilcode_crossgen STATIC ${UTILCODE_CROSSGEN_SOURCES}) - -@@ -106,9 +108,9 @@ if(CLR_CMAKE_HOST_UNIX) - target_link_libraries(utilcodestaticnohost nativeresourcestring) - target_link_libraries(utilcode_crossgen nativeresourcestring) - target_link_libraries(utilcode_dac nativeresourcestring) -- target_link_libraries(utilcode nativeresourcestring) -+ target_link_libraries(utilcode INTERFACE nativeresourcestring) - add_dependencies(utilcode_dac coreclrpal) -- add_dependencies(utilcode coreclrpal) -+ add_dependencies(utilcode_obj coreclrpal) - endif(CLR_CMAKE_HOST_UNIX) - - -@@ -121,10 +123,10 @@ set_target_properties(utilcode_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE) - target_compile_definitions(utilcode_dac PRIVATE SELF_NO_HOST) - target_compile_definitions(utilcodestaticnohost PRIVATE SELF_NO_HOST) - add_dependencies(utilcode_dac ${UTILCODE_DEPENDENCIES}) --add_dependencies(utilcode ${UTILCODE_DEPENDENCIES}) -+add_dependencies(utilcode_obj ${UTILCODE_DEPENDENCIES}) - add_dependencies(utilcode_crossgen ${UTILCODE_DEPENDENCIES}) - add_dependencies(utilcodestaticnohost ${UTILCODE_DEPENDENCIES}) - target_precompile_header(TARGET utilcode_dac HEADER stdafx.h) --target_precompile_header(TARGET utilcode HEADER stdafx.h) -+target_precompile_header(TARGET utilcode_obj HEADER stdafx.h) - target_precompile_header(TARGET utilcode_crossgen HEADER stdafx.h) - target_precompile_header(TARGET utilcodestaticnohost HEADER stdafx.h) -diff --git a/src/coreclr/src/vm/CMakeLists.txt b/src/coreclr/src/vm/CMakeLists.txt -index 3e37cebdc10..2b20d7d910a 100644 ---- a/src/coreclr/src/vm/CMakeLists.txt -+++ b/src/coreclr/src/vm/CMakeLists.txt -@@ -923,7 +923,7 @@ list(APPEND VM_HEADERS_DAC - - if (CLR_CMAKE_TARGET_WIN32) - list(APPEND VM_SOURCES_WKS ${VM_HEADERS_WKS}) -- list(APPEND VM_SOURCES_WKS_ARCH_ASM ${VM_HEADERS_WKS_ARCH_ASM}) -+ list(APPEND VM_SOURCES_WKS ${VM_HEADERS_WKS_ARCH_ASM}) - list(APPEND VM_SOURCES_DAC ${VM_HEADERS_DAC}) - endif(CLR_CMAKE_TARGET_WIN32) - -diff --git a/src/coreclr/src/vm/eventing/CMakeLists.txt b/src/coreclr/src/vm/eventing/CMakeLists.txt -index 98dd158df54..e2bf024fc59 100644 ---- a/src/coreclr/src/vm/eventing/CMakeLists.txt -+++ b/src/coreclr/src/vm/eventing/CMakeLists.txt -@@ -8,12 +8,13 @@ else() - set(NEED_XPLAT_HEADER ON) - endif() - --include(FindPython) -+include(FindPythonInterp) - - set (EventingHeaders - ${GENERATED_INCLUDE_DIR}/etmdummy.h - ${GENERATED_INCLUDE_DIR}/clretwallmain.h - ${GENERATED_INCLUDE_DIR}/clreventpipewriteevents.h -+ ${GENERATED_INCLUDE_DIR}/clrproviders.h - ) - - if (NEED_XPLAT_HEADER) -@@ -24,7 +25,7 @@ endif() - set(GENEVENTING_SCRIPT ${CLR_DIR}/src/scripts/genEventing.py) - - add_custom_target(eventing_headers -- ${Python_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --inc ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG} -+ ${PYTHON_EXECUTABLE} ${GENEVENTING_SCRIPT} --man ${EVENT_MANIFEST} --inc ${GENERATED_INCLUDE_DIR} --dummy ${GENERATED_INCLUDE_DIR}/etmdummy.h ${NONEXTERN_ARG} ${NOXPLATHEADER_ARG} - DEPENDS ${EVENT_MANIFEST} ${GENEVENTING_SCRIPT} - VERBATIM - ) -diff --git a/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt b/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt -index 34a067e1ec5..4c7df2fbb3c 100644 ---- a/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt -+++ b/src/coreclr/src/vm/eventing/EtwProvider/CMakeLists.txt -@@ -1,4 +1,4 @@ --include(FindPython) -+include(FindPythonInterp) - - set(ETW_PROVIDER_SCRIPT ${CLR_DIR}/src/scripts/genEtwProvider.py) - -@@ -14,5 +14,5 @@ set (ETW_PROVIDER_OUTPUTS - set_source_files_properties(${ETW_PROVIDER_OUTPUTS} PROPERTIES GENERATED TRUE) - - add_custom_target(eventprovider -- ${Python_EXECUTABLE} ${ETW_PROVIDER_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${GENERATED_INCLUDE_DIR} -+ ${PYTHON_EXECUTABLE} ${ETW_PROVIDER_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${GENERATED_INCLUDE_DIR} - DEPENDS ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS} ${ETW_PROVIDER_SCRIPT}) -diff --git a/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt -index 00b3f6f386f..00d79737e54 100644 ---- a/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt -+++ b/src/coreclr/src/vm/eventing/eventpipe/CMakeLists.txt -@@ -1,9 +1,9 @@ --include(FindPython) -+include(FindPythonInterp) - - set(CMAKE_INCLUDE_CURRENT_DIR ON) - - set(GENERATE_SCRIPT ${CLR_DIR}/src/scripts/genEventPipe.py) --set(GENERATE_COMMAND ${Python_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${CMAKE_CURRENT_BINARY_DIR} ${NONEXTERN_ARG}) -+set(GENERATE_COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_SCRIPT} --man ${EVENT_MANIFEST} --exc ${EVENT_EXCLUSIONS} --intermediate ${CMAKE_CURRENT_BINARY_DIR} ${NONEXTERN_ARG}) - - execute_process( - COMMAND ${GENERATE_COMMAND} --dry-run -@@ -28,10 +28,8 @@ add_custom_command(OUTPUT ${EVENTPIPE_SOURCES} - COMMAND ${GENERATE_COMMAND} - DEPENDS ${GENERATE_SCRIPT} ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS}) - --add_library_clr(eventpipe STATIC ${EVENTPIPE_SOURCES}) --set_target_properties(eventpipe PROPERTIES LINKER_LANGUAGE CXX) --add_dependencies(eventpipe eventing_headers) -- --if (NOT CLR_CMAKE_TARGET_WIN32) -- _install(TARGETS eventpipe DESTINATION lib) --endif() -+add_library_clr(eventpipe_obj OBJECT ${EVENTPIPE_SOURCES}) -+set_target_properties(eventpipe_obj PROPERTIES LINKER_LANGUAGE CXX) -+add_dependencies(eventpipe_obj eventing_headers) -+add_library(eventpipe INTERFACE) -+target_sources(eventpipe INTERFACE $) -diff --git a/src/coreclr/src/vm/wks/CMakeLists.txt b/src/coreclr/src/vm/wks/CMakeLists.txt -index 1e94b575fd6..5d355f6adcb 100644 ---- a/src/coreclr/src/vm/wks/CMakeLists.txt -+++ b/src/coreclr/src/vm/wks/CMakeLists.txt -@@ -7,13 +7,19 @@ if (CLR_CMAKE_TARGET_WIN32) - - endif (CLR_CMAKE_TARGET_WIN32) - --add_library_clr(cee_wks ${VM_SOURCES_WKS} ${VM_SOURCES_WKS_ARCH_ASM}) --target_precompile_header(TARGET cee_wks HEADER common.h) -+add_library_clr(cee_wks_core OBJECT ${VM_SOURCES_WKS} ${VM_SOURCES_WKS_ARCH_ASM}) -+add_library_clr(cee_wks_obj OBJECT ${VM_SOURCES_WKS_SPECIAL}) -+ -+target_precompile_header(TARGET cee_wks_core HEADER common.h) -+target_precompile_header(TARGET cee_wks_obj HEADER common.h) -+ - if (MSVC) - # mscorlib.cpp does not compile with precompiled header file - set_source_files_properties(../mscorlib.cpp PROPERTIES COMPILE_FLAGS "/Y-") - endif() --add_dependencies(cee_wks eventing_headers) -+ -+add_dependencies(cee_wks_core eventing_headers) -+add_dependencies(cee_wks_obj eventing_headers) - - if (CLR_CMAKE_TARGET_WIN32) - -@@ -45,8 +51,16 @@ if (CLR_CMAKE_TARGET_WIN32) - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/AsmConstants.inc - ) - -- add_dependencies(cee_wks asmconstants_inc) -+ add_dependencies(cee_wks_core asmconstants_inc) -+ add_dependencies(cee_wks_obj asmconstants_inc) - - endif(NOT CLR_CMAKE_HOST_ARCH_ARM AND NOT CLR_CMAKE_HOST_ARCH_ARM64) - - endif (CLR_CMAKE_TARGET_WIN32) -+ -+add_custom_target(preprocessd_asm DEPENDS ${VM_WKS_ARCH_ASM_OBJECTS}) -+add_dependencies(cee_wks_core preprocessd_asm) -+add_dependencies(cee_wks_obj preprocessd_asm) -+ -+add_library(cee_wks INTERFACE) -+target_sources(cee_wks INTERFACE $ ${VM_WKS_ARCH_ASM_OBJECTS}) -diff --git a/src/coreclr/tests/CMakeLists.txt b/src/coreclr/tests/CMakeLists.txt -index 53dbb85a58b..c5417cba7d0 100644 ---- a/src/coreclr/tests/CMakeLists.txt -+++ b/src/coreclr/tests/CMakeLists.txt -@@ -1,4 +1,4 @@ --cmake_minimum_required(VERSION 3.14.2) -+cmake_minimum_required(VERSION 3.6.2) - - cmake_policy(SET CMP0042 NEW) - project(Tests) -diff --git a/src/installer/corehost/CMakeLists.txt b/src/installer/corehost/CMakeLists.txt -index 43a59a1a695..dff0496cdd8 100644 ---- a/src/installer/corehost/CMakeLists.txt -+++ b/src/installer/corehost/CMakeLists.txt -@@ -1,4 +1,4 @@ --cmake_minimum_required(VERSION 3.14.2) -+cmake_minimum_required(VERSION 3.6.2) - - project(corehost) - -diff --git a/src/installer/corehost/cli/exe.cmake b/src/installer/corehost/cli/exe.cmake -index de8cd49396b..732faf97ff9 100644 ---- a/src/installer/corehost/cli/exe.cmake -+++ b/src/installer/corehost/cli/exe.cmake -@@ -5,7 +5,6 @@ - project (${DOTNET_PROJECT_NAME}) - - cmake_policy(SET CMP0011 NEW) --cmake_policy(SET CMP0083 NEW) - - include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) - -diff --git a/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt b/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt -index bcf6a051229..8572a6318ec 100644 ---- a/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt -+++ b/src/installer/corehost/cli/test/mockhostfxr/CMakeLists.txt -@@ -2,7 +2,6 @@ - # The .NET Foundation licenses this file to you under the MIT license. - # See the LICENSE file in the project root for more information. - --cmake_minimum_required (VERSION 2.6) - project(mockhostfxr_2_2) - - set(DOTNET_PROJECT_NAME "mockhostfxr_2_2") -diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt -index f14ada69fee..cb174fe5013 100644 ---- a/src/libraries/Native/Unix/CMakeLists.txt -+++ b/src/libraries/Native/Unix/CMakeLists.txt -@@ -1,19 +1,14 @@ --cmake_minimum_required(VERSION 3.14.2) -+cmake_minimum_required(VERSION 3.6.2) -+if(CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) -+ # CMake 3.14.5 contains bug fixes for iOS -+ cmake_minimum_required(VERSION 3.14.5) -+ endif() - cmake_policy(SET CMP0042 NEW) - - project(CoreFX C) - - include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake) - --if(CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) -- # CMake 3.14.5 contains bug fixes for iOS -- cmake_minimum_required(VERSION 3.14.5) --endif() -- --if(NOT CLR_CMAKE_TARGET_ARCH_WASM) -- cmake_policy(SET CMP0083 NEW) --endif(NOT CLR_CMAKE_TARGET_ARCH_WASM) -- - set(CMAKE_MACOSX_RPATH ON) - set(CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir}) - set(CMAKE_INCLUDE_CURRENT_DIR ON) -@@ -167,7 +162,8 @@ if(CLR_CMAKE_TARGET_UNIX) - if(NOT CLR_CMAKE_TARGET_ARCH_WASM AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) - if(CLR_CMAKE_TARGET_OSX) - add_definitions(-DTARGET_OSX) -- add_link_options(-Wl,-bind_at_load) -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-bind_at_load") -+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-bind_at_load" ) - else() - add_compile_options($<$:-Wa,--noexecstack>) - if(CLR_CMAKE_TARGET_SUNOS) -@@ -175,7 +171,8 @@ if(CLR_CMAKE_TARGET_UNIX) - else() - # -z,now is required for full relro. - # see https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro -- add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now) -+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now") -+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now" ) - endif() - endif() - endif() -diff --git a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt -index bcfc5dd106a..ebcb5a02b3f 100644 ---- a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt -+++ b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt -@@ -79,14 +79,15 @@ if (GEN_SHARED_LIB) - install_with_stripped_symbols (System.Globalization.Native PROGRAMS .) - endif() - --add_library(System.Globalization.Native-Static -- STATIC -+add_library(System.Globalization.Native-obj -+ OBJECT - ${NATIVEGLOBALIZATION_SOURCES} - ) - --set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) -+set_target_properties(System.Globalization.Native-obj PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) - --install (TARGETS System.Globalization.Native-Static DESTINATION .) -+add_library(System.Globalization.Native-static INTERFACE) -+target_sources(System.Globalization.Native-static INTERFACE $) - - if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID) - if (GEN_SHARED_LIB) diff --git a/runtime-linker-order.patch b/runtime-linker-order.patch new file mode 100644 index 0000000..6ca413f --- /dev/null +++ b/runtime-linker-order.patch @@ -0,0 +1,20 @@ +diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt +index 85ea6ffe642..e6369f6b9ad 100644 +--- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt ++++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt +@@ -204,11 +204,12 @@ target_link_libraries(singlefilehost + libhostcommon + ${CORECLR_LIBRARIES} + ++ ${START_WHOLE_ARCHIVE} ++ ${NATIVE_LIBS} ++ ${END_WHOLE_ARCHIVE} ++ + ${ZLIB_LIBRARIES} + ${LIBGSS} + ${NATIVE_LIBS_EXTRA} + +- ${START_WHOLE_ARCHIVE} +- ${NATIVE_LIBS} +- ${END_WHOLE_ARCHIVE} + ) From 120443366777f7d79f381716ae2b97a12340c874 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Fri, 4 Dec 2020 17:09:37 -0500 Subject: [PATCH 14/19] Update to .NET Core Runtime 5.0.0 and SDK 5.0.100 --- README.md | 2 +- SHAHashProvider.Browser.cs | 1184 +++++++++++++++++ build-additional-rids.patch | 24 - build-dotnet-tarball | 21 +- dotnet5.0.spec | 124 +- runtime-dont-strip.patch | 47 - runtime-flags-support.patch | 30 - source-build-runtime-fixup-linker-order.patch | 13 + tests/tests.yml | 5 +- 9 files changed, 1293 insertions(+), 157 deletions(-) create mode 100644 SHAHashProvider.Browser.cs delete mode 100644 build-additional-rids.patch delete mode 100644 runtime-dont-strip.patch delete mode 100644 runtime-flags-support.patch create mode 100644 source-build-runtime-fixup-linker-order.patch diff --git a/README.md b/README.md index 4d4fb58..3990ea2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Overview -This is the .NET Core 5.0 package for Fedora. +This is the .NET 5.0 package for Fedora. This package is maintained by the Fedora DotNet SIG (Special Interest Group). You can find out more about the DotNet SIG at: diff --git a/SHAHashProvider.Browser.cs b/SHAHashProvider.Browser.cs new file mode 100644 index 0000000..4515b8a --- /dev/null +++ b/SHAHashProvider.Browser.cs @@ -0,0 +1,1184 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.IO; +using System.Diagnostics; +using System.Numerics; +using System.Security.Cryptography; + +namespace Internal.Cryptography +{ + internal sealed class SHAHashProvider : HashProvider + { + private int hashSizeInBytes; + private SHAManagedImplementationBase impl; + private MemoryStream buffer; + + public SHAHashProvider(string hashAlgorithmId) + { + switch (hashAlgorithmId) + { + case HashAlgorithmNames.SHA1: + impl = new SHA1ManagedImplementation(); + hashSizeInBytes = 20; + break; + case HashAlgorithmNames.SHA256: + impl = new SHA256ManagedImplementation(); + hashSizeInBytes = 32; + break; + case HashAlgorithmNames.SHA384: + impl = new SHA384ManagedImplementation(); + hashSizeInBytes = 48; + break; + case HashAlgorithmNames.SHA512: + impl = new SHA512ManagedImplementation(); + hashSizeInBytes = 64; + break; + default: + throw new CryptographicException(SR.Format(SR.Cryptography_UnknownHashAlgorithm, hashAlgorithmId)); + } + } + + public override void AppendHashData(ReadOnlySpan data) + { + if (buffer == null) + { + buffer = new MemoryStream(1000); + } + + buffer.Write(data); + } + + public override int FinalizeHashAndReset(Span destination) + { + GetCurrentHash(destination); + buffer = null; + + return hashSizeInBytes; + } + + public override int GetCurrentHash(Span destination) + { + Debug.Assert(destination.Length >= hashSizeInBytes); + + impl.Initialize(); + if (buffer != null) + { + impl.HashCore(buffer.GetBuffer(), 0, (int)buffer.Length); + } + impl.HashFinal().CopyTo(destination); + + return hashSizeInBytes; + } + + public override int HashSizeInBytes => hashSizeInBytes; + + public override void Dispose(bool disposing) + { + } + + private abstract class SHAManagedImplementationBase + { + public abstract void Initialize(); + public abstract void HashCore(byte[] partIn, int ibStart, int cbSize); + public abstract byte[] HashFinal(); + } + + // Ported from src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs. + // n.b. It's ok to use a "non-secret purposes" hashing implementation here, as this is only + // used in wasm scenarios, and as of the current release we don't make any security guarantees + // about our crypto primitives in wasm environments. + private class SHA1ManagedImplementation : SHAManagedImplementationBase + { + private Sha1ForNonSecretPurposes _state; // mutable struct - don't make readonly + + public override void Initialize() + { + _state = default; + _state.Start(); + } + + public override void HashCore(byte[] partIn, int ibStart, int cbSize) + { + _state.Append(partIn.AsSpan(ibStart, cbSize)); + } + + public override byte[] HashFinal() + { + byte[] output = new byte[20]; + _state.Finish(output); + return output; + } + + /// + /// Implements the SHA1 hashing algorithm. Note that this + /// implementation is for hashing public information. Do not + /// use this code to hash private data, as this implementation does + /// not take any steps to avoid information disclosure. + /// + private struct Sha1ForNonSecretPurposes + { + private long length; // Total message length in bits + private uint[] w; // Workspace + private int pos; // Length of current chunk in bytes + + /// + /// Call Start() to initialize the hash object. + /// + public void Start() + { + this.w ??= new uint[85]; + + this.length = 0; + this.pos = 0; + this.w[80] = 0x67452301; + this.w[81] = 0xEFCDAB89; + this.w[82] = 0x98BADCFE; + this.w[83] = 0x10325476; + this.w[84] = 0xC3D2E1F0; + } + + /// + /// Adds an input byte to the hash. + /// + /// Data to include in the hash. + public void Append(byte input) + { + this.w[this.pos / 4] = (this.w[this.pos / 4] << 8) | input; + if (64 == ++this.pos) + { + this.Drain(); + } + } + + /// + /// Adds input bytes to the hash. + /// + /// + /// Data to include in the hash. Must not be null. + /// + public void Append(ReadOnlySpan input) + { + foreach (byte b in input) + { + this.Append(b); + } + } + + /// + /// Retrieves the hash value. + /// Note that after calling this function, the hash object should + /// be considered uninitialized. Subsequent calls to Append or + /// Finish will produce useless results. Call Start() to + /// reinitialize. + /// + /// + /// Buffer to receive the hash value. Must not be null. + /// Up to 20 bytes of hash will be written to the output buffer. + /// If the buffer is smaller than 20 bytes, the remaining hash + /// bytes will be lost. If the buffer is larger than 20 bytes, the + /// rest of the buffer is left unmodified. + /// + public void Finish(byte[] output) + { + long l = this.length + 8 * this.pos; + this.Append(0x80); + while (this.pos != 56) + { + this.Append(0x00); + } + + unchecked + { + this.Append((byte)(l >> 56)); + this.Append((byte)(l >> 48)); + this.Append((byte)(l >> 40)); + this.Append((byte)(l >> 32)); + this.Append((byte)(l >> 24)); + this.Append((byte)(l >> 16)); + this.Append((byte)(l >> 8)); + this.Append((byte)l); + + int end = output.Length < 20 ? output.Length : 20; + for (int i = 0; i != end; i++) + { + uint temp = this.w[80 + i / 4]; + output[i] = (byte)(temp >> 24); + this.w[80 + i / 4] = temp << 8; + } + } + } + + /// + /// Called when this.pos reaches 64. + /// + private void Drain() + { + for (int i = 16; i != 80; i++) + { + this.w[i] = BitOperations.RotateLeft(this.w[i - 3] ^ this.w[i - 8] ^ this.w[i - 14] ^ this.w[i - 16], 1); + } + + unchecked + { + uint a = this.w[80]; + uint b = this.w[81]; + uint c = this.w[82]; + uint d = this.w[83]; + uint e = this.w[84]; + + for (int i = 0; i != 20; i++) + { + const uint k = 0x5A827999; + uint f = (b & c) | ((~b) & d); + uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + this.w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; + } + + for (int i = 20; i != 40; i++) + { + uint f = b ^ c ^ d; + const uint k = 0x6ED9EBA1; + uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + this.w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; + } + + for (int i = 40; i != 60; i++) + { + uint f = (b & c) | (b & d) | (c & d); + const uint k = 0x8F1BBCDC; + uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + this.w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; + } + + for (int i = 60; i != 80; i++) + { + uint f = b ^ c ^ d; + const uint k = 0xCA62C1D6; + uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + this.w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; + } + + this.w[80] += a; + this.w[81] += b; + this.w[82] += c; + this.w[83] += d; + this.w[84] += e; + } + + this.length += 512; // 64 bytes == 512 bits + this.pos = 0; + } + } + } + + // ported from https://github.com/microsoft/referencesource/blob/a48449cb48a9a693903668a71449ac719b76867c/mscorlib/system/security/cryptography/sha256managed.cs + private class SHA256ManagedImplementation : SHAManagedImplementationBase + { + private byte[] _buffer; + private long _count; // Number of bytes in the hashed message + private uint[] _stateSHA256; + private uint[] _W; + + public SHA256ManagedImplementation() + { + _stateSHA256 = new uint[8]; + _buffer = new byte[64]; + _W = new uint[64]; + + InitializeState(); + } + + public override void Initialize() + { + InitializeState(); + + // Zeroize potentially sensitive information. + Array.Clear(_buffer, 0, _buffer.Length); + Array.Clear(_W, 0, _W.Length); + } + + private void InitializeState() + { + _count = 0; + + _stateSHA256[0] = 0x6a09e667; + _stateSHA256[1] = 0xbb67ae85; + _stateSHA256[2] = 0x3c6ef372; + _stateSHA256[3] = 0xa54ff53a; + _stateSHA256[4] = 0x510e527f; + _stateSHA256[5] = 0x9b05688c; + _stateSHA256[6] = 0x1f83d9ab; + _stateSHA256[7] = 0x5be0cd19; + } + + /* SHA256 block update operation. Continues an SHA message-digest + operation, processing another message block, and updating the + context. + */ + public override unsafe void HashCore(byte[] partIn, int ibStart, int cbSize) + { + int bufferLen; + int partInLen = cbSize; + int partInBase = ibStart; + + /* Compute length of buffer */ + bufferLen = (int)(_count & 0x3f); + + /* Update number of bytes */ + _count += partInLen; + + fixed (uint* stateSHA256 = _stateSHA256) + { + fixed (byte* buffer = _buffer) + { + fixed (uint* expandedBuffer = _W) + { + if ((bufferLen > 0) && (bufferLen + partInLen >= 64)) + { + Buffer.BlockCopy(partIn, partInBase, _buffer, bufferLen, 64 - bufferLen); + partInBase += (64 - bufferLen); + partInLen -= (64 - bufferLen); + SHATransform(expandedBuffer, stateSHA256, buffer); + bufferLen = 0; + } + + /* Copy input to temporary buffer and hash */ + while (partInLen >= 64) + { + Buffer.BlockCopy(partIn, partInBase, _buffer, 0, 64); + partInBase += 64; + partInLen -= 64; + SHATransform(expandedBuffer, stateSHA256, buffer); + } + + if (partInLen > 0) + { + Buffer.BlockCopy(partIn, partInBase, _buffer, bufferLen, partInLen); + } + } + } + } + } + + /* SHA256 finalization. Ends an SHA256 message-digest operation, writing + the message digest. + */ + public override byte[] HashFinal() + { + byte[] pad; + int padLen; + long bitCount; + byte[] hash = new byte[32]; // HashSizeValue = 256 + + /* Compute padding: 80 00 00 ... 00 00 + */ + + padLen = 64 - (int)(_count & 0x3f); + if (padLen <= 8) + padLen += 64; + + pad = new byte[padLen]; + pad[0] = 0x80; + + // Convert count to bit count + bitCount = _count * 8; + + pad[padLen - 8] = (byte)((bitCount >> 56) & 0xff); + pad[padLen - 7] = (byte)((bitCount >> 48) & 0xff); + pad[padLen - 6] = (byte)((bitCount >> 40) & 0xff); + pad[padLen - 5] = (byte)((bitCount >> 32) & 0xff); + pad[padLen - 4] = (byte)((bitCount >> 24) & 0xff); + pad[padLen - 3] = (byte)((bitCount >> 16) & 0xff); + pad[padLen - 2] = (byte)((bitCount >> 8) & 0xff); + pad[padLen - 1] = (byte)((bitCount >> 0) & 0xff); + + /* Digest padding */ + HashCore(pad, 0, pad.Length); + + /* Store digest */ + SHAUtils.DWORDToBigEndian(hash, _stateSHA256, 8); + + return hash; + } + + private static readonly uint[] _K = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + }; + + private static unsafe void SHATransform(uint* expandedBuffer, uint* state, byte* block) + { + uint a, b, c, d, e, f, h, g; + uint aa, bb, cc, dd, ee, ff, hh, gg; + uint T1; + + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + f = state[5]; + g = state[6]; + h = state[7]; + + // fill in the first 16 bytes of W. + SHAUtils.DWORDFromBigEndian(expandedBuffer, 16, block); + SHA256Expand(expandedBuffer); + + /* Apply the SHA256 compression function */ + // We are trying to be smart here and avoid as many copies as we can + // The perf gain with this method over the straightforward modify and shift + // forward is >= 20%, so it's worth the pain + for (int j = 0; j < 64;) + { + T1 = h + Sigma_1(e) + Ch(e, f, g) + _K[j] + expandedBuffer[j]; + ee = d + T1; + aa = T1 + Sigma_0(a) + Maj(a, b, c); + j++; + + T1 = g + Sigma_1(ee) + Ch(ee, e, f) + _K[j] + expandedBuffer[j]; + ff = c + T1; + bb = T1 + Sigma_0(aa) + Maj(aa, a, b); + j++; + + T1 = f + Sigma_1(ff) + Ch(ff, ee, e) + _K[j] + expandedBuffer[j]; + gg = b + T1; + cc = T1 + Sigma_0(bb) + Maj(bb, aa, a); + j++; + + T1 = e + Sigma_1(gg) + Ch(gg, ff, ee) + _K[j] + expandedBuffer[j]; + hh = a + T1; + dd = T1 + Sigma_0(cc) + Maj(cc, bb, aa); + j++; + + T1 = ee + Sigma_1(hh) + Ch(hh, gg, ff) + _K[j] + expandedBuffer[j]; + h = aa + T1; + d = T1 + Sigma_0(dd) + Maj(dd, cc, bb); + j++; + + T1 = ff + Sigma_1(h) + Ch(h, hh, gg) + _K[j] + expandedBuffer[j]; + g = bb + T1; + c = T1 + Sigma_0(d) + Maj(d, dd, cc); + j++; + + T1 = gg + Sigma_1(g) + Ch(g, h, hh) + _K[j] + expandedBuffer[j]; + f = cc + T1; + b = T1 + Sigma_0(c) + Maj(c, d, dd); + j++; + + T1 = hh + Sigma_1(f) + Ch(f, g, h) + _K[j] + expandedBuffer[j]; + e = dd + T1; + a = T1 + Sigma_0(b) + Maj(b, c, d); + j++; + } + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + state[5] += f; + state[6] += g; + state[7] += h; + } + + private static uint RotateRight(uint x, int n) + { + return (((x) >> (n)) | ((x) << (32 - (n)))); + } + + private static uint Ch(uint x, uint y, uint z) + { + return ((x & y) ^ ((x ^ 0xffffffff) & z)); + } + + private static uint Maj(uint x, uint y, uint z) + { + return ((x & y) ^ (x & z) ^ (y & z)); + } + + private static uint sigma_0(uint x) + { + return (RotateRight(x, 7) ^ RotateRight(x, 18) ^ (x >> 3)); + } + + private static uint sigma_1(uint x) + { + return (RotateRight(x, 17) ^ RotateRight(x, 19) ^ (x >> 10)); + } + + private static uint Sigma_0(uint x) + { + return (RotateRight(x, 2) ^ RotateRight(x, 13) ^ RotateRight(x, 22)); + } + + private static uint Sigma_1(uint x) + { + return (RotateRight(x, 6) ^ RotateRight(x, 11) ^ RotateRight(x, 25)); + } + + /* This function creates W_16,...,W_63 according to the formula + W_j <- sigma_1(W_{j-2}) + W_{j-7} + sigma_0(W_{j-15}) + W_{j-16}; + */ + private static unsafe void SHA256Expand(uint* x) + { + for (int i = 16; i < 64; i++) + { + x[i] = sigma_1(x[i - 2]) + x[i - 7] + sigma_0(x[i - 15]) + x[i - 16]; + } + } + } + + // ported from https://github.com/microsoft/referencesource/blob/a48449cb48a9a693903668a71449ac719b76867c/mscorlib/system/security/cryptography/sha384managed.cs + private class SHA384ManagedImplementation : SHAManagedImplementationBase + { + private byte[] _buffer; + private ulong _count; // Number of bytes in the hashed message + private ulong[] _stateSHA384; + private ulong[] _W; + + public SHA384ManagedImplementation() + { + _stateSHA384 = new ulong[8]; + _buffer = new byte[128]; + _W = new ulong[80]; + + InitializeState(); + } + + public override void Initialize() + { + InitializeState(); + + // Zeroize potentially sensitive information. + Array.Clear(_buffer, 0, _buffer.Length); + Array.Clear(_W, 0, _W.Length); + } + + private void InitializeState() + { + _count = 0; + + _stateSHA384[0] = 0xcbbb9d5dc1059ed8; + _stateSHA384[1] = 0x629a292a367cd507; + _stateSHA384[2] = 0x9159015a3070dd17; + _stateSHA384[3] = 0x152fecd8f70e5939; + _stateSHA384[4] = 0x67332667ffc00b31; + _stateSHA384[5] = 0x8eb44a8768581511; + _stateSHA384[6] = 0xdb0c2e0d64f98fa7; + _stateSHA384[7] = 0x47b5481dbefa4fa4; + } + + /* SHA384 block update operation. Continues an SHA message-digest + operation, processing another message block, and updating the + context. + */ + public override unsafe void HashCore(byte[] partIn, int ibStart, int cbSize) + { + int bufferLen; + int partInLen = cbSize; + int partInBase = ibStart; + + /* Compute length of buffer */ + bufferLen = (int)(_count & 0x7f); + + /* Update number of bytes */ + _count += (ulong)partInLen; + + fixed (ulong* stateSHA384 = _stateSHA384) + { + fixed (byte* buffer = _buffer) + { + fixed (ulong* expandedBuffer = _W) + { + if ((bufferLen > 0) && (bufferLen + partInLen >= 128)) + { + Buffer.BlockCopy(partIn, partInBase, _buffer, bufferLen, 128 - bufferLen); + partInBase += (128 - bufferLen); + partInLen -= (128 - bufferLen); + SHATransform(expandedBuffer, stateSHA384, buffer); + bufferLen = 0; + } + + /* Copy input to temporary buffer and hash */ + while (partInLen >= 128) + { + Buffer.BlockCopy(partIn, partInBase, _buffer, 0, 128); + partInBase += 128; + partInLen -= 128; + SHATransform(expandedBuffer, stateSHA384, buffer); + } + + if (partInLen > 0) + { + Buffer.BlockCopy(partIn, partInBase, _buffer, bufferLen, partInLen); + } + } + } + } + } + + /* SHA384 finalization. Ends an SHA384 message-digest operation, writing + the message digest. + */ + public override byte[] HashFinal() + { + byte[] pad; + int padLen; + ulong bitCount; + byte[] hash = new byte[48]; // HashSizeValue = 384 + + /* Compute padding: 80 00 00 ... 00 00 + */ + + padLen = 128 - (int)(_count & 0x7f); + if (padLen <= 16) + padLen += 128; + + pad = new byte[padLen]; + pad[0] = 0x80; + + // Convert count to bit count + bitCount = _count * 8; + + // bitCount is at most 8 * 128 = 1024. Its representation as a 128-bit number has all bits set to zero + // except eventually the 11 lower bits + + //pad[padLen-16] = (byte) ((bitCount >> 120) & 0xff); + //pad[padLen-15] = (byte) ((bitCount >> 112) & 0xff); + //pad[padLen-14] = (byte) ((bitCount >> 104) & 0xff); + //pad[padLen-13] = (byte) ((bitCount >> 96) & 0xff); + //pad[padLen-12] = (byte) ((bitCount >> 88) & 0xff); + //pad[padLen-11] = (byte) ((bitCount >> 80) & 0xff); + //pad[padLen-10] = (byte) ((bitCount >> 72) & 0xff); + //pad[padLen-9] = (byte) ((bitCount >> 64) & 0xff); + pad[padLen - 8] = (byte)((bitCount >> 56) & 0xff); + pad[padLen - 7] = (byte)((bitCount >> 48) & 0xff); + pad[padLen - 6] = (byte)((bitCount >> 40) & 0xff); + pad[padLen - 5] = (byte)((bitCount >> 32) & 0xff); + pad[padLen - 4] = (byte)((bitCount >> 24) & 0xff); + pad[padLen - 3] = (byte)((bitCount >> 16) & 0xff); + pad[padLen - 2] = (byte)((bitCount >> 8) & 0xff); + pad[padLen - 1] = (byte)((bitCount >> 0) & 0xff); + + /* Digest padding */ + HashCore(pad, 0, pad.Length); + + /* Store digest */ + SHAUtils.QuadWordToBigEndian(hash, _stateSHA384, 6); + + return hash; + } + + private static readonly ulong[] _K = { + 0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, + 0x3956c25bf348b538, 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, + 0xd807aa98a3030242, 0x12835b0145706fbe, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, + 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, 0xc19bf174cf692694, + 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65, + 0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, + 0x983e5152ee66dfab, 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4, + 0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0x06ca6351e003826f, 0x142929670a0e6e70, + 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df, + 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b, + 0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30, + 0xd192e819d6ef5218, 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8, + 0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, + 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3, + 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec, + 0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b, + 0xca273eceea26619c, 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178, + 0x06f067aa72176fba, 0x0a637dc5a2c898a6, 0x113f9804bef90dae, 0x1b710b35131c471b, + 0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c, + 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817, + }; + + private static unsafe void SHATransform(ulong* expandedBuffer, ulong* state, byte* block) + { + ulong a, b, c, d, e, f, g, h; + ulong aa, bb, cc, dd, ee, ff, hh, gg; + ulong T1; + + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + f = state[5]; + g = state[6]; + h = state[7]; + + // fill in the first 16 blocks of W. + SHAUtils.QuadWordFromBigEndian(expandedBuffer, 16, block); + SHA384Expand(expandedBuffer); + + /* Apply the SHA384 compression function */ + // We are trying to be smart here and avoid as many copies as we can + // The perf gain with this method over the straightforward modify and shift + // forward is >= 20%, so it's worth the pain + for (int j = 0; j < 80;) + { + T1 = h + Sigma_1(e) + Ch(e, f, g) + _K[j] + expandedBuffer[j]; + ee = d + T1; + aa = T1 + Sigma_0(a) + Maj(a, b, c); + j++; + + T1 = g + Sigma_1(ee) + Ch(ee, e, f) + _K[j] + expandedBuffer[j]; + ff = c + T1; + bb = T1 + Sigma_0(aa) + Maj(aa, a, b); + j++; + + T1 = f + Sigma_1(ff) + Ch(ff, ee, e) + _K[j] + expandedBuffer[j]; + gg = b + T1; + cc = T1 + Sigma_0(bb) + Maj(bb, aa, a); + j++; + + T1 = e + Sigma_1(gg) + Ch(gg, ff, ee) + _K[j] + expandedBuffer[j]; + hh = a + T1; + dd = T1 + Sigma_0(cc) + Maj(cc, bb, aa); + j++; + + T1 = ee + Sigma_1(hh) + Ch(hh, gg, ff) + _K[j] + expandedBuffer[j]; + h = aa + T1; + d = T1 + Sigma_0(dd) + Maj(dd, cc, bb); + j++; + + T1 = ff + Sigma_1(h) + Ch(h, hh, gg) + _K[j] + expandedBuffer[j]; + g = bb + T1; + c = T1 + Sigma_0(d) + Maj(d, dd, cc); + j++; + + T1 = gg + Sigma_1(g) + Ch(g, h, hh) + _K[j] + expandedBuffer[j]; + f = cc + T1; + b = T1 + Sigma_0(c) + Maj(c, d, dd); + j++; + + T1 = hh + Sigma_1(f) + Ch(f, g, h) + _K[j] + expandedBuffer[j]; + e = dd + T1; + a = T1 + Sigma_0(b) + Maj(b, c, d); + j++; + } + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + state[5] += f; + state[6] += g; + state[7] += h; + } + + private static ulong RotateRight(ulong x, int n) + { + return (((x) >> (n)) | ((x) << (64 - (n)))); + } + + private static ulong Ch(ulong x, ulong y, ulong z) + { + return ((x & y) ^ ((x ^ 0xffffffffffffffff) & z)); + } + + private static ulong Maj(ulong x, ulong y, ulong z) + { + return ((x & y) ^ (x & z) ^ (y & z)); + } + + private static ulong Sigma_0(ulong x) + { + return (RotateRight(x, 28) ^ RotateRight(x, 34) ^ RotateRight(x, 39)); + } + + private static ulong Sigma_1(ulong x) + { + return (RotateRight(x, 14) ^ RotateRight(x, 18) ^ RotateRight(x, 41)); + } + + private static ulong sigma_0(ulong x) + { + return (RotateRight(x, 1) ^ RotateRight(x, 8) ^ (x >> 7)); + } + + private static ulong sigma_1(ulong x) + { + return (RotateRight(x, 19) ^ RotateRight(x, 61) ^ (x >> 6)); + } + + /* This function creates W_16,...,W_79 according to the formula + W_j <- sigma_1(W_{j-2}) + W_{j-7} + sigma_0(W_{j-15}) + W_{j-16}; + */ + private static unsafe void SHA384Expand(ulong* x) + { + for (int i = 16; i < 80; i++) + { + x[i] = sigma_1(x[i - 2]) + x[i - 7] + sigma_0(x[i - 15]) + x[i - 16]; + } + } + } + + // ported from https://github.com/microsoft/referencesource/blob/a48449cb48a9a693903668a71449ac719b76867c/mscorlib/system/security/cryptography/sha512managed.cs + private class SHA512ManagedImplementation : SHAManagedImplementationBase + { + private byte[] _buffer; + private ulong _count; // Number of bytes in the hashed message + private ulong[] _stateSHA512; + private ulong[] _W; + + public SHA512ManagedImplementation() + { + _stateSHA512 = new ulong[8]; + _buffer = new byte[128]; + _W = new ulong[80]; + + InitializeState(); + } + + public override void Initialize() + { + InitializeState(); + + // Zeroize potentially sensitive information. + Array.Clear(_buffer, 0, _buffer.Length); + Array.Clear(_W, 0, _W.Length); + } + + private void InitializeState() + { + _count = 0; + + _stateSHA512[0] = 0x6a09e667f3bcc908; + _stateSHA512[1] = 0xbb67ae8584caa73b; + _stateSHA512[2] = 0x3c6ef372fe94f82b; + _stateSHA512[3] = 0xa54ff53a5f1d36f1; + _stateSHA512[4] = 0x510e527fade682d1; + _stateSHA512[5] = 0x9b05688c2b3e6c1f; + _stateSHA512[6] = 0x1f83d9abfb41bd6b; + _stateSHA512[7] = 0x5be0cd19137e2179; + } + + /* SHA512 block update operation. Continues an SHA message-digest + operation, processing another message block, and updating the + context. + */ + public override unsafe void HashCore(byte[] partIn, int ibStart, int cbSize) + { + int bufferLen; + int partInLen = cbSize; + int partInBase = ibStart; + + /* Compute length of buffer */ + bufferLen = (int)(_count & 0x7f); + + /* Update number of bytes */ + _count += (ulong)partInLen; + + fixed (ulong* stateSHA512 = _stateSHA512) + { + fixed (byte* buffer = _buffer) + { + fixed (ulong* expandedBuffer = _W) + { + if ((bufferLen > 0) && (bufferLen + partInLen >= 128)) + { + Buffer.BlockCopy(partIn, partInBase, _buffer, bufferLen, 128 - bufferLen); + partInBase += (128 - bufferLen); + partInLen -= (128 - bufferLen); + SHATransform(expandedBuffer, stateSHA512, buffer); + bufferLen = 0; + } + + /* Copy input to temporary buffer and hash */ + while (partInLen >= 128) + { + Buffer.BlockCopy(partIn, partInBase, _buffer, 0, 128); + partInBase += 128; + partInLen -= 128; + SHATransform(expandedBuffer, stateSHA512, buffer); + } + + if (partInLen > 0) + { + Buffer.BlockCopy(partIn, partInBase, _buffer, bufferLen, partInLen); + } + } + } + } + } + + /* SHA512 finalization. Ends an SHA512 message-digest operation, writing + the message digest. + */ + public override byte[] HashFinal() + { + byte[] pad; + int padLen; + ulong bitCount; + byte[] hash = new byte[64]; // HashSizeValue = 512 + + /* Compute padding: 80 00 00 ... 00 00 + */ + + padLen = 128 - (int)(_count & 0x7f); + if (padLen <= 16) + padLen += 128; + + pad = new byte[padLen]; + pad[0] = 0x80; + + // Convert count to bit count + bitCount = _count * 8; + + // If we ever have UInt128 for bitCount, then these need to be uncommented. + // Note that C# only looks at the low 6 bits of the shift value for ulongs, + // so >>0 and >>64 are equal! + + //pad[padLen-16] = (byte) ((bitCount >> 120) & 0xff); + //pad[padLen-15] = (byte) ((bitCount >> 112) & 0xff); + //pad[padLen-14] = (byte) ((bitCount >> 104) & 0xff); + //pad[padLen-13] = (byte) ((bitCount >> 96) & 0xff); + //pad[padLen-12] = (byte) ((bitCount >> 88) & 0xff); + //pad[padLen-11] = (byte) ((bitCount >> 80) & 0xff); + //pad[padLen-10] = (byte) ((bitCount >> 72) & 0xff); + //pad[padLen-9] = (byte) ((bitCount >> 64) & 0xff); + pad[padLen - 8] = (byte)((bitCount >> 56) & 0xff); + pad[padLen - 7] = (byte)((bitCount >> 48) & 0xff); + pad[padLen - 6] = (byte)((bitCount >> 40) & 0xff); + pad[padLen - 5] = (byte)((bitCount >> 32) & 0xff); + pad[padLen - 4] = (byte)((bitCount >> 24) & 0xff); + pad[padLen - 3] = (byte)((bitCount >> 16) & 0xff); + pad[padLen - 2] = (byte)((bitCount >> 8) & 0xff); + pad[padLen - 1] = (byte)((bitCount >> 0) & 0xff); + + /* Digest padding */ + HashCore(pad, 0, pad.Length); + + /* Store digest */ + SHAUtils.QuadWordToBigEndian(hash, _stateSHA512, 8); + + return hash; + } + + private static readonly ulong[] _K = { + 0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, + 0x3956c25bf348b538, 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, + 0xd807aa98a3030242, 0x12835b0145706fbe, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, + 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, 0xc19bf174cf692694, + 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65, + 0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, + 0x983e5152ee66dfab, 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4, + 0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0x06ca6351e003826f, 0x142929670a0e6e70, + 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df, + 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b, + 0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30, + 0xd192e819d6ef5218, 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8, + 0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, + 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3, + 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec, + 0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b, + 0xca273eceea26619c, 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178, + 0x06f067aa72176fba, 0x0a637dc5a2c898a6, 0x113f9804bef90dae, 0x1b710b35131c471b, + 0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c, + 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817, + }; + + private static unsafe void SHATransform(ulong* expandedBuffer, ulong* state, byte* block) + { + ulong a, b, c, d, e, f, g, h; + ulong aa, bb, cc, dd, ee, ff, hh, gg; + ulong T1; + + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + f = state[5]; + g = state[6]; + h = state[7]; + + // fill in the first 16 blocks of W. + SHAUtils.QuadWordFromBigEndian(expandedBuffer, 16, block); + SHA512Expand(expandedBuffer); + + /* Apply the SHA512 compression function */ + // We are trying to be smart here and avoid as many copies as we can + // The perf gain with this method over the straightforward modify and shift + // forward is >= 20%, so it's worth the pain + for (int j = 0; j < 80;) + { + T1 = h + Sigma_1(e) + Ch(e, f, g) + _K[j] + expandedBuffer[j]; + ee = d + T1; + aa = T1 + Sigma_0(a) + Maj(a, b, c); + j++; + + T1 = g + Sigma_1(ee) + Ch(ee, e, f) + _K[j] + expandedBuffer[j]; + ff = c + T1; + bb = T1 + Sigma_0(aa) + Maj(aa, a, b); + j++; + + T1 = f + Sigma_1(ff) + Ch(ff, ee, e) + _K[j] + expandedBuffer[j]; + gg = b + T1; + cc = T1 + Sigma_0(bb) + Maj(bb, aa, a); + j++; + + T1 = e + Sigma_1(gg) + Ch(gg, ff, ee) + _K[j] + expandedBuffer[j]; + hh = a + T1; + dd = T1 + Sigma_0(cc) + Maj(cc, bb, aa); + j++; + + T1 = ee + Sigma_1(hh) + Ch(hh, gg, ff) + _K[j] + expandedBuffer[j]; + h = aa + T1; + d = T1 + Sigma_0(dd) + Maj(dd, cc, bb); + j++; + + T1 = ff + Sigma_1(h) + Ch(h, hh, gg) + _K[j] + expandedBuffer[j]; + g = bb + T1; + c = T1 + Sigma_0(d) + Maj(d, dd, cc); + j++; + + T1 = gg + Sigma_1(g) + Ch(g, h, hh) + _K[j] + expandedBuffer[j]; + f = cc + T1; + b = T1 + Sigma_0(c) + Maj(c, d, dd); + j++; + + T1 = hh + Sigma_1(f) + Ch(f, g, h) + _K[j] + expandedBuffer[j]; + e = dd + T1; + a = T1 + Sigma_0(b) + Maj(b, c, d); + j++; + } + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + state[5] += f; + state[6] += g; + state[7] += h; + } + + private static ulong RotateRight(ulong x, int n) + { + return (((x) >> (n)) | ((x) << (64 - (n)))); + } + + private static ulong Ch(ulong x, ulong y, ulong z) + { + return ((x & y) ^ ((x ^ 0xffffffffffffffff) & z)); + } + + private static ulong Maj(ulong x, ulong y, ulong z) + { + return ((x & y) ^ (x & z) ^ (y & z)); + } + + private static ulong Sigma_0(ulong x) + { + return (RotateRight(x, 28) ^ RotateRight(x, 34) ^ RotateRight(x, 39)); + } + + private static ulong Sigma_1(ulong x) + { + return (RotateRight(x, 14) ^ RotateRight(x, 18) ^ RotateRight(x, 41)); + } + + private static ulong sigma_0(ulong x) + { + return (RotateRight(x, 1) ^ RotateRight(x, 8) ^ (x >> 7)); + } + + private static ulong sigma_1(ulong x) + { + return (RotateRight(x, 19) ^ RotateRight(x, 61) ^ (x >> 6)); + } + + /* This function creates W_16,...,W_79 according to the formula + W_j <- sigma_1(W_{j-2}) + W_{j-7} + sigma_0(W_{j-15}) + W_{j-16}; + */ + private static unsafe void SHA512Expand(ulong* x) + { + for (int i = 16; i < 80; i++) + { + x[i] = sigma_1(x[i - 2]) + x[i - 7] + sigma_0(x[i - 15]) + x[i - 16]; + } + } + } + + // ported from https://github.com/microsoft/referencesource/blob/a48449cb48a9a693903668a71449ac719b76867c/mscorlib/system/security/cryptography/utils.cs + private class SHAUtils + { + // digits == number of DWORDs + public static unsafe void DWORDFromBigEndian(uint* x, int digits, byte* block) + { + int i; + int j; + + for (i = 0, j = 0; i < digits; i++, j += 4) + x[i] = (uint)((block[j] << 24) | (block[j + 1] << 16) | (block[j + 2] << 8) | block[j + 3]); + } + + // encodes x (DWORD) into block (unsigned char), most significant byte first. + // digits == number of DWORDs + public static void DWORDToBigEndian(byte[] block, uint[] x, int digits) + { + int i; + int j; + + for (i = 0, j = 0; i < digits; i++, j += 4) + { + block[j] = (byte)((x[i] >> 24) & 0xff); + block[j + 1] = (byte)((x[i] >> 16) & 0xff); + block[j + 2] = (byte)((x[i] >> 8) & 0xff); + block[j + 3] = (byte)(x[i] & 0xff); + } + } + + // digits == number of QWORDs + public static unsafe void QuadWordFromBigEndian(ulong* x, int digits, byte* block) + { + int i; + int j; + + for (i = 0, j = 0; i < digits; i++, j += 8) + x[i] = ( + (((ulong)block[j]) << 56) | (((ulong)block[j + 1]) << 48) | + (((ulong)block[j + 2]) << 40) | (((ulong)block[j + 3]) << 32) | + (((ulong)block[j + 4]) << 24) | (((ulong)block[j + 5]) << 16) | + (((ulong)block[j + 6]) << 8) | ((ulong)block[j + 7]) + ); + } + + // encodes x (DWORD) into block (unsigned char), most significant byte first. + // digits = number of QWORDS + public static void QuadWordToBigEndian(byte[] block, ulong[] x, int digits) + { + int i; + int j; + + for (i = 0, j = 0; i < digits; i++, j += 8) + { + block[j] = (byte)((x[i] >> 56) & 0xff); + block[j + 1] = (byte)((x[i] >> 48) & 0xff); + block[j + 2] = (byte)((x[i] >> 40) & 0xff); + block[j + 3] = (byte)((x[i] >> 32) & 0xff); + block[j + 4] = (byte)((x[i] >> 24) & 0xff); + block[j + 5] = (byte)((x[i] >> 16) & 0xff); + block[j + 6] = (byte)((x[i] >> 8) & 0xff); + block[j + 7] = (byte)(x[i] & 0xff); + } + } + } + } +} diff --git a/build-additional-rids.patch b/build-additional-rids.patch deleted file mode 100644 index 5bfba35..0000000 --- a/build-additional-rids.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/PublishCoreSetupBinaries.cs b/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/PublishCoreSetupBinaries.cs -index 4394a8b..e32d338 100644 ---- a/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/PublishCoreSetupBinaries.cs -+++ b/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/PublishCoreSetupBinaries.cs -@@ -36,12 +36,15 @@ namespace Microsoft.DotNet.Build.Tasks - // should include the delimiter immediately before the RID, arch, or extension. - protected string[] BadAtoms = new[] { "-x64", ".x64", - ".tar", ".gz", -- "-rhel.7", "-rhel.8", -- ".rhel.7", ".rhel.8", -- "-centos.7", "-centos.8", -- ".centos.7", ".centos.8", -+ "-rhel.7", "-rhel.8", "-rhel.9", -+ ".rhel.7", ".rhel.8", ".rhel.9", -+ "-centos.7", "-centos.8", "-centos.9", -+ ".centos.7", ".centos.8", ".centos.9", - ".fedora.30", "-fedora.30", - ".fedora.31", "-fedora.31", -+ ".fedora.32", "-fedora.32", -+ ".fedora.33", "-fedora.33", -+ ".fedora.34", "-fedora.34", - "-linux", ".linux", - "-osx", ".osx", - "-OSX", ".OSX", diff --git a/build-dotnet-tarball b/build-dotnet-tarball index fbaea55..c250937 100755 --- a/build-dotnet-tarball +++ b/build-dotnet-tarball @@ -91,10 +91,8 @@ if [ ! -f "${unmodified_tarball_name}.tar.gz" ]; then git checkout "${tag}" git submodule update --init --recursive clean_dotnet_cache - sed -i -e 's|cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE||' repos/runtime.common.props # FIXME remove contineuonprebuilterror - patch -p1 -i ../../build-additional-rids.patch - ./build.sh -p:SkipPrebuiltEnforcement=true -p:ContinueOnPrebuiltBaselineError=true -p:ArchiveDownloadedPackages=true + ./build.sh -p:SkipPrebuiltEnforcement=true -p:ContinueOnPrebuiltBaselineError=true -p:ArchiveDownloadedPackages=true -p:UseSystemLibraries=true ./build-source-tarball.sh "${unmodified_tarball_name}" --skip-build -- -p:ContinueOnPrebuiltBaselineError=true -p:SkipPrebuiltEnforcement=true popd popd @@ -113,8 +111,23 @@ pushd "${tarball_name}" # not-very-useful artifacts to reduce tarball size rm -r src/aspnetcore.*/src/SignalR/clients/java/signalr/gradle* find src/aspnetcore.*/src -type d -name samples -print0 | xargs -0 rm -r -rm -r src/NuGet.Client.*/test/EndToEnd/ProjectTemplates/NetCoreWebApplication1.0.zip +rm -r src/NuGet.Client.*/test/EndToEnd find src/runtime.*/ -depth -name tests -print0 | xargs -0 rm -r +rm -r src/runtime.*/src/mono/ +rm -r src/Humanizer.*/samples/ + +# FIXME delete when upstream has a new release with this file fixed +if ! grep "RSA Data Security" src/runtime.*/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/SHAHashProvider.Browser.cs; then + echo "SHAHashProvider.Browser.cs has been fixed upstream. Please fix build-dotnet-tarball" + exit 1 +fi +# Delete the bad source +rm src/runtime.*/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/SHAHashProvider.Browser.cs +# Delete the patch that modifies the bad source +rm patches/runtime/0001-Use-substitute-SHA-1-implementation-in-wasm-44982.patch +# Add pre-patched copy +cp ../SHAHashProvider.Browser.cs src/runtime.*/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/ + popd tar czf "${tarball_name}.tar.gz" "${tarball_name}" diff --git a/dotnet5.0.spec b/dotnet5.0.spec index 8305ab1..9aad30e 100644 --- a/dotnet5.0.spec +++ b/dotnet5.0.spec @@ -14,23 +14,23 @@ %global __provides_exclude ^(%{privlibs})\\.so %global __requires_exclude ^(%{privlibs})\\.so -# Filter flags not supported by clang -# -fstack-clash-protection -# -specs= -%global dotnet_cflags %(echo %optflags | sed -e 's/-fstack-clash-protection//' | sed -re 's/-specs=[^ ]*//g') -%global dotnet_ldflags %(echo %{__global_ldflags} | sed -re 's/-specs=[^ ]*//g') +# LTO triggers a compilation error for a source level issue. Given that LTO should not +# change the validity of any given source and the nature of the error (undefined enum), I +# suspect a generator program is mis-behaving in some way. This needs further debugging, +# until that's done, disable LTO. This has to happen before setting the flags below. +%define _lto_cflags %{nil} -%global host_version 5.0.0-preview.8.20407.11 -%global runtime_version 5.0.0-preview.8.20407.11 -%global aspnetcore_runtime_version 5.0.0-preview.8.20414.8 -%global sdk_version 5.0.100-preview.8.20417.9 -%global templates_version 5.0.0-preview.8.20417.9 +%global host_version 5.0.0 +%global runtime_version 5.0.0 +%global aspnetcore_runtime_version 5.0.0 +%global sdk_version 5.0.100 +%global templates_version 5.0.0 #%%global templates_version %%(echo %%{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }') -%global host_rpm_version 5.0.0 -%global aspnetcore_runtime_rpm_version 5.0.0 -%global runtime_rpm_version 5.0.0 -%global sdk_rpm_version 5.0.100 +%global host_rpm_version %{host_version} +%global aspnetcore_runtime_rpm_version %{aspnetcore_runtime_version} +%global runtime_rpm_version %{runtime_version} +%global sdk_rpm_version %{sdk_version} # upstream can update releases without revving the SDK version so these don't always match %global src_version %{sdk_version} @@ -52,44 +52,36 @@ %global runtime_arch arm64 %endif -%if 0%{?fedora} -%global runtime_id fedora.%{fedora}-%{runtime_arch} -%else -%if 0%{?centos} -%global runtime_id centos.%{centos}-%{runtime_arch} -%else -%global runtime_id rhel.%{rhel}-%{runtime_arch} -%endif -%endif +%{!?runtime_id:%global runtime_id %(. /etc/os-release ; echo "${ID}.${VERSION_ID%%.*}")-%{runtime_arch}} Name: dotnet5.0 Version: %{sdk_rpm_version} -Release: 0.3.preview8%{?dist} +Release: 1%{?dist} Summary: .NET Runtime and SDK License: MIT and ASL 2.0 and BSD and LGPLv2+ and CC-BY and CC0 and MS-PL and EPL-1.0 and GPL+ and GPLv2 and ISC and OFL and zlib URL: https://github.com/dotnet/ # The source is generated on a Fedora box via: # ./build-dotnet-tarball v%%{src_version}-SDK -Source0: dotnet-v%{src_version}-SDK.tar.gz +Source0: dotnet-v%{src_version}-SDK-337413b.tar.gz Source1: check-debug-symbols.py Source2: dotnet.sh.in -# https://github.com/dotnet/runtime/pull/39203 -# Do not strip debuginfo from (native/unmanaged) binaries -Patch100: runtime-dont-strip.patch +Patch1: source-build-runtime-fixup-linker-order.patch + # https://github.com/dotnet/runtime/pull/42094 # Fix linker order when linking with --as-needed -Patch101: runtime-linker-order.patch -# https://github.com/dotnet/runtime/pull/39191 -# Fix building with our additional CFLAGS/CXXFLAGS/LDFLAGS -Patch102: runtime-flags-support.patch +Patch100: runtime-linker-order.patch # Disable telemetry by default; make it opt-in Patch500: sdk-telemetry-optout.patch -# ExclusiveArch: aarch64 x86_64 +%if 0%{?fedora} > 32 || 0%{?rhel} > 8 +ExclusiveArch: aarch64 x86_64 +%else ExclusiveArch: x86_64 +%endif + BuildRequires: clang BuildRequires: cmake @@ -318,7 +310,7 @@ These are not meant for general use. %prep -%setup -q -n dotnet-v%{src_version}-SDK +%setup -q -n dotnet-v%{src_version}-SDK-337413b %if %{without bootstrap} # Remove all prebuilts @@ -344,24 +336,16 @@ sed -i 's|/usr/share/dotnet|%{_libdir}/dotnet|' src/runtime.*/src/installer/core # Disable warnings sed -i 's|skiptests|skiptests ignorewarnings|' repos/runtime.common.props +%patch1 -p1 + pushd src/runtime.* %patch100 -p1 -%patch101 -p1 -%patch102 -p1 popd pushd src/sdk.* %patch500 -p1 popd -# If CLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE is misisng, add it back -grep CLR_CMAKE_USE_SYSTEM_LIBUNWIND repos/runtime.common.props || \ - sed -i 's|\$(BuildArguments) |$(BuildArguments) cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE|' repos/runtime.common.props - -%if %{use_bundled_libunwind} -sed -i 's|-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE|-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=FALSE|' repos/runtime.common.props -%endif - %ifnarch x86_64 mkdir -p artifacts/obj/%{runtime_arch}/Release cp artifacts/obj/x64/Release/PackageVersions.props artifacts/obj/%{runtime_arch}/Release/PackageVersions.props @@ -380,9 +364,37 @@ cat /etc/os-release cp -a %{_libdir}/dotnet previously-built-dotnet %endif -export EXTRA_CFLAGS="%{dotnet_cflags}" -export EXTRA_CXXFLAGS="%{dotnet_cflags}" -export EXTRA_LDFLAGS="%{dotnet_ldflags}" +%if 0%{?fedora} > 32 || 0%{?rhel} > 8 +# Setting this macro ensures that only clang supported options will be +# added to ldflags and cflags. +%global toolchain clang +%set_build_flags +%else +# Filter flags not supported by clang +%global dotnet_cflags %(echo %optflags | sed -re 's/-specs=[^ ]*//g') +%global dotnet_ldflags %(echo %{__global_ldflags} | sed -re 's/-specs=[^ ]*//g') +export CFLAGS="%{dotnet_cflags}" +export CXXFLAGS="%{dotnet_cflags}" +export LDFLAGS="%{dotnet_ldflags}" +%endif + +%ifarch aarch64 +# -mbranch-protection=standard breaks unwinding in CoreCLR through libunwind +CFLAGS=$(echo $CFLAGS | sed -e 's/-mbranch-protection=standard //') +CXXFLAGS=$(echo $CXXFLAGS | sed -e 's/-mbranch-protection=standard //') +%endif + +# -fstack-clash-protection breaks CoreCLR +CFLAGS=$(echo $CFLAGS | sed -e 's/-fstack-clash-protection//' ) +CXXFLAGS=$(echo $CXXFLAGS | sed -e 's/-fstack-clash-protection//' ) + +export EXTRA_CFLAGS="$CFLAGS" +export EXTRA_CXXFLAGS="$CXXFLAGS" +export EXTRA_LDFLAGS="$LDFLAGS" + +unset CFLAGS +unset CXXFLAGS +unset LDFLAGS #%%if %%{without bootstrap} # --with-ref-packages %%{_libdir}/dotnet/reference-packages/ \ @@ -400,6 +412,11 @@ VERBOSE=1 ./build.sh \ /p:LogVerbosity=n \ /p:MinimalConsoleLogOutput=false \ /p:ContinueOnPrebuiltBaselineError=true \ +%if %{use_bundled_libunwind} + /p:UseSystemLibunwind=false \ +%else + /p:UseSystemLibunwind=true \ +%endif sed -e 's|[@]LIBDIR[@]|%{_libdir}|g' %{SOURCE2} > dotnet.sh @@ -415,12 +432,14 @@ tar xf artifacts/%{runtime_arch}/Release/runtime/dotnet-runtime-symbols-%{runtim -C %{buildroot}/%{_libdir}/dotnet/shared/Microsoft.NETCore.App/%{runtime_version}/ # Fix executable permissions on files +find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.a' -exec chmod -x {} \; find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.dll' -exec chmod -x {} \; +find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.h' -exec chmod -x {} \; find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.pdb' -exec chmod -x {} \; find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.props' -exec chmod -x {} \; find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.pubxml' -exec chmod -x {} \; find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.targets' -exec chmod -x {} \; -find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.a' -exec chmod -x {} \; +find %{buildroot}%{_libdir}/dotnet/ -type f -name '*.xml' -exec chmod -x {} \; chmod 0755 %{buildroot}/%{_libdir}/dotnet/sdk/%{sdk_version}/AppHostTemplate/apphost chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/apphost chmod 0755 %{buildroot}/%{_libdir}/dotnet/packs/Microsoft.NETCore.App.Host.%{runtime_id}/%{runtime_version}/runtimes/%{runtime_id}/native/libnethost.so @@ -509,6 +528,15 @@ echo "Testing build results for debug symbols..." %changelog +* Fri Dec 04 13:22:13 EST 2020 Omair Majid - 5.0.100-1 +- Update to .NET Core Runtime 5.0.0 and SDK 5.0.100 + +* Thu Dec 03 2020 Omair Majid - 5.0.100-0.4.20201202git337413b +- Update to latest 5.0 pre-GA commit + +* Tue Nov 24 2020 Omair Majid - 5.0.100-0.4.20201123gitdee899c +- Update to 5.0 pre-GA commit + * Mon Sep 14 2020 Omair Majid - 5.0.100-0.3.preview8 - Update to Preview 8 diff --git a/runtime-dont-strip.patch b/runtime-dont-strip.patch deleted file mode 100644 index 694face..0000000 --- a/runtime-dont-strip.patch +++ /dev/null @@ -1,47 +0,0 @@ -Do not strip native/unmanaged symbols from binaries - -This is a hack. It rips out the calls to strip directly. - -The correct/upstreamable fix is to add a configure/build option to -keep symbols for some builds, such as those needed by upstream. - -diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake -index 8b73581ed14..7697908425e 100644 ---- a/eng/native/functions.cmake -+++ b/eng/native/functions.cmake -@@ -282,7 +282,7 @@ function(target_precompile_header) - endif(MSVC) - endfunction() - --function(strip_symbols targetName outputFilename) -+function(strip_symbols_renamed targetName outputFilename) - if (CLR_CMAKE_HOST_UNIX) - set(strip_source_file $) - -@@ -336,8 +336,8 @@ function(strip_symbols targetName outputFilename) - endfunction() - - function(install_with_stripped_symbols targetName kind destination) -- strip_symbols(${targetName} symbol_file) -- install_symbols(${symbol_file} ${destination}) -+ # strip_symbols_renamed(${targetName} symbol_file) -+ # install_symbols(${symbol_file} ${destination}) - if ("${kind}" STREQUAL "TARGETS") - set(install_source ${targetName}) - elseif("${kind}" STREQUAL "PROGRAMS") -@@ -375,13 +375,13 @@ function(install_clr) - foreach(targetName ${INSTALL_CLR_TARGETS}) - list(FIND CLR_CROSS_COMPONENTS_LIST ${targetName} INDEX) - if (NOT DEFINED CLR_CROSS_COMPONENTS_LIST OR NOT ${INDEX} EQUAL -1) -- strip_symbols(${targetName} symbol_file) -+ # strip_symbols_renamed(${targetName} symbol_file) - - foreach(destination ${destinations}) - # We don't need to install the export libraries for our DLLs - # since they won't be directly linked against. - install(PROGRAMS $ DESTINATION ${destination}) -- install_symbols(${symbol_file} ${destination}) -+ # install_symbols(${symbol_file} ${destination}) - - if(CLR_CMAKE_PGO_INSTRUMENT) - if(WIN32) diff --git a/runtime-flags-support.patch b/runtime-flags-support.patch deleted file mode 100644 index 921e483..0000000 --- a/runtime-flags-support.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh -index b976f5fdc6c..853580b1c7a 100755 ---- a/eng/native/build-commons.sh -+++ b/eng/native/build-commons.sh -@@ -163,6 +163,14 @@ EOF - return - fi - -+ SAVED_CFLAGS="${CFLAGS}" -+ SAVED_CXXFLAGS="${CXXFLAGS}" -+ SAVED_LDFLAGS="${LDFLAGS}" -+ -+ export CFLAGS="${CFLAGS} ${EXTRA_CFLAGS}" -+ export CXXFLAGS="${CXXFLAGS} ${EXTRA_CXXFLAGS}" -+ export LDFLAGS="${LDFLAGS} ${EXTRA_LDFLAGS}" -+ - if [[ "$__StaticAnalyzer" == 1 ]]; then - pushd "$intermediatesDir" - -@@ -181,6 +189,10 @@ EOF - $cmake_command --build "$intermediatesDir" --target install -- -j "$__NumProc" - fi - -+ CFLAGS="${SAVED_CFLAGS}" -+ CXXFLAGS="${SAVED_CXXFLAGS}" -+ LDFLAGS="${SAVED_LDFLAGS}" -+ - local exit_code="$?" - if [[ "$exit_code" != 0 ]]; then - echo "${__ErrMsgPrefix}Failed to build \"$message\"." diff --git a/source-build-runtime-fixup-linker-order.patch b/source-build-runtime-fixup-linker-order.patch new file mode 100644 index 0000000..5a74b5d --- /dev/null +++ b/source-build-runtime-fixup-linker-order.patch @@ -0,0 +1,13 @@ +--- a/patches/runtime/0014-Fix-singlefilehost-build-in-non-portable-mode-42415.patch ++++ b/patches/runtime/0014-Fix-singlefilehost-build-in-non-portable-mode-42415.patch +@@ -45,8 +45,8 @@ + # These options are used to force every object to be included even if it's unused. + set(START_WHOLE_ARCHIVE -Wl,--whole-archive) + @@ -212,3 +217,10 @@ target_link_libraries(singlefilehost +- ${NATIVE_LIBS} +- ${END_WHOLE_ARCHIVE} ++ ${NATIVE_LIBS_EXTRA} ++ + ) + + + +if(NOT FEATURE_DISTRO_AGNOSTIC_SSL) diff --git a/tests/tests.yml b/tests/tests.yml index f3825cf..d63f183 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -9,6 +9,7 @@ repositories: - repo: "https://github.com/redhat-developer/dotnet-regular-tests.git" dest: "dotnet-regular-tests" + version: main tests: - download_test_runner: dir: ./ @@ -18,17 +19,15 @@ run: ./turkey --version - regular: dir: ./ - run: ./turkey -l={{ remote_artifacts }} -s=$(pwd)/nuget-prerelease dotnet-regular-tests + run: ./turkey -l={{ remote_artifacts }} dotnet-regular-tests required_packages: - babeltrace - bash-completion - binutils - expect - - git - jq - lldb - lttng-tools - - make - npm - python3 - strace From 12422fd0a6ac964bde1cb1a90a611a343a1c914f Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 18 Jan 2021 10:26:45 -0500 Subject: [PATCH 15/19] Update for bootstrapping 5.0 --- build-bootstrap-tarball | 50 --------------------------- build-dotnet-tarball | 76 ++++++++++++++++++++++++++++++++--------- dotnet5.0.spec | 24 +++++++------ 3 files changed, 72 insertions(+), 78 deletions(-) delete mode 100755 build-bootstrap-tarball diff --git a/build-bootstrap-tarball b/build-bootstrap-tarball deleted file mode 100755 index d3f3547..0000000 --- a/build-bootstrap-tarball +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -set -x - -sdk_version=3.1.105 - -arch=$(uname -m) -if [[ $arch == "x86_64" ]]; then - arch=x64 -elif [[ $arch == "aarch64" ]]; then - arch=arm64 -fi - -if rpm -qa | grep libunwind; then - echo "error: libunwind is installed. Not a good idea for bootstrapping." - exit 1 -fi -if rpm -qa | grep dotnet ; then - echo "error: dotnet is installed. Not a good idea for bootstrapping." - exit 1 -fi -if [ -d /usr/lib/dotnet ] || [ -d /usr/lib64/dotnet ] || [ -d /usr/share/dotnet ] ; then - echo "error: one of /usr/lib/dotnet /usr/lib64/dotnet or /usr/share/dotnet/ exists. Not a good idea for bootstrapping." - exit 1 -fi -if command -v dotnet ; then - echo "error: dotnet is in $PATH. Not a good idea for bootstrapping." - exit 1 -fi - -if [ ! -d dotnet-source-build-tarball ]; then - if [ ! -d source-build ]; then - git clone https://github.com/dotnet/source-build - fi - pushd source-build - sed -i -e 's|cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE||' repos/coreclr.common.props - git clean -xdf - ./build-source-tarball.sh ../dotnet-source-build-tarball/ -- -p:DownloadSourceBuildReferencePackagesTimeoutSeconds=100000 - popd -fi - -rm -rf dotnet-v${sdk_version}-SDK dotnet-v${sdk_version}-SDK.tar.gz - -cp -a dotnet-source-build-tarball dotnet-v${sdk_version}-SDK -cp -a source-build/artifacts/$arch/Release/Private.SourceBuilt.Artifacts.*.tar.gz dotnet-v${sdk_version}-SDK/packages/archive/Private.SourceBuilt.Artifacts.*.tar.gz - -tar czf dotnet-v${sdk_version}-SDK-$arch.tar.gz dotnet-v${sdk_version}-SDK - diff --git a/build-dotnet-tarball b/build-dotnet-tarball index c250937..6eba1bf 100755 --- a/build-dotnet-tarball +++ b/build-dotnet-tarball @@ -1,7 +1,7 @@ #!/bin/bash # Usage: -# build-dotnet-tarball +# build-dotnet-tarball [--bootstrap] # # Creates a source archive from a tag (or commit) at github.com/dotnet/source-build @@ -13,32 +13,41 @@ set -euo pipefail IFS=$'\n\t' -print_usage() { +function print_usage { echo "Usage:" - echo "$0 " + echo "$0 [--bootstrap] " echo echo "Creates a source archive from a tag at https://github.com/dotnet/source-build" + echo "" + echo " --bootstrap build a source tarball usable for bootstrapping .NET" } -clean_dotnet_cache() { +function clean_dotnet_cache { rm -rf ~/.aspnet ~/.dotnet/ ~/.nuget/ ~/.local/share/NuGet ~/.templateengine rm -rf /tmp/NuGet /tmp/NuGetScratch /tmp/.NETCore* /tmp/.NETStandard* /tmp/.dotnet /tmp/dotnet.* /tmp/clr-debug-pipe* /tmp/Razor-Server /tmp/CoreFxPipe* /tmp/VBCSCompiler /tmp/.NETFramework* } +function check_bootstrap_environment { + if rpm -qa | grep libunwind-devel; then + echo "error: libunwind-devel is installed. Not a good idea for bootstrapping." + exit 1 + fi + if rpm -qa | grep dotnet ; then + echo "error: dotnet is installed. Not a good idea for bootstrapping." + exit 1 + fi + if [ -d /usr/lib/dotnet ] || [ -d /usr/lib64/dotnet ] || [ -d /usr/share/dotnet ] ; then + echo "error: one of /usr/lib/dotnet /usr/lib64/dotnet or /usr/share/dotnet/ exists. Not a good idea for bootstrapping." + exit 1 + fi + if command -v dotnet ; then + echo "error: dotnet is in $PATH. Not a good idea for bootstrapping." + exit 1 + fi +} + function runtime_id { - declare -A archmap - archmap=( - ["aarch64"]="arm64" - ["amd64"]="x64" - ["armv8l"]="arm" - ["i686"]="x86" - ["i386"]="x86" - ["x86_64"]="x64" - ) - - arch=${archmap["$(uname -m)"]} - source /etc/os-release case "${ID}" in # Remove the RHEL minor version @@ -50,10 +59,29 @@ function runtime_id { echo "${ID}.${rid_version}-${arch}" } +build_bootstrap=false + +declare -A archmap +archmap=( + ["aarch64"]="arm64" + ["amd64"]="x64" + ["armv8l"]="arm" + ["i686"]="x86" + ["i386"]="x86" + ["x86_64"]="x64" +) + +arch=${archmap["$(uname -m)"]} + + positional_args=() while [[ "$#" -gt 0 ]]; do arg="${1}" case "${arg}" in + --bootstrap) + build_bootstrap=true + shift + ;; -h|--help) print_usage exit 0 @@ -78,6 +106,11 @@ dir_name="dotnet-${tag}" unmodified_tarball_name="${dir_name}-original" tarball_name="${dir_name}" +if [[ ${build_bootstrap} == true ]]; then + unmodified_tarball_name="${unmodified_tarball_name}-${arch}-bootstrap" + tarball_name="${tarball_name}-${arch}-bootstrap" +fi + if [ -f "${tarball_name}.tar.gz" ]; then echo "error: ${tarball_name}.tar.gz already exists" exit 1 @@ -94,6 +127,10 @@ if [ ! -f "${unmodified_tarball_name}.tar.gz" ]; then # FIXME remove contineuonprebuilterror ./build.sh -p:SkipPrebuiltEnforcement=true -p:ContinueOnPrebuiltBaselineError=true -p:ArchiveDownloadedPackages=true -p:UseSystemLibraries=true ./build-source-tarball.sh "${unmodified_tarball_name}" --skip-build -- -p:ContinueOnPrebuiltBaselineError=true -p:SkipPrebuiltEnforcement=true + + if [[ ${build_bootstrap} == true ]]; then + cp -a artifacts/"${arch}"/Release/Private.SourceBuilt.Artifacts.*.tar.gz "${unmodified_tarball_name}"/packages/archive/Private.SourceBuilt.Artifacts.*.tar.gz + fi popd popd @@ -107,12 +144,17 @@ tar xf "${unmodified_tarball_name}.tar.gz" mv "${unmodified_tarball_name}" "${tarball_name}" pushd "${tarball_name}" + +if [[ ${build_bootstrap} != true ]]; then + find . -type f -iname '*.tar.gz' -delete + rm -rf .dotnet +fi + # Remove files with funny licenses, crypto implementations and other # not-very-useful artifacts to reduce tarball size rm -r src/aspnetcore.*/src/SignalR/clients/java/signalr/gradle* find src/aspnetcore.*/src -type d -name samples -print0 | xargs -0 rm -r rm -r src/NuGet.Client.*/test/EndToEnd -find src/runtime.*/ -depth -name tests -print0 | xargs -0 rm -r rm -r src/runtime.*/src/mono/ rm -r src/Humanizer.*/samples/ diff --git a/dotnet5.0.spec b/dotnet5.0.spec index 9aad30e..5523053 100644 --- a/dotnet5.0.spec +++ b/dotnet5.0.spec @@ -63,7 +63,7 @@ URL: https://github.com/dotnet/ # The source is generated on a Fedora box via: # ./build-dotnet-tarball v%%{src_version}-SDK -Source0: dotnet-v%{src_version}-SDK-337413b.tar.gz +Source0: dotnet-9c4e5de-x64-bootstrap.tar.gz Source1: check-debug-symbols.py Source2: dotnet.sh.in @@ -87,7 +87,7 @@ BuildRequires: clang BuildRequires: cmake BuildRequires: coreutils %if %{without bootstrap} -BuildRequires: dotnet-build-reference-packages +BuildRequires: dotnet-5.0-build-reference-packages BuildRequires: dotnet-sdk-5.0 BuildRequires: dotnet-sdk-5.0-source-built-artifacts %endif @@ -310,7 +310,7 @@ These are not meant for general use. %prep -%setup -q -n dotnet-v%{src_version}-SDK-337413b +%setup -q -n dotnet-9c4e5de-x64-bootstrap %if %{without bootstrap} # Remove all prebuilts @@ -324,10 +324,9 @@ rm -rf packages/source-built %endif %if %{without bootstrap} -sed -i -e 's|5.0.100-preview1-014459|5.0.103|' global.json mkdir -p packages/archive ln -s %{_libdir}/dotnet/source-built-artifacts/*.tar.gz packages/archive/ -ln -s %{_libdir}/dotnet/reference-packages/Private.SourceBuild.ReferencePackages*.tar.gz packages/archive +ln -s %{_libdir}/dotnet/reference-packages/*.tar.gz packages/archive %endif # Fix bad hardcoded path in build @@ -467,8 +466,8 @@ echo "%{_libdir}/dotnet" >> install_location install -dm 0755 %{buildroot}%{_sysconfdir}/dotnet install install_location %{buildroot}%{_sysconfdir}/dotnet/ -#install -dm 0755 %%{buildroot}%%{_libdir}/dotnet/source-built-artifacts -#install artifacts/%%{runtime_arch}/Release/Private.SourceBuilt.Artifacts.*.tar.gz %%{buildroot}/%%{_libdir}/dotnet/source-built-artifacts/ +install -dm 0755 %{buildroot}%{_libdir}/dotnet/source-built-artifacts +install artifacts/%{runtime_arch}/Release/Private.SourceBuilt.Artifacts.*.tar.gz %{buildroot}/%{_libdir}/dotnet/source-built-artifacts/ # Check debug symbols in all elf objects. This is not in %%check # because native binaries are stripped by rpm-build after %%install. @@ -522,13 +521,16 @@ echo "Testing build results for debug symbols..." %{_libdir}/dotnet/sdk/%{sdk_version} %dir %{_libdir}/dotnet/packs -#%%files -n dotnet-sdk-5.0-source-built-artifacts -#%%dir %%{_libdir}/dotnet -#%%{_libdir}/dotnet/source-built-artifacts +%files -n dotnet-sdk-5.0-source-built-artifacts +%dir %{_libdir}/dotnet +%{_libdir}/dotnet/source-built-artifacts %changelog -* Fri Dec 04 13:22:13 EST 2020 Omair Majid - 5.0.100-1 +* Fri Dec 18 2020 Omair Majid - 5.0.100-2 +- Update to .NET Core Runtime 5.0.0 and SDK 5.0.100 commit 9c4e5de + +* Fri Dec 04 2020 Omair Majid - 5.0.100-1 - Update to .NET Core Runtime 5.0.0 and SDK 5.0.100 * Thu Dec 03 2020 Omair Majid - 5.0.100-0.4.20201202git337413b From 96fb4c4fa914c5f1f92dabc920ab1f1079333a7d Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Wed, 20 Jan 2021 17:24:05 -0500 Subject: [PATCH 16/19] Update for 5.0.102 and bootstrapping --- build-dotnet-tarball | 2 +- dotnet5.0.spec | 42 ++++++++++++++++++------------ runtime-47020-gcc11.patch | 55 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 runtime-47020-gcc11.patch diff --git a/build-dotnet-tarball b/build-dotnet-tarball index 6eba1bf..6135973 100755 --- a/build-dotnet-tarball +++ b/build-dotnet-tarball @@ -125,7 +125,7 @@ if [ ! -f "${unmodified_tarball_name}.tar.gz" ]; then git submodule update --init --recursive clean_dotnet_cache # FIXME remove contineuonprebuilterror - ./build.sh -p:SkipPrebuiltEnforcement=true -p:ContinueOnPrebuiltBaselineError=true -p:ArchiveDownloadedPackages=true -p:UseSystemLibraries=true + ./build.sh -p:SkipPrebuiltEnforcement=true -p:ContinueOnPrebuiltBaselineError=true -p:ArchiveDownloadedPackages=true -p:UseSystemLibraries=true -p:UseSystemLibunwind=false ./build-source-tarball.sh "${unmodified_tarball_name}" --skip-build -- -p:ContinueOnPrebuiltBaselineError=true -p:SkipPrebuiltEnforcement=true if [[ ${build_bootstrap} == true ]]; then diff --git a/dotnet5.0.spec b/dotnet5.0.spec index 5523053..5cd020d 100644 --- a/dotnet5.0.spec +++ b/dotnet5.0.spec @@ -20,11 +20,11 @@ # until that's done, disable LTO. This has to happen before setting the flags below. %define _lto_cflags %{nil} -%global host_version 5.0.0 -%global runtime_version 5.0.0 -%global aspnetcore_runtime_version 5.0.0 -%global sdk_version 5.0.100 -%global templates_version 5.0.0 +%global host_version 5.0.2 +%global runtime_version 5.0.2 +%global aspnetcore_runtime_version 5.0.2 +%global sdk_version 5.0.102 +%global templates_version %{runtime_version} #%%global templates_version %%(echo %%{runtime_version} | awk 'BEGIN { FS="."; OFS="." } {print $1, $2, $3+1 }') %global host_rpm_version %{host_version} @@ -63,15 +63,20 @@ URL: https://github.com/dotnet/ # The source is generated on a Fedora box via: # ./build-dotnet-tarball v%%{src_version}-SDK -Source0: dotnet-9c4e5de-x64-bootstrap.tar.gz -Source1: check-debug-symbols.py -Source2: dotnet.sh.in +Source0: dotnet-v%{src_version}-SDK-x64-bootstrap.tar.gz +Source1: dotnet-v%{src_version}-SDK-arm64-bootstrap.tar.gz + +Source10: check-debug-symbols.py +Source11: dotnet.sh.in Patch1: source-build-runtime-fixup-linker-order.patch # https://github.com/dotnet/runtime/pull/42094 # Fix linker order when linking with --as-needed Patch100: runtime-linker-order.patch +# https://github.com/dotnet/runtime/pull/47020 +# Fix build with gcc 11 +Patch101: runtime-47020-gcc11.patch # Disable telemetry by default; make it opt-in Patch500: sdk-telemetry-optout.patch @@ -310,7 +315,16 @@ These are not meant for general use. %prep -%setup -q -n dotnet-9c4e5de-x64-bootstrap +%if %{without bootstrap} +%setup -q -n dotnet-v%{src_version}-SDK +%else +%ifarch x86_64 +%setup -q -T -b 0 -n dotnet-v%{src_version}-SDK-%{runtime_arch}-bootstrap +%endif +%ifarch aarch64 +%setup -q -T -b 1 -n dotnet-v%{src_version}-SDK-%{runtime_arch}-bootstrap +%endif +%endif %if %{without bootstrap} # Remove all prebuilts @@ -339,17 +353,13 @@ sed -i 's|skiptests|skiptests ignorewarnings|' repos/runtime.common.props pushd src/runtime.* %patch100 -p1 +%patch101 -p1 popd pushd src/sdk.* %patch500 -p1 popd -%ifnarch x86_64 -mkdir -p artifacts/obj/%{runtime_arch}/Release -cp artifacts/obj/x64/Release/PackageVersions.props artifacts/obj/%{runtime_arch}/Release/PackageVersions.props -%endif - cat source-build-info.txt find -iname 'nuget.config' -exec echo {}: \; -exec cat {} \; -exec echo \; @@ -418,7 +428,7 @@ VERBOSE=1 ./build.sh \ %endif -sed -e 's|[@]LIBDIR[@]|%{_libdir}|g' %{SOURCE2} > dotnet.sh +sed -e 's|[@]LIBDIR[@]|%{_libdir}|g' %{SOURCE11} > dotnet.sh %install @@ -473,7 +483,7 @@ install artifacts/%{runtime_arch}/Release/Private.SourceBuilt.Artifacts.*.tar.gz # because native binaries are stripped by rpm-build after %%install. # So we need to do this check earlier. echo "Testing build results for debug symbols..." -%{SOURCE1} -v %{buildroot}%{_libdir}/dotnet/ +%{SOURCE10} -v %{buildroot}%{_libdir}/dotnet/ %check diff --git a/runtime-47020-gcc11.patch b/runtime-47020-gcc11.patch new file mode 100644 index 0000000..3751fcf --- /dev/null +++ b/runtime-47020-gcc11.patch @@ -0,0 +1,55 @@ +From 7123b8344ddc1c883483f13d34abbd22d4170452 Mon Sep 17 00:00:00 2001 +From: Omair Majid +Date: Tue, 5 Jan 2021 18:50:18 -0500 +Subject: [PATCH] Fix build errors using GCC 11 (#46334) + +Building runtime with GCC 11 leads to some new errors. The errors are +consistent with the "Header dependency changes" section documented at +https://gcc.gnu.org/gcc-11/porting_to.html + +The first set of errors looks like this: + + runtime/src/coreclr/pal/src/misc/cgroup.cpp:403:29: + error: no member named 'numeric_limits' in namespace 'std' + if (temp > std::numeric_limits::max()) + ~~~~~^ + +Fix that by including . + +The second set of errors looks like this: + + runtime/src/installer/corehost/cli/test/nativehost/host_context_test.cpp:634:31: + error: no member named 'sleep_for' in namespace 'std::this_thread' + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + ~~~~~~~~~~~~~~~~~~^ + +Fix that by including . +--- + src/coreclr/src/pal/src/misc/cgroup.cpp | 1 + + src/installer/corehost/cli/test/nativehost/host_context_test.cpp | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/src/coreclr/src/pal/src/misc/cgroup.cpp b/src/coreclr/src/pal/src/misc/cgroup.cpp +index f3e20012c539..24617359a21b 100644 +--- a/src/coreclr/src/pal/src/misc/cgroup.cpp ++++ b/src/coreclr/src/pal/src/misc/cgroup.cpp +@@ -14,6 +14,7 @@ Module Name: + #include "pal/dbgmsg.h" + SET_DEFAULT_DEBUG_CHANNEL(MISC); + #include "pal/palinternal.h" ++#include + #include + #include + #include "pal/virtual.h" +diff --git a/src/installer/corehost/cli/test/nativehost/host_context_test.cpp b/src/installer/corehost/cli/test/nativehost/host_context_test.cpp +index cea98db6673a..371ec2d7e2aa 100644 +--- a/src/installer/corehost/cli/test/nativehost/host_context_test.cpp ++++ b/src/installer/corehost/cli/test/nativehost/host_context_test.cpp +@@ -11,6 +11,7 @@ + #include + #include "hostfxr_exports.h" + #include "host_context_test.h" ++#include + #include + + namespace From b0a5c898c259c15d8c7969236ff34a77d5c05eaa Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Thu, 21 Jan 2021 10:05:23 -0500 Subject: [PATCH 17/19] Change name of source-build-references-package --- dotnet5.0.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet5.0.spec b/dotnet5.0.spec index 5cd020d..bd6c36e 100644 --- a/dotnet5.0.spec +++ b/dotnet5.0.spec @@ -92,7 +92,7 @@ BuildRequires: clang BuildRequires: cmake BuildRequires: coreutils %if %{without bootstrap} -BuildRequires: dotnet-5.0-build-reference-packages +BuildRequires: dotnet5.0-build-reference-packages BuildRequires: dotnet-sdk-5.0 BuildRequires: dotnet-sdk-5.0-source-built-artifacts %endif From b9e285d220d38729101bed96ed18f20be8d3d0ad Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Thu, 21 Jan 2021 18:53:18 -0500 Subject: [PATCH 18/19] Fix non-bootstrap build on aarch64 --- dotnet5.0.spec | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dotnet5.0.spec b/dotnet5.0.spec index bd6c36e..7bccb47 100644 --- a/dotnet5.0.spec +++ b/dotnet5.0.spec @@ -360,6 +360,13 @@ pushd src/sdk.* %patch500 -p1 popd +%if %{without bootstrap} +%ifnarch x86_64 +mkdir -p artifacts/obj/%{runtime_arch}/Release +cp artifacts/obj/x64/Release/PackageVersions.props artifacts/obj/%{runtime_arch}/Release/PackageVersions.props +%endif +%endif + cat source-build-info.txt find -iname 'nuget.config' -exec echo {}: \; -exec cat {} \; -exec echo \; From a8e63940d4d93dfeebe5397994a37a608f1b734b Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Fri, 29 Jan 2021 12:47:59 -0500 Subject: [PATCH 19/19] Add a comment describing the patch Requested in the package review. --- dotnet5.0.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/dotnet5.0.spec b/dotnet5.0.spec index 7bccb47..6d2e962 100644 --- a/dotnet5.0.spec +++ b/dotnet5.0.spec @@ -69,6 +69,7 @@ Source1: dotnet-v%{src_version}-SDK-arm64-bootstrap.tar.gz Source10: check-debug-symbols.py Source11: dotnet.sh.in +# Fix up a patch included in source-build to apply after we apply the linker-order patch first Patch1: source-build-runtime-fixup-linker-order.patch # https://github.com/dotnet/runtime/pull/42094