summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--etc/patches/TARGETS1
-rw-r--r--etc/patches/clang-19/libcxx-musl-support.patch57
-rw-r--r--etc/repos.json58
-rw-r--r--src/compilers/clang-19-native.TARGETS282
5 files changed, 403 insertions, 2 deletions
diff --git a/README.md b/README.md
index 55a5775..9a2b60c 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,7 @@ Available compiler toolchains are:
- `gcc-14.2.0-native`
- `gcc-13.3.0-native`
- `clang-latest-native`
+- `clang-19.1.1-native`
- `clang-18.1.8-native`
- `clang-17.0.6-native`
- `clang-16.0.6-native`
@@ -177,7 +178,11 @@ Fields for building the toolchains:
it can be avoided that the autotools draw wrong conclusions from calling the
compiler without the specified flags (as some tests do).
- `INCLUDE_LINTER`:
- Add linter to toolchain if supported, e.g., `clang-tidy` (default: `false`)
+ Add linter to toolchain if supported. (default: `false`)
+ Currently this option is only supported by `clang` toolchains, adding
+ `clang-tidy`. Additionally, Clang versions `18` and `19` will also include
+ the *external project*
+ [Include What You Use](https://github.com/include-what-you-use/include-what-you-use).
Fields for using the toolchains
(within [Justbuild](https://github.com/just-buildsystem/justbuild) projects):
diff --git a/etc/patches/TARGETS b/etc/patches/TARGETS
index 6eab87b..f52388c 100644
--- a/etc/patches/TARGETS
+++ b/etc/patches/TARGETS
@@ -7,4 +7,5 @@
, "clang-16": {"type": "install", "deps": [["TREE", null, "clang-16"]]}
, "clang-17": {"type": "install", "deps": [["TREE", null, "clang-17"]]}
, "clang-18": {"type": "install", "deps": [["TREE", null, "clang-18"]]}
+, "clang-19": {"type": "install", "deps": [["TREE", null, "clang-19"]]}
}
diff --git a/etc/patches/clang-19/libcxx-musl-support.patch b/etc/patches/clang-19/libcxx-musl-support.patch
new file mode 100644
index 0000000..f19a221
--- /dev/null
+++ b/etc/patches/clang-19/libcxx-musl-support.patch
@@ -0,0 +1,57 @@
+From cfceef12ffa2963ffc32a0e2797dfc7e5ff7a2ac Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 20 Mar 2025 12:05:42 +0200
+Subject: [PATCH] libcxx: Add musl support for __locale
+
+... which does not provide a known rune table and uses
+missing locale-based string to integer conversion functions.
+---
+ libcxx/include/__locale | 32 ++++++++++++++++++++++++++++++++
+ 1 file changed, 32 insertions(+)
+
+diff --git a/libcxx/include/__locale b/libcxx/include/__locale
+index 3ba7ac1..98563b6 100644
+--- a/libcxx/include/__locale
++++ b/libcxx/include/__locale
+@@ -27,6 +27,38 @@
+ #include <cstddef>
+ #include <cstring>
+
++// Detect musl libc (inspired by musl detection from gcc's config.guess)
++#include <features.h>
++#if !(defined(__UCLIBC__) || defined(__dietlibc__) || defined(__GLIBC__))
++# include <stdarg.h>
++# ifdef __DEFINED_va_list
++# ifndef __MUSL_LIBC__
++# define __MUSL_LIBC__
++# endif
++# endif
++#endif
++
++#ifdef __MUSL_LIBC__
++// Fall back to default rune table for musl libc
++# ifndef _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
++# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
++# endif
++// Implement missing strto*_l functions for musl libc
++# define __MUSL_LIBC_CREATE_STRTOX_L(X) \
++ static inline auto \
++ strto ## X ## _l(const char* str, char** end, int base, locale_t l) { \
++ locale_t old = uselocale(l); \
++ auto result = strto ## X(str, end, base); \
++ uselocale(old); \
++ return result; \
++ }
++__MUSL_LIBC_CREATE_STRTOX_L(l)
++__MUSL_LIBC_CREATE_STRTOX_L(ll)
++__MUSL_LIBC_CREATE_STRTOX_L(ul)
++__MUSL_LIBC_CREATE_STRTOX_L(ull)
++# undef __MUSL_LIBC_CREATE_STRTOX_L
++#endif
++
+ #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ # include <cwchar>
+ #else
+--
+2.30.2
+
diff --git a/etc/repos.json b/etc/repos.json
index c5d338f..dab8c31 100644
--- a/etc/repos.json
+++ b/etc/repos.json
@@ -80,6 +80,19 @@
, "stage-0": "rules/stage-0"
}
}
+ , "rules/clang_with_gcc14":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "clang.TARGETS"
+ , "rule_root": "rules"
+ , "bindings":
+ { "base": "rules/gcc"
+ , "gcc": "compilers/gcc-14.2.0-native"
+ , "cmake": "cmake-3.27.1"
+ , "python": "python-3.12.0"
+ , "stage-0": "rules/stage-0"
+ }
+ }
, "rules/tools":
{ "repository": "rules"
, "target_root": "defaults"
@@ -479,6 +492,24 @@
, "iwyu": "iwyu-18"
}
}
+ , "compilers/clang-19.1.1-native":
+ { "repository":
+ { "type": "archive"
+ , "content": "6fbd4ba1578adadde3ab0d215c93bbda30be61c5"
+ , "fetch": "https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-19.1.1.tar.gz"
+ , "sha256": "115dfd98a353d05bffdab3f80db22f159da48aca0124e8c416f437adcd54b77f"
+ , "subdir": "llvm-project-llvmorg-19.1.1"
+ , "pragma": {"special": "resolve-partially"}
+ }
+ , "target_root": "compilers"
+ , "target_file_name": "clang-19-native.TARGETS"
+ , "bindings":
+ { "rules": "rules/clang_with_gcc14"
+ , "binutils": "imports/binutils-latest"
+ , "patches": "patches"
+ , "iwyu": "iwyu-19"
+ }
+ }
, "tools/busybox-1.36.1":
{ "repository":
{ "type": "archive"
@@ -575,7 +606,12 @@
, "clang-latest-native":
{ "repository": "toolchains"
, "target_file_name": "clang.TARGETS"
- , "bindings": {"rules": "rules", "clang": "compilers/clang-18.1.8-native"}
+ , "bindings": {"rules": "rules", "clang": "compilers/clang-19.1.1-native"}
+ }
+ , "clang-19.1.1-native":
+ { "repository": "toolchains"
+ , "target_file_name": "clang.TARGETS"
+ , "bindings": {"rules": "rules", "clang": "compilers/clang-19.1.1-native"}
}
, "clang-18.1.8-native":
{ "repository": "toolchains"
@@ -715,6 +751,15 @@
, "compiler": "clang-latest-native"
}
}
+ , "clang-19.1.1-native+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ { "rules": "rules"
+ , "tools": "tools-all"
+ , "compiler": "clang-19.1.1-native"
+ }
+ }
, "clang-18.1.8-native+tools":
{ "repository": "toolchains"
, "target_file_name": "compiler+tools.TARGETS"
@@ -817,6 +862,17 @@
, "target_file_name": "iwyu.TARGETS"
, "target_root": "imports"
}
+ , "iwyu-19":
+ { "repository":
+ { "type": "archive"
+ , "content": "66888a7220ad0939788b49e12fe1909b68483ee7"
+ , "fetch": "https://github.com/include-what-you-use/include-what-you-use/archive/refs/tags/0.23.tar.gz"
+ , "sha256": "16672743fdf781d7db313f48c7f4b34bc6517eddfd92d7db793790fe793a306c"
+ , "subdir": "include-what-you-use-0.23"
+ }
+ , "target_file_name": "iwyu.TARGETS"
+ , "target_root": "imports"
+ }
, "patches/busybox-1593":
{ "repository":
{ "type": "foreign file"
diff --git a/src/compilers/clang-19-native.TARGETS b/src/compilers/clang-19-native.TARGETS
new file mode 100644
index 0000000..6ab96c3
--- /dev/null
+++ b/src/compilers/clang-19-native.TARGETS
@@ -0,0 +1,282 @@
+{ "toolchain":
+ { "type": "configure"
+ , "arguments_config": ["ARCH", "TARGET_ARCH", "BUILD_ARCH"]
+ , "config":
+ { "type": "if"
+ , "cond":
+ { "type": "=="
+ , "$1":
+ { "type": "var"
+ , "name": "TARGET_ARCH"
+ , "default": {"type": "var", "name": "ARCH"}
+ }
+ , "$2":
+ { "type": "var"
+ , "name": "BUILD_ARCH"
+ , "default": {"type": "var", "name": "ARCH"}
+ }
+ }
+ , "then": {"type": "empty_map"}
+ , "else":
+ { "type": "fail"
+ , "msg": "clang-native does not support cross-compilation."
+ }
+ }
+ , "target": "toolchain_native"
+ }
+, "toolchain_native":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "clang-native"
+ }
+, "runlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "libstdc++"
+ }
+, "runlibs_libcxx":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "libc++"
+ }
+, "original_sources_and_patches":
+ { "type": "install"
+ , "dirs":
+ [ [["TREE", null, "."], "src"]
+ , [["@", "patches", "", "clang-19"], "patches"]
+ ]
+ }
+, "patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["original_sources_and_patches"]
+ , "cmds":
+ [ "cp -r src/. ${DESTDIR}/."
+ , "cd ${DESTDIR}"
+ , "chmod -R +w *"
+ , "patch -p1 < ${WORKDIR}/patches/clang-19/libcxx-musl-support.patch >/dev/null"
+ ]
+ , "out_dirs": ["."]
+ }
+, "binutils_dir":
+ { "type": "install"
+ , "dirs": [[["@", "binutils", "", "binutils"], "binutils"]]
+ }
+, "clang-native":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "project": ["patched_sources"]
+ , "localbase":
+ [ "binutils_dir"
+ , ["@", "iwyu", "", "sources"]
+ ]
+ , "cmds":
+ [ { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_HDR_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_HDR_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_LIB_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_LIB_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_DYNAMIC_LINKER='"
+ , { "type": "lookup"
+ , "key": "HOST_DYNAMIC_LINKER"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , "NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "HOST_TRIPLE=$(${CC} -dumpmachine)"
+ , "GCC_TOOLCHAIN=$(dirname ${CC})/.."
+ , "export PATH=${LOCALBASE}/binutils/bin:$PATH"
+ , "export PKG_CONFIG=false"
+ , "export LD_LIBRARY_PATH=\"${GCC_TOOLCHAIN}/lib64\""
+ , "unset LDFLAGS"
+ , "CONF_ARGS="
+ , "INCL_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_HDR_DIR\" ]; then"
+ , " CONF_ARGS=\"-DC_INCLUDE_DIRS=$HOST_SYSTEM_HDR_DIR\""
+ , " INCL_ARGS=\"-I$HOST_SYSTEM_HDR_DIR\""
+ , "fi"
+ , "LINK_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_LIB_DIR\" ]; then"
+ , " export LIBRARY_PATH=\"$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -B$HOST_SYSTEM_LIB_DIR -L$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -Xlinker -rpath -Xlinker $HOST_SYSTEM_LIB_DIR\""
+ , "fi"
+ , "if [ -n \"$HOST_DYNAMIC_LINKER\" ]; then"
+ , " LINK_ARGS=\"$LINK_ARGS -Xlinker --dynamic-linker -Xlinker $HOST_DYNAMIC_LINKER\""
+ , "fi"
+ , "cp -r ${LOCALBASE}/binutils/. ${DESTDIR}/."
+ , "chmod -R +w ${DESTDIR}/*"
+ , "mkdir build"
+ , { "type": "join"
+ , "separator": " "
+ , "$1":
+ [ "${CMAKE}"
+ , "-B"
+ , "build"
+ , "-S"
+ , "llvm"
+ , "-DCMAKE_MAKE_PROGRAM=${MAKE}"
+ , "${CONF_ARGS}"
+ , "-DLLVM_USE_FOLDERS=OFF"
+ , "-DLLVM_INCLUDE_DOCS=OFF"
+ , "-DLLVM_INCLUDE_TESTS=OFF"
+ , "-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON"
+ , { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "INCLUDE_LINTER"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "then":
+ { "type": "join"
+ , "separator": " "
+ , "$1":
+ [ "-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra'"
+ , "-DLLVM_EXTERNAL_PROJECTS=iwyu"
+ , "-DLLVM_EXTERNAL_IWYU_SOURCE_DIR=${LOCALBASE}/iwyu"
+ ]
+ }
+ , "else": "-DLLVM_ENABLE_PROJECTS=clang"
+ }
+ , "-DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind'"
+ , "-DLLVM_TARGETS_TO_BUILD=X86"
+ , "-DLLVM_PARALLEL_LINK_JOBS=1"
+ , "-DCMAKE_BUILD_TYPE=Release"
+ , "-DCMAKE_INSTALL_PREFIX="
+ , "-DLLVM_HOST_TRIPLE=${HOST_TRIPLE}"
+ , "-DLLVM_NATIVE_TARGET=ON"
+ , "-DLIBCXXABI_ENABLE_ASSERTIONS=OFF"
+ , "-DLIBUNWIND_ENABLE_ASSERTIONS=OFF"
+ , ">configure.log 2>&1 || (cat configure.log && exit 1)"
+ ]
+ }
+ , "${CMAKE} --build build --target clang -j${NJOBS} >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "export LDFLAGS=\"--gcc-toolchain=${GCC_TOOLCHAIN} ${LINK_ARGS}\""
+ , "${CMAKE} --build build --target all -j${NJOBS} >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${CMAKE} --build build --target install -j${NJOBS} >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "cd ${DESTDIR}"
+ , "strip ./bin/* 2>/dev/null || true"
+ , "find . -type f -name '*.so*' -exec sh -c \"strip {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.a' -exec sh -c \"strip -g {}\" \\;"
+ , "find . -type f -name '*.o' -exec sh -c \"strip -g {}\" \\;"
+ , "cp -r ${GCC_TOOLCHAIN}/include/c++ ${DESTDIR}/include/."
+ , "cp -r ${GCC_TOOLCHAIN}/lib/gcc ${DESTDIR}/lib/."
+ , "cp -r ${GCC_TOOLCHAIN}/lib64/. ${DESTDIR}/lib/."
+ , "ln -s lib ${DESTDIR}/lib64"
+ , "if [ -n \"${INCL_ARGS}${LINK_ARGS}\" ]; then"
+ , " cd ${DESTDIR}/bin"
+ , " mv clang clang.real"
+ , " mv clang++ clang++.real"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/clang.real %s \"$@\"' \"${INCL_ARGS} ${LINK_ARGS}\" >clang"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/clang++.real %s \"$@\"' \"${INCL_ARGS} ${LINK_ARGS}\" >clang++"
+ , " chmod +x clang clang++"
+ , "fi"
+ ]
+ , "out_dirs": ["."]
+ }
+, "libstdc++":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libstdc++"]
+ , "lib": ["libstdc++_files"]
+ , "deps": ["libgcc_s"]
+ }
+, "libc++":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libc++"]
+ , "lib": ["libc++_files"]
+ , "deps": ["libgcc_s", "libatomic", "libc++abi", "libunwind"]
+ }
+, "libc++abi":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libc++abi"]
+ , "lib": ["libc++abi_files"]
+ }
+, "libunwind":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libunwind"]
+ , "lib": ["libunwind_files"]
+ }
+, "libgcc_s":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libgcc_s"]
+ , "lib": ["libgcc_s_files"]
+ }
+, "libatomic":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libatomic"]
+ , "lib": ["libatomic_files"]
+ }
+, "libstdc++_files":
+ { "type": ["@", "rules", "shell", "cmds"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp -L lib64/libstdc++.so.6 ."]
+ , "outs": ["libstdc++.so.6"]
+ }
+, "libc++_files":
+ { "type": ["@", "rules", "shell", "cmds"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp -L lib/$(./bin/clang -dumpmachine)/libc++.so.1 ."]
+ , "outs": ["libc++.so.1"]
+ }
+, "libc++abi_files":
+ { "type": ["@", "rules", "shell", "cmds"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp -L lib/$(./bin/clang -dumpmachine)/libc++abi.so.1 ."]
+ , "outs": ["libc++abi.so.1"]
+ }
+, "libunwind_files":
+ { "type": ["@", "rules", "shell", "cmds"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp -L lib/$(./bin/clang -dumpmachine)/libunwind.so.1 ."]
+ , "outs": ["libunwind.so.1"]
+ }
+, "libgcc_s_files":
+ { "type": ["@", "rules", "shell", "cmds"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp -L lib64/libgcc_s.so.1 ."]
+ , "outs": ["libgcc_s.so.1"]
+ }
+, "libatomic_files":
+ { "type": ["@", "rules", "shell", "cmds"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp -L lib64/libatomic.so.1 ."]
+ , "outs": ["libatomic.so.1"]
+ }
+}