-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
277 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
diff '--color=auto' -urN include/stddef.h include-patched/stddef.h | ||
--- include/stddef.h 2024-09-05 07:27:19.393557253 +0200 | ||
+++ include-patched/stddef.h 2024-09-05 07:55:12.109152021 +0200 | ||
@@ -430,7 +430,7 @@ | ||
use __float128 here; that is only available on some | ||
architectures, but only on i386 is extra alignment needed for | ||
__float128. */ | ||
-#ifdef __i386__ | ||
+#if defined(__i386__) && !defined(__clang__) | ||
__float128 __max_align_f128 __attribute__((__aligned__(__alignof(__float128)))); | ||
#endif | ||
} max_align_t; | ||
diff '--color=auto' -urN include/stdint-gcc.h include-patched/stdint-gcc.h | ||
--- include/stdint-gcc.h 2024-09-05 07:27:19.393557253 +0200 | ||
+++ include-patched/stdint-gcc.h 2024-09-05 07:28:40.819840459 +0200 | ||
@@ -236,26 +236,59 @@ | ||
#if (!defined __cplusplus || __cplusplus >= 201103L \ | ||
|| defined __STDC_CONSTANT_MACROS) | ||
|
||
-#undef INT8_C | ||
-#define INT8_C(c) __INT8_C(c) | ||
-#undef INT16_C | ||
-#define INT16_C(c) __INT16_C(c) | ||
-#undef INT32_C | ||
-#define INT32_C(c) __INT32_C(c) | ||
-#undef INT64_C | ||
-#define INT64_C(c) __INT64_C(c) | ||
-#undef UINT8_C | ||
-#define UINT8_C(c) __UINT8_C(c) | ||
-#undef UINT16_C | ||
-#define UINT16_C(c) __UINT16_C(c) | ||
-#undef UINT32_C | ||
-#define UINT32_C(c) __UINT32_C(c) | ||
-#undef UINT64_C | ||
-#define UINT64_C(c) __UINT64_C(c) | ||
-#undef INTMAX_C | ||
-#define INTMAX_C(c) __INTMAX_C(c) | ||
-#undef UINTMAX_C | ||
-#define UINTMAX_C(c) __UINTMAX_C(c) | ||
+/* Clang and GCC have different mechanisms for INT32_C and friends. */ | ||
+#ifdef __clang__ | ||
+# ifndef __FSTD_HDRS_C_JOIN | ||
+# define __FSTD_HDRS_C_EXPAND_JOIN(x, suffix) x ## suffix | ||
+# define __FSTD_HDRS_C_JOIN(x, suffix) __FSTD_HDRS_C_EXPAND_JOIN(x, suffix) | ||
+# endif | ||
+ | ||
+# undef INT8_C | ||
+# define INT8_C(x) __FSTD_HDRS_C_JOIN(x, __INT8_C_SUFFIX__) | ||
+# undef INT16_C | ||
+# define INT16_C(x) __FSTD_HDRS_C_JOIN(x, __INT16_C_SUFFIX__) | ||
+# undef INT32_C | ||
+# define INT32_C(x) __FSTD_HDRS_C_JOIN(x, __INT32_C_SUFFIX__) | ||
+# undef INT64_C | ||
+# define INT64_C(x) __FSTD_HDRS_C_JOIN(x, __INT64_C_SUFFIX__) | ||
+ | ||
+# undef UINT8_C | ||
+# define UINT8_C(x) __FSTD_HDRS_C_JOIN(x, __UINT8_C_SUFFIX__) | ||
+# undef UINT16_C | ||
+# define UINT16_C(x) __FSTD_HDRS_C_JOIN(x, __UINT16_C_SUFFIX__) | ||
+# undef UINT32_C | ||
+# define UINT32_C(x) __FSTD_HDRS_C_JOIN(x, __UINT32_C_SUFFIX__) | ||
+# undef UINT64_C | ||
+# define UINT64_C(x) __FSTD_HDRS_C_JOIN(x, __UINT64_C_SUFFIX__) | ||
+ | ||
+# undef INTMAX_C | ||
+# define INTMAX_C(x) __FSTD_HDRS_C_JOIN(x, __INTMAX_C_SUFFIX__) | ||
+# undef UINTMAX_C | ||
+# define UINTMAX_C(x) __FSTD_HDRS_C_JOIN(x, __UINTMAX_C_SUFFIX__) | ||
+#else | ||
+# undef INT8_C | ||
+# define INT8_C(x) __INT8_C(x) | ||
+# undef INT16_C | ||
+# define INT16_C(x) __INT16_C(x) | ||
+# undef INT32_C | ||
+# define INT32_C(x) __INT32_C(x) | ||
+# undef INT64_C | ||
+# define INT64_C(x) __INT64_C(x) | ||
+ | ||
+# undef UINT8_C | ||
+# define UINT8_C(x) __UINT8_C(x) | ||
+# undef UINT16_C | ||
+# define UINT16_C(x) __UINT16_C(x) | ||
+# undef UINT32_C | ||
+# define UINT32_C(x) __UINT32_C(x) | ||
+# undef UINT64_C | ||
+# define UINT64_C(x) __UINT64_C(x) | ||
+ | ||
+# undef INTMAX_C | ||
+# define INTMAX_C(x) __INTMAX_C(x) | ||
+# undef UINTMAX_C | ||
+# define UINTMAX_C(x) __UINTMAX_C(x) | ||
+#endif | ||
|
||
#endif /* (!defined __cplusplus || __cplusplus >= 201103L | ||
|| defined __STDC_CONSTANT_MACROS) */ | ||
diff '--color=auto' -urN include/limits.h include-patched/limits.h | ||
--- include/limits.h 2024-09-05 04:31:21.782703031 +0200 | ||
+++ include-patched/limits.h 2024-09-06 01:12:23.798468521 +0200 | ||
@@ -126,12 +126,21 @@ | ||
#if (defined __STDC_WANT_IEC_60559_BFP_EXT__ \ | ||
|| (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L)) | ||
/* TS 18661-1 / C23 widths of integer types. */ | ||
+#if defined (__clang__) | ||
+# undef CHAR_WIDTH | ||
+# define CHAR_WIDTH CHAR_BIT | ||
+# undef SCHAR_WIDTH | ||
+# define SCHAR_WIDTH CHAR_BIT | ||
+# undef UCHAR_WIDTH | ||
+# define UCHAR_WIDTH CHAR_BIT | ||
+#else | ||
# undef CHAR_WIDTH | ||
# define CHAR_WIDTH __SCHAR_WIDTH__ | ||
# undef SCHAR_WIDTH | ||
# define SCHAR_WIDTH __SCHAR_WIDTH__ | ||
# undef UCHAR_WIDTH | ||
# define UCHAR_WIDTH __SCHAR_WIDTH__ | ||
+#endif | ||
# undef SHRT_WIDTH | ||
# define SHRT_WIDTH __SHRT_WIDTH__ | ||
# undef USHRT_WIDTH | ||
@@ -144,11 +153,18 @@ | ||
# define LONG_WIDTH __LONG_WIDTH__ | ||
# undef ULONG_WIDTH | ||
# define ULONG_WIDTH __LONG_WIDTH__ | ||
+#if defined(__clang__) | ||
+# undef LLONG_WIDTH | ||
+# define LLONG_WIDTH __LLONG_WIDTH__ | ||
+# undef ULLONG_WIDTH | ||
+# define ULLONG_WIDTH __LLONG_WIDTH__ | ||
+#else | ||
# undef LLONG_WIDTH | ||
# define LLONG_WIDTH __LONG_LONG_WIDTH__ | ||
# undef ULLONG_WIDTH | ||
# define ULLONG_WIDTH __LONG_LONG_WIDTH__ | ||
#endif | ||
+#endif | ||
|
||
#if defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L | ||
/* C23 width and limit of _Bool. */ | ||
diff '--color=auto' -urN include/stdint-gcc.h include-patched/stdint-gcc.h | ||
--- include/stdint-gcc.h 2024-09-06 00:26:21.287515779 +0200 | ||
+++ include-patched/stdint-gcc.h 2024-09-06 01:05:07.176103182 +0200 | ||
@@ -215,7 +215,7 @@ | ||
#undef SIG_ATOMIC_MAX | ||
#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__ | ||
#undef SIG_ATOMIC_MIN | ||
-#define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__ | ||
+#define SIG_ATOMIC_MIN (-SIG_ATOMIC_MAX - 1) | ||
|
||
#undef SIZE_MAX | ||
#define SIZE_MAX __SIZE_MAX__ | ||
@@ -223,12 +223,12 @@ | ||
#undef WCHAR_MAX | ||
#define WCHAR_MAX __WCHAR_MAX__ | ||
#undef WCHAR_MIN | ||
-#define WCHAR_MIN __WCHAR_MIN__ | ||
+#define WCHAR_MIN (-WCHAR_MAX - 1) | ||
|
||
#undef WINT_MAX | ||
#define WINT_MAX __WINT_MAX__ | ||
#undef WINT_MIN | ||
-#define WINT_MIN __WINT_MIN__ | ||
+#define WINT_MIN (-WINT_MAX - 1) | ||
|
||
#endif /* (!defined __cplusplus || __cplusplus >= 201103L | ||
|| defined __STDC_LIMIT_MACROS) */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#! /bin/sh | ||
|
||
set -ex | ||
|
||
srcdir="$(dirname "$0")" | ||
test -z "$srcdir" && srcdir=. | ||
srcdir="$(cd "${srcdir}" && pwd -P)" | ||
|
||
cd "$srcdir" | ||
|
||
if [ -z "$TARGET" ]; then | ||
set +x | ||
echo "TARGET not specified" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$BINUTILSVERSION" ]; then | ||
BINUTILSVERSION=2.43.1 | ||
fi | ||
|
||
if [ -z "$GCCVERSION" ]; then | ||
GCCVERSION=14.2.0 | ||
fi | ||
|
||
if command -v gmake; then | ||
export MAKE=gmake | ||
else | ||
export MAKE=make | ||
fi | ||
|
||
if command -v gtar; then | ||
export TAR=gtar | ||
else | ||
export TAR=tar | ||
fi | ||
|
||
if [ -z "$CFLAGS" ]; then | ||
export CFLAGS="-O2 -pipe" | ||
fi | ||
|
||
unset CC | ||
unset CXX | ||
|
||
if [ "$(uname)" = "OpenBSD" ]; then | ||
# OpenBSD has an awfully ancient GCC which fails to build our toolchain. | ||
# Force clang/clang++. | ||
export CC="clang" | ||
export CXX="clang++" | ||
fi | ||
|
||
mkdir -p toolchain && cd toolchain | ||
PREFIX="$(pwd -P)" | ||
|
||
export MAKEFLAGS="-j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || psrinfo -tc 2>/dev/null || echo 1)" | ||
|
||
export PATH="$PREFIX/bin:$PATH" | ||
|
||
if [ ! -f binutils-$BINUTILSVERSION.tar.gz ]; then | ||
curl -o binutils-$BINUTILSVERSION.tar.gz https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILSVERSION.tar.gz | ||
fi | ||
if [ ! -f gcc-$GCCVERSION.tar.gz ]; then | ||
curl -o gcc-$GCCVERSION.tar.gz https://ftp.gnu.org/gnu/gcc/gcc-$GCCVERSION/gcc-$GCCVERSION.tar.gz | ||
fi | ||
|
||
rm -rf build | ||
mkdir build | ||
cd build | ||
|
||
$TAR -zxf ../binutils-$BINUTILSVERSION.tar.gz | ||
$TAR -zxf ../gcc-$GCCVERSION.tar.gz | ||
|
||
cd binutils-$BINUTILSVERSION | ||
# Apply patches, if any | ||
for patch in "${srcdir}"/toolchain-patches/binutils/*; do | ||
[ "${patch}" = "${srcdir}/toolchain-patches/binutils/*" ] && break | ||
patch -p1 < "${patch}" | ||
done | ||
cd .. | ||
mkdir build-binutils | ||
cd build-binutils | ||
../binutils-$BINUTILSVERSION/configure CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror | ||
$MAKE | ||
$MAKE install | ||
cd .. | ||
|
||
cd gcc-$GCCVERSION | ||
# Apply patches, if any | ||
for patch in "${srcdir}"/toolchain-patches/gcc/*; do | ||
[ "${patch}" = "${srcdir}/toolchain-patches/gcc/*" ] && break | ||
patch -p1 < "${patch}" | ||
done | ||
sed 's|http://gcc.gnu|https://gcc.gnu|g' < contrib/download_prerequisites > dp.sed | ||
mv dp.sed contrib/download_prerequisites | ||
chmod +x contrib/download_prerequisites | ||
./contrib/download_prerequisites --no-verify | ||
cd .. | ||
mkdir build-gcc | ||
cd build-gcc | ||
../gcc-$GCCVERSION/configure CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers | ||
$MAKE all-gcc | ||
$MAKE all-target-libgcc | ||
$MAKE install-gcc | ||
$MAKE install-target-libgcc | ||
cd .. | ||
|
||
mkdir build-libstdcxx | ||
cd build-libstdcxx | ||
ac_cv_func_getexecname=no ac_cv_func_fcntl=no ../gcc-$GCCVERSION/libstdc++-v3/configure --host=$TARGET --prefix="$PREFIX" --disable-nls --disable-tls --disable-multilib --disable-hosted-libstdcxx --disable-libstdcxx-verbose --disable-libstdcxx-threads --disable-libstdcxx-filesystem-ts --disable-libstdcxx-backtrace --without-headers | ||
$MAKE install-data | ||
cd .. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.