diff options
Diffstat (limited to 'pkgs/development/interpreters/python/cpython')
-rw-r--r-- | pkgs/development/interpreters/python/cpython/default.nix | 5 | ||||
-rw-r--r-- | pkgs/development/interpreters/python/cpython/platform-triplet-detection.patch | 295 |
2 files changed, 299 insertions, 1 deletions
diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index 4e60b15ba4cb..839ac99a7574 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -302,9 +302,12 @@ in with passthru; stdenv.mkDerivation { ./3.8/0001-On-all-posix-systems-not-just-Darwin-set-LDSHARED-if.patch # Use sysconfigdata to find headers. Fixes cross-compilation of extension modules. ./3.7/fix-finding-headers-when-cross-compiling.patch - ] ++ optionals stdenv.hostPlatform.isLoongArch64 [ + ] ++ optionals (pythonOlder "3.12") [ # https://github.com/python/cpython/issues/90656 ./loongarch-support.patch + ] ++ optionals (pythonAtLeast "3.11" && pythonOlder "3.13") [ + # backport fix for https://github.com/python/cpython/issues/95855 + ./platform-triplet-detection.patch ] ++ optionals (stdenv.hostPlatform.isMinGW) (let # https://src.fedoraproject.org/rpms/mingw-python3 mingw-patch = fetchgit { diff --git a/pkgs/development/interpreters/python/cpython/platform-triplet-detection.patch b/pkgs/development/interpreters/python/cpython/platform-triplet-detection.patch new file mode 100644 index 000000000000..ec76546f54ee --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/platform-triplet-detection.patch @@ -0,0 +1,295 @@ +diff --git a/configure.ac b/configure.ac +index ba768aea93..621ac166bd 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -936,125 +936,192 @@ cat > conftest.c <<EOF + #if defined(__ANDROID__) + # Android is not a multiarch system. + #elif defined(__linux__) ++# include <features.h> ++# if defined(__UCLIBC__) ++# error uclibc not supported ++# elif defined(__dietlibc__) ++# error dietlibc not supported ++# elif defined(__GLIBC__) ++# define LIBC gnu ++# define LIBC_X32 gnux32 ++# if defined(__ARM_PCS_VFP) ++# define LIBC_ARM gnueabihf ++# else ++# define LIBC_ARM gnueabi ++# endif ++# if defined(__loongarch__) ++# if defined(__loongarch_soft_float) ++# define LIBC_LA gnusf ++# elif defined(__loongarch_single_float) ++# define LIBC_LA gnuf32 ++# elif defined(__loongarch_double_float) ++# define LIBC_LA gnu ++# else ++# error unknown loongarch floating-point base abi ++# endif ++# endif ++# if defined(_MIPS_SIM) ++# if defined(__mips_hard_float) ++# if _MIPS_SIM == _ABIO32 ++# define LIBC_MIPS gnu ++# elif _MIPS_SIM == _ABIN32 ++# define LIBC_MIPS gnuabin32 ++# elif _MIPS_SIM == _ABI64 ++# define LIBC_MIPS gnuabi64 ++# else ++# error unknown mips sim value ++# endif ++# else ++# if _MIPS_SIM == _ABIO32 ++# define LIBC_MIPS gnusf ++# elif _MIPS_SIM == _ABIN32 ++# define LIBC_MIPS gnuabin32sf ++# elif _MIPS_SIM == _ABI64 ++# define LIBC_MIPS gnuabi64sf ++# else ++# error unknown mips sim value ++# endif ++# endif ++# endif ++# if defined(__SPE__) ++# define LIBC_PPC gnuspe ++# else ++# define LIBC_PPC gnu ++# endif ++# else ++# include <stdarg.h> ++# ifdef __DEFINED_va_list ++# define LIBC musl ++# define LIBC_X32 muslx32 ++# if defined(__ARM_PCS_VFP) ++# define LIBC_ARM musleabihf ++# else ++# define LIBC_ARM musleabi ++# endif ++# if defined(__loongarch__) ++# if defined(__loongarch_soft_float) ++# define LIBC_LA muslsf ++# elif defined(__loongarch_single_float) ++# define LIBC_LA muslf32 ++# elif defined(__loongarch_double_float) ++# define LIBC_LA musl ++# else ++# error unknown loongarch floating-point base abi ++# endif ++# endif ++# if defined(_MIPS_SIM) ++# if defined(__mips_hard_float) ++# if _MIPS_SIM == _ABIO32 ++# define LIBC_MIPS musl ++# elif _MIPS_SIM == _ABIN32 ++# define LIBC_MIPS musln32 ++# elif _MIPS_SIM == _ABI64 ++# define LIBC_MIPS musl ++# else ++# error unknown mips sim value ++# endif ++# else ++# if _MIPS_SIM == _ABIO32 ++# define LIBC_MIPS muslsf ++# elif _MIPS_SIM == _ABIN32 ++# define LIBC_MIPS musln32sf ++# elif _MIPS_SIM == _ABI64 ++# define LIBC_MIPS muslsf ++# else ++# error unknown mips sim value ++# endif ++# endif ++# endif ++# if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) ++# define LIBC_PPC muslsf ++# else ++# define LIBC_PPC musl ++# endif ++# else ++# error unknown libc ++# endif ++# endif + # if defined(__x86_64__) && defined(__LP64__) +- x86_64-linux-gnu ++ x86_64-linux-LIBC + # elif defined(__x86_64__) && defined(__ILP32__) +- x86_64-linux-gnux32 ++ x86_64-linux-LIBC_X32 + # elif defined(__i386__) +- i386-linux-gnu ++ i386-linux-LIBC + # elif defined(__aarch64__) && defined(__AARCH64EL__) + # if defined(__ILP32__) +- aarch64_ilp32-linux-gnu ++ aarch64_ilp32-linux-LIBC + # else +- aarch64-linux-gnu ++ aarch64-linux-LIBC + # endif + # elif defined(__aarch64__) && defined(__AARCH64EB__) + # if defined(__ILP32__) +- aarch64_be_ilp32-linux-gnu ++ aarch64_be_ilp32-linux-LIBC + # else +- aarch64_be-linux-gnu ++ aarch64_be-linux-LIBC + # endif + # elif defined(__alpha__) +- alpha-linux-gnu +-# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP) ++ alpha-linux-LIBC ++# elif defined(__ARM_EABI__) + # if defined(__ARMEL__) +- arm-linux-gnueabihf ++ arm-linux-LIBC_ARM + # else +- armeb-linux-gnueabihf +-# endif +-# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP) +-# if defined(__ARMEL__) +- arm-linux-gnueabi +-# else +- armeb-linux-gnueabi ++ armeb-linux-LIBC_ARM + # endif + # elif defined(__hppa__) +- hppa-linux-gnu ++ hppa-linux-LIBC + # elif defined(__ia64__) +- ia64-linux-gnu +-# elif defined(__loongarch__) +-# if defined(__loongarch_lp64) +-# if defined(__loongarch_soft_float) +- loongarch64-linux-gnusf +-# elif defined(__loongarch_single_float) +- loongarch64-linux-gnuf32 +-# elif defined(__loongarch_double_float) +- loongarch64-linux-gnu ++ ia64-linux-LIBC ++# elif defined(__loongarch__) && defined(__loongarch_lp64) ++ loongarch64-linux-LIBC_LA ++# elif defined(__m68k__) && !defined(__mcoldfire__) ++ m68k-linux-LIBC ++# elif defined(__mips__) ++# if defined(__mips_isa_rev) && (__mips_isa_rev >=6) ++# if defined(_MIPSEL) && defined(__mips64) ++ mipsisa64r6el-linux-LIBC_MIPS ++# elif defined(_MIPSEL) ++ mipsisa32r6el-linux-LIBC_MIPS ++# elif defined(__mips64) ++ mipsisa64r6-linux-LIBC_MIPS + # else +-# error unknown platform triplet ++ mipsisa32r6-linux-LIBC_MIPS + # endif + # else +-# error unknown platform triplet +-# endif +-# elif defined(__m68k__) && !defined(__mcoldfire__) +- m68k-linux-gnu +-# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) && defined(_MIPSEL) +-# if _MIPS_SIM == _ABIO32 +- mipsisa32r6el-linux-gnu +-# elif _MIPS_SIM == _ABIN32 +- mipsisa64r6el-linux-gnuabin32 +-# elif _MIPS_SIM == _ABI64 +- mipsisa64r6el-linux-gnuabi64 +-# else +-# error unknown platform triplet +-# endif +-# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) +-# if _MIPS_SIM == _ABIO32 +- mipsisa32r6-linux-gnu +-# elif _MIPS_SIM == _ABIN32 +- mipsisa64r6-linux-gnuabin32 +-# elif _MIPS_SIM == _ABI64 +- mipsisa64r6-linux-gnuabi64 +-# else +-# error unknown platform triplet +-# endif +-# elif defined(__mips_hard_float) && defined(_MIPSEL) +-# if _MIPS_SIM == _ABIO32 +- mipsel-linux-gnu +-# elif _MIPS_SIM == _ABIN32 +- mips64el-linux-gnuabin32 +-# elif _MIPS_SIM == _ABI64 +- mips64el-linux-gnuabi64 +-# else +-# error unknown platform triplet +-# endif +-# elif defined(__mips_hard_float) +-# if _MIPS_SIM == _ABIO32 +- mips-linux-gnu +-# elif _MIPS_SIM == _ABIN32 +- mips64-linux-gnuabin32 +-# elif _MIPS_SIM == _ABI64 +- mips64-linux-gnuabi64 +-# else +-# error unknown platform triplet ++# if defined(_MIPSEL) && defined(__mips64) ++ mips64el-linux-LIBC_MIPS ++# elif defined(_MIPSEL) ++ mipsel-linux-LIBC_MIPS ++# elif defined(__mips64) ++ mips64-linux-LIBC_MIPS ++# else ++ mips-linux-LIBC_MIPS ++# endif + # endif + # elif defined(__or1k__) +- or1k-linux-gnu +-# elif defined(__powerpc__) && defined(__SPE__) +- powerpc-linux-gnuspe ++ or1k-linux-LIBC + # elif defined(__powerpc64__) + # if defined(__LITTLE_ENDIAN__) +- powerpc64le-linux-gnu ++ powerpc64le-linux-LIBC + # else +- powerpc64-linux-gnu ++ powerpc64-linux-LIBC + # endif + # elif defined(__powerpc__) +- powerpc-linux-gnu ++ powerpc-linux-LIBC_PPC + # elif defined(__s390x__) +- s390x-linux-gnu ++ s390x-linux-LIBC + # elif defined(__s390__) +- s390-linux-gnu ++ s390-linux-LIBC + # elif defined(__sh__) && defined(__LITTLE_ENDIAN__) +- sh4-linux-gnu ++ sh4-linux-LIBC + # elif defined(__sparc__) && defined(__arch64__) +- sparc64-linux-gnu ++ sparc64-linux-LIBC + # elif defined(__sparc__) +- sparc-linux-gnu ++ sparc-linux-LIBC + # elif defined(__riscv) + # if __riscv_xlen == 32 +- riscv32-linux-gnu ++ riscv32-linux-LIBC + # elif __riscv_xlen == 64 +- riscv64-linux-gnu ++ riscv64-linux-LIBC + # else + # error unknown platform triplet + # endif +@@ -1102,12 +1169,7 @@ cat > conftest.c <<EOF + EOF + + if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then +- PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '` +- case "$build_os" in +- linux-musl*) +- PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'` +- ;; +- esac ++ PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | grep -v typedef | tr -d ' '` + AC_MSG_RESULT([$PLATFORM_TRIPLET]) + else + AC_MSG_RESULT([none]) |