python3Packages.sipsimple: Fix build on aarch64 (#433120)

authored by Cosima Neidahl and committed by GitHub 8e76c562 ff58b6fb

+308 -5
+23 -5
pkgs/development/python-modules/sipsimple/default.nix
··· 30 30 url = "https://github.com/pjsip/pjproject/archive/${version}.tar.gz"; 31 31 hash = "sha256-k2pMW5hgG1IyVGOjl93xGrQQbGp7BPjcfN03fvu1l94="; 32 32 }; 33 + patches = [ 34 + # Backported https://github.com/pjsip/pjproject/commit/4a8d180529d6ffb0760838b1f8cadc4cb5f7ac03 35 + ./pjsip-0001-NEON.patch 36 + 37 + # Backported https://github.com/pjsip/pjproject/commit/f56fd48e23982c47f38574a3fd93ebf248ef3762 38 + ./pjsip-0002-RISC-V.patch 39 + 40 + # Backported https://github.com/pjsip/pjproject/commit/f94b18ef6e0c0b5d34eb274f85ac0a3b2cf9107a 41 + ./pjsip-0003-LoongArch64.patch 42 + ]; 33 43 }; 34 44 zrtpcpp = rec { 35 45 # Hardcoded in get_dependencies.sh, NOT checked at buildtime ··· 42 52 }; 43 53 }; 44 54 }; 55 + 56 + applyPatchesWhenAvailable = 57 + extDep: dir: 58 + lib.optionalString (extDep ? patches) ( 59 + lib.strings.concatMapStringsSep "\n" (patch: '' 60 + echo "Applying patch ${patch}" 61 + patch -p1 -d ${dir} < ${patch} 62 + '') extDep.patches 63 + ); 45 64 in 46 65 buildPythonPackage rec { 47 66 pname = "python3-sipsimple"; ··· 102 121 cp -r --no-preserve=all ${passthru.extDeps.zrtpcpp.src} deps/ZRTPCPP 103 122 104 123 bash ./get_dependencies.sh 105 - 124 + '' 125 + + applyPatchesWhenAvailable extDeps.pjsip "deps/pjsip" 126 + + applyPatchesWhenAvailable extDeps.zrtpcpp "deps/ZRTPCPP" 127 + + '' 106 128 # Fails to link some static libs due to missing -lc DSO. Just use the compiler frontend instead of raw ld. 107 129 substituteInPlace deps/pjsip/build/rules.mak \ 108 130 --replace-fail '$(LD)' "$CC" ··· 128 150 license = lib.licenses.gpl3Plus; 129 151 teams = [ lib.teams.ngi ]; 130 152 maintainers = [ lib.maintainers.ethancedwards8 ]; 131 - badPlatforms = [ 132 - # ../../webrtc/src/webrtc//modules/audio_processing/aec/aec_core_sse2.c:15:10: fatal error: emmintrin.h: No such file or directory 133 - "aarch64-linux" 134 - ]; 135 153 }; 136 154 }
+133
pkgs/development/python-modules/sipsimple/pjsip-0001-NEON.patch
··· 1 + From c18466834e4f845dfc9383c6944a72f31a78fafc Mon Sep 17 00:00:00 2001 2 + From: Andrey <loukhnov@lotes-tm.ru> 3 + Date: Thu, 14 Nov 2024 05:51:54 +0300 4 + Subject: [PATCH 1/3] Correct cpu features detection during cross-compiation 5 + (#4151) 6 + 7 + --- 8 + aconfigure | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 9 + aconfigure.ac | 35 ++++++++++++++++++++++++++++++++--- 10 + 2 files changed, 77 insertions(+), 6 deletions(-) 11 + 12 + diff --git a/aconfigure b/aconfigure 13 + index 57716969d..eac120472 100755 14 + --- a/aconfigure 15 + +++ b/aconfigure 16 + @@ -8997,6 +8997,36 @@ $as_echo "Checking if libyuv is disabled...no" >&6; } 17 + fi 18 + 19 + 20 + +SAVED_CFLAGS="$CFLAGS" 21 + +case $target_cpu in 22 + + arm*) 23 + + CFLAGS="-mfpu=neon $CFLAGS" 24 + + ;; 25 + + aarch64*) 26 + + CFLAGS="-march=armv8-a+simd $CFLAGS" 27 + + ;; 28 + +esac 29 + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 30 + +/* end confdefs.h. */ 31 + + 32 + +int 33 + +main (void) 34 + +{ 35 + + 36 + + ; 37 + + return 0; 38 + +} 39 + +_ACEOF 40 + +if ac_fn_c_try_compile "$LINENO" 41 + +then : 42 + + ax_cv_support_neon_ext=yes 43 + +else $as_nop 44 + + ax_cv_support_neon_ext=no 45 + + 46 + +fi 47 + +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext 48 + +CFLAGS="$SAVED_CFLAGS" 49 + + 50 + 51 + 52 + 53 + @@ -9064,9 +9094,21 @@ $as_echo "Checking if libwebrtc is disabled...no" >&6; } 54 + ;; 55 + *win32* | *w32* | *darwin* | *linux*) 56 + case $target in 57 + - armv7l*gnueabihf) 58 + - ac_webrtc_instset=neon 59 + - ac_webrtc_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon" 60 + + arm*gnueabihf) 61 + + if test "x$ax_cv_support_neon_ext" = "xyes"; then 62 + + ac_webrtc_instset=neon 63 + + ac_webrtc_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon" 64 + + else 65 + + ac_webrtc_instset=generic 66 + + fi 67 + + ;; 68 + + aarch64*) 69 + + if test "x$ax_cv_support_neon_ext" = "xyes"; then 70 + + ac_webrtc_instset=neon 71 + + ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64" 72 + + else 73 + + ac_webrtc_instset=generic 74 + + fi 75 + ;; 76 + arm-apple-darwin*) 77 + ac_webrtc_instset=neon 78 + diff --git a/aconfigure.ac b/aconfigure.ac 79 + index 48ff9f18e..fc472c7de 100644 80 + --- a/aconfigure.ac 81 + +++ b/aconfigure.ac 82 + @@ -2057,6 +2057,23 @@ AC_ARG_ENABLE(libyuv, 83 + AC_MSG_RESULT([Checking if libyuv is disabled...no])) 84 + 85 + 86 + +dnl proper neon detector 87 + +SAVED_CFLAGS="$CFLAGS" 88 + +case $target_cpu in 89 + + arm*) 90 + + CFLAGS="-mfpu=neon $CFLAGS" 91 + + ;; 92 + + aarch64*) 93 + + CFLAGS="-march=armv8-a+simd $CFLAGS" 94 + + ;; 95 + +esac 96 + +AC_COMPILE_IFELSE( 97 + + [AC_LANG_PROGRAM()], 98 + + [ax_cv_support_neon_ext=yes], 99 + + [ax_cv_support_neon_ext=no] 100 + +) 101 + +CFLAGS="$SAVED_CFLAGS" 102 + + 103 + dnl # Include webrtc 104 + AC_SUBST(ac_no_webrtc) 105 + AC_SUBST(ac_webrtc_instset) 106 + @@ -2121,9 +2138,21 @@ AC_ARG_ENABLE(libwebrtc, 107 + ;; 108 + *win32* | *w32* | *darwin* | *linux*) 109 + case $target in 110 + - armv7l*gnueabihf) 111 + - ac_webrtc_instset=neon 112 + - ac_webrtc_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon" 113 + + arm*gnueabihf) 114 + + if test "x$ax_cv_support_neon_ext" = "xyes"; then 115 + + ac_webrtc_instset=neon 116 + + ac_webrtc_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon" 117 + + else 118 + + ac_webrtc_instset=generic 119 + + fi 120 + + ;; 121 + + aarch64*) 122 + + if test "x$ax_cv_support_neon_ext" = "xyes"; then 123 + + ac_webrtc_instset=neon 124 + + ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64" 125 + + else 126 + + ac_webrtc_instset=generic 127 + + fi 128 + ;; 129 + *) 130 + ac_webrtc_instset=sse2 131 + -- 132 + 2.50.1 133 +
+96
pkgs/development/python-modules/sipsimple/pjsip-0002-RISC-V.patch
··· 1 + From da5a961150fc20e48fb83ec3a279266600f47472 Mon Sep 17 00:00:00 2001 2 + From: Guoguo <16666742+imguoguo@users.noreply.github.com> 3 + Date: Tue, 12 Aug 2025 16:08:22 +0200 4 + Subject: [PATCH 2/3] Fix build failure on RISC-V architecture (#4173) 5 + 6 + --- 7 + aconfigure | 3 +++ 8 + aconfigure.ac | 3 +++ 9 + config.guess | 3 +++ 10 + config.sub | 2 ++ 11 + third_party/webrtc/src/webrtc/typedefs.h | 7 +++++++ 12 + 5 files changed, 18 insertions(+) 13 + 14 + diff --git a/aconfigure b/aconfigure 15 + index eac120472..09cd7b901 100755 16 + --- a/aconfigure 17 + +++ b/aconfigure 18 + @@ -9114,6 +9114,9 @@ $as_echo "Checking if libwebrtc is disabled...no" >&6; } 19 + ac_webrtc_instset=neon 20 + ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64" 21 + ;; 22 + + riscv*) 23 + + ac_webrtc_instset=generic 24 + + ;; 25 + *) 26 + ac_webrtc_instset=sse2 27 + ;; 28 + diff --git a/aconfigure.ac b/aconfigure.ac 29 + index fc472c7de..81be8ed7b 100644 30 + --- a/aconfigure.ac 31 + +++ b/aconfigure.ac 32 + @@ -2154,6 +2154,9 @@ AC_ARG_ENABLE(libwebrtc, 33 + ac_webrtc_instset=generic 34 + fi 35 + ;; 36 + + riscv*) 37 + + ac_webrtc_instset=generic 38 + + ;; 39 + *) 40 + ac_webrtc_instset=sse2 41 + ;; 42 + diff --git a/config.guess b/config.guess 43 + index aa04f04bd..b6f948fdc 100755 44 + --- a/config.guess 45 + +++ b/config.guess 46 + @@ -979,6 +979,9 @@ EOF 47 + ppc:Linux:*:*) 48 + echo powerpc-unknown-linux-gnu 49 + exit ;; 50 + + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) 51 + + echo ${UNAME_MACHINE}-unknown-linux-gnu 52 + + exit ;; 53 + s390:Linux:*:* | s390x:Linux:*:*) 54 + echo ${UNAME_MACHINE}-ibm-linux 55 + exit ;; 56 + diff --git a/config.sub b/config.sub 57 + index a92e84680..3117281cb 100755 58 + --- a/config.sub 59 + +++ b/config.sub 60 + @@ -304,6 +304,7 @@ case $basic_machine in 61 + | pdp10 | pdp11 | pj | pjl \ 62 + | powerpc | powerpc64 | powerpc64le | powerpcle \ 63 + | pyramid \ 64 + + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ 65 + | rl78 | rx \ 66 + | score \ 67 + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ 68 + @@ -419,6 +420,7 @@ case $basic_machine in 69 + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ 70 + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ 71 + | pyramid-* \ 72 + + | riscv-* | riscv32-* | riscv32be-* | riscv64-* | riscv64be-* \ 73 + | rl78-* | romp-* | rs6000-* | rx-* \ 74 + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ 75 + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ 76 + diff --git a/third_party/webrtc/src/webrtc/typedefs.h b/third_party/webrtc/src/webrtc/typedefs.h 77 + index 3034c7e74..d8d9813fe 100644 78 + --- a/third_party/webrtc/src/webrtc/typedefs.h 79 + +++ b/third_party/webrtc/src/webrtc/typedefs.h 80 + @@ -47,6 +47,13 @@ 81 + #elif defined(__pnacl__) 82 + #define WEBRTC_ARCH_32_BITS 83 + #define WEBRTC_ARCH_LITTLE_ENDIAN 84 + +#elif defined(__riscv) || defined(__riscv__) 85 + +#define WEBRTC_ARCH_LITTLE_ENDIAN 86 + +#if __riscv_xlen == 64 87 + +#define WEBRTC_ARCH_64_BITS 88 + +#else 89 + +#define WEBRTC_ARCH_32_BITS 90 + +#endif 91 + #else 92 + #error Please add support for your architecture in typedefs.h 93 + #endif 94 + -- 95 + 2.50.1 96 +
+56
pkgs/development/python-modules/sipsimple/pjsip-0003-LoongArch64.patch
··· 1 + From 837d5d183588bfd42fc581a415714972f758b83d Mon Sep 17 00:00:00 2001 2 + From: xiaoxiaoafeifei <zhailiangliang@loongson.cn> 3 + Date: Tue, 12 Aug 2025 16:11:35 +0200 4 + Subject: [PATCH 3/3] Add support for the LoongArch64 architecture (#4386) 5 + 6 + --- 7 + aconfigure | 3 +++ 8 + aconfigure.ac | 3 +++ 9 + third_party/webrtc/src/webrtc/typedefs.h | 3 +++ 10 + 3 files changed, 9 insertions(+) 11 + 12 + diff --git a/aconfigure b/aconfigure 13 + index 09cd7b901..d551e6338 100755 14 + --- a/aconfigure 15 + +++ b/aconfigure 16 + @@ -9114,6 +9114,9 @@ $as_echo "Checking if libwebrtc is disabled...no" >&6; } 17 + ac_webrtc_instset=neon 18 + ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64" 19 + ;; 20 + + loongarch*) 21 + + ac_webrtc_instset=generic 22 + + ;; 23 + riscv*) 24 + ac_webrtc_instset=generic 25 + ;; 26 + diff --git a/aconfigure.ac b/aconfigure.ac 27 + index 81be8ed7b..cb4552ab5 100644 28 + --- a/aconfigure.ac 29 + +++ b/aconfigure.ac 30 + @@ -2154,6 +2154,9 @@ AC_ARG_ENABLE(libwebrtc, 31 + ac_webrtc_instset=generic 32 + fi 33 + ;; 34 + + loongarch*) 35 + + ac_webrtc_instset=generic 36 + + ;; 37 + riscv*) 38 + ac_webrtc_instset=generic 39 + ;; 40 + diff --git a/third_party/webrtc/src/webrtc/typedefs.h b/third_party/webrtc/src/webrtc/typedefs.h 41 + index d8d9813fe..2493f77cd 100644 42 + --- a/third_party/webrtc/src/webrtc/typedefs.h 43 + +++ b/third_party/webrtc/src/webrtc/typedefs.h 44 + @@ -54,6 +54,9 @@ 45 + #else 46 + #define WEBRTC_ARCH_32_BITS 47 + #endif 48 + +#elif defined(__loongarch64) || defined(__loongarch64__) 49 + +#define WEBRTC_ARCH_LITTLE_ENDIAN 50 + +#define WEBRTC_ARCH_64_BITS 51 + #else 52 + #error Please add support for your architecture in typedefs.h 53 + #endif 54 + -- 55 + 2.50.1 56 +