Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLVM_full] Build version 16 #6777

Merged
merged 11 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions L/LLVM/LLVM_full@16/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version = v"16.0.6"

include("../common.jl")

build_tarballs(ARGS, configure_build(ARGS, version; experimental_platforms=true)...;
preferred_gcc_version=v"13", preferred_llvm_version=v"16", julia_compat="1.10")
#Let's build!!
22 changes: 22 additions & 0 deletions L/LLVM/LLVM_full@16/bundled/libcxx_patches/7005_libcxx_musl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/include/locale b/include/locale
index 874866f69822..8206013a0719 100644
--- a/include/locale
+++ b/include/locale
@@ -758,7 +758,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
__libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
errno = 0;
char *__p2;
- long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
+ long long __ll = strtoll(__a, &__p2, __base);
__libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
@@ -798,7 +798,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
__libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
errno = 0;
char *__p2;
- unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
+ unsigned long long __ll = strtoull(__a, &__p2, __base);
__libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 4047d58d75624f929744d7218d8934c8cb204d66 Mon Sep 17 00:00:00 2001
From: Gabriel Baraldi <baraldigabriel@gmail.com>
Date: Wed, 1 Mar 2023 18:03:45 -0300
Subject: [PATCH] Disable tblgen lsp server

---
mlir/lib/Tools/CMakeLists.txt | 2 +-
mlir/test/CMakeLists.txt | 2 +-
mlir/tools/CMakeLists.txt | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mlir/lib/Tools/CMakeLists.txt b/mlir/lib/Tools/CMakeLists.txt
index 57e570437e8b..9e8c359064bf 100644
--- a/mlir/lib/Tools/CMakeLists.txt
+++ b/mlir/lib/Tools/CMakeLists.txt
@@ -5,4 +5,4 @@ add_subdirectory(mlir-pdll-lsp-server)
add_subdirectory(mlir-reduce)
add_subdirectory(mlir-translate)
add_subdirectory(PDLL)
-add_subdirectory(tblgen-lsp-server)
+# add_subdirectory(tblgen-lsp-server)
diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt
index 74f805865d2d..60908a0268f4 100644
--- a/mlir/test/CMakeLists.txt
+++ b/mlir/test/CMakeLists.txt
@@ -98,7 +98,7 @@ set(MLIR_TEST_DEPENDS
mlir-reduce
mlir-tblgen
mlir-translate
- tblgen-lsp-server
+ # tblgen-lsp-server
)

# The native target may not be enabled, in this case we won't
diff --git a/mlir/tools/CMakeLists.txt b/mlir/tools/CMakeLists.txt
index e9a1e4d62517..014ebdbb22fc 100644
--- a/mlir/tools/CMakeLists.txt
+++ b/mlir/tools/CMakeLists.txt
@@ -7,7 +7,7 @@ add_subdirectory(mlir-shlib)
add_subdirectory(mlir-spirv-cpu-runner)
add_subdirectory(mlir-translate)
add_subdirectory(mlir-vulkan-runner)
-add_subdirectory(tblgen-lsp-server)
+# add_subdirectory(tblgen-lsp-server)

# mlir-cpu-runner requires ExecutionEngine.
if(MLIR_ENABLE_EXECUTION_ENGINE)
--
2.39.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 1fa6efaa946243004c45be92e66b324dc980df7d Mon Sep 17 00:00:00 2001
From: Valentin Churavy <v.churavy@gmail.com>
Date: Thu, 17 Sep 2020 23:22:45 +0200
Subject: [PATCH] clang-sa can't determine that !RHS implies !LHS

---
llvm/include/llvm/ADT/FunctionExtras.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index 121aa527a5d..b9b6d829b14 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -193,9 +193,11 @@ public:
// Copy the callback and inline flag.
CallbackAndInlineFlag = RHS.CallbackAndInlineFlag;

+#ifndef __clang_analyzer__
// If the RHS is empty, just copying the above is sufficient.
if (!RHS)
return;
+#endif

if (!isInlineStorage()) {
// The out-of-line case is easiest to move.
--
2.28.0

37 changes: 37 additions & 0 deletions L/LLVM/LLVM_full@16/bundled/patches/0100-llvm-12-musl-bb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From f1901de14ff1f1abcc729c4adccfbd5017e30357 Mon Sep 17 00:00:00 2001
From: Valentin Churavy <v.churavy@gmail.com>
Date: Fri, 7 May 2021 13:54:41 -0400
Subject: [PATCH] [Compiler-RT] Fix compilation on musl

---
compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp | 1 +
.../lib/sanitizer_common/sanitizer_platform_limits_posix.cpp | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp b/compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
index b87798603fda..452a08aafe0e 100644
--- a/compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
@@ -26,6 +26,7 @@

#include <cassert>
#include <cstdint>
+#include <stddef.h>
#include <dlfcn.h> // for dlsym()

static void *getFuncAddr(const char *name, uintptr_t wrapper_addr) {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
index 12dd39e674ac..bb0f7a2daa8c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -69,7 +69,6 @@
#include <malloc.h>
#include <mntent.h>
#include <netinet/ether.h>
-#include <sys/sysinfo.h>
#include <sys/vt.h>
#include <linux/cdrom.h>
#include <linux/fd.h>
--
2.31.1

17 changes: 17 additions & 0 deletions L/LLVM/LLVM_full@16/bundled/patches/0123-cast-allequal.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 79b145632d5a..ff28ac694d70 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -891,9 +891,9 @@ detail::zippy<detail::zip_shortest, T, U, Args...> zip(T &&t, U &&u,
template <typename T, typename U, typename... Args>
detail::zippy<detail::zip_first, T, U, Args...> zip_equal(T &&t, U &&u,
Args &&...args) {
- assert(all_equal({std::distance(adl_begin(t), adl_end(t)),
- std::distance(adl_begin(u), adl_end(u)),
- std::distance(adl_begin(args), adl_end(args))...}) &&
+ assert(all_equal({(long long int)std::distance(adl_begin(t), adl_end(t)),
+ (long long int)std::distance(adl_begin(u), adl_end(u)),
+ (long long int)std::distance(adl_begin(args), adl_end(args))...}) &&
"Iteratees do not have equal length");
return detail::zippy<detail::zip_first, T, U, Args...>(
std::forward<T>(t), std::forward<U>(u), std::forward<Args>(args)...);
53 changes: 53 additions & 0 deletions L/LLVM/LLVM_full@16/bundled/patches/0200-templates.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From ad520c15cc2dae3231c38cca916f93c8347c1bd9 Mon Sep 17 00:00:00 2001
From: Valentin Churavy <v.churavy@gmail.com>
Date: Tue, 8 Nov 2022 13:18:59 -0500
Subject: [PATCH] handle template weirdness

---
lld/ELF/InputFiles.cpp | 4 ++--
lld/ELF/InputSection.cpp | 2 +-
lld/ELF/SyntheticSections.cpp | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 7dacdeb9f042..b43b3b3db6f5 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -275,7 +275,7 @@ template <class ELFT> static void doParseFile(InputFile *file) {

// .so file
if (auto *f = dyn_cast<SharedFile>(file)) {
- f->parse<ELFT>();
+ f->template parse<ELFT>();
return;
}

diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 8fe36eca6a4b..b9564f2184c3 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -130,7 +130,7 @@ template <class ELFT> RelsOrRelas<ELFT> InputSectionBase::relsOrRelas() const {
return {};
RelsOrRelas<ELFT> ret;
typename ELFT::Shdr shdr =
- cast<ELFFileBase>(file)->getELFShdrs<ELFT>()[relSecIdx];
+ cast<ELFFileBase>(file)->template getELFShdrs<ELFT>()[relSecIdx];
if (shdr.sh_type == SHT_REL) {
ret.rels = makeArrayRef(reinterpret_cast<const typename ELFT::Rel *>(
file->mb.getBufferStart() + shdr.sh_offset),
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index b359c2e7bcea..812d38ca81de 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -3360,7 +3360,7 @@ template <class ELFT> void elf::splitSections() {
if (auto *s = dyn_cast<MergeInputSection>(sec))
s->splitIntoPieces();
else if (auto *eh = dyn_cast<EhInputSection>(sec))
- eh->split<ELFT>();
+ eh->template split<ELFT>();
}
});
}
--
2.38.1

25 changes: 25 additions & 0 deletions L/LLVM/LLVM_full@16/bundled/patches/0704-no-codesign.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 811bde347d425929813cbf40620f497b924c2c45 Mon Sep 17 00:00:00 2001
From: Valentin Churavy <v.churavy@gmail.com>
Date: Tue, 8 Nov 2022 19:52:32 -0500
Subject: [PATCH] no codesign

---
compiler-rt/cmake/Modules/AddCompilerRT.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 00bb892be595..98956b2e1a22 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -416,7 +416,7 @@ function(add_compiler_rt_runtime name type)
if (NEED_EXPLICIT_ADHOC_CODESIGN)
add_custom_command(TARGET ${libname}
POST_BUILD
- COMMAND codesign --sign - $<TARGET_FILE:${libname}>
+ # COMMAND codesign --sign - $<TARGET_FILE:${libname}>
WORKING_DIRECTORY ${COMPILER_RT_OUTPUT_LIBRARY_DIR}
)
endif()
--
2.38.1

7 changes: 7 additions & 0 deletions L/LLVM/LLVM_full_assert@16/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version = v"16.0.6"

include("../common.jl")

build_tarballs(ARGS, configure_build(ARGS, version; assert=true, experimental_platforms=true)...;
preferred_gcc_version=v"13", preferred_llvm_version=v"16", julia_compat="1.10")
# It's building time!!
1 change: 1 addition & 0 deletions L/LLVM/LLVM_full_assert@16/bundled
46 changes: 33 additions & 13 deletions L/LLVM/common.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LLVMBuilder -- reliable LLVM builds all the time.
using BinaryBuilder, Pkg, LibGit2
using BinaryBuilderBase: get_addable_spec, sanitize
using BinaryBuilderBase: get_addable_spec, sanitize, proc_family

# Everybody is just going to use the same set of platforms

Expand All @@ -16,12 +16,17 @@ const llvm_tags = Dict(
v"13.0.1" => "8a2ae8c8064a0544814c6fac7dd0c4a9aa29a7e6", # julia-13.0.1-3
v"14.0.6" => "5c82f5309b10fab0adf6a94969e0dddffdb3dbce", # julia-14.0.6-3
v"15.0.7" => "e010657e399d312a9440732a8a67125ecd0e2298", # julia-15.0.7-7
v"16.0.6" => "47769d362cb27243a60b02167df0d23a2dfa1e25", # julia-16.0.6-0
)

const buildscript = raw"""
# We want to exit the program if errors occur.
set -o errexit

# Increase max file descriptors
fd_lim=$(ulimit -n -H)
ulimit -n $fd_lim

if [[ ("${target}" == x86_64-apple-darwin*) && ! -z "${LLVM_UPDATE_MAC_SDK}" ]]; then
# LLVM 15 requires macOS SDK 10.14, see
# <https://github.com/JuliaPackaging/Yggdrasil/pull/5592#issuecomment-1309525112> and
Expand Down Expand Up @@ -139,9 +144,9 @@ mkdir ${WORKSPACE}/build && cd ${WORKSPACE}/build

# Accumulate these flags outside CMAKE_FLAGS,
# they will be added at the end.
CMAKE_CPP_FLAGS=""
CMAKE_CXX_FLAGS=""
CMAKE_C_FLAGS=""
CMAKE_CPP_FLAGS=()
CMAKE_CXX_FLAGS=()
CMAKE_C_FLAGS=()

CMAKE_FLAGS=()

Expand All @@ -152,7 +157,12 @@ if [[ "${ASSERTS}" == "1" ]]; then
fi

# build for our host arch and our GPU targets NVidia and AMD
TARGETS=(host NVPTX AMDGPU)
TARGETS=(host)

if [[ "${target}" != *-apple-darwin* ]]; then
TARGETS+=(AMDGPU NVPTX)
fi

# Add WASM and BPF for LLVM >6
if [[ "${LLVM_MAJ_VER}" != "6" ]]; then
TARGETS+=(WebAssembly BPF AVR)
Expand All @@ -162,6 +172,7 @@ CMAKE_FLAGS+=(-DLLVM_TARGETS_TO_BUILD:STRING=$LLVM_TARGETS)

# We mostly care about clang and LLVM
PROJECTS=(llvm clang clang-tools-extra compiler-rt lld)
# Note: we disable building MLIR dylib on 32-bit archs because of <https://github.com/llvm/llvm-project/issues/61581>.
if [[ ("${LLVM_MAJ_VER}" -eq "12" && "${LLVM_PATCH_VER}" -gt "0") || "${LLVM_MAJ_VER}" -gt "12" ]]; then
PROJECTS+=(mlir)
fi
Expand Down Expand Up @@ -201,10 +212,10 @@ if [ ! -z "${LLVM_WANT_EH_RTTI}" ]; then
CMAKE_FLAGS+=(-DLLVM_ENABLE_RTTI=ON)
CMAKE_FLAGS+=(-DLLVM_ENABLE_EH=ON)
fi

if [[ "${bb_full_target}" != *sanitize* && ( "${target}" == *linux* || "${target}" == *mingw* ) ]]; then
# Change this to check if we are building with clang?
if [[ "${bb_full_target}" != *sanitize* && ( "${target}" == *linux* ) ]]; then
# https://bugs.llvm.org/show_bug.cgi?id=48221
CMAKE_CXX_FLAGS+="-fno-gnu-unique"
CMAKE_CXX_FLAGS+=(-fno-gnu-unique)
fi

# Install things into $prefix, and make sure it knows we're cross-compiling
Expand Down Expand Up @@ -254,7 +265,13 @@ if [[ "${LLVM_MAJ_VER}" -gt "14" ]]; then
fi

# Explicitly use our cmake toolchain file
CMAKE_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN})
# Windows runs out of symbols so use clang which can do some fancy things
if [[ "${target}" == *mingw* ]]; then
CMAKE_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN%.*}_clang.cmake)
else
CMAKE_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN})
fi


# Manually set the host triplet, as otherwise on some platforms it tries to guess using
# `ld -v`, which is hilariously wrong.
Expand All @@ -271,13 +288,13 @@ if [[ "${target}" == *apple* ]]; then
else
CMAKE_FLAGS+=(-DDARWIN_macosx_OVERRIDE_SDK_VERSION:STRING=10.8)
fi

CMAKE_FLAGS+=(-DSANITIZER_MIN_OSX_VERSION="${MACOSX_DEPLOYMENT_TARGET}")
# We need to link against libc++ on OSX
CMAKE_FLAGS+=(-DLLVM_ENABLE_LIBCXX=ON)

CMAKE_FLAGS+=(-DCOMPILER_RT_ENABLE_IOS=OFF)
CMAKE_FLAGS+=(-DCOMPILER_RT_ENABLE_WATCHOS=OFF)
CMAKE_FLAGS+=(-DCOMPILER_RT_ENABLE_TVOS=OFF)
CMAKE_FLAGS+=(-DCOMPILER_RT_ENABLE_MACCATALYST=OFF)

# If we're building for Apple, CMake gets confused with `aarch64-apple-darwin` and instead prefers
# `arm64-apple-darwin`. If this issue persists, we may have to change our triplet printing.
Expand All @@ -299,7 +316,10 @@ if [[ "${target}" == *apple* ]] || [[ "${target}" == *freebsd* ]]; then
fi

if [[ "${target}" == *mingw* ]]; then
CMAKE_CPP_FLAGS="${CMAKE_CPP_FLAGS} -remap -D__USING_SJLJ_EXCEPTIONS__ -D__CRT__NO_INLINE"
CMAKE_CPP_FLAGS+=(-remap -D__USING_SJLJ_EXCEPTIONS__ -D__CRT__NO_INLINE -pthread -DMLIR_CAPI_ENABLE_WINDOWS_DLL_DECLSPEC)
CMAKE_C_FLAGS+=(-pthread -DMLIR_CAPI_ENABLE_WINDOWS_DLL_DECLSPEC)
CMAKE_FLAGS+=(-DLLVM_USE_LINKER=lld)
CMAKE_FLAGS+=(-DCOMPILER_RT_BUILD_SANITIZERS=OFF)
# Windows is case-insensitive and some dependencies take full advantage of that
echo "BaseTsd.h basetsd.h" >> /opt/${target}/${target}/include/header.gcc
CMAKE_FLAGS+=(-DCLANG_INCLUDE_TESTS=OFF)
Expand Down Expand Up @@ -327,7 +347,7 @@ CMAKE_FLAGS+=(-DCMAKE_C_COMPILER_TARGET=${CMAKE_TARGET})
CMAKE_FLAGS+=(-DCMAKE_CXX_COMPILER_TARGET=${CMAKE_TARGET})
CMAKE_FLAGS+=(-DCMAKE_ASM_COMPILER_TARGET=${CMAKE_TARGET})

cmake -GNinja ${LLVM_SRCDIR} ${CMAKE_FLAGS[@]} -DCMAKE_CXX_FLAGS="${CMAKE_CPP_FLAGS} ${CMAKE_CXX_FLAGS}" -DCMAKE_C_FLAGS="${CMAKE_CPP_FLAGS} ${CMAKE_CXX_FLAGS}"
cmake -GNinja ${LLVM_SRCDIR} ${CMAKE_FLAGS[@]} -DCMAKE_CXX_FLAGS=\"${CMAKE_CPP_FLAGS[*]} ${CMAKE_CXX_FLAGS[*]}\" -DCMAKE_C_FLAGS=\"${CMAKE_C_FLAGS[*]}\"
ninja -j${nproc} -vv

# Install!
Expand Down