swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.27k stars 10.33k forks source link

[SR-5319] swift-clang does not build with gcc 4.8 #47893

Open swift-ci opened 7 years ago

swift-ci commented 7 years ago
Previous ID SR-5319
Radar None
Original Reporter rhochstedler (JIRA User)
Type Bug
Environment Linux reid-ubuntu-14 4.4.0-81-generic \#104-Ubuntu SMP Wed Jun 14 08:17:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux gcc (Ubuntu 4.8.5-4ubuntu2) 4.8.5 swift-4.0-branch
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, Linux | |Assignee | None | |Priority | Medium | md5: fed3d772fa0e5ed6760984e5c6ee5840

Issue Description:

The swift-4.0-branch is not able to be built using GCC 4.8 Compilation fails on clang/lib/APINotes/APINotesWriter.cpp, it appears to choke on some C++ template voodoo not supported in GCC 4.8.

Here is a snippet of the error

[ 21%] Updating Attributes.gen...
[ 21%] Updating Intrinsics.gen...
[ 21%] Built target intrinsics_gen
[ 21%] Building CXX object tools/clang/lib/Basic/CMakeFiles/clangBasic.dir/Builtins.cpp.o
In file included from /home/rhochstedler/apple-swift-llvm/tools/clang/lib/APINotes/APINotesReader.cpp:17:0:
/home/rhochstedler/apple-swift-llvm/tools/clang/lib/APINotes/APINotesFormat.h:239:2: warning: extra ';' [-Wpedantic]
 };
  ^
/home/rhochstedler/apple-swift-llvm/tools/clang/lib/APINotes/APINotesFormat.h:251:2: warning: extra ';' [-Wpedantic]
 };
  ^
[ 21%] Building CXX object tools/clang/lib/Basic/CMakeFiles/clangBasic.dir/CharInfo.cpp.o
[ 21%] Building CXX object tools/clang/lib/Lex/CMakeFiles/clangLex.dir/HeaderSearch.cpp.o
/home/rhochstedler/apple-swift-llvm/tools/clang/lib/APINotes/APINotesWriter.cpp: In instantiation of 'std::pair<unsigned int, unsigned int> {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::EmitKeyDataLength(llvm::raw_ostream&, {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::key_type_ref, {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::data_type_ref) [with Derived = {anonymous}::ObjCContextInfoTableInfo; KeyType = unsigned int; UnversionedDataType = clang::api_notes::ObjCContextInfo; {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::key_type_ref = unsigned int; {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::data_type_ref = const llvm::SmallVector<std::pair<clang::VersionTuple, clang::api_notes::ObjCContextInfo>, 1u>&; {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::data_type = llvm::SmallVector<std::pair<clang::VersionTuple, clang::api_notes::ObjCContextInfo>, 1u>]':
/home/rhochstedler/apple-swift-llvm/include/llvm/Support/OnDiskHashTable.h:188:59:   required from 'llvm::OnDiskChainedHashTableGenerator<Info>::offset_type llvm::OnDiskChainedHashTableGenerator<Info>::Emit(llvm::raw_ostream&, Info&) [with Info = {anonymous}::ObjCContextInfoTableInfo; llvm::OnDiskChainedHashTableGenerator<Info>::offset_type = unsigned int]'
/home/rhochstedler/apple-swift-llvm/include/llvm/Support/OnDiskHashTable.h:144:29:   required from 'llvm::OnDiskChainedHashTableGenerator<Info>::offset_type llvm::OnDiskChainedHashTableGenerator<Info>::Emit(llvm::raw_ostream&) [with Info = {anonymous}::ObjCContextInfoTableInfo; llvm::OnDiskChainedHashTableGenerator<Info>::offset_type = unsigned int]'
/home/rhochstedler/apple-swift-llvm/tools/clang/lib/APINotes/APINotesWriter.cpp:673:46:   required from here
/home/rhochstedler/apple-swift-llvm/tools/clang/lib/APINotes/APINotesWriter.cpp:546:8: error: no matching function for call to 'getVersionedInfoSize(const data_type&, {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::EmitKeyDataLength(llvm::raw_ostream&, {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::key_type_ref, {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::data_type_ref) [with Derived = {anonymous}::ObjCContextInfoTableInfo; KeyType = unsigned int; UnversionedDataType = clang::api_notes::ObjCContextInfo; {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::key_type_ref = unsigned int; {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::data_type_ref = const llvm::SmallVector<std::pair<clang::VersionTuple, clang::api_notes::ObjCContextInfo>, 1u>&; {anonymous}::VersionedTableInfo<Derived, KeyType, UnversionedDataType>::data_type = llvm::SmallVector<std::pair<clang::VersionTuple, clang::api_notes::ObjCContextInfo>, 1u>]::__lambda2)'
       });
        ^
swift-ci commented 7 years ago

Comment by Jason Holajter (JIRA)

Further debugging points to an issue with the lambda functions when using gcc 4.8 that I have not been able to pinpoint.

Stubbing out the lambda functions in VersionedTableInfo::EmitKeyDataLength() and VersionedTableInfo::EmitData() allows the build to complete successfully, but obviously the functionality is not correct in this case.

Alternatively, defining EmitKeyDataLength() and EmitData() in the classes that derive from VersionedTableInfo allows the build to complete successfully. This would allow the functionality to be correct, but defeats the purpose of deriving from VersionedTableInfo.

Any other thoughts on why the lambda function is causing build failures?