clang_4: fix build w/gcc9

As noted in the incorporated patch, name collisions between lambda
arguments and lambda captures cause compilation failures in GCC9[1].

The issue has been fixed in a later version of CLang, unfortunately the
relevant patches weren't backported to the versions 3.9 and 4.0[2].

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2211
[2] bb177a9307 (diff-d63bede6ed85300ad2aaf4eaee571456L6278)
This commit is contained in:
Maximilian Bosch 2019-12-30 02:18:24 +01:00
parent 2e5fd9f03e
commit 129fbd7550
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E
2 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,59 @@
From a2af0b02eba35d0670e3e442ff7c61b3e2304edd Mon Sep 17 00:00:00 2001
From: Maximilian Bosch <maximilian@mbosch.me>
Date: Mon, 30 Dec 2019 02:11:35 +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:6275:24: error: lambda parameter 'CGF' previously declared as a capture
clang> 6275 | CodeGenFunction &CGF, PrePostActionTy &) {
clang> | ~~~~~~~~~~~~~~~~~^~~
clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function:
clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6321:62: error: lambda parameter 'CGF' previously declared as a capture
clang> 6321 | auto &&EndThenGen = [&CGF, Device, &Info](CodeGenFunction &CGF,
clang> | ~~~~~~~~~~~~~~~~~^~~
clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp: In lambda function:
clang> /build/clang/lib/CodeGen/CGOpenMPRuntime.cpp:6400:56: error: lambda parameter 'CGF' previously declared as a capture
clang> 6400 | auto &&ThenGen = [&D, &CGF, Device](CodeGenFunction &CGF, PrePostActionTy &) {
clang> | ~~~~~~~~~~~~~~~~~^~~
```
---
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 4025217..40a73ef 100644
--- a/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6271,7 +6271,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(
// 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, Device, &Info, &CodeGen, &NoPrivAction](
+ auto &&BeginThenGen = [&D, Device, &Info, &CodeGen, &NoPrivAction](
CodeGenFunction &CGF, PrePostActionTy &) {
// Fill up the arrays with all the mapped variables.
MappableExprsHandler::MapBaseValuesArrayTy BasePointers;
@@ -6318,7 +6318,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(
};
// Generate code for the closing of the data region.
- auto &&EndThenGen = [&CGF, Device, &Info](CodeGenFunction &CGF,
+ auto &&EndThenGen = [Device, &Info](CodeGenFunction &CGF,
PrePostActionTy &) {
assert(Info.isValid() && "Invalid data environment closing arguments.");
@@ -6397,7 +6397,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::MapBaseValuesArrayTy BasePointers;
MappableExprsHandler::MapValuesArrayTy Pointers;
--
2.23.1

View File

@ -38,7 +38,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