diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4528b88 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/llvm-5.0.0.src.tar.xz diff --git a/0001-CMake-Fix-pthread-handling-for-out-of-tree-builds.patch b/0001-CMake-Fix-pthread-handling-for-out-of-tree-builds.patch new file mode 100644 index 0000000..0ad05d4 --- /dev/null +++ b/0001-CMake-Fix-pthread-handling-for-out-of-tree-builds.patch @@ -0,0 +1,193 @@ +From a61fc423f3c043314efd4c0cdb1367de2077ac36 Mon Sep 17 00:00:00 2001 +From: Eric Fiselier +Date: Fri, 10 Feb 2017 01:59:20 +0000 +Subject: [PATCH] [CMake] Fix pthread handling for out-of-tree builds + +LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects +to correctly link the threading library when needed. Unfortunately +`PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed +and therefore can't be used when configuring out-of-tree builds. This causes +such builds to fail since `pthread` isn't being correctly linked. + +This patch attempts to fix that problem by renaming and exporting +`LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB` +because It seemed likely to cause collisions with downstream users of +`LLVMConfig.cmake`. + + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294690 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + cmake/config-ix.cmake | 2 +- + cmake/modules/AddLLVM.cmake | 6 +++--- + cmake/modules/LLVMConfig.cmake.in | 4 ++++ + examples/ParallelJIT/CMakeLists.txt | 2 +- + lib/CodeGen/CMakeLists.txt | 2 +- + lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt | 2 +- + lib/Fuzzer/CMakeLists.txt | 4 ++-- + lib/Support/CMakeLists.txt | 2 +- + unittests/ExecutionEngine/Orc/CMakeLists.txt | 2 +- + unittests/Support/CMakeLists.txt | 2 +- + utils/unittest/CMakeLists.txt | 4 ++-- + 11 files changed, 18 insertions(+), 14 deletions(-) + +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +index 50bcc50..6bd2b53 100755 +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake +@@ -115,7 +115,7 @@ if(HAVE_LIBPTHREAD) + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + set(THREADS_HAVE_PTHREAD_ARG Off) + find_package(Threads REQUIRED) +- set(PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT}) ++ set(LLVM_PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT}) + endif() + + # Don't look for these libraries on Windows. Also don't look for them if we're +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index b3c7746..cb4171c 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -718,11 +718,11 @@ macro(add_llvm_executable name) + if(NOT ARG_IGNORE_EXTERNALIZE_DEBUGINFO) + llvm_externalize_debuginfo(${name}) + endif() +- if (PTHREAD_LIB) ++ if (LLVM_PTHREAD_LIB) + # libpthreads overrides some standard library symbols, so main + # executable must be linked with it in order to provide consistent + # API for all shared libaries loaded by this executable. +- target_link_libraries(${name} ${PTHREAD_LIB}) ++ target_link_libraries(${name} ${LLVM_PTHREAD_LIB}) + endif() + endmacro(add_llvm_executable name) + +@@ -1027,7 +1027,7 @@ function(add_unittest test_suite test_name) + # libpthreads overrides some standard library symbols, so main + # executable must be linked with it in order to provide consistent + # API for all shared libaries loaded by this executable. +- target_link_libraries(${test_name} gtest_main gtest ${PTHREAD_LIB}) ++ target_link_libraries(${test_name} gtest_main gtest ${LLVM_PTHREAD_LIB}) + + add_dependencies(${test_suite} ${test_name}) + get_target_property(test_suite_folder ${test_suite} FOLDER) +diff --git a/cmake/modules/LLVMConfig.cmake.in b/cmake/modules/LLVMConfig.cmake.in +index 2aea2dc..7a8eb36 100644 +--- a/cmake/modules/LLVMConfig.cmake.in ++++ b/cmake/modules/LLVMConfig.cmake.in +@@ -45,6 +45,10 @@ set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@) + + set(LLVM_BUILD_32_BITS @LLVM_BUILD_32_BITS@) + ++if (NOT "@LLVM_PTHREAD_LIB@" STREQUAL "") ++ set(LLVM_PTHREAD_LIB "@LLVM_PTHREAD_LIB@") ++endif() ++ + set(LLVM_ENABLE_PLUGINS @LLVM_ENABLE_PLUGINS@) + set(LLVM_EXPORT_SYMBOLS_FOR_PLUGINS @LLVM_EXPORT_SYMBOLS_FOR_PLUGINS@) + set(LLVM_PLUGIN_EXT @LLVM_PLUGIN_EXT@) +diff --git a/examples/ParallelJIT/CMakeLists.txt b/examples/ParallelJIT/CMakeLists.txt +index e85b470..deeee07 100644 +--- a/examples/ParallelJIT/CMakeLists.txt ++++ b/examples/ParallelJIT/CMakeLists.txt +@@ -11,4 +11,4 @@ add_llvm_example(ParallelJIT + ParallelJIT.cpp + ) + +-target_link_libraries(ParallelJIT ${PTHREAD_LIB}) ++target_link_libraries(ParallelJIT ${LLVM_PTHREAD_LIB}) +diff --git a/lib/CodeGen/CMakeLists.txt b/lib/CodeGen/CMakeLists.txt +index a1e5fd4..a9a3d85 100644 +--- a/lib/CodeGen/CMakeLists.txt ++++ b/lib/CodeGen/CMakeLists.txt +@@ -150,7 +150,7 @@ add_llvm_library(LLVMCodeGen + ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen + ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen/PBQP + +- LINK_LIBS ${PTHREAD_LIB} ++ LINK_LIBS ${LLVM_PTHREAD_LIB} + + DEPENDS + intrinsics_gen +diff --git a/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt b/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt +index 3b8c4b9..e6c33b2 100644 +--- a/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt ++++ b/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt +@@ -4,7 +4,7 @@ if( HAVE_LIBDL ) + set(LLVM_INTEL_JIT_LIBS ${CMAKE_DL_LIBS}) + endif() + +-set(LLVM_INTEL_JIT_LIBS ${PTHREAD_LIB} ${LLVM_INTEL_JIT_LIBS}) ++set(LLVM_INTEL_JIT_LIBS ${LLVM_PTHREAD_LIB} ${LLVM_INTEL_JIT_LIBS}) + + + add_llvm_library(LLVMIntelJITEvents +diff --git a/lib/Fuzzer/CMakeLists.txt b/lib/Fuzzer/CMakeLists.txt +index 5ba126e..f490b36 100644 +--- a/lib/Fuzzer/CMakeLists.txt ++++ b/lib/Fuzzer/CMakeLists.txt +@@ -34,12 +34,12 @@ if( LLVM_USE_SANITIZE_COVERAGE ) + add_library(LLVMFuzzerNoMain STATIC + $ + ) +- target_link_libraries(LLVMFuzzerNoMain ${PTHREAD_LIB}) ++ target_link_libraries(LLVMFuzzerNoMain ${LLVM_PTHREAD_LIB}) + add_library(LLVMFuzzer STATIC + FuzzerMain.cpp + $ + ) +- target_link_libraries(LLVMFuzzer ${PTHREAD_LIB}) ++ target_link_libraries(LLVMFuzzer ${LLVM_PTHREAD_LIB}) + + if( LLVM_INCLUDE_TESTS ) + add_subdirectory(test) +diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt +index 3301364..f7cfa76 100644 +--- a/lib/Support/CMakeLists.txt ++++ b/lib/Support/CMakeLists.txt +@@ -17,7 +17,7 @@ elseif( CMAKE_HOST_UNIX ) + if( LLVM_ENABLE_THREADS AND HAVE_LIBATOMIC ) + set(system_libs ${system_libs} atomic) + endif() +- set(system_libs ${system_libs} ${PTHREAD_LIB}) ++ set(system_libs ${system_libs} ${LLVM_PTHREAD_LIB}) + if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ ) + set(system_libs ${system_libs} z) + endif() +diff --git a/unittests/ExecutionEngine/Orc/CMakeLists.txt b/unittests/ExecutionEngine/Orc/CMakeLists.txt +index 68f6d0c..80c344e 100644 +--- a/unittests/ExecutionEngine/Orc/CMakeLists.txt ++++ b/unittests/ExecutionEngine/Orc/CMakeLists.txt +@@ -21,4 +21,4 @@ add_llvm_unittest(OrcJITTests + RPCUtilsTest.cpp + ) + +-target_link_libraries(OrcJITTests ${PTHREAD_LIB}) ++target_link_libraries(OrcJITTests ${LLVM_PTHREAD_LIB}) +diff --git a/unittests/Support/CMakeLists.txt b/unittests/Support/CMakeLists.txt +index 4c9bb5e..ea26079 100644 +--- a/unittests/Support/CMakeLists.txt ++++ b/unittests/Support/CMakeLists.txt +@@ -64,4 +64,4 @@ add_llvm_unittest(SupportTests + ) + + # ManagedStatic.cpp uses . +-target_link_libraries(SupportTests ${PTHREAD_LIB}) ++target_link_libraries(SupportTests ${LLVM_PTHREAD_LIB}) +diff --git a/utils/unittest/CMakeLists.txt b/utils/unittest/CMakeLists.txt +index a50733a..b42ac83 100644 +--- a/utils/unittest/CMakeLists.txt ++++ b/utils/unittest/CMakeLists.txt +@@ -40,8 +40,8 @@ if (NOT LLVM_ENABLE_THREADS) + add_definitions( -DGTEST_HAS_PTHREAD=0 ) + endif() + +-find_library(PTHREAD_LIBRARY_PATH pthread) +-if (PTHREAD_LIBRARY_PATH) ++find_library(LLVM_PTHREAD_LIBRARY_PATH pthread) ++if (LLVM_PTHREAD_LIBRARY_PATH) + list(APPEND LIBS pthread) + endif() + +-- +1.8.3.1 + diff --git a/0001-CMake-Split-static-library-exports-into-their-own-ex.patch b/0001-CMake-Split-static-library-exports-into-their-own-ex.patch new file mode 100644 index 0000000..123fb1a --- /dev/null +++ b/0001-CMake-Split-static-library-exports-into-their-own-ex.patch @@ -0,0 +1,86 @@ +From 80d3393d3e324dd8bef7de1b9c6db3010585f3e8 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Sat, 29 Apr 2017 02:03:23 +0000 +Subject: [PATCH] CMake: Split static library exports into their own export + file + +Summary: +This is to better support distros which split the static libraries into +their own package. + +The current problem is that any project the includes LLVMConfig.cmake +will fail to configure unless the static libraries are installed. This +is because LLVMConfig.cmake includes LLVMExports.cmake, which throws an +error if it can't find files linked to one of the exported targets. + +This patch resolves the problem by putting the static library targets +into their own export file, LLVMStaticExports.cmake. This file +is optionally included by LLVMConfig.cmake, so distros can put this +new file in their static library package to make LLVMConfig.cmake +no longer depend on these libraries when they are not installed. + +Reviewers: beanz, mgorny, chapuni + +Subscribers: llvm-commits + +Differential Revision: https://reviews.llvm.org/D32668 +--- + cmake/modules/AddLLVM.cmake | 6 +++++- + cmake/modules/CMakeLists.txt | 3 +++ + cmake/modules/LLVMConfig.cmake.in | 2 ++ + 3 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index 1c92265..e1ad9b9 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -603,7 +603,11 @@ macro(add_llvm_library name) + + if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR + NOT LLVM_DISTRIBUTION_COMPONENTS) +- set(export_to_llvmexports EXPORT LLVMExports) ++ if (ARG_SHARED) ++ set(export_to_llvmexports EXPORT LLVMExports) ++ else() ++ set(export_to_llvmexports EXPORT LLVMStaticExports) ++ endif() + set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True) + endif() + +diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt +index ac4b0b7..f77c905 100644 +--- a/cmake/modules/CMakeLists.txt ++++ b/cmake/modules/CMakeLists.txt +@@ -91,6 +91,7 @@ set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}") + set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin") + set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake") + set(LLVM_CONFIG_EXPORTS "${LLVM_EXPORTS}") ++set(LLVM_CONFIG_STATIC_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMStaticExports.cmake") + configure_file( + LLVMConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake +@@ -107,6 +108,8 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + if(llvm_has_exports) + install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR} + COMPONENT cmake-exports) ++ install(EXPORT LLVMStaticExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR} ++ COMPONENT cmake-exports) + endif() + + install(FILES +diff --git a/cmake/modules/LLVMConfig.cmake.in b/cmake/modules/LLVMConfig.cmake.in +index 7a8eb36..1fa0028 100644 +--- a/cmake/modules/LLVMConfig.cmake.in ++++ b/cmake/modules/LLVMConfig.cmake.in +@@ -77,6 +77,8 @@ if(NOT TARGET LLVMSupport) + set(LLVM_EXPORTED_TARGETS "@LLVM_CONFIG_EXPORTS@") + include("@LLVM_CONFIG_EXPORTS_FILE@") + @llvm_config_include_buildtree_only_exports@ ++ ++ include("@LLVM_CONFIG_STATIC_EXPORTS_FILE@" OPTIONAL) + endif() + + set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On) +-- +1.8.3.1 + diff --git a/0001-Fix-llvm-config-paths-on-Fedora.patch b/0001-Fix-llvm-config-paths-on-Fedora.patch new file mode 100644 index 0000000..e0243d2 --- /dev/null +++ b/0001-Fix-llvm-config-paths-on-Fedora.patch @@ -0,0 +1,74 @@ +From c33b570fe85518e2a4119c65635a75c53007214e Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Thu, 18 May 2017 12:10:20 -0400 +Subject: [PATCH] Fix llvm-config paths on Fedora + +--- + .../0001-Fix-llvm-config-paths-on-Fedora.patch | 32 ++++++++++++++++++++++ + tools/llvm-config/llvm-config.cpp | 10 +++---- + 2 files changed, 36 insertions(+), 6 deletions(-) + create mode 100644 tools/llvm-config/0001-Fix-llvm-config-paths-on-Fedora.patch + +diff --git a/tools/llvm-config/0001-Fix-llvm-config-paths-on-Fedora.patch b/tools/llvm-config/0001-Fix-llvm-config-paths-on-Fedora.patch +new file mode 100644 +index 0000000..07ecaba +--- /dev/null ++++ b/tools/llvm-config/0001-Fix-llvm-config-paths-on-Fedora.patch +@@ -0,0 +1,32 @@ ++From 57e09a7c656fa29dfe474d6921fcc050bf6ee921 Mon Sep 17 00:00:00 2001 ++From: Tom Stellard ++Date: Thu, 18 May 2017 12:10:20 -0400 ++Subject: [PATCH] Fix llvm-config paths on Fedora ++ ++--- ++ tools/llvm-config/llvm-config.cpp | 8 ++++---- ++ 1 file changed, 4 insertions(+), 4 deletions(-) ++ ++diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp ++index 25344e4..ccc9617 100644 ++--- a/tools/llvm-config/llvm-config.cpp +++++ b/tools/llvm-config/llvm-config.cpp ++@@ -331,11 +331,11 @@ int main(int argc, char **argv) { ++ ActiveIncludeOption = ++ ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include"); ++ } else { ++- ActivePrefix = CurrentExecPrefix; ++- ActiveIncludeDir = ActivePrefix + "/include"; ++- ActiveBinDir = ActivePrefix + "/bin"; +++ ActivePrefix = CurrentExecPrefix + "/../../../"; +++ ActiveIncludeDir = ActivePrefix + "/include/llvm-4.0"; +++ ActiveBinDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX + "/llvm-4.0/bin"; ++ ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX; ++- ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; +++ ActiveCMakeDir = ActiveLibDir + "/cmake/llvm-4.0"; ++ ActiveIncludeOption = "-I" + ActiveIncludeDir; ++ } ++ ++-- ++1.8.3.1 ++ +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index 08b096a..7dcd8c9 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -331,13 +331,11 @@ int main(int argc, char **argv) { + ActiveIncludeOption = + ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include"); + } else { +- ActivePrefix = CurrentExecPrefix; +- ActiveIncludeDir = ActivePrefix + "/include"; +- SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR)); +- sys::fs::make_absolute(ActivePrefix, path); +- ActiveBinDir = path.str(); ++ ActivePrefix = CurrentExecPrefix + "/../../"; ++ ActiveIncludeDir = ActivePrefix + "/include/llvm-5.0"; ++ ActiveBinDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX + "/llvm-5.0/bin"; + ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX; +- ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; ++ ActiveCMakeDir = ActiveLibDir + "/cmake/llvm-5.0"; + ActiveIncludeOption = "-I" + ActiveIncludeDir; + } + +-- +1.8.3.1 + diff --git a/0001-Merging-r318289.patch b/0001-Merging-r318289.patch new file mode 100644 index 0000000..d4bff92 --- /dev/null +++ b/0001-Merging-r318289.patch @@ -0,0 +1,157 @@ +From d61468959556ddc180c6c28edff476244fd0e8a6 Mon Sep 17 00:00:00 2001 +From: tstellar +Date: Fri, 17 Nov 2017 18:48:34 +0000 +Subject: [PATCH] Merging r318289: + +------------------------------------------------------------------------ +r318289 | jdevlieghere | 2017-11-15 02:57:05 -0800 (Wed, 15 Nov 2017) | 14 lines + +[DebugInfo] Fix potential CU mismatch for SubprogramScopeDIEs. + +In constructAbstractSubprogramScopeDIE there can be a potential mismatch +between `this` and the CU of ContextDIE when a scope is shared between +two DISubprograms belonging to a different CU. In that case, `this` is +the CU that was specified in the IR, but the CU of ContextDIE is that of +the first subprogram that was emitted. This patch fixes the mismatch by +looking up the CU of ContextDIE, and switching to use that. + +This fixes PR35212 (https://bugs.llvm.org/show_bug.cgi?id=35212) + +Patch by Philip Craig! + +Differential revision: https://reviews.llvm.org/D39981 +------------------------------------------------------------------------ + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@318542 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 20 ++++++++---- + lib/CodeGen/AsmPrinter/DwarfDebug.h | 5 ++- + test/DebugInfo/cross-cu-scope.ll | 50 +++++++++++++++++++++++++++++ + 3 files changed, 67 insertions(+), 8 deletions(-) + create mode 100644 test/DebugInfo/cross-cu-scope.ll + +diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +index 676c48f..333d14a 100644 +--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp ++++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +@@ -621,6 +621,7 @@ void DwarfCompileUnit::constructAbstractSubprogramScopeDIE( + auto *SP = cast(Scope->getScopeNode()); + + DIE *ContextDIE; ++ DwarfCompileUnit *ContextCU = this; + + if (includeMinimalInlineScopes()) + ContextDIE = &getUnitDie(); +@@ -631,18 +632,23 @@ void DwarfCompileUnit::constructAbstractSubprogramScopeDIE( + else if (auto *SPDecl = SP->getDeclaration()) { + ContextDIE = &getUnitDie(); + getOrCreateSubprogramDIE(SPDecl); +- } else ++ } else { + ContextDIE = getOrCreateContextDIE(resolve(SP->getScope())); ++ // The scope may be shared with a subprogram that has already been ++ // constructed in another CU, in which case we need to construct this ++ // subprogram in the same CU. ++ ContextCU = DD->lookupCU(ContextDIE->getUnitDie()); ++ } + + // Passing null as the associated node because the abstract definition + // shouldn't be found by lookup. +- AbsDef = &createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, nullptr); +- applySubprogramAttributesToDefinition(SP, *AbsDef); ++ AbsDef = &ContextCU->createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, nullptr); ++ ContextCU->applySubprogramAttributesToDefinition(SP, *AbsDef); + +- if (!includeMinimalInlineScopes()) +- addUInt(*AbsDef, dwarf::DW_AT_inline, None, dwarf::DW_INL_inlined); +- if (DIE *ObjectPointer = createAndAddScopeChildren(Scope, *AbsDef)) +- addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer); ++ if (!ContextCU->includeMinimalInlineScopes()) ++ ContextCU->addUInt(*AbsDef, dwarf::DW_AT_inline, None, dwarf::DW_INL_inlined); ++ if (DIE *ObjectPointer = ContextCU->createAndAddScopeChildren(Scope, *AbsDef)) ++ ContextCU->addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer); + } + + DIE *DwarfCompileUnit::constructImportedEntityDIE( +diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h +index 5dfe06c..78ee9a1 100644 +--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h ++++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h +@@ -283,7 +283,7 @@ class DwarfDebug : public DebugHandlerBase { + // 0, referencing the comp_dir of all the type units that use it. + MCDwarfDwoLineTable SplitTypeUnitFileTable; + /// @} +- ++ + /// True iff there are multiple CUs in this module. + bool SingleCU; + bool IsDarwin; +@@ -562,6 +562,9 @@ public: + bool isLexicalScopeDIENull(LexicalScope *Scope); + + bool hasDwarfPubSections(bool includeMinimalInlineScopes) const; ++ ++ /// Find the matching DwarfCompileUnit for the given CU DIE. ++ DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); } + }; + } // End of namespace llvm + +diff --git a/test/DebugInfo/cross-cu-scope.ll b/test/DebugInfo/cross-cu-scope.ll +new file mode 100644 +index 0000000..7c71f27 +--- /dev/null ++++ b/test/DebugInfo/cross-cu-scope.ll +@@ -0,0 +1,50 @@ ++; RUN: %llc_dwarf %s -filetype=obj -o %t ++; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s ++ ++; Reduced test case from PR35212. Two DISubprogram belong to a different CU but ++; share a scope. Both are declarations and end up in the scope's CU. We want to ++; check that the CU from the context DIE is used (rather than from the IR). ++; This manifests itself by the DW_base_type ending up in the second CU, rather ++; than in the first one as specified in the IR. ++ ++; CHECK: DW_TAG_compile_unit ++; CHECK-NEXT: discriminator 0 ++; CHECK: DW_TAG_compile_unit ++; CHECK-NEXT: discriminator 1 ++; CHECK: DW_TAG_structure_type ++; CHECK-NOT: NULL ++; CHECK: DW_TAG_subprogram ++; CHECK-NOT: NULL ++; CHECK: DW_TAG_formal_parameter ++; CHECK-NOT: NULL ++; CHECK: DW_AT_type{{.*}}{[[USIZE_LABEL:0x[0-9a-f]+]]} ++; CHECK: NULL ++; CHECK: [[USIZE_LABEL]]: DW_TAG_base_type ++; CHECK-NOT: NULL ++; CHECK: DW_AT_name{{.*}}"usize" ++ ++define hidden void @foo() !dbg !4 { ++ ret void, !dbg !7 ++} ++ ++!llvm.dbg.cu = !{!0, !2} ++!llvm.module.flags = !{!3} ++ ++!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "clang LLVM (rustc version 1.23.0-nightly (discriminator 0))", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) ++!1 = !DIFile(filename: "../lib.rs", directory: "/home/alex/code/rust4/lol") ++!2 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "clang LLVM (rustc version 1.23.0-nightly (discriminator 1))", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) ++!3 = !{i32 2, !"Debug Info Version", i32 3} ++!4 = distinct !DISubprogram(name: "clone", linkageName: "_ZN5alloc3vec8{{impl}}28cloneE", scope: null, file: !1, line: 1519, type: !5, isLocal: false, isDefinition: true, scopeLine: 1519, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !6, variables: !6) ++!5 = !DISubroutineType(types: !6) ++!6 = !{} ++!7 = !DILocation(line: 1612, scope: !8, inlinedAt: !11) ++!8 = distinct !DILexicalBlock(scope: !9, file: !1, line: 86, column: 12) ++!9 = distinct !DISubprogram(name: "allocate_in", linkageName: "_ZN5alloc7raw_vec8{{impl}}52allocate_inE", scope: !10, file: !1, line: 82, type: !5, isLocal: false, isDefinition: true, scopeLine: 82, flags: DIFlagPrototyped, isOptimized: true, unit: !2, templateParams: !6, variables: !6) ++!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "RawVec", file: !1, size: 128, align: 64, elements: !6, identifier: "5c6e4db16d2c64555e40661d70c4d81e") ++!11 = distinct !DILocation(line: 86, scope: !8, inlinedAt: !12) ++!12 = distinct !DILocation(line: 141, scope: !13, inlinedAt: !17) ++!13 = distinct !DISubprogram(name: "with_capacity", linkageName: "_ZN5alloc7raw_vec8{{impl}}36with_capacityE", scope: !10, file: !1, line: 140, type: !5, isLocal: false, isDefinition: true, scopeLine: 140, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !6, variables: !14) ++!14 = !{!15} ++!15 = !DILocalVariable(name: "cap", arg: 1, scope: !13, file: !1, line: 1, type: !16) ++!16 = !DIBasicType(name: "usize", size: 64, encoding: DW_ATE_unsigned) ++!17 = !DILocation(line: 1521, scope: !4) +-- +1.8.3.1 + diff --git a/0001-Revert-Add-a-linker-script-to-version-LLVM-symbols.patch b/0001-Revert-Add-a-linker-script-to-version-LLVM-symbols.patch new file mode 100644 index 0000000..af11182 --- /dev/null +++ b/0001-Revert-Add-a-linker-script-to-version-LLVM-symbols.patch @@ -0,0 +1,61 @@ +From 2912190aec4a215849a6dea0463f6599425fb7c7 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Mon, 14 Aug 2017 17:46:14 -0700 +Subject: [PATCH] Revert "Add a linker script to version LLVM symbols" + +This reverts commit cd789d8cfe12aa374e66eafc748f4fc06e149ca7. + +Conflicts: + tools/llvm-shlib/CMakeLists.txt +--- + cmake/modules/AddLLVM.cmake | 3 +-- + tools/llvm-shlib/CMakeLists.txt | 8 ++------ + tools/llvm-shlib/simple_version_script.map.in | 1 - + 3 files changed, 3 insertions(+), 9 deletions(-) + delete mode 100644 tools/llvm-shlib/simple_version_script.map.in + +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index e1ad9b9..e5ee4ee 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -81,9 +81,8 @@ function(add_llvm_symbol_exports target_name export_file) + # Gold and BFD ld require a version script rather than a plain list. + set(native_export_file "${target_name}.exports") + # FIXME: Don't write the "local:" line on OpenBSD. +- # in the export file, also add a linker script to version LLVM symbols (form: LLVM_N.M) + add_custom_command(OUTPUT ${native_export_file} +- COMMAND echo "LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR} {" > ${native_export_file} ++ COMMAND echo "{" > ${native_export_file} + COMMAND grep -q "[[:alnum:]]" ${export_file} && echo " global:" >> ${native_export_file} || : + COMMAND sed -e "s/$/;/" -e "s/^/ /" < ${export_file} >> ${native_export_file} + COMMAND echo " local: *;" >> ${native_export_file} +diff --git a/tools/llvm-shlib/CMakeLists.txt b/tools/llvm-shlib/CMakeLists.txt +index 907345a..01a37b5 100644 +--- a/tools/llvm-shlib/CMakeLists.txt ++++ b/tools/llvm-shlib/CMakeLists.txt +@@ -37,13 +37,9 @@ endif() + add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES}) + + list(REMOVE_DUPLICATES LIB_NAMES) +-if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")) # FIXME: It should be "GNU ld for elf" +- configure_file( +- ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in +- ${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map) +- ++if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")) # FIXME: It should be "GNU ld for elf" + # GNU ld doesn't resolve symbols in the version script. +- set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive) ++ set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive) + elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") + set(LIB_NAMES -Wl,-all_load ${LIB_NAMES}) + endif() +diff --git a/tools/llvm-shlib/simple_version_script.map.in b/tools/llvm-shlib/simple_version_script.map.in +deleted file mode 100644 +index e9515fe..0000000 +--- a/tools/llvm-shlib/simple_version_script.map.in ++++ /dev/null +@@ -1 +0,0 @@ +-LLVM_@LLVM_VERSION_MAJOR@.@LLVM_VERSION_MINOR@ { global: *; }; +-- +1.8.3.1 + diff --git a/llvm-3.7.1-cmake-s390.patch b/llvm-3.7.1-cmake-s390.patch new file mode 100644 index 0000000..bc9b583 --- /dev/null +++ b/llvm-3.7.1-cmake-s390.patch @@ -0,0 +1,12 @@ +diff -up llvm-3.7.1.src/cmake/config-ix.cmake.s390 llvm-3.7.1.src/cmake/config-ix.cmake +--- llvm-3.7.1.src/cmake/config-ix.cmake.s390 2016-02-16 12:27:36.000000000 +0100 ++++ llvm-3.7.1.src/cmake/config-ix.cmake 2016-02-16 12:27:52.000000000 +0100 +@@ -356,6 +356,8 @@ elseif (LLVM_NATIVE_ARCH MATCHES "msp430 + set(LLVM_NATIVE_ARCH MSP430) + elseif (LLVM_NATIVE_ARCH MATCHES "hexagon") + set(LLVM_NATIVE_ARCH Hexagon) ++elseif (LLVM_NATIVE_ARCH MATCHES "s390") ++ set(LLVM_NATIVE_ARCH SystemZ) + elseif (LLVM_NATIVE_ARCH MATCHES "s390x") + set(LLVM_NATIVE_ARCH SystemZ) + elseif (LLVM_NATIVE_ARCH MATCHES "wasm32") diff --git a/llvm5.0.spec b/llvm5.0.spec new file mode 100644 index 0000000..177231a --- /dev/null +++ b/llvm5.0.spec @@ -0,0 +1,283 @@ +# Components enabled if supported by target architecture: +%ifarch %ix86 x86_64 + %bcond_without gold +%else + %bcond_with gold +%endif + +%global git_hash 7913836381e3f3984b711f921a1cf9da5d37e107 +%global ver_major_minor 5.0 +%global exec_suffix -%{ver_major_minor} +%global install_prefix %{_libdir}/%{name} +%global llvm_bindir %{_libdir}/llvm-%{ver_major_minor}/bin +%global llvm_includedir %{_includedir}/llvm-%{ver_major_minor} +%global llvm_libdir %{_libdir} + +Name: llvm%{ver_major_minor} +Version: %ver_major_minor.0 +Release: 1%{?dist} +Summary: The Low Level Virtual Machine + +License: NCSA +URL: http://llvm.org +Source0: http://llvm.org/releases/%{version}/llvm-%{version}.src.tar.xz + +# recognize s390 as SystemZ when configuring build +Patch0: llvm-3.7.1-cmake-s390.patch +Patch2: 0001-Fix-llvm-config-paths-on-Fedora.patch +Patch3: 0001-Merging-r318289.patch +# FIXME: Symbol versioning breaks some unittests when statically linking +# libstdc++, so we disable it for now. +Patch4: 0001-Revert-Add-a-linker-script-to-version-LLVM-symbols.patch +Patch5: 0001-CMake-Split-static-library-exports-into-their-own-ex.patch + + +BuildRequires: cmake +BuildRequires: zlib-devel +BuildRequires: libffi-devel +BuildRequires: ncurses-devel +BuildRequires: python3-sphinx +BuildRequires: multilib-rpm-config +%if %{with gold} +BuildRequires: binutils-devel +%endif +BuildRequires: libstdc++-static + +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%description +LLVM is a compiler infrastructure designed for compile-time, link-time, +runtime, and idle-time optimization of programs from arbitrary programming +languages. The compiler infrastructure includes mirror sets of programming +tools as well as libraries with equivalent functionality. + +%package devel +Summary: Libraries and header files for LLVM +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires(post): %{_sbindir}/alternatives +Requires(postun): %{_sbindir}/alternatives + +%description devel +This package contains library and header files needed to develop new native +programs that use the LLVM infrastructure. + +%package doc +Summary: Documentation for LLVM +BuildArch: noarch +Requires: %{name} = %{version}-%{release} + +%description doc +Documentation for the LLVM compiler infrastructure. + +%package libs +Summary: LLVM shared libraries +Obsoletes: llvm-libs < %{version}-%{release} + +%description libs +Shared libraries for the LLVM compiler infrastructure. + +%package -n llvm-devel +Summary: Meta package for llvm development files. +Requires: llvm = %{version}-%{release} +Requires: %{name}-devel = %{version}-%{release} +Obsoletes: llvm-devel < %{version}-%{release} + +%description -n llvm-devel +Meta package for llvm development files. + +%package -n llvm-libs +Summary: Meta package for llvm shared libraries. +Requires: %{name}-libs = %{version}-%{release} + +%description -n llvm-libs +Meta package fro llvm shared libraries. + +%package -n llvm-static +Summary: LLVM static libraries. +Obsoletes: llvm-static < %{version}-%{release} + +%description -n llvm-static +Static libraries for the LLVM compiler infrastructure. + +%package -n llvm +Summary: Meta package for llvm +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description -n llvm +Meta package for llvm + +%prep +%autosetup -n llvm-%{version}.src -p1 + +%ifarch armv7hl + +# These tests are marked as XFAIL, but they still run and hang on ARM. +for f in `grep -Rl 'XFAIL.\+arm' test/ExecutionEngine `; do rm $f; done + +%endif + +%build +mkdir -p _build +cd _build + +%ifarch s390 +# Decrease debuginfo verbosity to reduce memory consumption during final library linking +%global optflags %(echo %{optflags} | sed 's/-g /-g1 /') +%endif + +# force off shared libs as cmake macros turns it on. +%cmake .. \ + -DBUILD_SHARED_LIBS:BOOL=OFF \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-Bsymbolic -static-libstdc++" \ +%ifarch s390 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ +%endif +%if 0%{?__isa_bits} == 64 + -DLLVM_LIBDIR_SUFFIX=64 \ +%else + -DLLVM_LIBDIR_SUFFIX= \ +%endif + \ + -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU;PowerPC;NVPTX;SystemZ;AArch64;ARM;Mips;BPF" \ + -DLLVM_ENABLE_LIBCXX:BOOL=OFF \ + -DLLVM_ENABLE_ZLIB:BOOL=ON \ + -DLLVM_ENABLE_FFI:BOOL=ON \ + -DLLVM_ENABLE_RTTI:BOOL=ON \ + -DLLVM_TOOLS_INSTALL_DIR=%{_libdir}/llvm-%{ver_major_minor}/bin \ +%if %{with gold} + -DLLVM_BINUTILS_INCDIR=%{_includedir} \ +%endif + \ + -DLLVM_BUILD_RUNTIME:BOOL=ON \ + \ + -DLLVM_INCLUDE_TOOLS:BOOL=ON \ + -DLLVM_BUILD_TOOLS:BOOL=ON \ + \ + -DLLVM_INCLUDE_TESTS:BOOL=ON \ + -DLLVM_BUILD_TESTS:BOOL=ON \ + \ + -DLLVM_INCLUDE_EXAMPLES:BOOL=ON \ + -DLLVM_BUILD_EXAMPLES:BOOL=OFF \ + \ + -DLLVM_INCLUDE_UTILS:BOOL=ON \ + -DLLVM_INSTALL_UTILS:BOOL=OFF \ + \ + -DLLVM_INCLUDE_DOCS:BOOL=ON \ + -DLLVM_BUILD_DOCS:BOOL=ON \ + -DLLVM_ENABLE_SPHINX:BOOL=ON \ + -DLLVM_ENABLE_DOXYGEN:BOOL=OFF \ + \ + -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \ + -DLLVM_DYLIB_EXPORT_ALL:BOOL=ON \ + -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ + -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \ + -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF \ + \ + -DSPHINX_WARNINGS_AS_ERRORS=OFF \ + -DLLVM_INSTALL_SPHINX_HTML_DIR=%{_pkgdocdir}/html \ + -DSPHINX_EXECUTABLE=%{_bindir}/sphinx-build-3 + +make %{?_smp_mflags} + +%install +cd _build +make install DESTDIR=%{buildroot} + +# Add version suffix to binaries +mkdir -p %{buildroot}/%{_bindir} +for f in `ls %{buildroot}/%{_libdir}/llvm-%{ver_major_minor}/bin/*`; do + filename=`basename $f` + ln -s %{_libdir}/llvm-%{ver_major_minor}/bin/$filename %{buildroot}/%{_bindir}/$filename%{exec_suffix} + ln -s %{_libdir}/llvm-%{ver_major_minor}/bin/$filename %{buildroot}/%{_bindir}/$filename +done + +rm %{buildroot}%{_bindir}/llvm-config +ln -s %{_libdir}/llvm-%{ver_major_minor}/bin/llvm-config %{buildroot}/%{_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} + +# Move header files +mkdir -p %{buildroot}/%{_includedir}/llvm-%{ver_major_minor}/ +mv %{buildroot}/%{_includedir}/llvm %{buildroot}/%{_includedir}/llvm-%{ver_major_minor}/ +mv %{buildroot}/%{_includedir}/llvm-c %{buildroot}/%{_includedir}/llvm-%{ver_major_minor}/ + +# Move cmake files +mv %{buildroot}/%{_libdir}/cmake/{llvm,llvm-%{ver_major_minor}} + +# Add symlink to headers and cmake files +ln -s %{_includedir}/llvm-%{ver_major_minor}/llvm %{buildroot}/%{_includedir}/llvm +ln -s %{_includedir}/llvm-%{ver_major_minor}/llvm-c %{buildroot}/%{_includedir}/llvm-c +ln -s %{_libdir}/cmake/llvm-%{ver_major_minor} %{buildroot}/%{_libdir}/cmake/llvm + +# Remove opt-viewer, since this is just a compatibility package. +rm -Rf %{buildroot}%{_datadir}/opt-viewer + +%check +cd _build +#make check-all || : + +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{buildroot}/%{_libdir} +test "`%{buildroot}/%{llvm_bindir}/llvm-config --bindir`" -ef "%{buildroot}/%{llvm_bindir}" +test "`%{buildroot}/%{llvm_bindir}/llvm-config --libdir`" -ef "%{buildroot}/%{llvm_libdir}" +test "`%{buildroot}/%{llvm_bindir}/llvm-config --includedir`" -ef "%{buildroot}/%{llvm_includedir}" +test "`%{buildroot}/%{llvm_bindir}/llvm-config --cmakedir`" -ef "%{buildroot}/%{_libdir}/cmake/llvm-%{ver_major_minor}" + +%post libs -p /sbin/ldconfig +%postun libs -p /sbin/ldconfig + +%post -n llvm-devel +%{_sbindir}/update-alternatives --install %{_bindir}/llvm-config llvm-config %{_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} %{__isa_bits} + +%postun -n llvm-devel +if [ $1 -eq 0 ]; then + %{_sbindir}/update-alternatives --remove llvm-config %{_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} +fi + +%files +%{_bindir}/*-%{ver_major_minor} +%exclude %{_bindir}/* +%{_libdir}/llvm-%{ver_major_minor}/bin/* +%exclude %{_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} +%exclude %{_mandir}/man1/llvm-config.1.gz + +%files -n llvm +%exclude %{_bindir}/*-%{ver_major_minor} +%exclude %{_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} +%{_bindir}/* +%{_mandir}/man1/*.1.gz + +%files libs +%{_libdir}/libLLVM-%{ver_major_minor}*.so +%{_libdir}/libLTO.so* +%exclude %{_libdir}/libLTO.so + +%files -n llvm-libs +%{_libdir}/BugpointPasses.so +%{_libdir}/LLVMHello.so +%if %{with gold} +%{_libdir}/LLVMgold.so +%endif + +%files devel +%{_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} +%{_includedir}/llvm-%{ver_major_minor}/llvm +%{_includedir}/llvm-%{ver_major_minor}/llvm-c +%{_libdir}/cmake/llvm-%{ver_major_minor} + +%files -n llvm-devel +%{_includedir}/llvm +%{_includedir}/llvm-c +%{_libdir}/cmake/llvm +%{_libdir}/libLLVM.so +%{_libdir}/libLTO.so +%{_mandir}/man1/llvm-config.1.gz + +%files doc +%doc %{_pkgdocdir}/html + +%files -n llvm-static +%{_libdir}/*.a + +%changelog +* Fri Apr 21 2017 Tom Stellard - 5.0.0-1 +- Initial version. diff --git a/sources b/sources new file mode 100644 index 0000000..cbd0a80 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (llvm-5.0.0.src.tar.xz) = e6d8fdcb5bf27bded814d02f39f69c6171bc3a512d5957c03e5ac2e231f903b7de87634b059bd5c5da670f7c3a8f7a538f6299225799f15f921857f1452f6b3a