From b45161fbbe5b36ba7f8bc27af6493d6e63f7c2ee Mon Sep 17 00:00:00 2001 From: Moritz Ulrich Date: Thu, 24 Dec 2015 14:18:27 +0100 Subject: [PATCH] llvm: Add backported patch for Rust. Rust runs into a bug with LLVM 3.7.0 that's fixed in the upcoming release 3.7.1. This commit backports this fix. --- pkgs/development/compilers/llvm/3.7/llvm.nix | 5 ++ .../3.7/r242372-fix-LLVMBuildLandingPad.patch | 60 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 pkgs/development/compilers/llvm/3.7/r242372-fix-LLVMBuildLandingPad.patch diff --git a/pkgs/development/compilers/llvm/3.7/llvm.nix b/pkgs/development/compilers/llvm/3.7/llvm.nix index 060c0f3e867..bbeb0c858e5 100644 --- a/pkgs/development/compilers/llvm/3.7/llvm.nix +++ b/pkgs/development/compilers/llvm/3.7/llvm.nix @@ -22,6 +22,11 @@ let in stdenv.mkDerivation rec { name = "llvm-${version}"; + patches = [ + # Backport for Rust, remove when 3.7.1 is released + ./r242372-fix-LLVMBuildLandingPad.patch + ]; + unpackPhase = '' unpackFile ${src} mv llvm-${version}.src llvm diff --git a/pkgs/development/compilers/llvm/3.7/r242372-fix-LLVMBuildLandingPad.patch b/pkgs/development/compilers/llvm/3.7/r242372-fix-LLVMBuildLandingPad.patch new file mode 100644 index 00000000000..749de6e9b6a --- /dev/null +++ b/pkgs/development/compilers/llvm/3.7/r242372-fix-LLVMBuildLandingPad.patch @@ -0,0 +1,60 @@ +Index: llvm/bindings/ocaml/llvm/llvm_ocaml.c +=================================================================== +--- llvm/bindings/ocaml/llvm/llvm_ocaml.c (revision 242371) ++++ llvm/bindings/ocaml/llvm/llvm_ocaml.c (revision 242372) +@@ -1745,7 +1745,7 @@ + CAMLprim LLVMValueRef llvm_build_landingpad(LLVMTypeRef Ty, LLVMValueRef PersFn, + value NumClauses, value Name, + value B) { +- return LLVMBuildLandingPad(Builder_val(B), Ty, Int_val(NumClauses), ++ return LLVMBuildLandingPad(Builder_val(B), Ty, PersFn, Int_val(NumClauses), + String_val(Name)); + } + +Index: llvm/bindings/go/llvm/ir.go +=================================================================== +--- llvm/bindings/go/llvm/ir.go (revision 242371) ++++ llvm/bindings/go/llvm/ir.go (revision 242372) +@@ -1731,7 +1731,7 @@ + func (b Builder) CreateLandingPad(t Type, nclauses int, name string) (l Value) { + cname := C.CString(name) + defer C.free(unsafe.Pointer(cname)) +- l.C = C.LLVMBuildLandingPad(b.C, t.C, C.unsigned(nclauses), cname) ++ l.C = C.LLVMBuildLandingPad(b.C, t.C, nil, C.unsigned(nclauses), cname) + return l + } + +Index: llvm/lib/IR/Core.cpp +=================================================================== +--- llvm/lib/IR/Core.cpp (revision 242371) ++++ llvm/lib/IR/Core.cpp (revision 242372) +@@ -2257,7 +2257,14 @@ + } + + LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, +- unsigned NumClauses, const char *Name) { ++ LLVMValueRef PersFn, unsigned NumClauses, ++ const char *Name) { ++ // The personality used to live on the landingpad instruction, but now it ++ // lives on the parent function. For compatibility, take the provided ++ // personality and put it on the parent function. ++ if (PersFn) ++ unwrap(B)->GetInsertBlock()->getParent()->setPersonalityFn( ++ cast(unwrap(PersFn))); + return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), NumClauses, Name)); + } + +Index: llvm/include/llvm-c/Core.h +=================================================================== +--- llvm/include/llvm-c/Core.h (revision 242371) ++++ llvm/include/llvm-c/Core.h (revision 242372) +@@ -2675,7 +2675,8 @@ + LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, + const char *Name); + LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, +- unsigned NumClauses, const char *Name); ++ LLVMValueRef PersFn, unsigned NumClauses, ++ const char *Name); + LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn); + LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); +