diff --git a/pkgs/development/compilers/llvm/3.9/clang/0001-Fix-compilation-w-gcc9.patch b/pkgs/development/compilers/llvm/3.9/clang/0001-Fix-compilation-w-gcc9.patch new file mode 100644 index 000000000000..1058cd031767 --- /dev/null +++ b/pkgs/development/compilers/llvm/3.9/clang/0001-Fix-compilation-w-gcc9.patch @@ -0,0 +1,63 @@ +From 7225c7754cc3431d05df367c60f309f27586f188 Mon Sep 17 00:00:00 2001 +From: Maximilian Bosch +Date: Mon, 30 Dec 2019 01:42:52 +0100 +Subject: [PATCH] Fix compilation w/gcc9 + +Build broken with the following errors: + +``` +clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function: +clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6078:55: error: lambda parameter 'CGF' previously declared as a capture +clang> 6078 | &NumOfPtrs](CodeGenFunction &CGF, PrePostActionTy &) { +clang> | ~~~~~~~~~~~~~~~~~^~~ +clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function: +clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6126:53: error: lambda parameter 'CGF' previously declared as a capture +clang> 6126 | &NumOfPtrs](CodeGenFunction &CGF, PrePostActionTy &) { +clang> | ~~~~~~~~~~~~~~~~~^~~ +clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function: +clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6191:56: error: lambda parameter 'CGF' previously declared as a capture +clang> 6191 | auto &&ThenGen = [&D, &CGF, Device](CodeGenFunction &CGF, PrePostActionTy &) { +clang> | ~~~~~~~~~~~~~~~~~^~~ +``` + +This was due to a bug about name-collisions fixed in GCC 9.0[1]. + +[1] http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2211 +--- + lib/CodeGen/CGOpenMPRuntime.cpp | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp +index 6a0edbe..96c281c 100644 +--- a/lib/CodeGen/CGOpenMPRuntime.cpp ++++ b/lib/CodeGen/CGOpenMPRuntime.cpp +@@ -6073,7 +6073,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(CodeGenFunction &CGF, + // Generate the code for the opening of the data environment. Capture all the + // arguments of the runtime call by reference because they are used in the + // closing of the region. +- auto &&BeginThenGen = [&D, &CGF, &BasePointersArray, &PointersArray, ++ auto &&BeginThenGen = [&D, &BasePointersArray, &PointersArray, + &SizesArray, &MapTypesArray, Device, + &NumOfPtrs](CodeGenFunction &CGF, PrePostActionTy &) { + // Fill up the arrays with all the mapped variables. +@@ -6121,7 +6121,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(CodeGenFunction &CGF, + }; + + // Generate code for the closing of the data region. +- auto &&EndThenGen = [&CGF, &BasePointersArray, &PointersArray, &SizesArray, ++ auto &&EndThenGen = [&BasePointersArray, &PointersArray, &SizesArray, + &MapTypesArray, Device, + &NumOfPtrs](CodeGenFunction &CGF, PrePostActionTy &) { + assert(BasePointersArray && PointersArray && SizesArray && MapTypesArray && +@@ -6188,7 +6188,7 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall( + "Expecting either target enter, exit data, or update directives."); + + // Generate the code for the opening of the data environment. +- auto &&ThenGen = [&D, &CGF, Device](CodeGenFunction &CGF, PrePostActionTy &) { ++ auto &&ThenGen = [&D, Device](CodeGenFunction &CGF, PrePostActionTy &) { + // Fill up the arrays with all the mapped variables. + MappableExprsHandler::MapValuesArrayTy BasePointers; + MappableExprsHandler::MapValuesArrayTy Pointers; +-- +2.23.1 + diff --git a/pkgs/development/compilers/llvm/3.9/clang/default.nix b/pkgs/development/compilers/llvm/3.9/clang/default.nix index 3d09277ad4cf..1666b3d842d9 100644 --- a/pkgs/development/compilers/llvm/3.9/clang/default.nix +++ b/pkgs/development/compilers/llvm/3.9/clang/default.nix @@ -27,7 +27,10 @@ let (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); - patches = [ ./purity.patch ]; + patches = [ + ./purity.patch + ./0001-Fix-compilation-w-gcc9.patch + ]; postPatch = '' sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp