git.iko.soy/typeable/nixpkgs
on master help sign in
llvm: Include aarch64 patch in repo

The URL is already a dead link.

commitfc26ff04b236030a47bc3f57ba95017fdab53f8f authorTuomas Tynkkynen <tuomas@tuxera.com> dateWed 29 Nov 2017, 17:01 (9 years ago) parent99bab78
3 files changed+53−12
pkgs/development/compilers/llvm/4/llvm.nix+1−6 pkgs/development/compilers/llvm/5/llvm.nix+1−6 pkgs/development/compilers/llvm/aarch64.patch+51
pkgs/development/compilers/llvm/4/llvm.nix+1−6
@@ -24,11 +24,6 @@
2424let
2525 src = fetch "llvm" "0l9bf7kdwhlj0kq1hawpyxhna1062z3h7qcz2y8nfl9dz2qksy6s";
2626
27− aarch64Patch = fetchpatch {
28− url = https://reviews.llvm.org/file/data/2oqw5rhhklsapbjrhlpd/PHID-FILE-lvo4fcs6hjvkxb5wneg2/D40423.diff;
29− sha256 = "0b0h7n7lxw33pn2j061hm9050zn263gmiig937g5cmcvjimxlybb";
30− };
31−
3227 # Used when creating a version-suffixed symlink of libLLVM.dylib
3328 shortVersion = with stdenv.lib;
3429 concatStringsSep "." (take 2 (splitString "." release_version));
@@ -87,7 +82,7 @@ in stdenv.mkDerivation rec {
8782 --replace 'struct sigaltstack' 'stack_t'
8883 )
8984 '' + stdenv.lib.optionalString stdenv.isAarch64 ''
90− patch -p0 < ${aarch64Patch}
85+ patch -p0 < ${../aarch64.patch}
9186 '';
9287
9388 # hacky fix: created binaries need to be run before installation
pkgs/development/compilers/llvm/5/llvm.nix+1−6
@@ -24,11 +24,6 @@
2424let
2525 src = fetch "llvm" "1nin64vz21hyng6jr19knxipvggaqlkl2l9jpd5czbc4c2pcnpg3";
2626
27− aarch64Patch = fetchpatch {
28− url = https://reviews.llvm.org/file/data/2oqw5rhhklsapbjrhlpd/PHID-FILE-lvo4fcs6hjvkxb5wneg2/D40423.diff;
29− sha256 = "0b0h7n7lxw33pn2j061hm9050zn263gmiig937g5cmcvjimxlybb";
30− };
31−
3227 # Used when creating a version-suffixed symlink of libLLVM.dylib
3328 shortVersion = with stdenv.lib;
3429 concatStringsSep "." (take 2 (splitString "." release_version));
@@ -81,7 +76,7 @@ in stdenv.mkDerivation rec {
8176 # Revert compiler-rt commit that makes codesign mandatory
8277 patch -p1 -i ${./compiler-rt-codesign.patch} -d projects/compiler-rt
8378 '' + stdenv.lib.optionalString stdenv.isAarch64 ''
84− patch -p0 < ${aarch64Patch}
79+ patch -p0 < ${../aarch64.patch}
8580 '';
8681
8782 # hacky fix: created binaries need to be run before installation
pkgs/development/compilers/llvm/aarch64.patchnew file+51
@@ -0,0 +1,51 @@
1+--- lib/Support/Unix/Memory.inc
2++++ lib/Support/Unix/Memory.inc
3+@@ -126,8 +126,12 @@
4+ Result.Address = Addr;
5+ Result.Size = NumPages*PageSize;
6+
7+- if (PFlags & MF_EXEC)
8+- Memory::InvalidateInstructionCache(Result.Address, Result.Size);
9++ // Rely on protectMappedMemory to invalidate instruction cache.
10++ if (PFlags & MF_EXEC) {
11++ EC = Memory::protectMappedMemory (Result, PFlags);
12++ if (EC != std::error_code())
13++ return MemoryBlock();
14++ }
15+
16+ return Result;
17+ }
18+@@ -156,15 +160,31 @@
19+ return std::error_code(EINVAL, std::generic_category());
20+
21+ int Protect = getPosixProtectionFlags(Flags);
22+-
23+ uintptr_t Start = alignAddr((uint8_t *)M.Address - PageSize + 1, PageSize);
24+ uintptr_t End = alignAddr((uint8_t *)M.Address + M.Size, PageSize);
25++
26++ bool InvalidateCache = (Flags & MF_EXEC);
27++
28++#if defined(__arm__) || defined(__aarch64__)
29++ // Certain ARM implementations treat icache clear instruction as a memory read,
30++ // and CPU segfaults on trying to clear cache on !PROT_READ page. Therefore we need
31++ // to temporarily add PROT_READ for the sake of flushing the instruction caches.
32++ if (InvalidateCache && !(Protect & PROT_READ)) {
33++ int Result = ::mprotect((void *)Start, End - Start, Protect | PROT_READ);
34++ if (Result != 0)
35++ return std::error_code(errno, std::generic_category());
36++
37++ Memory::InvalidateInstructionCache(M.Address, M.Size);
38++ InvalidateCache = false;
39++ }
40++#endif
41++
42+ int Result = ::mprotect((void *)Start, End - Start, Protect);
43+
44+ if (Result != 0)
45+ return std::error_code(errno, std::generic_category());
46+
47+- if (Flags & MF_EXEC)
48++ if (InvalidateCache)
49+ Memory::InvalidateInstructionCache(M.Address, M.Size);
50+
51+ return std::error_code();