diff --git a/debian/changelog b/debian/changelog index 789089d5..e8df8616 100644 --- a/debian/changelog +++ b/debian/changelog @@ -231,8 +231,129 @@ llvm-toolchain-snapshot (1:13~++20210129063721+010b176cdefb-1~exp1) experimental -- Sylvestre Ledru Sat, 30 Jan 2021 17:31:15 +0100 -llvm-toolchain-12 (1:12.0.1-10) UNRELEASED; urgency=medium +llvm-toolchain-12 (1:12.0.1-16) unstable; urgency=medium + [ Erik Maciejewski ] + * use make variables populated by /usr/share/dpkg/buildflags.mk and remove + _EXTRA suffix from STAGE_1_ and STAGE_2_ flag vars to improve clarity and + readability for the multi-stage setup in debian/rules + * remove some redundant cmake options (options with the same value as their + default) from, and move PYTHON_EXECUTABLE cmake option to, the cmake + configure command in debian/rules + * re-disable fixfilepath in dpkg-buildflags in favor of using the more llvm + aware implementation provided by the llvm-project by setting + LLVM_USE_RELATIVE_PATHS_IN_FILES=ON in both stages of the toolchain + build in debian/rules + + [ Sylvestre Ledru ] + * autopkgtest/integration-test-suite-test: restrict to arm64/amd64 for now + + -- Sylvestre Ledru Thu, 28 Oct 2021 16:45:49 +0200 + +llvm-toolchain-12 (1:12.0.1-15) unstable; urgency=medium + + * Disable lldb on mipsel and mips64el as it isn't supported + See https://reviews.llvm.org/D102872 + (Closes: #997011) + + [ Erik Maciejewski ] + * disable compiler-rt builtins for unsupported arch s390x in debian/rules + * set arm toolchain arch profiles explicitly to debian baselines in + debian/rules as the target host triples alone are ambiguous and compiler + defaults and debian baselines may not align + * add arch specific config for powerpc to debian/rules and set host target + triple and compiler-rt config to force correct arch profile for builtins + * set LIBCXX_USE_COMPILER_RT to OFF in debian/rules to disable builtins when + libunwind is not enabled since the unwind implementation with gnu builtins + will then be required + + -- Sylvestre Ledru Sat, 23 Oct 2021 10:33:56 +0200 + +llvm-toolchain-12 (1:12.0.1-14) unstable; urgency=medium + + * fix build flag inconsistencies (potentially causing build failures) by + utilizing dpkg-buildflags for defaults where appropriate and making sure all + flags intended for a given stage are also applied to the stage's builtins + and runtimes builds + * re-enable fixfilepath for use with dpkg-buildflags in debian/rules as it has + been supported since clang-10 + * establish a consistent STAGE_[stage]_ prefix naming scheme for stage + variables and replace STAGE1_AND_STAGE2_ prefix with STAGE_ALL_ prefix for + better future-proofing in debian/rules + * modify stage dir var names to use new prefix scheme in debian/rules + * add explicit s390x build options to debian/rules, set + LLVM_HOST_TRIPLE=s390x-linux-gnu and COMPILER_RT_DEFAULT_TARGET_ONLY=ON + so that builtins are only built for the explicit host arch (Closes: #996802) + + -- Erik Maciejewski Fri, 22 Oct 2021 03:12:48 -0700 + +llvm-toolchain-12 (1:12.0.1-13) unstable; urgency=medium + + * update rules to incorporate relevant arch specific configs from snapshot + * patch llvm runtimes cmake build to add a check and only set up and build + compiler-rt builtins if they have not been disabled in a runtimes build + * patch compiler-rt builtins cmake build to fix default arch detection for + armhf by adding the same target triple handling used for compiler-rt libs + * remove legacy var for use when libcxx was a standalone build + + -- Erik Maciejewski Wed, 20 Oct 2021 09:04:42 -0700 + +llvm-toolchain-12 (1:12.0.1-12) unstable; urgency=medium + + * re-disable building builtins on armel as they still fail (Closes: #996828) + * add patch to libcxxabi cmake build for adding builtins to lib flags fixing + an issue where builtins were not being linked into libcxxabi when + LIBCXXABI_USE_COMPILER_RT=ON (Closes: #996796) + + -- Erik Maciejewski Tue, 19 Oct 2021 01:28:50 -0700 + +llvm-toolchain-12 (1:12.0.1-11) unstable; urgency=medium + + * add missing LIBUNWIND_USE_COMPILER_RT to CLANG_BOOTSTRAP_PASSTHROUGH to link + correct compiler-rt lib in stage2 + * consolidate two conditionals for libatomic that were essentially the same, + but the one removed could conflict with BOOTSTRAP_SHARED_LINK_FLAGS + elsewhere in the rules file + * attempt to fix arm builtins by adding COMPILER_RT_DEFAULT_TARGET_ONLY=ON to + armel and armhf toolchain build options to prevent related arches that might + not be supported on the build host from being included in the build (like + armv6m soft-float on the armhf build host) + * reorganize flags and cmake options around stages for the toolchain build + * set baseline arch to armv5t, remove older 3.8 workaround for armel build + * update to debian host triple for the armhf build + + [ Jordan Justen ] + * d/rules: Add amdgcn-mesa-mesa3d to libclc build. + Closes: #993904, #995069 + + [ Sylvestre Ledru ] + * Bring back the llvm manpages (Closes: #995684) + Were generated at the wrong place + + -- Erik Maciejewski Sat, 16 Oct 2021 09:07:25 -0700 + +llvm-toolchain-12 (1:12.0.1-10) unstable; urgency=medium + + * evolve llvm build configuration in rules to leverage the two stage build + with runtimes support whereby the resulting stage2 (final) compiler is used + to build the stage2 (final) runtimes as part of a single monolithic build + * the stage2 runtimes build now includes compiler-rt, libcxx and libcxxabi as + well as libunwind and openmp where supported. Additionally, legacy + corresponding standalone build targets are removed from the rules file + * patch openmp build to include required runtimes as dependencies to build + targets so they are built first when included as part of a runtimes build + since openmp can depend on them + * patch libclc build to set rpath for prepare_builtins build utility to find + correct stage2 libs at runtime when executed as part of a build + * patch libcxx build so that if libatomic is found, only link it if libgcc is + the rtlib + * patch compiler-rt build to suppress xray and testing warns when not enabled + * patch llvm linker detection to account for vendor being prepended to lld + version string + * remove several existing patches incorporating workarounds no longer required + by the modified build configuration + + [ Sylvestre Ledru ] * If parallel is not set in DEB_BUILD_OPTIONS, use nproc * Add source-is-missing llvm/test/* / lldb/test/* / lld/test/* to the source override @@ -241,7 +362,7 @@ llvm-toolchain-12 (1:12.0.1-10) UNRELEASED; urgency=medium [ John Paul Adrian Glaubitz ] * Disable libunwind on sparc, sparc64 and x32 - -- Sylvestre Ledru Sat, 02 Oct 2021 10:50:27 +0200 + -- Erik Maciejewski Wed, 06 Oct 2021 01:25:08 -0700 llvm-toolchain-12 (1:12.0.1-9) unstable; urgency=medium diff --git a/debian/control b/debian/control index 337f2a03..80a6a6d8 100644 --- a/debian/control +++ b/debian/control @@ -6,6 +6,7 @@ Maintainer: LLVM Packaging Team Uploaders: Sylvestre Ledru , Gianfranco Costamagna Build-Depends: debhelper (>= 11.0), cmake, ninja-build, chrpath, texinfo, sharutils, + libelf-dev, libffi-dev, lsb-release, patchutils, diffstat, xz-utils, python3-dev, libedit-dev, libncurses5-dev, swig, python3-six, python3-sphinx (>= 1.3.6), @@ -13,7 +14,7 @@ Build-Depends: debhelper (>= 11.0), cmake, ninja-build, libxml2-dev, libjsoncpp-dev, pkg-config, lcov, procps, help2man, zlib1g-dev, - g++-multilib [amd64 i386 kfreebsd-amd64 mips mips64 mips64el mipsel powerpc ppc64 s390 s390x sparc sparc64 x32], + g++-multilib [amd64 i386 kfreebsd-amd64 mips64 mips64el mipsel powerpc ppc64 s390 s390x sparc sparc64 x32], libjs-mathjax, python3-recommonmark, doxygen, gfortran, ocaml-nox [amd64 arm64 armhf ppc64el riscv64 s390x], @@ -457,7 +458,7 @@ Description: Modular compiler and toolchain technologies, examples # ------------- lld ------------- Package: lld-13 -Architecture: amd64 arm64 armel armhf i386 mips mipsel mips64el ppc64el kfreebsd-amd64 kfreebsd-i386 s390 s390x sparc alpha hppa m68k powerpcspe ppc64 sh4 sparc64 x32 riscv64 +Architecture: amd64 arm64 armel armhf i386 mipsel mips64el ppc64el kfreebsd-amd64 kfreebsd-i386 s390 s390x sparc alpha hppa m68k powerpcspe ppc64 sh4 sparc64 x32 riscv64 # ia64 hurd powerpc have been removed Depends: ${shlibs:Depends}, ${misc:Depends}, libllvm13 (= ${binary:Version}) Pre-Depends: ${misc:Pre-Depends} @@ -467,7 +468,7 @@ Description: LLVM-based linker Project. Package: liblld-13 -Architecture: amd64 arm64 armel armhf i386 mips mipsel mips64el ppc64el kfreebsd-amd64 kfreebsd-i386 s390 s390x sparc alpha hppa m68k powerpcspe ppc64 sh4 sparc64 x32 riscv64 +Architecture: amd64 arm64 armel armhf i386 mipsel mips64el ppc64el kfreebsd-amd64 kfreebsd-i386 s390 s390x sparc alpha hppa m68k powerpcspe ppc64 sh4 sparc64 x32 riscv64 # ia64 hurd powerpc have been removed Depends: ${shlibs:Depends}, ${misc:Depends}, libllvm13 (= ${binary:Version}) Pre-Depends: ${misc:Pre-Depends} @@ -481,7 +482,7 @@ Description: LLVM-based linker, library Package: liblld-13-dev Section: libdevel -Architecture: amd64 arm64 armel armhf i386 mips mipsel mips64el ppc64el kfreebsd-amd64 kfreebsd-i386 s390 s390x sparc alpha hppa m68k powerpcspe ppc64 sh4 sparc64 x32 riscv64 +Architecture: amd64 arm64 armel armhf i386 mipsel mips64el ppc64el kfreebsd-amd64 kfreebsd-i386 s390 s390x sparc alpha hppa m68k powerpcspe ppc64 sh4 sparc64 x32 riscv64 # ia64 hurd powerpc have been removed Depends: ${shlibs:Depends}, ${misc:Depends}, lld-13 (= ${binary:Version}), liblld-13 (= ${binary:Version}) diff --git a/debian/patches/compilerrt-builtins-arch-fix-armhf.diff b/debian/patches/compilerrt-builtins-arch-fix-armhf.diff new file mode 100644 index 00000000..d762b29c --- /dev/null +++ b/debian/patches/compilerrt-builtins-arch-fix-armhf.diff @@ -0,0 +1,18 @@ +fix builtins armhf default arch detection by adding the same armhf triple +handling use for compiler-rt +Index: llvm-toolchain-12_12.0.1/compiler-rt/lib/builtins/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/compiler-rt/lib/builtins/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/compiler-rt/lib/builtins/CMakeLists.txt +@@ -16,6 +16,11 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR + + load_llvm_config() + construct_compiler_rt_default_triple() ++ if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*hf$") ++ if (${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "^arm") ++ set(COMPILER_RT_DEFAULT_TARGET_ARCH "armhf") ++ endif() ++ endif() + + if(APPLE) + include(CompilerRTDarwinUtils) diff --git a/debian/patches/compilerrt-fix-warn-xray-testing.diff b/debian/patches/compilerrt-fix-warn-xray-testing.diff new file mode 100644 index 00000000..38babc96 --- /dev/null +++ b/debian/patches/compilerrt-fix-warn-xray-testing.diff @@ -0,0 +1,33 @@ +suppress warnings for xray and testing when not enabled +Index: llvm-toolchain-12_12.0.1/compiler-rt/cmake/Modules/CompilerRTUtils.cmake +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/compiler-rt/cmake/Modules/CompilerRTUtils.cmake ++++ llvm-toolchain-12_12.0.1/compiler-rt/cmake/Modules/CompilerRTUtils.cmake +@@ -242,15 +242,15 @@ macro(load_llvm_config) + + # Detect if we have the LLVMXRay and TestingSupport library installed and + # available from llvm-config. ++ set(COMPILER_RT_HAS_LLVMXRAY FALSE) + execute_process( + COMMAND ${LLVM_CONFIG_PATH} "--ldflags" "--libs" "xray" + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE CONFIG_OUTPUT + ERROR_QUIET) +- if (HAD_ERROR) ++ if (HAD_ERROR AND COMPILER_RT_BUILD_XRAY) + message(WARNING "llvm-config finding xray failed with status ${HAD_ERROR}") +- set(COMPILER_RT_HAS_LLVMXRAY FALSE) +- else() ++ elseif(COMPILER_RT_BUILD_XRAY) + string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT ${CONFIG_OUTPUT}) + list(GET CONFIG_OUTPUT 0 LDFLAGS) + list(GET CONFIG_OUTPUT 1 LIBLIST) +@@ -267,7 +267,7 @@ macro(load_llvm_config) + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE CONFIG_OUTPUT + ERROR_QUIET) +- if (HAD_ERROR) ++ if (HAD_ERROR AND COMPILER_RT_INCLUDE_TESTS) + message(WARNING "llvm-config finding testingsupport failed with status ${HAD_ERROR}") + elseif(COMPILER_RT_INCLUDE_TESTS) + string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT ${CONFIG_OUTPUT}) diff --git a/debian/patches/fix-llvm-config-obj-src-root.patch b/debian/patches/fix-llvm-config-obj-src-root.patch deleted file mode 100644 index 2981e9b7..00000000 --- a/debian/patches/fix-llvm-config-obj-src-root.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- - tools/llvm-config/llvm-config.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -Index: llvm-toolchain-snapshot_11~++20200326111000+4673699a470/llvm/tools/llvm-config/llvm-config.cpp -=================================================================== ---- llvm-toolchain-snapshot_11~++20200326111000+4673699a470.orig/llvm/tools/llvm-config/llvm-config.cpp -+++ llvm-toolchain-snapshot_11~++20200326111000+4673699a470/llvm/tools/llvm-config/llvm-config.cpp -@@ -561,9 +561,9 @@ int main(int argc, char **argv) { - } else if (Arg == "--shared-mode") { - PrintSharedMode = true; - } else if (Arg == "--obj-root") { -- OS << ActivePrefix << '\n'; -+ OS << ActivePrefix << "/build/" << '\n'; - } else if (Arg == "--src-root") { -- OS << LLVM_SRC_ROOT << '\n'; -+ OS << ActivePrefix << "/build/" << '\n'; - } else if (Arg == "--ignore-libllvm") { - LinkDyLib = false; - LinkMode = BuiltSharedLibs ? LinkModeShared : LinkModeAuto; diff --git a/debian/patches/libclc-fix-prepare_builtins-rpath.diff b/debian/patches/libclc-fix-prepare_builtins-rpath.diff new file mode 100644 index 00000000..c1f87571 --- /dev/null +++ b/debian/patches/libclc-fix-prepare_builtins-rpath.diff @@ -0,0 +1,16 @@ +set rpath for prepare_builtins build utility to find correct stage2 +libs at runtime when executed as part of a build +Index: llvm-toolchain-12_12.0.1/libclc/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/libclc/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/libclc/CMakeLists.txt +@@ -139,6 +139,9 @@ target_compile_options( prepare_builtins + target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} ) + target_link_libraries( prepare_builtins PRIVATE ${LLVM_LIBS} ) + target_link_libraries( prepare_builtins PRIVATE ${LLVM_SYSTEM_LIBS} ) ++set_target_properties( prepare_builtins ++ PROPERTIES INSTALL_RPATH "${LLVM_LIBDIR}" ++ BUILD_WITH_INSTALL_RPATH "ON") + + # Setup arch devices + set( r600--_devices cedar cypress barts cayman ) diff --git a/debian/patches/libcxx-libatomic-only-with-gcc-rtlib.diff b/debian/patches/libcxx-libatomic-only-with-gcc-rtlib.diff new file mode 100644 index 00000000..41662966 --- /dev/null +++ b/debian/patches/libcxx-libatomic-only-with-gcc-rtlib.diff @@ -0,0 +1,24 @@ +if libatomic is found only link it if libgcc is the rtlib +Index: llvm-toolchain-12_12.0.1/libcxx/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/libcxx/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/libcxx/CMakeLists.txt +@@ -756,12 +756,14 @@ function(cxx_link_system_libraries targe + endif() + elseif (LIBCXX_HAS_GCC_LIB) + target_link_libraries(${target} PRIVATE gcc) ++ if (LIBCXX_HAS_ATOMIC_LIB) ++ target_link_libraries(${target} PRIVATE atomic) ++ endif() + elseif (LIBCXX_HAS_GCC_S_LIB) + target_link_libraries(${target} PRIVATE gcc_s) +- endif() +- +- if (LIBCXX_HAS_ATOMIC_LIB) +- target_link_libraries(${target} PRIVATE atomic) ++ if (LIBCXX_HAS_ATOMIC_LIB) ++ target_link_libraries(${target} PRIVATE atomic) ++ endif() + endif() + + if (MINGW) diff --git a/debian/patches/libcxxabi-fix-link-builtins.diff b/debian/patches/libcxxabi-fix-link-builtins.diff new file mode 100644 index 00000000..7a71c4f1 --- /dev/null +++ b/debian/patches/libcxxabi-fix-link-builtins.diff @@ -0,0 +1,16 @@ +if LIBCXXABI_USE_COMPILER_RT=ON, add builtins to libcxxabi library +flags, otherwise add libgcc following how libunwind does the same +Index: llvm-toolchain-12_12.0.1/libcxxabi/src/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/libcxxabi/src/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/libcxxabi/src/CMakeLists.txt +@@ -104,7 +104,9 @@ if (ANDROID AND ANDROID_PLATFORM_LEVEL L + list(APPEND LIBCXXABI_LIBRARIES android_support) + endif() + +-if (NOT LIBCXXABI_USE_COMPILER_RT) ++if (LIBCXXABI_USE_COMPILER_RT) ++ add_library_flags("${LIBCXXABI_BUILTINS_LIBRARY}") ++else() + add_library_flags_if(LIBCXXABI_HAS_GCC_LIB gcc) + endif () diff --git a/debian/patches/lld-use-link-atomic-i386.diff b/debian/patches/lld-use-link-atomic-i386.diff deleted file mode 100644 index d27fbc00..00000000 --- a/debian/patches/lld-use-link-atomic-i386.diff +++ /dev/null @@ -1,32 +0,0 @@ -Index: llvm-toolchain-snapshot_13~++20210603111529+5c0d1b2f902a/lld/tools/lld/CMakeLists.txt -=================================================================== ---- llvm-toolchain-snapshot_13~++20210603111529+5c0d1b2f902a.orig/lld/tools/lld/CMakeLists.txt -+++ llvm-toolchain-snapshot_13~++20210603111529+5c0d1b2f902a/lld/tools/lld/CMakeLists.txt -@@ -1,10 +1,18 @@ -+set(LLD_ATOMIC_LIB "") -+ - set(LLVM_LINK_COMPONENTS - Support - ) - -+if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i386" OR -+ CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i686" OR -+ CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64" -+ ) -+ list(APPEND LLD_ATOMIC_LIB "atomic") -+endif() -+ - add_lld_tool(lld - lld.cpp -- - SUPPORT_PLUGINS - ) - export_executable_symbols_for_plugins(lld) -@@ -18,6 +26,7 @@ target_link_libraries(lld - lldMachO2 - lldMinGW - lldWasm -+ ${LLD_ATOMIC_LIB} - ) - - install(TARGETS lld diff --git a/debian/patches/llvm-fix-lld-linker-check.diff b/debian/patches/llvm-fix-lld-linker-check.diff new file mode 100644 index 00000000..bad28992 --- /dev/null +++ b/debian/patches/llvm-fix-lld-linker-check.diff @@ -0,0 +1,15 @@ +remove regex anchor in lld linker detection to account for vendor, if +specified, being prepended to lld version string +Index: llvm-toolchain-12_12.0.1/llvm/cmake/modules/AddLLVM.cmake +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/llvm/cmake/modules/AddLLVM.cmake ++++ llvm-toolchain-12_12.0.1/llvm/cmake/modules/AddLLVM.cmake +@@ -196,7 +196,7 @@ if (NOT DEFINED LLVM_LINKER_DETECTED) + set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "") + set(LLVM_LINKER_IS_GOLD YES CACHE INTERNAL "") + message(STATUS "Linker detection: GNU Gold") +- elseif("${stdout}" MATCHES "^LLD") ++ elseif("${stdout}" MATCHES "LLD") + set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "") + set(LLVM_LINKER_IS_LLD YES CACHE INTERNAL "") + message(STATUS "Linker detection: LLD") diff --git a/debian/patches/llvm-runtimes-builtins-build-check.diff b/debian/patches/llvm-runtimes-builtins-build-check.diff new file mode 100644 index 00000000..b4f7eab9 --- /dev/null +++ b/debian/patches/llvm-runtimes-builtins-build-check.diff @@ -0,0 +1,20 @@ +add a check and only set up and build compiler-rt builtins if they have +not been disabled +Index: llvm-toolchain-12_12.0.1/llvm/runtimes/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/llvm/runtimes/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/llvm/runtimes/CMakeLists.txt +@@ -131,7 +131,12 @@ endfunction() + # is required because the other runtimes need the builtin libraries present + # before the just-built compiler can pass the configuration tests. + get_compiler_rt_path(compiler_rt_path) +-if(compiler_rt_path) ++# check if builtins have been disabled ++set(RUNTIMES_BUILD_BUILTINS ON) ++if(DEFINED COMPILER_RT_BUILD_BUILTINS) ++ set(RUNTIMES_BUILD_BUILTINS ${COMPILER_RT_BUILD_BUILTINS}) ++endif() ++if(compiler_rt_path AND RUNTIMES_BUILD_BUILTINS) + if(NOT LLVM_BUILTIN_TARGETS) + builtin_default_target(${compiler_rt_path} + DEPENDS clang-resource-headers) diff --git a/debian/patches/openmp-fix-runtimes-build.diff b/debian/patches/openmp-fix-runtimes-build.diff new file mode 100644 index 00000000..b8d20cd0 --- /dev/null +++ b/debian/patches/openmp-fix-runtimes-build.diff @@ -0,0 +1,162 @@ +include required runtimes as dependencies to openmp targets to make sure +they are built first when included as part of a runtimes build since openmp +can depend on them +Index: llvm-toolchain-12_12.0.1/llvm/runtimes/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/llvm/runtimes/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/llvm/runtimes/CMakeLists.txt +@@ -236,6 +236,7 @@ function(runtime_default_target) + -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE} + -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED} + -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default} ++ -DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR} + -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE} + -DCMAKE_CXX_COMPILER_TARGET=${TARGET_TRIPLE} + -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE} +@@ -440,7 +441,7 @@ if(runtimes) + # build directory cannot find the C++ headers in certain configurations. + # I need to build a mechanism for runtime projects to provide CMake code + # that executes at LLVM configuration time to handle this case. +- add_dependencies(clang-bootstrap-deps runtimes-configure) ++ #add_dependencies(clang-bootstrap-deps runtimes-configure) + # We need to add the runtimes as a dependency because compiler-rt can be + # built as part of runtimes and we need the profile runtime for PGO + add_dependencies(clang-bootstrap-deps runtimes) +Index: llvm-toolchain-12_12.0.1/openmp/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/openmp/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/openmp/CMakeLists.txt +@@ -83,6 +83,28 @@ option(OPENMP_ENABLE_LIBOMPTARGET_PROFIL + ${ENABLE_LIBOMPTARGET}) + option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF) + ++option(OPENMP_USE_LLVM_UNWINDER "Build and use the LLVM unwinder" OFF) ++ ++option(LIBOMP_ENABLE_RTTI "Enabling RTTI forces libomp to be a c++ lib" ${LLVM_ENABLE_RTTI}) ++ ++macro(add_runtimes_build_depends_if_needed target) ++ if(RUNTIMES_BUILD) ++ # required for rtti and libomp/libomptarget profiling if enabled ++ add_dependencies(${target} cxx-headers cxxabi_static cxx_static cxxabi_shared cxx_shared) ++ if(OPENMP_USE_LLVM_UNWINDER AND (NOT target STREQUAL "omp" AND NOT LIBOMP_ENABLE_RTTI)) ++ add_dependencies(${target} unwind_static unwind_shared) ++ get_target_property(target_link_flags ${target} LINK_FLAGS) ++ set(runtimes_link_flags "-lunwind") ++ if(target_link_flags) ++ set(runtimes_link_flags "${target_link_flags} -lunwind") ++ endif() ++ set_target_properties(${target} ++ PROPERTIES ++ LINK_FLAGS "${runtimes_link_flags}") ++ endif() ++ endif() ++endmacro() ++ + # Build host runtime library, after LIBOMPTARGET variables are set since they are needed + # to enable time profiling support in the OpenMP runtime. + add_subdirectory(runtime) +Index: llvm-toolchain-12_12.0.1/openmp/cmake/HandleOpenMPOptions.cmake +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/openmp/cmake/HandleOpenMPOptions.cmake ++++ llvm-toolchain-12_12.0.1/openmp/cmake/HandleOpenMPOptions.cmake +@@ -29,7 +29,8 @@ append_if(OPENMP_HAVE_WNO_EXTRA_FLAG "-W + append_if(OPENMP_HAVE_WNO_PEDANTIC_FLAG "-Wno-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append_if(OPENMP_HAVE_WNO_MAYBE_UNINITIALIZED_FLAG "-Wno-maybe-uninitialized" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + +-append_if(OPENMP_HAVE_STD_GNUPP14_FLAG "-std=gnu++14" CMAKE_CXX_FLAGS) +-if (NOT OPENMP_HAVE_STD_GNUPP14_FLAG) +- append_if(OPENMP_HAVE_STD_CPP14_FLAG "-std=c++14" CMAKE_CXX_FLAGS) ++# prefer c++14 over gnu++14? ++append_if(OPENMP_HAVE_STD_CPP14_FLAG "-std=c++14" CMAKE_CXX_FLAGS) ++if (NOT OPENMP_HAVE_STD_CPP14_FLAG) ++ append_if(OPENMP_HAVE_STD_GNUPP14_FLAG "-std=gnu++14" CMAKE_CXX_FLAGS) + endif() +Index: llvm-toolchain-12_12.0.1/openmp/libomptarget/plugins/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/openmp/libomptarget/plugins/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/openmp/libomptarget/plugins/CMakeLists.txt +@@ -36,6 +36,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tma + add_library("omptarget.rtl.${tmachine_libname}" SHARED + ${CMAKE_CURRENT_SOURCE_DIR}/../generic-elf-64bit/src/rtl.cpp) + ++ add_runtimes_build_depends_if_needed("omptarget.rtl.${tmachine_libname}") ++ + # Install plugin under the lib destination folder. + install(TARGETS "omptarget.rtl.${tmachine_libname}" + LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") +Index: llvm-toolchain-12_12.0.1/openmp/libomptarget/plugins/cuda/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/openmp/libomptarget/plugins/cuda/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/openmp/libomptarget/plugins/cuda/CMakeLists.txt +@@ -44,6 +44,8 @@ else() + set (LIBOMPTARGET_DEP_LIBRARIES ${CMAKE_DL_LIBS}) + endif() + ++add_runtimes_build_depends_if_needed(omptarget.rtl.cuda) ++ + # Install plugin under the lib destination folder. + install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") + +Index: llvm-toolchain-12_12.0.1/openmp/libomptarget/src/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/openmp/libomptarget/src/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/openmp/libomptarget/src/CMakeLists.txt +@@ -48,6 +48,8 @@ set_target_properties(omptarget + PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR}) + ++add_runtimes_build_depends_if_needed(omptarget) ++ + # Install libomptarget under the lib destination folder. + install(TARGETS omptarget LIBRARY COMPONENT omptarget + DESTINATION "${OPENMP_INSTALL_LIBDIR}") +Index: llvm-toolchain-12_12.0.1/openmp/runtime/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/openmp/runtime/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/openmp/runtime/CMakeLists.txt +@@ -287,6 +287,10 @@ if(LIBOMP_STATS) + set(LIBOMP_USE_STDCPPLIB TRUE) + endif() + ++if(LIBOMP_ENABLE_RTTI) ++ set(LIBOMP_USE_STDCPPLIB TRUE) ++endif() ++ + # Shared library can be switched to a static library + set(LIBOMP_ENABLE_SHARED TRUE CACHE BOOL + "Shared library instead of static library?") +Index: llvm-toolchain-12_12.0.1/openmp/runtime/src/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/openmp/runtime/src/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/openmp/runtime/src/CMakeLists.txt +@@ -134,6 +134,7 @@ endif() + if(NOT ${LIBOMP_USE_STDCPPLIB}) + set(LIBOMP_LINKER_LANGUAGE C) + set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES) ++ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") + else() + set(LIBOMP_LINKER_LANGUAGE CXX) + endif() +@@ -162,6 +163,8 @@ set_target_properties(omp PROPERTIES + LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE} + ) + ++add_runtimes_build_depends_if_needed(omp) ++ + # Get the library's location within the build tree for the unit tester + if(NOT WIN32) + get_target_property(LIBOMP_LIBRARY_DIR omp LIBRARY_OUTPUT_DIRECTORY) +Index: llvm-toolchain-12_12.0.1/openmp/tools/archer/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/openmp/tools/archer/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/openmp/tools/archer/CMakeLists.txt +@@ -14,6 +14,9 @@ if(LIBOMP_OMPT_SUPPORT) + add_library(archer SHARED ompt-tsan.cpp) + add_library(archer_static STATIC ompt-tsan.cpp) + ++ add_runtimes_build_depends_if_needed(archer) ++ add_runtimes_build_depends_if_needed(archer_static) ++ + install(TARGETS archer archer_static + LIBRARY DESTINATION ${OPENMP_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${OPENMP_INSTALL_LIBDIR}) diff --git a/debian/patches/series b/debian/patches/series index f035e4d0..4a619575 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -27,7 +27,6 @@ do-not-fail-on-unexpected-pass.diff disable-display-PASS-UNSUPPORTED-XFAIL.diff # llvm-config -fix-llvm-config-obj-src-root.patch 0001-llvm-cmake-resolve-symlinks-in-LLVMConfig.cmake.patch # Lib names @@ -125,9 +124,6 @@ risc/clang-riscv64-multiarch.diff D98574.patch D98575.patch -# Compiler-rt - workaround -workaround-bug-42994-use-linker.diff - # bug 939472 #try-to-unbreak-thinlto.diff #D67877-cmake-clang-example.patch @@ -137,7 +133,6 @@ x86-fuzzer.patch python3-shebang.patch print-lldb-path.patch libcxx-armhf-ftbfs.diff -lld-use-link-atomic-i386.diff lower-python-dep.diff scan-build-py-fix-analyze-path.diff scan-build-py-fix-default-bin.diff @@ -146,3 +141,11 @@ libclc-llvm-spirv.diff omp-riscv64.patch test-disable-lldb-i386.diff unbreak-atomic-mips.diff +llvm-fix-lld-linker-check.diff +compilerrt-fix-warn-xray-testing.diff +openmp-fix-runtimes-build.diff +libclc-fix-prepare_builtins-rpath.diff +libcxx-libatomic-only-with-gcc-rtlib.diff +libcxxabi-fix-link-builtins.diff +llvm-runtimes-builtins-build-check.diff +compilerrt-builtins-arch-fix-armhf.diff diff --git a/debian/patches/symbolizer-path.diff b/debian/patches/symbolizer-path.diff index 3eaaaf84..69caab13 100644 --- a/debian/patches/symbolizer-path.diff +++ b/debian/patches/symbolizer-path.diff @@ -1,7 +1,7 @@ -Index: llvm-toolchain-snapshot_11~++20200326111000+4673699a470/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp +Index: llvm-toolchain-12_12.0.1/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp =================================================================== ---- llvm-toolchain-snapshot_11~++20200326111000+4673699a470.orig/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp -+++ llvm-toolchain-snapshot_11~++20200326111000+4673699a470/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp +--- llvm-toolchain-12_12.0.1.orig/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp ++++ llvm-toolchain-12_12.0.1/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp @@ -25,6 +25,10 @@ #include "sanitizer_symbolizer_internal.h" #include "sanitizer_symbolizer_libbacktrace.h" @@ -13,7 +13,7 @@ Index: llvm-toolchain-snapshot_11~++20200326111000+4673699a470/compiler-rt/lib/s #include // for dlsym() #include -@@ -428,7 +432,7 @@ static SymbolizerTool *ChooseExternalSym +@@ -433,7 +437,7 @@ static SymbolizerTool *ChooseExternalSym return new(*allocator) AtosSymbolizer(found_path, allocator); } #endif // SANITIZER_MAC @@ -22,3 +22,15 @@ Index: llvm-toolchain-snapshot_11~++20200326111000+4673699a470/compiler-rt/lib/s VReport(2, "Using llvm-symbolizer found at: %s\n", found_path); return new(*allocator) LLVMSymbolizer(found_path, allocator); } +Index: llvm-toolchain-12_12.0.1/compiler-rt/lib/sanitizer_common/CMakeLists.txt +=================================================================== +--- llvm-toolchain-12_12.0.1.orig/compiler-rt/lib/sanitizer_common/CMakeLists.txt ++++ llvm-toolchain-12_12.0.1/compiler-rt/lib/sanitizer_common/CMakeLists.txt +@@ -195,6 +195,7 @@ set(SANITIZER_IMPL_HEADERS + ) + + include_directories(..) ++include_directories(${LLVM_INCLUDE_DIR}) + + set(SANITIZER_COMMON_DEFINITIONS + HAVE_RPC_XDR_H=${HAVE_RPC_XDR_H}) diff --git a/debian/patches/workaround-bug-42994-use-linker.diff b/debian/patches/workaround-bug-42994-use-linker.diff deleted file mode 100644 index f2cfa116..00000000 --- a/debian/patches/workaround-bug-42994-use-linker.diff +++ /dev/null @@ -1,34 +0,0 @@ -Index: llvm-toolchain-snapshot_13~++20210517085206+0f417789192e/compiler-rt/lib/hwasan/CMakeLists.txt -=================================================================== ---- llvm-toolchain-snapshot_13~++20210517085206+0f417789192e.orig/compiler-rt/lib/hwasan/CMakeLists.txt -+++ llvm-toolchain-snapshot_13~++20210517085206+0f417789192e/compiler-rt/lib/hwasan/CMakeLists.txt -@@ -45,9 +45,9 @@ append_list_if(COMPILER_RT_HWASAN_WITH_I - - set(HWASAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS}) - append_rtti_flag(OFF HWASAN_RTL_CFLAGS) --append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC HWASAN_RTL_CFLAGS) -+append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC -fuse-ld=gold HWASAN_RTL_CFLAGS) - # Prevent clang from generating libc calls. --append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding HWASAN_RTL_CFLAGS) -+append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding -fuse-ld=gold HWASAN_RTL_CFLAGS) - - set(HWASAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) - -@@ -59,7 +59,7 @@ if(ANDROID) - endif() - endif() - --set(HWASAN_DYNAMIC_CFLAGS ${HWASAN_RTL_CFLAGS}) -+set(HWASAN_DYNAMIC_CFLAGS ${HWASAN_RTL_CFLAGS} -fuse-ld=gold) - append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC - -ftls-model=initial-exec HWASAN_DYNAMIC_CFLAGS) - append_list_if(MSVC /DEBUG HWASAN_DYNAMIC_LINK_FLAGS) -@@ -153,7 +153,7 @@ function(add_hwasan_runtimes arch use_al - LIBS ${hwasan_runtime}-${arch} ${hwasan_runtime}_cxx-${arch} - EXTRA hwasan.syms.extra) - set(VERSION_SCRIPT_FLAG -- -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${hwasan_runtime}-dynamic-${arch}.vers) -+ -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${hwasan_runtime}-dynamic-${arch}.vers -fuse-ld=gold) - set_property(SOURCE - ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp - APPEND PROPERTY diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index b1b7fcb7..45671d98 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -45,7 +45,7 @@ if grep "File format not recognized" foo.log; then fi # Test #995684 -if test /usr/share/man/man1/llc-$VERSION.1.gz; then +if test ! -f /usr/share/man/man1/llc-$VERSION.1.gz; then echo "llvm manpage are missing (using llc as an example)" exit 1 fi @@ -1067,6 +1067,12 @@ if test ! -f /usr/lib/clc/amdgcn--amdhsa.bc; then exit -1; fi +if test ! -f /usr/lib/clc/polaris10-amdgcn-mesa-mesa3d.bc; then + # Make sure that #993904 and #995069 don't come back + echo "/usr/lib/clc/polaris10-amdgcn-mesa-mesa3d.bc doesn't exist" + exit 1 +fi + LLVM_CONFIG=llvm-config-$VERSION /usr/lib/llvm-$VERSION/share/libclc/check_external_calls.sh /usr/lib/clc/amdgcn--amdhsa.bc > /dev/null # libunwind @@ -1328,6 +1334,7 @@ if dpkg -l|grep -q clang-$VERSION-dbgsym; then if ! grep "main at driver.cpp" foo.log; then echo "Could not find the debug info" echo "Or the main() of clang isn't in driver.cpp anymore" + cat foo.log exit -1 fi else @@ -1457,8 +1464,9 @@ echo "Testing all other sanitizers ..." echo "int main() { return 1; }" > foo.c # fails to run on i386 with the following error: #clang: error: unsupported option '-fsanitize=efficiency-working-set' for target 'i686-pc-linux-gnu' -clang-$VERSION -fsanitize=efficiency-working-set -o foo foo.c || true -./foo &> /dev/null || true +# seems like esan was removed from clang: https://github.com/llvm/llvm-project/commit/885b790f89b6068ec4caad8eaa51aa8098327059 +#clang-$VERSION -fsanitize=efficiency-working-set -o foo foo.c || true +#./foo &> /dev/null || true cat > "$TEMPDIR/test.c" < diff --git a/debian/rules b/debian/rules index ea9f7bde..22f5dda2 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,9 @@ #!/usr/bin/make -f -# polly, openmp & lldb aren't enabled for every platform -PROJECTS = clang;clang-tools-extra;libcxx;libcxxabi;compiler-rt;lld;debuginfo-tests +# polly & lldb aren't enabled for every platform +PROJECTS = clang;clang-tools-extra;lld;debuginfo-tests +# openmp & libunwind aren't enabled for every platform +RUNTIMES = compiler-rt;libcxx;libcxxabi TARGET_BUILD := build-llvm TARGET_BUILD_STAGE2 := $(TARGET_BUILD)/tools/clang/stage2-bins @@ -39,42 +41,68 @@ DH_VERSION := $(shell dpkg -s debhelper | grep '^Version' | awk '{print $$2}') include /usr/share/dpkg/architecture.mk -LDFLAGS_EXTRA = -CXXFLAGS_EXTRA = -CFLAGS_EXTRA = CONFIGURE_EXTRA = -CMAKE_EXTRA = -DPYTHON_EXECUTABLE=/usr/bin/python3 -CMAKE_LIBCXX_EXTRA = -BASE_PATH := $(CURDIR) -LIBCXX_EXCEPTIONS :=ON +# dpkg-buildflags support +# disable fixfilepath in favor of the llvm-project supplied flavor, disable lto +export DEB_BUILD_MAINT_OPTIONS = reproducible=-fixfilepath,-fixdebugpath optimize=-lto +# these are handled on a per stage / build basis +export DEB_CFLAGS_MAINT_STRIP = -g -O2 +export DEB_CXXFLAGS_MAINT_STRIP = -g -O2 -ifneq (,$(filter $(DEB_HOST_ARCH),s390x)) - LIBCXX_EXCEPTIONS :=OFF -endif +include /usr/share/dpkg/buildflags.mk -ifneq (,$(filter $(DEB_HOST_ARCH),i386 armel mips mipsel powerpc powerpcspe riscv64)) -CMAKE_EXTRA += -DLIBOMP_LIBFLAGS="-latomic" -DCMAKE_SHARED_LINKER_FLAGS="-latomic" -endif +# We use a stage2 build. It means that a first clang is built using gcc, +# a second clang is built with the first +# And the various compoments are built using the second clang. +# See https://llvm.org/docs/AdvancedBuilds.html + +# collect additional flags for all stages all builds +CFLAGS_EXTRA = -Wno-unused-command-line-argument +CXXFLAGS_EXTRA = -Wno-unused-command-line-argument +LDFLAGS_EXTRA = -Wl,--build-id + +# collect all flags for stage 1 toolchain build only +STAGE_1_CFLAGS = $(CFLAGS) $(CFLAGS_EXTRA) $(CPPFLAGS) +STAGE_1_CXXFLAGS = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(CPPFLAGS) +STAGE_1_LDFLAGS = $(LDFLAGS) $(LDFLAGS_EXTRA) + +# collect all flags for stage 2 toolchain and stand-alone builds +STAGE_2_CFLAGS = $(CFLAGS) $(CFLAGS_EXTRA) $(CPPFLAGS) +STAGE_2_CXXFLAGS = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(CPPFLAGS) +STAGE_2_LDFLAGS = $(LDFLAGS) $(LDFLAGS_EXTRA) + +# collect additional cmake options for toolchain build configuration +STAGE_1_CMAKE_EXTRA = +STAGE_2_CMAKE_EXTRA = +STAGE_ALL_CMAKE_EXTRA = +# toolchain config-only var combining all stage 1 cmake options +CMAKE_EXTRA = $(STAGE_1_CMAKE_EXTRA) $(STAGE_ALL_CMAKE_EXTRA) +# toolchain config-only var prepending BOOTSTRAP_ to all stage 2 cmake options +BOOTSTRAP_CMAKE_EXTRA = $(foreach extra,$(STAGE_2_CMAKE_EXTRA) $(STAGE_ALL_CMAKE_EXTRA), $(subst -D,-DBOOTSTRAP_,$(extra))) + +BASE_PATH := $(CURDIR) +STAGE_1_BIN_DIR := $(BASE_PATH)/$(TARGET_BUILD)/bin +STAGE_1_LIB_DIR := $(BASE_PATH)/$(TARGET_BUILD)/lib +STAGE_2_BIN_DIR := $(BASE_PATH)/$(TARGET_BUILD_STAGE2)/bin +STAGE_2_LIB_DIR := $(BASE_PATH)/$(TARGET_BUILD_STAGE2)/lib + +# toggleable defaults +COMPILER_RT_USE_BUILTINS_LIBRARY := ON +LIBCXX_EXCEPTIONS := ON +LIBCXX_USE_COMPILER_RT := ON ifneq (,$(filter $(DEB_HOST_ARCH),sparc sparc64)) -CMAKE_EXTRA += -DLLVM_PARALLEL_LINK_JOBS=4 +STAGE_1_CMAKE_EXTRA += -DLLVM_PARALLEL_LINK_JOBS=4 endif -ifneq (,$(filter $(DEB_HOST_ARCH),armel mipsel powerpc riscv64)) +ifneq (,$(filter $(DEB_HOST_ARCH),i386 armel mipsel powerpc powerpcspe riscv64)) # For some reason, in the stage2 build, when clang is used to compile -# itself. The atomic detection is failing on armel and riscv64. Forcing the inclusion everywhere. +# itself. The atomic detection is failing on armel and riscv64. Forcing the inclusion +# everywhere and in all stages LDFLAGS_EXTRA += -latomic endif -# Ensure fixfilepath feature is disabled. The fixfilepath feature -# sets a -ffile-prefix-map flag, which is only supported in clang-10. -# Disable also lto -export DEB_BUILD_MAINT_OPTIONS=reproducible=-fixfilepath optimize=-lto - -# Cxx flags for building libcxx and libcxxabi -LIBCXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(shell dpkg-buildflags --get CPPFLAGS) - ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' g++-$(GCC_VERSION)) lt 4.9-20140411-1~ ; echo $$?),0) # Too old version of gcc. Force 4.9 GCC_VERSION := 4.9 @@ -87,13 +115,14 @@ ifneq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes) Z3_FLAG = -DLLVM_ENABLE_Z3_SOLVER=ON endif endif +STAGE_2_CMAKE_EXTRA += $(Z3_FLAG) # Change the default CPU for s390x ZARCH=z196 ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes) ZARCH=z13 endif -CMAKE_EXTRA += -DCLANG_SYSTEMZ_DEFAULT_ARCH=$(ZARCH) +STAGE_2_CMAKE_EXTRA += -DCLANG_SYSTEMZ_DEFAULT_ARCH=$(ZARCH) export CC=gcc-$(GCC_VERSION) export CXX=g++-$(GCC_VERSION) @@ -101,32 +130,57 @@ export CXX=g++-$(GCC_VERSION) opt_flags = -O2 -DNDEBUG -g1 ifneq (,$(findstring $(DEB_HOST_ARCH),armel)) - opt_flags += -marm - # 3.8 fails to build, disable the compiler_rt builtins - # See http://lists.llvm.org/pipermail/llvm-dev/2016-May/099761.html - CMAKE_EXTRA += -DCOMPILER_RT_BUILD_BUILTINS=OFF - # Check for ancient libstdc++ fails due to atomics usage - CMAKE_LIBCXX_EXTRA += -DLLVM_COMPILER_CHECKED=ON - # Prevent clang from getting a > v4t default - # See bug #868779 - CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=arm-linux-gnueabi + STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=arm-linux-gnueabi + STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON +# align arch profile with debian baseline +# https://wiki.debian.org/ArmEabiPort + CFLAGS_EXTRA += -march=armv5t + CXXFLAGS_EXTRA += -march=armv5t +# disable compiler-rt builtins (not supported for baseline armel arch: armv5t) +# See http://lists.llvm.org/pipermail/llvm-dev/2016-May/099761.html + STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_BUILD_BUILTINS=OFF + COMPILER_RT_USE_BUILTINS_LIBRARY := OFF + LIBCXX_USE_COMPILER_RT := OFF endif - ifneq (,$(findstring $(DEB_HOST_ARCH),armhf)) -# avoid an issue with openmp on armhf - CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=armv7l-unknown-linux-gnueabihf + STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=arm-linux-gnueabihf + STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON +# align arch profile with debian baseline +# https://wiki.debian.org/ArmHardFloatPort#Minimum_CPU_.26_FPU + CFLAGS_EXTRA += -march=armv7-a -mfpu=vfpv3-d16 + CXXFLAGS_EXTRA += -march=armv7-a -mfpu=vfpv3-d16 +endif + +ifneq (,$(filter $(DEB_HOST_ARCH),i386)) +# Sometimes, i386 needs help with the triple + STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=i386-linux-gnu endif ifneq (,$(filter $(DEB_HOST_ARCH),mips64el)) # avoid an issue with search path on mips64el # https://bugs.llvm.org/show_bug.cgi?id=41204 - CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=mips64el-linux-gnuabi64 + STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=mips64el-linux-gnuabi64 +endif + +ifneq (,$(filter $(DEB_HOST_ARCH),powerpc)) + STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=powerpc-linux-gnu + STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON +endif + +ifneq (,$(filter $(DEB_HOST_ARCH),s390x)) + STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=s390x-linux-gnu + STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON + LIBCXX_EXCEPTIONS := OFF +# disable compiler-rt builtins (not supported for s390x) + STAGE_ALL_CMAKE_EXTRA += -DCOMPILER_RT_BUILD_BUILTINS=OFF + COMPILER_RT_USE_BUILTINS_LIBRARY := OFF + LIBCXX_USE_COMPILER_RT := OFF endif ifneq (,$(filter $(DEB_HOST_ARCH),x32)) - CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=x86_64-linux-gnux32 - CMAKE_EXTRA += -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-linux-gnux32 + STAGE_ALL_CMAKE_EXTRA += -DLLVM_HOST_TRIPLE=x86_64-linux-gnux32 + STAGE_ALL_CMAKE_EXTRA += -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-linux-gnux32 endif ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' g++-$(GCC_VERSION)) ge 4.8-20121128-1~ ; echo $$?),0) @@ -145,28 +199,16 @@ else LLVM_SPIRV_INSTALLED = yes endif -LIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" +LIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;amdgcn-mesa-mesa3d;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" ifeq ($(LLVM_SPIRV_INSTALLED),yes) LIBCLC_TARGETS_TO_BUILD := $(LIBCLC_TARGETS_TO_BUILD)";spirv-mesa3d-;spirv64-mesa3d-" endif -# Disabled: -# Host compiler does not support '-fuse-ld=lld' -# USE_LLD_ARCHS := amd64 -# ifneq (,$(filter $(DEB_HOST_ARCH),$(USE_LLD_ARCHS))) -# CMAKE_EXTRA += -DLLVM_ENABLE_LLD=ON -# endif - BINUTILS_GOLD_ARCHS := amd64 arm64 armhf i386 ppc64 ppc64el x32 s390x hurd-i386 kfreebsd-amd64 kfreebsd-i386 ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' binutils) ge 2.23.1-1~exp3 ; echo $$?),0) ifneq (,$(filter $(DEB_HOST_ARCH),$(BINUTILS_GOLD_ARCHS))) -# -fused-ld=gold enables the gold linker (but is not supported by all archs / distro) - LDFLAGS_EXTRA += -fuse-ld=gold -#--no-keep-files-mapped --no-map-whole-files - CXXFLAGS_EXTRA += -fuse-ld=gold - CFLAGS_EXTRA += -fuse-ld=gold -#-Wl,--no-keep-files-mapped -Wl,--no-map-whole-files - CMAKE_EXTRA += -DLLVM_BINUTILS_INCDIR=/usr/include/ + STAGE_ALL_CMAKE_EXTRA += -DLLVM_USE_LINKER=gold + STAGE_ALL_CMAKE_EXTRA += -DLLVM_BINUTILS_INCDIR=/usr/include/ endif endif @@ -179,16 +221,9 @@ ifneq (,$(filter codecoverage,$(DEB_BUILD_OPTIONS))) LDFLAGS_EXTRA += -coverage -lgcov RUN_TEST=yes # OpenMP doesn't respect LDFLAGS - CMAKE_EXTRA+= -DLIBOMP_LDFLAGS="-coverage -lgcov" # don't pass LDFLAGS_EXTRA because it expects gcc arg + STAGE_2_CMAKE_EXTRA+= -DLIBOMP_LDFLAGS="-coverage -lgcov" # don't pass LDFLAGS_EXTRA because it expects gcc arg endif -# Enable for bootstrap -LDFLAGS_EXTRA += -fPIC -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wl,--build-id -CXXFLAGS_EXTRA += -fPIC -Wno-unused-command-line-argument -Wno-unknown-warning-option -BOOTSTRAP_CXXFLAGS_EXTRA = $(CXXFLAGS_EXTRA) # Nothing for now. Keeping in case we need it -CFLAGS_EXTRA += -fPIC -Wno-unused-command-line-argument -Wno-unknown-warning-option -BOOTSTRAP_CFLAGS_EXTRA = $(CFLAGS_EXTRA) # Nothing for now. Keeping in case we need it - # Enable polly (or not) POLLY_ENABLE=yes ifneq (,$(filter $(DEB_HOST_ARCH), powerpc powerpcspe)) @@ -197,22 +232,28 @@ else PROJECTS+=;polly endif -# Enable openmp (or not) -OPENMP_ENABLE=yes -ifneq (,$(filter $(DEB_HOST_ARCH), m68k mips mipsel powerpc powerpcspe sparc64 s390x x32)) - OPENMP_ENABLE=no -else - PROJECTS+=;openmp -endif - # Enable libunwind (or not) LIBUNWIND_ENABLE=yes ifneq (,$(filter $(DEB_HOST_ARCH), s390x armel m68k mipsel hurd-i386 powerpc sparc sparc64 x32)) LIBUNWIND_ENABLE=no +# do not use compiler-rt builtins for libcxx (libcxxabi) when libunwind is +# disabled since the gnu implementation in libgcc_s will then be required + LIBCXX_USE_COMPILER_RT := OFF else - PROJECTS += ;libunwind - CMAKE_LIBCXX_EXTRA += -DLIBCXXABI_USE_LLVM_UNWINDER=ON \ - -DLIBUNWIND_USE_COMPILER_RT=ON + RUNTIMES += ;libunwind + STAGE_ALL_CMAKE_EXTRA += -DLIBCXXABI_USE_LLVM_UNWINDER=ON +endif + +# Enable openmp (or not) +OPENMP_ENABLE=yes +ifneq (,$(filter $(DEB_HOST_ARCH), m68k mipsel powerpc powerpcspe sparc64 s390x x32)) + OPENMP_ENABLE=no +else + RUNTIMES+=;openmp + STAGE_ALL_CMAKE_EXTRA += -DLIBOMP_LIBFLAGS="-lm" +ifeq ($(LIBUNWIND_ENABLE),yes) + STAGE_ALL_CMAKE_EXTRA += -DOPENMP_USE_LLVM_UNWINDER=ON +endif endif RUN_TEST=yes @@ -241,7 +282,7 @@ ifneq (,$(filter scan-build,$(DEB_BUILD_OPTIONS))) # no need to run tests in this case RUN_TEST=no CONFIGURE_EXTRA += --enable-assertions - CMAKE_EXTRA += -DLLVM_ENABLE_ASSERTIONS=ON + STAGE_ALL_CMAKE_EXTRA += -DLLVM_ENABLE_ASSERTIONS=ON endif ifneq (,$(filter coverity,$(DEB_BUILD_OPTIONS))) @@ -254,7 +295,7 @@ ifneq (,$(filter coverity,$(DEB_BUILD_OPTIONS))) PRE_PROCESS_CONF= COVERITY_ENABLE=1 CONFIGURE_EXTRA += --enable-assertions - CMAKE_EXTRA += -DLLVM_ENABLE_ASSERTIONS=ON + STAGE_ALL_CMAKE_EXTRA += -DLLVM_ENABLE_ASSERTIONS=ON # no need to run tests in this case RUN_TEST=no else @@ -268,9 +309,6 @@ ifeq (,$(filter-out $(LLDB_DISABLE_ARCHS), $(DEB_HOST_ARCH))) # Disable LLDB for this arch. LLDB_ENABLE=no else -# See https://llvm.org/bugs/show_bug.cgi?id=28898 -# Enable it again as it seems it is fixed upstream https://bugs.llvm.org/show_bug.cgi?id=35291 -# CMAKE_EXTRA += -DLLDB_DISABLE_LIBEDIT=ON PROJECTS+=;lldb endif @@ -278,7 +316,7 @@ LLD_ENABLE=yes ifneq (,$(filter $(DEB_HOST_ARCH_OS),linux)) # only for linux - CMAKE_EXTRA += -DLLVM_USE_PERF=yes -DLLVM_ENABLE_LIBPFM=ON + STAGE_2_CMAKE_EXTRA += -DLLVM_USE_PERF=ON -DLLVM_ENABLE_LIBPFM=ON endif # Only enable it for archs supporting gold @@ -292,7 +330,7 @@ ifeq (,$(filter $(DEB_HOST_ARCH), armhf)) # * LLVM_ENABLE_LTO doesn't work with gcc >= 9 (option not accepted) # * BOOTSTRAP_LLVM_ENABLE_LTO is producing some large binary # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=943623 -# CMAKE_EXTRA += -DBOOTSTRAP_LLVM_ENABLE_LTO="Thin" +# STAGE_2_CMAKE_EXTRA += -DLLVM_ENABLE_LTO="Thin" endif endif @@ -311,7 +349,7 @@ ifeq (,$(filter $(DEB_HOST_ARCH_OS),linux)) LIBFUZZER_ENABLE=no endif -ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel)) +ifneq (,$(filter $(DEB_HOST_ARCH), mipsel)) LIBOMP_ARCH = mips endif @@ -329,12 +367,15 @@ endif GENERATOR=Ninja +# enables cmake build targets like stage2-[target_name] +ENABLED_STAGE2_CMAKE_BUILD_TARGETS = check-all;check-llvm;check-clang;check-clang-tools;check-lld;check-libcxx;check-libcxxabi;check-sanitizer;llvm-config;test-suite + %: dh $@ $(DH_OPTIONS) # For some reasons, some spaces are added, removing them PROJECTS_LIST := $(shell echo "$(PROJECTS)"|sed -e "s| ||g") -#RUNTIMES_LIST := $(shell echo "$(RUNTIMES)"|sed -e "s| ||g") +RUNTIMES_LIST := $(shell echo "$(RUNTIMES)"|sed -e "s| ||g") preconfigure: @@ -351,7 +392,7 @@ preconfigure: @echo "DISTRO=$(DISTRO)" @echo "GCC_VERSION=$(GCC_VERSION)" @echo "PROJECTS=$(PROJECTS_LIST)" -# @echo "RUNTIMES=$(RUNTIMES_LIST)" + @echo "RUNTIMES=$(RUNTIMES_LIST)" @echo "LLVM_VERSION=$(LLVM_VERSION)" @echo "LLVM_VERSION_FULL=$(LLVM_VERSION_FULL)" @echo "LLVM_VERSION_SNAPSHOT=$(LLVM_VERSION_SNAPSHOT)" @@ -421,57 +462,110 @@ override_dh_auto_configure: preconfigure --xml-option append_arg:"replace/llvm::AlignOf::Alignment/(llvm::AlignOf::Alignment)"; \ fi) +# Fails with No target "unwind_static" +# -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON \ +# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY=OFF \ +# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=ON \ +#- to libc++ when libunwind is built +#- Matches what is done on brew: +#- https://bit.ly/3kDNpC9 + echo "Running tests: $(RUN_TEST)" echo "Using cmake: $(CMAKE_BIN)"; \ - CFLAGS="$(CFLAGS_EXTRA)" \ - CXXFLAGS="$(CXXFLAGS_EXTRA)" \ - LDFLAGS="$(LDFLAGS_EXTRA)" \ - LD_LIBRARY_PATH=$$LD_LIBRARY_PATH $(PRE_PROCESS_CONF) $(CMAKE_BIN) -S llvm/ -B $(TARGET_BUILD) \ + LD_LIBRARY_PATH=$$LD_LIBRARY_PATH \ + $(PRE_PROCESS_CONF) $(CMAKE_BIN) -S llvm/ -B $(TARGET_BUILD) \ -G $(GENERATOR) \ - -DLLVM_ENABLE_PROJECTS="$(PROJECTS_LIST)" \ - -DCMAKE_SUPPRESS_REGENERATION=ON \ -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$(LLVM_VERSION) \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(opt_flags)" \ - -DLLVM_LINK_LLVM_DYLIB=ON \ - -DLLVM_INSTALL_UTILS=ON \ - -DLLVM_VERSION_SUFFIX= \ - -DLLVM_ENABLE_SPHINX=ON \ - -DSPHINX_WARNINGS_AS_ERRORS=OFF \ - -DLLVM_ENABLE_RTTI=ON \ - -DLLVM_ENABLE_FFI=ON \ - -DLLVM_ENABLE_DUMP=ON \ - -DLIBCLANG_LIBRARY_VERSION=$(SONAME_EXT) \ - -DCLANG_LINK_CLANG_DYLIB=ON \ + -DCMAKE_SUPPRESS_REGENERATION=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_FLAGS="$(STAGE_1_CFLAGS)" \ + -DCMAKE_CXX_FLAGS="$(STAGE_1_CXXFLAGS)" \ + -DCMAKE_SHARED_LINKER_FLAGS="$(STAGE_1_LDFLAGS)" \ + -DCMAKE_MODULE_LINKER_FLAGS="$(STAGE_1_LDFLAGS)" \ + -DCMAKE_EXE_LINKER_FLAGS="$(STAGE_1_LDFLAGS)" \ + -DPACKAGE_VENDOR=$(VENDOR) \ -DENABLE_LINKER_BUILD_ID=ON \ - -DCOMPILER_RT_USE_LIBCXX=NO \ - $(CMAKE_EXTRA) \ - $(Z3_FLAG) \ - -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="AVR;M68k" \ + -DLLVM_TARGETS_TO_BUILD=Native \ + -DLLVM_ENABLE_PROJECTS="$(PROJECTS_LIST)" \ + -DLLVM_ENABLE_RUNTIMES="$(RUNTIMES_LIST)" \ + -DLLVM_ENABLE_PIC=ON \ + -DLLVM_ENABLE_RTTI=ON \ + -DLVVM_ENABLE_ZLIB=OFF \ + -DLLVM_BUILD_DOCS=OFF \ + -DLLVM_INCLUDE_GO_TESTS=OFF \ + -DLLVM_USE_RELATIVE_PATHS_IN_FILES=ON \ -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ - -DCLANG_VENDOR=$(VENDOR) \ - -DCLANG_ENABLE_BOOTSTRAP=ON \ + -DCLANG_PLUGIN_SUPPORT=OFF \ -DCLANG_BUILD_EXAMPLES=OFF \ - -DLLVM_POLLY_LINK_INTO_TOOLS=ON \ - -DBOOTSTRAP_CMAKE_CXX_FLAGS='$(BOOTSTRAP_CXXFLAGS_EXTRA)' \ - -DBOOTSTRAP_CMAKE_C_FLAGS='$(BOOTSTRAP_CFLAGS_EXTRA)' \ - -DBOOTSTRAP_CMAKE_SHARED_LINKER_FLAGS="$(LDFLAGS_EXTRA)" \ - -DBOOTSTRAP_CMAKE_MODULE_LINKER_FLAGS="$(LDFLAGS_EXTRA)" \ - -DBOOTSTRAP_CMAKE_EXE_LINKER_FLAGS="$(LDFLAGS_EXTRA)" \ - -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_VERBOSE_MAKEFILE;CMAKE_BUILD_TYPE;CMAKE_CXX_FLAGS_RELWITHDEBINFO;LLVM_LINK_LLVM_DYLIB;LLVM_INSTALL_UTILS;LLVM_VERSION_SUFFIX;LLVM_ENABLE_SPHINX;SPHINX_WARNINGS_AS_ERRORS;LLVM_BUILD_LLVM_DYLIB;LLVM_ENABLE_RTTI;LLVM_ENABLE_FFI;LIBCLANG_LIBRARY_VERSION;ENABLE_LINKER_BUILD_ID;POLLY_BUNDLED_JSONCPP;LLVM_EXPERIMENTAL_TARGETS_TO_BUILD;LLVM_USE_PERF;LLVM_ENABLE_ASSERTIONS;LLVM_BINUTILS_INCDIR;LLVM_HOST_TRIPLE;LLVM_COMPILER_CHECKED;COMPILER_RT_BUILD_BUILTINS;LIBOMP_LIBFLAGS;CMAKE_SHARED_LINKER_FLAGS;PYTHON_EXECUTABLE;LLVM_ENABLE_Z3_SOLVER;LLVM_POLLY_LINK_INTO_TOOLS;CLANG_VENDOR;LIBUNWIND_USE_COMPILER_RT"|| tail -100 build-llvm/CMakeFiles/CMakeError.log + -DCLANG_DEFAULT_LINKER=ld \ + -DCLANG_DEFAULT_CXX_STDLIB=libstdc++ \ + -DCLANG_DEFAULT_RTLIB=libgcc \ + -DCOMPILER_RT_BUILD_XRAY=OFF \ + -DCOMPILER_RT_INCLUDE_TESTS=OFF \ + -DCOMPILER_RT_USE_LIBCXX=OFF \ + -DCOMPILER_RT_USE_BUILTINS_LIBRARY=$(COMPILER_RT_USE_BUILTINS_LIBRARY) \ + -DLIBUNWIND_USE_COMPILER_RT=ON \ + -DLIBUNWIND_INSTALL_LIBRARY=OFF \ + -DLIBCXXABI_ENABLE_EXCEPTIONS=$(LIBCXX_EXCEPTIONS) \ + -DLIBCXXABI_USE_COMPILER_RT=$(LIBCXX_USE_COMPILER_RT) \ + -DLIBCXXABI_INSTALL_LIBRARY=OFF \ + -DLIBCXX_ENABLE_EXCEPTIONS=$(LIBCXX_EXCEPTIONS) \ + -DLIBCXX_USE_COMPILER_RT=$(LIBCXX_USE_COMPILER_RT) \ + -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \ + -DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \ + -DLIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY=OFF \ + -DLIBCXX_INSTALL_LIBRARY=OFF \ + -DOPENMP_ENABLE_LIBOMP_PROFILING=OFF \ + -DOPENMP_ENABLE_LIBOMPTARGET_PROFILING=OFF \ + -DLIBOMP_ENABLE_RTTI=OFF \ + -DLIBOMP_OMPT_SUPPORT=OFF \ + $(CMAKE_EXTRA) \ + -DBUILTINS_CMAKE_ARGS="-DCMAKE_C_FLAGS=$(STAGE_1_CFLAGS);-DCMAKE_CXX_FLAGS=$(STAGE_1_CXXFLAGS);-DCMAKE_EXE_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_SHARED_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_MODULE_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_BUILD_TYPE=Release;-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF" \ + -DRUNTIMES_CMAKE_ARGS="-DCMAKE_C_FLAGS=$(STAGE_1_CFLAGS);-DCMAKE_CXX_FLAGS=$(STAGE_1_CXXFLAGS);-DCMAKE_EXE_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_SHARED_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_MODULE_LINKER_FLAGS=$(STAGE_1_LDFLAGS);-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_BUILD_TYPE=Release;-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF" \ + -DCLANG_ENABLE_BOOTSTRAP=ON \ + -DCLANG_BOOTSTRAP_TARGETS="$(ENABLED_STAGE2_CMAKE_BUILD_TARGETS)" \ + -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_SUPPRESS_REGENERATION;ENABLE_LINKER_BUILD_ID;LLVM_ENABLE_PIC;LLVM_ENABLE_RTTI;LLVM_INCLUDE_GO_TESTS;LLVM_USE_RELATIVE_PATHS_IN_FILES;CLANG_DEFAULT_LINKER;CLANG_DEFAULT_CXX_STDLIB;CLANG_DEFAULT_RTLIB;COMPILER_RT_USE_LIBCXX;COMPILER_RT_USE_BUILTINS_LIBRARY;COMPILER_RT_INCLUDE_TESTS;LIBUNWIND_USE_COMPILER_RT;LIBCXXABI_ENABLE_EXCEPTIONS;LIBCXXABI_USE_COMPILER_RT;LIBCXX_USE_COMPILER_RT;LIBCXX_ENABLE_EXCEPTIONS;LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY;LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY;LIBOMP_ENABLE_RTTI" \ + -DBOOTSTRAP_CMAKE_BUILD_TYPE=RelWithDebInfo \ + -DBOOTSTRAP_CMAKE_C_FLAGS_RELWITHDEBINFO="$(opt_flags)" \ + -DBOOTSTRAP_CMAKE_CXX_FLAGS_RELWITHDEBINFO="$(opt_flags)" \ + -DBOOTSTRAP_CMAKE_C_FLAGS="$(STAGE_2_CFLAGS)" \ + -DBOOTSTRAP_CMAKE_CXX_FLAGS="$(STAGE_2_CXXFLAGS)" \ + -DBOOTSTRAP_CMAKE_SHARED_LINKER_FLAGS="$(STAGE_2_LDFLAGS)" \ + -DBOOTSTRAP_CMAKE_MODULE_LINKER_FLAGS="$(STAGE_2_LDFLAGS)" \ + -DBOOTSTRAP_CMAKE_EXE_LINKER_FLAGS="$(STAGE_2_LDFLAGS)" \ + -DBOOTSTRAP_LLVM_ENABLE_FFI=ON \ + -DBOOTSTRAP_LLVM_ENABLE_DUMP=ON \ + -DBOOTSTRAP_LLVM_ENABLE_LIBPFM=ON \ + -DBOOTSTRAP_LLVM_ENABLE_SPHINX=ON \ + -DBOOTSTRAP_SPHINX_WARNINGS_AS_ERRORS=OFF \ + -DBOOTSTRAP_LLVM_USE_RELATIVE_PATHS_IN_FILES=ON \ + -DBOOTSTRAP_LLVM_INSTALL_UTILS=ON \ + -DBOOTSTRAP_LLVM_VERSION_SUFFIX= \ + -DBOOTSTRAP_LLVM_POLLY_LINK_INTO_TOOLS=ON \ + -DBOOTSTRAP_LLVM_EXPERIMENTAL_TARGETS_TO_BUILD="AVR;M68k" \ + -DBOOTSTRAP_LLVM_LINK_LLVM_DYLIB=ON \ + -DBOOTSTRAP_CLANG_LINK_CLANG_DYLIB=ON \ + -DBOOTSTRAP_LIBCLANG_LIBRARY_VERSION=$(SONAME_EXT) \ + -DBOOTSTRAP_LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON \ + -DBOOTSTRAP_PYTHON_EXECUTABLE=/usr/bin/python3 \ + $(BOOTSTRAP_CMAKE_EXTRA) \ + -DBOOTSTRAP_BUILTINS_CMAKE_ARGS="-DCMAKE_C_FLAGS=$(STAGE_2_CFLAGS);-DCMAKE_CXX_FLAGS=$(STAGE_2_CXXFLAGS);-DCMAKE_EXE_LINKER_FLAGS=$(STAGE_2_LDFLAGS);-DCMAKE_SHARED_LINKER_FLAGS=$(STAGE_2_LDFLAGS);-DCMAKE_MODULE_LINKER_FLAGS=$(STAGE_2_LDFLAGS);-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_BUILD_TYPE=RelWithDebInfo;-DCMAKE_C_FLAGS_RELWITHDEBINFO=$(opt_flags);-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$(opt_flags);-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF" \ + -DBOOTSTRAP_RUNTIMES_CMAKE_ARGS="-DCMAKE_C_FLAGS=$(STAGE_2_CFLAGS);-DCMAKE_CXX_FLAGS=$(STAGE_2_CXXFLAGS);-DCMAKE_EXE_LINKER_FLAGS=$(STAGE_2_LDFLAGS) -L$(STAGE_1_LIB_DIR);-DCMAKE_SHARED_LINKER_FLAGS=$(STAGE_2_LDFLAGS) -L$(STAGE_1_LIB_DIR);-DCMAKE_MODULE_LINKER_FLAGS=$(STAGE_2_LDFLAGS) -L$(STAGE_1_LIB_DIR);-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_BUILD_TYPE=RelWithDebInfo;-DCMAKE_C_FLAGS_RELWITHDEBINFO=$(opt_flags);-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$(opt_flags);-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF" + FOUND_VERSION=`grep LLVM_VERSION_STRING build-llvm/include/llvm/Config/llvm-config.h|cut -d\" -f2`; \ if ! echo "$(LLVM_VERSION_FULL)"|grep "$$FOUND_VERSION"; then \ echo "mistmatch of version. Found: $$FOUND_VERSION / Expected: $(LLVM_VERSION_FULL)"; \ exit 1; \ fi - # ninja VERBOSE=-v debian-full-build: - $(PRE_PROCESS) ninja $(NJOBS) -C $(TARGET_BUILD) $(VERBOSE) stage2 + echo "Using cmake: $(CMAKE_BIN)" +# linker hack so stage2 can link against stage1 libs at runtime + LD_LIBRARY_PATH=$(STAGE_1_LIB_DIR):$$LD_LIBRARY_PATH \ + VERBOSE=1 $(PRE_PROCESS) $(CMAKE_BIN) --build $(TARGET_BUILD) $(NJOBS) --target stage2 # Check the stage 2 build worked if ! readelf --string-dump .comment $(TARGET_BUILD_STAGE2)/bin/clang 2>&1|grep -q "clang version"; then \ @@ -482,115 +576,41 @@ debian-full-build: echo "libclang-$(LLVM_VERSION).so.1 depends on libclang-cpp. Should not be the case"; \ exit 2; \ fi -# $(PRE_PROCESS) make $(NJOBS) -C $(TARGET_BUILD) $(VERBOSE) CFLAGS="$(CFLAGS_EXTRA)" CXXFLAGS="$(CXXFLAGS_EXTRA)" LDFLAGS="$(LDFLAGS_EXTRA)" REQUIRES_RTTI=1 DEBUGMAKE=1 runtimes - touch $@ debian-libfuzzer-build: ifeq (${LIBFUZZER_ENABLE},yes) cd $(TARGET_BUILD); \ - CFLAGS=`dpkg-buildflags --get CFLAGS`; \ - CFLAGS="$$CFLAGS `dpkg-buildflags --get CPPFLAGS`"; \ + CFLAGS="$(opt_flags) $(STAGE_2_CFLAGS)"; \ echo $$CFLAGS; \ - $(BASE_PATH)/$(TARGET_BUILD_STAGE2)/bin/clang++ -c $$CFLAGS -std=c++11 $(BASE_PATH)/compiler-rt/lib/fuzzer/*.cpp -IFuzzer; \ + $(STAGE_2_BIN_DIR)/clang++ -c $$CFLAGS -std=c++11 $(BASE_PATH)/compiler-rt/lib/fuzzer/*.cpp -IFuzzer; \ ar ruv libFuzzer.a Fuzzer*.o endif touch $@ -# The various options to build libc++ and libc++abi - -LIBCXX_CMAKE_OPTIONS := \ - -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$(LLVM_VERSION) \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DLLVM_CONFIG_PATH=$(CURDIR)/$(TARGET_BUILD_STAGE2)/bin/llvm-config \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_COMPILER=$(CURDIR)/$(TARGET_BUILD_STAGE2)/bin/clang++ \ - -DCMAKE_C_COMPILER=$(CURDIR)/$(TARGET_BUILD_STAGE2)/bin/clang \ - -DCMAKE_CXX_FLAGS="$(LIBCXXFLAGS)" \ - -DCMAKE_EXE_LINKER_FLAGS="" \ - -DCMAKE_SHARED_LINKER_FLAGS="" \ - -DCMAKE_MODULE_LINKER_FLAGS="" \ - -DCMAKE_AR=$(CURDIR)/$(TARGET_BUILD_STAGE2)/bin/llvm-ar \ - -DCMAKE_RANLIB=$(CURDIR)/$(TARGET_BUILD_STAGE2)/bin/llvm-ranlib \ - -DLLVM_EXTERNAL_LIT=$(BASE_PATH)/llvm/utils/lit/lit.py \ - -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ - $(CMAKE_EXTRA) - -debian-libcxxabi-build: -# Builds libcxxabi - echo "Using cmake: $(CMAKE_BIN)"; \ - cd libcxxabi && \ - CXXFLAGS="$(CXXFLAGS_EXTRA)" LDFLAGS="$(LDFLAGS_EXTRA)" \ - $(PRE_PROCESS_CONF) $(CMAKE_BIN) \ - -S . -B build \ - -G $(GENERATOR) \ - $(LIBCXX_CMAKE_OPTIONS) \ - -DLIBCXXABI_LIBCXX_PATH=$(BASE_PATH)/libcxx \ - -DLIBCXXABI_LIBCXX_LIBRARY_PATH=$(BASE_PATH)/libcxx/build/lib \ - -DLIBCXXABI_LIBCXX_INCLUDES=$(BASE_PATH)/$(TARGET_BUILD_STAGE2)/include/c++/v1/ \ - -DLIBCXXABI_ENABLE_EXCEPTIONS=$(LIBCXX_EXCEPTIONS) \ - -DLIBCXXABI_USE_COMPILER_RT=ON \ - -DLLVM_ENABLE_RTTI=ON \ - $(CMAKE_LIBCXX_EXTRA) && \ - $(PRE_PROCESS_CONF) ninja -C build/ $(VERBOSE) - touch $@ - -# Fails with $ -# No target "unwind_static" -# on 12. Will test with 13 -# -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON \ -# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY=OFF \ -# -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=ON \ -N -#- to libc++ when libunwind is built -#- Matches what is done on brew: -#- https://bit.ly/3kDNpC9 - -debian-libcxx-build: -# Builds libcxx - echo "Using cmake: $(CMAKE_BIN)"; \ - cd libcxx && \ - $(PRE_PROCESS_CONF) $(CMAKE_BIN) \ - CXXFLAGS="$(CXXFLAGS_EXTRA)" LDFLAGS="$(LDFLAGS_EXTRA)" \ - -S . -B build \ - -G $(GENERATOR) \ - $(LIBCXX_CMAKE_OPTIONS) \ - -DLIBCXX_CXX_ABI=libcxxabi \ - -DLIBCXX_CXX_ABI_INCLUDE_PATHS=$(BASE_PATH)/libcxxabi/include \ - -DLIBCXX_CXX_ABI_LIBRARY_PATH=$(BASE_PATH)/libcxxabi/build/lib \ - -DLIBCXX_ENABLE_EXCEPTIONS=$(LIBCXX_EXCEPTIONS) \ - -DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON \ - -DLIBCXX_USE_COMPILER_RT=ON \ - -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \ - -DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \ - -DLIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY=OFF \ - $(CMAKE_LIBCXX_EXTRA) && \ - $(PRE_PROCESS_CONF) ninja -C build/ $(VERBOSE) - touch $@ - - debian-libclc-build: # Builds libclc - mkdir -p libclc/build - - CMAKE_BIN=cmake; \ - if test -f /tmp/cmake/bin/cmake; then \ - CMAKE_BIN=/tmp/cmake/bin/cmake; \ - fi; \ - echo "Using cmake: $$CMAKE_BIN"; \ + echo "Using cmake: $(CMAKE_BIN)" cd libclc/build && \ - $$CMAKE_BIN ../ \ + $(CMAKE_BIN) ../ \ -G $(GENERATOR) \ + -DCMAKE_C_COMPILER=$(STAGE_2_BIN_DIR)/clang \ + -DCMAKE_CXX_COMPILER=$(STAGE_2_BIN_DIR)/clang++ \ + -DCMAKE_C_FLAGS="$(opt_flags) $(STAGE_2_CFLAGS)" \ + -DCMAKE_CXX_FLAGS="$(opt_flags) $(STAGE_2_CXXFLAGS)" \ + -DCMAKE_SHARED_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ + -DCMAKE_MODULE_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ + -DCMAKE_EXE_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_DATADIR=lib \ -DCMAKE_INSTALL_INCLUDEDIR=include \ - -DLLVM_CONFIG=$(CURDIR)/$(TARGET_BUILD_STAGE2)/bin/llvm-config \ + -DLLVM_CONFIG=$(STAGE_2_BIN_DIR)/llvm-config \ -DLIBCLC_TARGETS_TO_BUILD=$(LIBCLC_TARGETS_TO_BUILD); \ - ninja $(VERBOSE) + ninja $(NJOBS) $(VERBOSE) touch $@ -override_dh_auto_build: debian-full-build debian-libfuzzer-build debian-libcxxabi-build debian-libcxx-build debian-libclc-build +override_dh_auto_build: debian-full-build debian-libfuzzer-build debian-libclc-build override_dh_prep: build_doc dh_prep @@ -620,7 +640,7 @@ endif fi # the clang doc generation only generates clang manpage # When it will do more, we should move that in the loop above - cd $(CURDIR)/clang/docs/_build/man/; mv clang.1 clang-$(LLVM_VERSION).1 + cd $(CURDIR)/clang/docs/_build/man/ && mv clang.1 clang-$(LLVM_VERSION).1 # Remove the copy of jquery. See bug #701087 for d in $(TARGET_BUILD_STAGE2)/docs/html/_static/ $(TARGET_BUILD_STAGE2)/tools/clang/docs/html/_static/ $(TARGET_BUILD_STAGE2)/tools/clang/tools/extra/docs/html/_static/; do \ @@ -664,27 +684,22 @@ override_dh_auto_install: # Only run on executable, not script chrpath -d `find $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/bin/ -type f -executable -exec file -i '{}' \; | grep 'x-executable; charset=binary'|cut -d: -f1` - chrpath -d libcxxabi/build/lib/libc++abi.so.1.0 - chrpath -d libcxx/build/lib/libc++.so.1.0 : # libclang cd debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/ && \ ln -s libclang-$(LLVM_VERSION).so.$(SONAME_CLANG) libclang.so.$(SONAME_EXT) && \ ln -s libclang-$(LLVM_VERSION).so.$(SONAME_CLANG) libclang-$(SONAME_CLANG).so.$(SONAME_EXT) - : # libomp - cd debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib && rm -f libomp.so; \ - ln -s libomp.so.$(SONAME_OPENMP) libomp.so - if test "$(LIBUNWIND_ENABLE)" = yes; then \ mkdir -p debian/tmp/usr/include/libunwind; \ cp -R libunwind/include/* debian/tmp/usr/include/libunwind/; \ fi + : # libomp if test "$(OPENMP_ENABLE)" = yes; then \ - mkdir -p debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/include/openmp; \ - cp -f openmp/runtime/exports/common*/include/* debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/include/openmp; \ - cd debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib && cp libomp.so.$(SONAME_OPENMP) libomp-$(LLVM_VERSION).so.$(SONAME_OPENMP); \ + cd debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib; \ + ln -s libomp.so.$(SONAME_OPENMP) libomp.so; \ + cp libomp.so.$(SONAME_OPENMP) libomp-$(LLVM_VERSION).so.$(SONAME_OPENMP); \ fi # Remove artifact (where compiler-rt is built) @@ -724,8 +739,6 @@ endif rm -rf $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/build/utils/lit/lit/__pycache__/ \ $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/build/utils/lit/lit/*/__pycache__/ - DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C libcxxabi/build install - DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C libcxx/build install DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C libclc/build install # Rename binaries @@ -782,8 +795,8 @@ endif # Manage the polly files. Sometimes, we build them. Sometimes not. if test "$(POLLY_ENABLE)" = yes; then \ mkdir -p $(CURDIR)/debian/libclang-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/ $(CURDIR)/debian/libclang-common-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/include/polly/; \ - mv -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/libpolly* \ - $(CURDIR)/debian/libclang-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/; \ + mv -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/libPolly* \ + $(CURDIR)/debian/libclang-common-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/lib/; \ rm -rf $(CURDIR)/debian/libclang-common-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/include/polly; \ mv -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/include/polly/ \ $(CURDIR)/debian/libclang-common-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/include/; \ @@ -924,10 +937,10 @@ endif ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-sanitizer || true # Libcxx - ninja $(VERBOSE) -C libcxx/build check-libcxx || true + ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-libcxx || true # Libcxxabi - ninja $(VERBOSE) -C libcxxabi/build check-libcxxabi || true + ninja $(VERBOSE) -C $(TARGET_BUILD_STAGE2) check-libcxxabi || true # Libclc ninja $(VERBOSE) -C libclc/build test || true diff --git a/debian/tests/control b/debian/tests/control index 5af6a774..6bff47a6 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -8,6 +8,7 @@ Restrictions: allow-stderr Tests: integration-test-suite-test Depends: @, cmake, make, g++, libstdc++-10-dev Restrictions: allow-stderr +Architecture: amd64 arm64 Tests: cmake-test Depends: gcc, build-essential, cmake, llvm-13-dev