added my Recipes

This commit is contained in:
2024-07-11 14:16:35 +02:00
parent 38bc4f53ac
commit 09b621d929
7118 changed files with 525762 additions and 3 deletions

View File

@@ -0,0 +1,32 @@
From bb46a8a729cc4d66ad36db40c17e36a5111f19c3 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex@linutronix.de>
Date: Fri, 1 Oct 2021 13:00:24 +0200
Subject: [PATCH] Cargo.toml: do not abort on panic
OE's rust is configured to unwind, and this setting clashes with it/
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
Cargo.toml | 2 --
1 file changed, 2 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index f576534bf3..5ecc17c319 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -56,13 +56,11 @@ opt-level = 1
rpath = false
lto = false
debug-assertions = true
-panic = "abort"
[profile.release]
opt-level = 2
rpath = false
debug-assertions = false
-panic = "abort"
# Optimize build dependencies, because bindgen and proc macros / style
# compilation take more to run than to build otherwise.

View File

@@ -0,0 +1,25 @@
Backport patch from firefox bugzilla to fix compile error for qemuarm with
some armv7ve tunes such as 'armv7vethf' and 'armv7vet-vfpv3d16':
| /path/to/build/tmp/work/armv7vet2hf-vfp-poky-linux-gnueabi/mozjs-102/102.5.0-r0/build/js/src/jit/AtomicOperationsGenerated.h:240:17:
error: 'asm' operand has impossible constraints
| 240 | asm volatile (
| | ^~~
Upstream-Status: Submitted [https://bugzilla.mozilla.org/show_bug.cgi?id=1761665]
Signed-off-by: Kai Kang <kai.kang@windriver.com>
diff --git a/js/src/jit/GenerateAtomicOperations.py b/js/src/jit/GenerateAtomicOperations.py
index d8a38a0..65f91ab 100644
--- a/js/src/jit/GenerateAtomicOperations.py
+++ b/js/src/jit/GenerateAtomicOperations.py
@@ -856,7 +856,7 @@ def generate_atomics_header(c_out):
# Work around a GCC issue on 32-bit x86 by adding MOZ_NEVER_INLINE.
# See bug 1756347.
- if is_gcc and cpu_arch == "x86":
+ if is_gcc and cpu_arch in ("x86", "arm"):
contents = contents.replace("INLINE_ATTR", "MOZ_NEVER_INLINE inline")
else:
contents = contents.replace("INLINE_ATTR", "inline")

View File

@@ -0,0 +1,29 @@
From c860dcbe63b0e393c95bfb0131238f91aaac11d3 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex@linutronix.de>
Date: Thu, 7 Oct 2021 12:44:18 +0200
Subject: [PATCH] build: do not use autoconf's config.sub to 'canonicalize'
names
The outcome is that processed names no longer match our custom rust
target definitions, and the build fails.
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
build/moz.configure/init.configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure
index 81f500a0b7..0b7a2ff60f 100644
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -585,7 +585,7 @@ def help_host_target(help, host, target):
def config_sub(shell, triplet):
config_sub = os.path.join(os.path.dirname(__file__), "..", "autoconf", "config.sub")
- return check_cmd_output(shell, config_sub, triplet).strip()
+ return triplet
@depends("--host", shell)

View File

@@ -0,0 +1,54 @@
From 8e318c4e7e732327dabf51027860de45b6fb731e Mon Sep 17 00:00:00 2001
From: Changqing Li <changqing.li@windriver.com>
Date: Thu, 18 Nov 2021 07:16:39 +0000
Subject: [PATCH] Rewrite cargo-host-linker in python3
Mozjs compile failed with this failure:
/bin/sh: /lib64/libc.so.6: version `GLIBC_2.33' not found (required by /build/tmp-glibc/work/corei7-64-wrs-linux/mozjs/91.1.0-r0/recipe-sysroot-native/usr/lib/libtinfo.so.5)
Root Cause:
cargo-host-linker has /bin/sh as it's interpreter, but cargo run the cmd
with LD_LIBRARY_PATH set to recipe-sysroot-native. The host /bin/sh links
libtinfo.so.5 under recipe-sysroot-native, which needs higher libc. But
host libc is older libc. So the incompatible problem occurred.
Solution:
rewrite cargo-host-linker in python3
Upstream-Status: Inappropriate [oe specific]
Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
build/cargo-host-linker | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/build/cargo-host-linker b/build/cargo-host-linker
index cbd0472bf7..87d43ce9ec 100755
--- a/build/cargo-host-linker
+++ b/build/cargo-host-linker
@@ -1,3 +1,21 @@
-#!/bin/sh
-# See comment in cargo-linker.
-eval ${MOZ_CARGO_WRAP_HOST_LD} ${MOZ_CARGO_WRAP_HOST_LDFLAGS} '"$@"'
+#!/usr/bin/env python3
+
+import os,sys
+
+if os.environ['MOZ_CARGO_WRAP_HOST_LD'].strip():
+ binary=os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]
+else:
+ sys.exit(0)
+
+if os.environ['MOZ_CARGO_WRAP_HOST_LDFLAGS'].strip():
+ if os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:]:
+ args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:] + [os.environ['MOZ_CARGO_WRAP_HOST_LDFLAGS']] + sys.argv[1:]
+ else:
+ args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + [os.environ['MOZ_CARGO_WRAP_HOST_LDFLAGS']] + sys.argv[1:]
+else:
+ if os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:]:
+ args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:] + sys.argv[1:]
+ else:
+ args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + sys.argv[1:]
+
+os.execvp(binary, args)

View File

@@ -0,0 +1,48 @@
From 2a6f66f39b4e623428b6d282bd4cb72dde67c1a6 Mon Sep 17 00:00:00 2001
From: Changqing Li <changqing.li@windriver.com>
Date: Thu, 11 Nov 2021 16:05:54 +0800
Subject: [PATCH] util.configure: fix one occasionally reproduced configure
failure
error:
| checking whether the C++ compiler supports -Wno-range-loop-analysis...
| DEBUG: Creating /tmp/conftest.jr1qrcw3.cpp with content:
| DEBUG: | int
| DEBUG: | main(void)
| DEBUG: | {
| DEBUG: |
| DEBUG: | ;
| DEBUG: | return 0;
| DEBUG: | }
| DEBUG: Executing: aarch64-wrs-linux-g++ -mcpu=cortex-a53 -march=armv8-a+crc -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/mozjs/91.1.0-r0/recipe-sysroot /tmp/conftest.jr1qrcw3.cpp -Werror -Wrange-loop-analysis -c
| DEBUG: The command returned non-zero exit status 1.
| DEBUG: Its error output was:
...
| File "/mozjs/91.1.0-r0/firefox-91.1.0/build/moz.configure/util.configure", line 239, in try_invoke_compiler
| os.remove(path)
| FileNotFoundError: [Errno 2] No such file or directory: '/tmp/conftest.jr1qrcw3.cpp'
It should be another process that deleted this file by using
"rm -rf conftest*" inappropriately
Upstream-Status: Submitted [https://bugzilla.mozilla.org/show_bug.cgi?id=1740667]
Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
build/moz.configure/util.configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build/moz.configure/util.configure b/build/moz.configure/util.configure
index 80c3a34522..0ac0c6b611 100644
--- a/build/moz.configure/util.configure
+++ b/build/moz.configure/util.configure
@@ -216,7 +216,7 @@ def try_invoke_compiler(compiler, language, source, flags=None, onerror=None):
"C++": ".cpp",
}[language]
- fd, path = mkstemp(prefix="conftest.", suffix=suffix, text=True)
+ fd, path = mkstemp(prefix="try_invoke_compiler_conftest.", suffix=suffix, text=True)
try:
source = source.encode("ascii", "replace")

View File

@@ -0,0 +1,44 @@
From 0133ddb86eb6e0741e02b0032c41468db6438530 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex@linutronix.de>
Date: Fri, 1 Oct 2021 13:01:10 +0200
Subject: [PATCH] moz.configure: do not look for llvm-objdump
This avoid dragging in a dependency that isn't even needed
for js builds.
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
moz.configure | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/moz.configure b/moz.configure
index fc66b520d0..15de9a2ee0 100755
--- a/moz.configure
+++ b/moz.configure
@@ -785,15 +785,15 @@
return llvm_tool
-llvm_objdump = check_prog(
- "LLVM_OBJDUMP",
- llvm_tool("llvm-objdump"),
- what="llvm-objdump",
- when="--enable-compile-environment",
- paths=clang_search_path,
-)
-
-add_old_configure_assignment("LLVM_OBJDUMP", llvm_objdump)
+#llvm_objdump = check_prog(
+# "LLVM_OBJDUMP",
+# llvm_tool("llvm-objdump"),
+# what="llvm-objdump",
+# when="--enable-compile-environment",
+# paths=clang_search_path,
+#)
+#
+#add_old_configure_assignment("LLVM_OBJDUMP", llvm_objdump)
@depends(llvm_tool("llvm-readelf"), toolchain_prefix)

View File

@@ -0,0 +1,66 @@
From 33ff25e2b126dd4135006139641d8b7f6e4da200 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex@linutronix.de>
Date: Fri, 1 Oct 2021 13:02:17 +0200
Subject: [PATCH] rust.configure: do not try to find a suitable upstream target
OE is using custom targets and so this is bound to fail.
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
build/moz.configure/rust.configure | 34 ++----------------------------
1 file changed, 2 insertions(+), 32 deletions(-)
diff --git a/build/moz.configure/rust.configure b/build/moz.configure/rust.configure
index e64dc5d5ec..edf21baca6 100644
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -471,33 +471,7 @@ def assert_rust_compile(host_or_target, rustc_target, rustc):
def rust_host_triple(
rustc, host, compiler_info, rustc_host, rust_supported_targets, arm_target
):
- rustc_target = detect_rustc_target(
- host, compiler_info, arm_target, rust_supported_targets
- )
- if rustc_target != rustc_host:
- if host.alias == rustc_target:
- configure_host = host.alias
- else:
- configure_host = "{}/{}".format(host.alias, rustc_target)
- die(
- dedent(
- """\
- The rust compiler host ({rustc}) is not suitable for the configure host ({configure}).
-
- You can solve this by:
- * Set your configure host to match the rust compiler host by editing your
- mozconfig and adding "ac_add_options --host={rustc}".
- * Or, install the rust toolchain for {configure}, if supported, by running
- "rustup default stable-{rustc_target}"
- """.format(
- rustc=rustc_host,
- configure=configure_host,
- rustc_target=rustc_target,
- )
- )
- )
- assert_rust_compile(host, rustc_target, rustc)
- return rustc_target
+ return rustc_host
@depends(
@@ -507,11 +481,7 @@ def rust_host_triple(
def rust_target_triple(
rustc, target, compiler_info, rust_supported_targets, arm_target
):
- rustc_target = detect_rustc_target(
- target, compiler_info, arm_target, rust_supported_targets
- )
- assert_rust_compile(target, rustc_target, rustc)
- return rustc_target
+ return target.alias
set_config("RUST_TARGET", rust_target_triple)

View File

@@ -0,0 +1,38 @@
From 0ec73937b01869a701ed9b60a6a84469e035ded4 Mon Sep 17 00:00:00 2001
From: Andre McCurdy <amccurdy@gmail.com>
Date: Sat, 30 Apr 2016 15:29:06 -0700
Subject: [PATCH] use <asm/sgidefs.h>
Build fix for MIPS with musl libc
The MIPS specific header <sgidefs.h> is provided by glibc and uclibc
but not by musl. Regardless of the libc, the kernel headers provide
<asm/sgidefs.h> which provides the same definitions, so use that
instead.
Upstream-Status: Pending
[Vincent:
Taken from: https://sourceware.org/bugzilla/show_bug.cgi?id=21070]
Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
---
mfbt/RandomNum.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mfbt/RandomNum.cpp b/mfbt/RandomNum.cpp
index 23381db0cd..7f127c0715 100644
--- a/mfbt/RandomNum.cpp
+++ b/mfbt/RandomNum.cpp
@@ -52,7 +52,7 @@ extern "C" BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer,
# elif defined(__s390__)
# define GETRANDOM_NR 349
# elif defined(__mips__)
-# include <sgidefs.h>
+# include <asm/sgidefs.h>
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define GETRANDOM_NR 4353
# elif _MIPS_SIM == _MIPS_SIM_ABI64

View File

@@ -0,0 +1,27 @@
From 1110483c6c06adf2d03ed9154a8957defc175c80 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 20 Oct 2021 16:21:14 -0700
Subject: [PATCH] mozjs: Fix musl miscompiles with HAVE_THREAD_TLS_KEYWORD
Upstream: No
Reason: mozjs60 miscompiles on musl if built with HAVE_THREAD_TLS_KEYWORD:
https://github.com/void-linux/void-packages/issues/2598
---
js/src/old-configure.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/js/src/old-configure.in b/js/src/old-configure.in
index 8dfd75c63d..c82e580428 100644
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -839,6 +839,9 @@ if test "$ac_cv_thread_keyword" = yes; then
*-android*|*-linuxandroid*)
:
;;
+ *-musl*)
+ :
+ ;;
*)
AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
;;

View File

@@ -0,0 +1,18 @@
Musl does not have stack unwinder like glibc therefore
we can not assume that its always available on musl, we
do need to check for target environment as well which
could be musl or glibc.
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
--- a/mozglue/misc/StackWalk.cpp
+++ b/mozglue/misc/StackWalk.cpp
@@ -44,7 +44,7 @@ using namespace mozilla;
# define MOZ_STACKWALK_SUPPORTS_MACOSX 0
#endif
-#if (defined(linux) && \
+#if (defined(linux) && defined(__GLIBC__) && \
((defined(__GNUC__) && (defined(__i386) || defined(PPC))) || \
defined(HAVE__UNWIND_BACKTRACE)))
# define MOZ_STACKWALK_SUPPORTS_LINUX 1

View File

@@ -0,0 +1,139 @@
From 1479dd9c75917d2be70ee840c9db141e59987e44 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex@linutronix.de>
Date: Wed, 14 Sep 2022 14:03:10 +0200
Subject: [PATCH] mozjs-91: backport a python 3.11 compatibility patch
# HG changeset patch
# User ahochheiden <ahochheiden@mozilla.com>
# Date 1654151264 0
# Node ID f54162b2c1f2fe52c6137ab2c3469a1944f58b27
# Parent 6e7776492240c27732840d65a33dcc440fa1aba0
Bug 1769631 - Remove 'U' from 'mode' parameters for various 'open' calls to ensure Python3.11 compatibility r=firefox-build-system-reviewers,glandium
The 'U' flag represents "universal newline". It has been deprecated
since Python3.3. Since then "universal newline" is the default when a
file is opened in text mode (not bytes). In Python3.11 using the 'U'
flag throws errors. There should be no harm in removing 'U' from 'open'
everywhere it is used, and doing allows the use of Python3.11.
For more reading see: https://docs.python.org/3.11/whatsnew/3.11.html#changes-in-the-python-api
Differential Revision: https://phabricator.services.mozilla.com/D147721
Upstream-Status: Backport [https://hg.mozilla.org/mozilla-central/rev/f54162b2c1f2fe52c6137ab2c3469a1944f58b27]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
dom/base/usecounters.py | 2 +-
python/mozbuild/mozbuild/action/process_define_files.py | 2 +-
python/mozbuild/mozbuild/backend/base.py | 2 +-
python/mozbuild/mozbuild/preprocessor.py | 6 +++---
python/mozbuild/mozbuild/util.py | 2 +-
python/mozbuild/mozpack/files.py | 4 ++--
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dom/base/usecounters.py b/dom/base/usecounters.py
index 780e3b32b2..7e2c7148ec 100644
--- a/dom/base/usecounters.py
+++ b/dom/base/usecounters.py
@@ -8,7 +8,7 @@ import re
def read_conf(conf_filename):
# Can't read/write from a single StringIO, so make a new one for reading.
- stream = open(conf_filename, "rU")
+ stream = open(conf_filename, "r")
def parse_counters(stream):
for line_num, line in enumerate(stream):
diff --git a/python/mozbuild/mozbuild/action/process_define_files.py b/python/mozbuild/mozbuild/action/process_define_files.py
index f1d401ac26..aca59d0f05 100644
--- a/python/mozbuild/mozbuild/action/process_define_files.py
+++ b/python/mozbuild/mozbuild/action/process_define_files.py
@@ -36,7 +36,7 @@ def process_define_file(output, input):
) and not config.substs.get("JS_STANDALONE"):
config = PartialConfigEnvironment(mozpath.join(topobjdir, "js", "src"))
- with open(path, "rU") as input:
+ with open(path, "r") as input:
r = re.compile(
"^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?", re.U
)
diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py
index 7bc1986d86..b64a709468 100644
--- a/python/mozbuild/mozbuild/backend/base.py
+++ b/python/mozbuild/mozbuild/backend/base.py
@@ -272,7 +272,7 @@ class BuildBackend(LoggingMixin):
return status
@contextmanager
- def _write_file(self, path=None, fh=None, readmode="rU"):
+ def _write_file(self, path=None, fh=None, readmode="r"):
"""Context manager to write a file.
This is a glorified wrapper around FileAvoidWrite with integration to
diff --git a/python/mozbuild/mozbuild/preprocessor.py b/python/mozbuild/mozbuild/preprocessor.py
index f7820b9c91..857f1a6c9b 100644
--- a/python/mozbuild/mozbuild/preprocessor.py
+++ b/python/mozbuild/mozbuild/preprocessor.py
@@ -531,7 +531,7 @@ class Preprocessor:
if args:
for f in args:
- with io.open(f, "rU", encoding="utf-8") as input:
+ with io.open(f, "r", encoding="utf-8") as input:
self.processFile(input=input, output=out)
if depfile:
mk = Makefile()
@@ -860,7 +860,7 @@ class Preprocessor:
args = self.applyFilters(args)
if not os.path.isabs(args):
args = os.path.join(self.curdir, args)
- args = io.open(args, "rU", encoding="utf-8")
+ args = io.open(args, "r", encoding="utf-8")
except Preprocessor.Error:
raise
except Exception:
@@ -914,7 +914,7 @@ class Preprocessor:
def preprocess(includes=[sys.stdin], defines={}, output=sys.stdout, marker="#"):
pp = Preprocessor(defines=defines, marker=marker)
for f in includes:
- with io.open(f, "rU", encoding="utf-8") as input:
+ with io.open(f, "r", encoding="utf-8") as input:
pp.processFile(input=input, output=output)
return pp.includes
diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py
index b09f164698..4f1e0cdc5f 100644
--- a/python/mozbuild/mozbuild/util.py
+++ b/python/mozbuild/mozbuild/util.py
@@ -236,7 +236,7 @@ class FileAvoidWrite(BytesIO):
still occur, as well as diff capture if requested.
"""
- def __init__(self, filename, capture_diff=False, dry_run=False, readmode="rU"):
+ def __init__(self, filename, capture_diff=False, dry_run=False, readmode="r"):
BytesIO.__init__(self)
self.name = filename
assert type(capture_diff) == bool
diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py
index 1d8a1ed2d8..a295a67b5a 100644
--- a/python/mozbuild/mozpack/files.py
+++ b/python/mozbuild/mozpack/files.py
@@ -554,7 +554,7 @@ class PreprocessedFile(BaseFile):
pp = Preprocessor(defines=self.defines, marker=self.marker)
pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
- with _open(self.path, "rU") as input:
+ with _open(self.path, "r") as input:
with _open(os.devnull, "w") as output:
pp.processFile(input=input, output=output)
@@ -611,7 +611,7 @@ class PreprocessedFile(BaseFile):
pp = Preprocessor(defines=self.defines, marker=self.marker)
pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
- with _open(self.path, "rU") as input:
+ with _open(self.path, "r") as input:
pp.processFile(input=input, output=dest, depfile=deps_out)
dest.close()

View File

@@ -0,0 +1,60 @@
From 81385fe53ffde5e1636e9ace0736d914da8dbc0f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 24 Oct 2021 22:32:50 -0700
Subject: [PATCH] Add RISCV32 support
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
build/moz.configure/init.configure | 3 +++
python/mozbuild/mozbuild/configure/constants.py | 2 ++
.../mozbuild/test/configure/test_toolchain_configure.py | 1 +
3 files changed, 6 insertions(+)
diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure
index 0b7a2ff60f..54f8325b44 100644
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -524,6 +524,9 @@ def split_triplet(triplet, allow_msvc=False, allow_wasi=False):
elif cpu.startswith("aarch64"):
canonical_cpu = "aarch64"
endianness = "little"
+ elif cpu in ("riscv32", "riscv32gc"):
+ canonical_cpu = "riscv32"
+ endianness = "little"
elif cpu in ("riscv64", "riscv64gc"):
canonical_cpu = "riscv64"
endianness = "little"
diff --git a/python/mozbuild/mozbuild/configure/constants.py b/python/mozbuild/mozbuild/configure/constants.py
index c71460cb20..15bef93e19 100644
--- a/python/mozbuild/mozbuild/configure/constants.py
+++ b/python/mozbuild/mozbuild/configure/constants.py
@@ -53,6 +53,7 @@ CPU_bitness = {
"mips64": 64,
"ppc": 32,
"ppc64": 64,
+ 'riscv32': 32,
"riscv64": 64,
"s390": 32,
"s390x": 64,
@@ -95,6 +96,7 @@ CPU_preprocessor_checks = OrderedDict(
("m68k", "__m68k__"),
("mips64", "__mips64"),
("mips32", "__mips__"),
+ ("riscv32", "__riscv && __riscv_xlen == 32"),
("riscv64", "__riscv && __riscv_xlen == 64"),
("loongarch64", "__loongarch64"),
("sh4", "__sh__"),
diff --git a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
index 059cde0139..4f9986eb31 100644
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -1192,6 +1192,7 @@ class LinuxCrossCompileToolchainTest(BaseToolchainTest):
"m68k-unknown-linux-gnu": big_endian + {"__m68k__": 1},
"mips64-unknown-linux-gnuabi64": big_endian + {"__mips64": 1, "__mips__": 1},
"mips-unknown-linux-gnu": big_endian + {"__mips__": 1},
+ "riscv32-unknown-linux-gnu": little_endian + {"__riscv": 1, "__riscv_xlen": 32},
"riscv64-unknown-linux-gnu": little_endian + {"__riscv": 1, "__riscv_xlen": 64},
"sh4-unknown-linux-gnu": little_endian + {"__sh__": 1},
}