From 84b428a155cda8d96ddf3aa2a844d22b1ac27c50 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Tue, 30 Nov 2021 08:40:18 -0500 Subject: [PATCH] Fix build against clang 13 --- copr-build | 2 +- dotnet6.0.spec | 3 ++ runtime-62170-clang13.patch | 76 +++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 runtime-62170-clang13.patch diff --git a/copr-build b/copr-build index 8a7cf46..f0d4ca3 100755 --- a/copr-build +++ b/copr-build @@ -4,7 +4,7 @@ set -euo pipefail set -x -fedpkg --release f32 srpm 2>&1 | tee fedpkg.output +fedpkg --release f34 srpm 2>&1 | tee fedpkg.output srpm_name=$(grep 'Wrote: ' fedpkg.output | cut -d' ' -f 2) diff --git a/dotnet6.0.spec b/dotnet6.0.spec index fc63a3f..7aed931 100644 --- a/dotnet6.0.spec +++ b/dotnet6.0.spec @@ -88,6 +88,8 @@ Patch100: runtime-arm64-lld-fix.patch Patch101: runtime-mono-remove-ilstrip.patch # https://github.com/dotnet/runtime/pull/61442 Patch102: runtime-61442-disable-werror.patch +# https://github.com/dotnet/runtime/pull/62170 +Patch103: runtime-62170-clang13.patch # https://github.com/dotnet/command-line-api/pull/1401 Patch300: command-line-api-use-work-tree-with-git-apply.patch @@ -414,6 +416,7 @@ pushd src/runtime.* %patch100 -p1 %patch101 -p1 %patch102 -p1 +%patch103 -p1 popd pushd src/command-line-api.* diff --git a/runtime-62170-clang13.patch b/runtime-62170-clang13.patch new file mode 100644 index 0000000..8c47186 --- /dev/null +++ b/runtime-62170-clang13.patch @@ -0,0 +1,76 @@ +From 9cd95a5608b667e22727d9eb1a5330efd61dfe50 Mon Sep 17 00:00:00 2001 +From: Jan Vorlicek +Date: Mon, 29 Nov 2021 17:32:45 -0800 +Subject: [PATCH] Fix clang 13 induced runtime issues + +The clang 13 optimizer started to assume that "this" pointer is always +properly aligned. That lead to elimination of some code that was actually +needed. +It also takes pointer aliasing rules more strictly in one place in jit. +That caused the optimizer to falsely assume that a callee with an argument +passed by reference is not modifying that argument and used a stale +copy of the original value at the caller site. + +This change fixes both of the issues. With this fix, runtime compiled +using clang 13 seems to be fully functional. +--- + src/coreclr/inc/corhlpr.h | 8 ++++---- + src/coreclr/jit/bitsetasshortlong.h | 4 ++-- + 2 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/src/coreclr/inc/corhlpr.h b/src/coreclr/inc/corhlpr.h +index 450514da95c1..427e8cdc0ff5 100644 +--- a/src/coreclr/inc/corhlpr.h ++++ b/src/coreclr/inc/corhlpr.h +@@ -336,7 +336,7 @@ struct COR_ILMETHOD_SECT + const COR_ILMETHOD_SECT* Next() const + { + if (!More()) return(0); +- return ((COR_ILMETHOD_SECT*)(((BYTE *)this) + DataSize()))->Align(); ++ return ((COR_ILMETHOD_SECT*)Align(((BYTE *)this) + DataSize())); + } + + const BYTE* Data() const +@@ -374,9 +374,9 @@ struct COR_ILMETHOD_SECT + return((AsSmall()->Kind & CorILMethod_Sect_FatFormat) != 0); + } + +- const COR_ILMETHOD_SECT* Align() const ++ static const void* Align(const void* p) + { +- return((COR_ILMETHOD_SECT*) ((((UINT_PTR) this) + 3) & ~3)); ++ return((void*) ((((UINT_PTR) p) + 3) & ~3)); + } + + protected: +@@ -579,7 +579,7 @@ typedef struct tagCOR_ILMETHOD_FAT : IMAGE_COR_ILMETHOD_FAT + + const COR_ILMETHOD_SECT* GetSect() const { + if (!More()) return (0); +- return(((COR_ILMETHOD_SECT*) (GetCode() + GetCodeSize()))->Align()); ++ return(((COR_ILMETHOD_SECT*) COR_ILMETHOD_SECT::Align(GetCode() + GetCodeSize()))); + } + } COR_ILMETHOD_FAT; + +diff --git a/src/coreclr/jit/bitsetasshortlong.h b/src/coreclr/jit/bitsetasshortlong.h +index d343edeeda4c..365cf346a10a 100644 +--- a/src/coreclr/jit/bitsetasshortlong.h ++++ b/src/coreclr/jit/bitsetasshortlong.h +@@ -345,7 +345,7 @@ class BitSetOps