1From da5a961150fc20e48fb83ec3a279266600f47472 Mon Sep 17 00:00:00 2001
2From: Guoguo <16666742+imguoguo@users.noreply.github.com>
3Date: Tue, 12 Aug 2025 16:08:22 +0200
4Subject: [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
14diff --git a/aconfigure b/aconfigure
15index 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 ;;
28diff --git a/aconfigure.ac b/aconfigure.ac
29index 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 ;;
42diff --git a/config.guess b/config.guess
43index 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 ;;
56diff --git a/config.sub b/config.sub
57index 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-* \
76diff --git a/third_party/webrtc/src/webrtc/typedefs.h b/third_party/webrtc/src/webrtc/typedefs.h
77index 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--
952.50.1
96