From 5e1670b0c06585cff4152950c1a2e7baa835c946 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Thu, 22 May 2025 04:15:24 +0200 Subject: [PATCH 1/8] Fix OHOS define Signed-off-by: Jonathan Schwender --- ...ild__Add_compile_definition_for_ohos.patch | 6 ++- ...irect_errors_to_hilog_on_OpenHarmony.patch | 42 ++++++++++--------- .../mozjs/build/moz.configure/init.configure | 4 +- .../mozjs/memory/mozalloc/mozalloc_abort.cpp | 4 +- mozjs-sys/mozjs/mfbt/Assertions.h | 12 +++--- mozjs-sys/mozjs/mfbt/DbgMacro.h | 4 +- mozjs-sys/mozjs/mozglue/misc/Debug.cpp | 10 ++--- mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c | 8 ++-- 8 files changed, 48 insertions(+), 42 deletions(-) diff --git a/mozjs-sys/etc/patches/0034-build__Add_compile_definition_for_ohos.patch b/mozjs-sys/etc/patches/0034-build__Add_compile_definition_for_ohos.patch index a5903822c97..d80b55cb1ae 100644 --- a/mozjs-sys/etc/patches/0034-build__Add_compile_definition_for_ohos.patch +++ b/mozjs-sys/etc/patches/0034-build__Add_compile_definition_for_ohos.patch @@ -1,13 +1,15 @@ diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure --- a/build/moz.configure/init.configure (revision dbffebd0937c14d3c73ce9be4798da15cb2f369d) +++ b/build/moz.configure/init.configure (revision 8a1dbb7da45148151dbb0d05d969118103cfa8d0) -@@ -950,6 +950,14 @@ +@@ -950,6 +950,16 @@ set_define("ANDROID", target_is_android) +@depends(target) +def target_is_ohos(target): -+ return target.raw_os.endswith("-ohos") ++ if target.raw_os.endswith("-ohos"): ++ return True ++ return None + + +set_define("XP_OHOS", target_is_ohos) diff --git a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch index eb5319d9610..51ae0eda7c1 100644 --- a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch +++ b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch @@ -34,7 +34,7 @@ index 3cfc92533..9c487ac45 100644 #ifdef ANDROID # include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif #ifdef MOZ_WIDGET_ANDROID @@ -46,7 +46,7 @@ index 3cfc92533..9c487ac45 100644 -#ifndef ANDROID +#ifdef ANDROID + __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg); -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "Gecko", + "mozalloc_abort: %{public}s\n", msg); +#else @@ -65,7 +65,7 @@ index 0b7395177..e84d76aba 100644 #endif #ifdef ANDROID # include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif @@ -74,24 +74,26 @@ index 0b7395177..e84d76aba 100644 MozWalkTheStackWithWriter(MOZ_ReportAssertionFailurePrintFrame, CallerPC(), /* aMaxFrames */ 0); # endif -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert", + "Assertion failure: %{public}s, at %{public}s:%{public}d\n", + aStr, aFilename, aLine); #else # if defined(MOZ_BUFFER_STDERR) char msg[1024] = ""; -@@ -144,6 +150,10 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash( +@@ -144,8 +150,12 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash( __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", "[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr, aFilename, aLine); -+#elif defined(OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH", -+ "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", -+ aStr, aFilename, aLine); # if defined(MOZ_DUMP_ASSERTION_STACK) MozWalkTheStackWithWriter(MOZ_CrashPrintFrame, CallerPC(), /* aMaxFrames */ 0); + # endif ++#elif defined(XP_OHOS) ++ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH", ++ "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", ++ aStr, aFilename, aLine); + #else diff --git a/mfbt/DbgMacro.h b/mfbt/DbgMacro.h index 3247b993c..c7039d5f8 100644 --- a/mfbt/DbgMacro.h @@ -103,7 +105,7 @@ index 3247b993c..c7039d5f8 100644 -#ifdef ANDROID +#if defined(ANDROID) # include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif @@ -115,7 +117,7 @@ index 3247b993c..c7039d5f8 100644 -#ifdef ANDROID +#if defined(ANDROID) __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str()); -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str()); #else fputs(s.str().c_str(), stderr); @@ -128,12 +130,12 @@ index c3a2ca89e..3fea33f4b 100644 #ifdef ANDROID # include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif -#ifndef ANDROID -+#if ! (defined(ANDROID) || defined(OHOS)) ++#if ! (defined(ANDROID) || defined(XP_OHOS)) static void vprintf_stderr_buffered(const char* aFmt, va_list aArgs) { // Avoid interleaving by writing to an on-stack buffer and then writing in one // go with fputs, as long as the output fits into the buffer. @@ -141,7 +143,7 @@ index c3a2ca89e..3fea33f4b 100644 MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { __android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs); } -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { + (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs); +} @@ -153,14 +155,14 @@ index c3a2ca89e..3fea33f4b 100644 MFBT_API void print_stderr(std::stringstream& aStr) { -#if defined(ANDROID) -+#if defined(ANDROID) || defined(OHOS) ++#if defined(ANDROID) || defined(XP_OHOS) // On Android logcat output is truncated to 1024 chars per line, and // we usually use std::stringstream to build up giant multi-line gobs // of output. So to avoid the truncation we find the newlines and // print the lines individually. std::string line; while (std::getline(aStr, line)) { -+# ifdef OHOS ++# ifdef XP_OHOS + printf_stderr("%{public}s\n", line.c_str()); +# else printf_stderr("%s\n", line.c_str()); @@ -179,7 +181,7 @@ index 52bd6abc5..781402d56 100644 -#ifdef ANDROID +#if defined(ANDROID) # include -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +# include #endif @@ -188,7 +190,7 @@ index 52bd6abc5..781402d56 100644 PR_Write(fd, buf, nb); \ } \ PR_END_MACRO -+#elif defined(OHOS) ++#elif defined(XP_OHOS) +#define _PUT_LOG(fd, buf, nb) \ + PR_BEGIN_MACRO \ + if (fd == _pr_stderr) { \ @@ -208,7 +210,7 @@ index 52bd6abc5..781402d56 100644 PR_LogPrint("Aborting"); #ifdef ANDROID __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting"); -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n"); #endif abort(); @@ -217,7 +219,7 @@ index 52bd6abc5..781402d56 100644 #elif defined(ANDROID) __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s, file, ln); -+#elif defined(OHOS) ++#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", + "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln); #endif diff --git a/mozjs-sys/mozjs/build/moz.configure/init.configure b/mozjs-sys/mozjs/build/moz.configure/init.configure index 6c4626f1eb5..c00f9412155 100644 --- a/mozjs-sys/mozjs/build/moz.configure/init.configure +++ b/mozjs-sys/mozjs/build/moz.configure/init.configure @@ -910,7 +910,9 @@ set_define("ANDROID", target_is_android) @depends(target) def target_is_ohos(target): - return target.raw_os.endswith("-ohos") + if target.raw_os.endswith("-ohos"): + return True + return None set_define("XP_OHOS", target_is_ohos) diff --git a/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp b/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp index 1d9e8ed159f..e9e3eb606fe 100644 --- a/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp +++ b/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp @@ -9,7 +9,7 @@ #ifdef ANDROID # include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif #ifdef MOZ_WIDGET_ANDROID @@ -25,7 +25,7 @@ void mozalloc_abort(const char* const msg) { #ifdef ANDROID __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg); -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "Gecko", "mozalloc_abort: %{public}s\n", msg); #else diff --git a/mozjs-sys/mozjs/mfbt/Assertions.h b/mozjs-sys/mozjs/mfbt/Assertions.h index f7577207789..76d92698daa 100644 --- a/mozjs-sys/mozjs/mfbt/Assertions.h +++ b/mozjs-sys/mozjs/mfbt/Assertions.h @@ -92,7 +92,7 @@ MOZ_END_EXTERN_C #endif #ifdef ANDROID # include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif @@ -129,7 +129,7 @@ MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, MozWalkTheStackWithWriter(MOZ_ReportAssertionFailurePrintFrame, CallerPC(), /* aMaxFrames */ 0); # endif -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert", "Assertion failure: %{public}s, at %{public}s:%{public}d\n", aStr, aFilename, aLine); @@ -157,14 +157,14 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash( __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", "[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr, aFilename, aLine); -#elif defined(OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH", - "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", - aStr, aFilename, aLine); # if defined(MOZ_DUMP_ASSERTION_STACK) MozWalkTheStackWithWriter(MOZ_CrashPrintFrame, CallerPC(), /* aMaxFrames */ 0); # endif +#elif defined(XP_OHOS) + (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH", + "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", + aStr, aFilename, aLine); #else # if defined(MOZ_BUFFER_STDERR) char msg[1024] = ""; diff --git a/mozjs-sys/mozjs/mfbt/DbgMacro.h b/mozjs-sys/mozjs/mfbt/DbgMacro.h index c7039d5f83b..f3c8e95cf09 100644 --- a/mozjs-sys/mozjs/mfbt/DbgMacro.h +++ b/mozjs-sys/mozjs/mfbt/DbgMacro.h @@ -20,7 +20,7 @@ class nsTSubstring; #if defined(ANDROID) # include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif @@ -100,7 +100,7 @@ auto&& MozDbg(const char* aFile, int aLine, const char* aExpression, s << '\n'; #if defined(ANDROID) __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str()); -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str()); #else fputs(s.str().c_str(), stderr); diff --git a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp index 3fea33f4b4c..5728e233056 100644 --- a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp +++ b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp @@ -18,11 +18,11 @@ #ifdef ANDROID # include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif -#if ! (defined(ANDROID) || defined(OHOS)) +#if ! (defined(ANDROID) || defined(XP_OHOS)) static void vprintf_stderr_buffered(const char* aFmt, va_list aArgs) { // Avoid interleaving by writing to an on-stack buffer and then writing in one // go with fputs, as long as the output fits into the buffer. @@ -68,7 +68,7 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { __android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs); } -#elif defined(OHOS) +#elif defined(XP_OHOS) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs); } @@ -106,14 +106,14 @@ MFBT_API void fprintf_stderr(FILE* aFile, const char* aFmt, ...) { } MFBT_API void print_stderr(std::stringstream& aStr) { -#if defined(ANDROID) || defined(OHOS) +#if defined(ANDROID) || defined(XP_OHOS) // On Android logcat output is truncated to 1024 chars per line, and // we usually use std::stringstream to build up giant multi-line gobs // of output. So to avoid the truncation we find the newlines and // print the lines individually. std::string line; while (std::getline(aStr, line)) { -# ifdef OHOS +# ifdef XP_OHOS printf_stderr("%{public}s\n", line.c_str()); # else printf_stderr("%s\n", line.c_str()); diff --git a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c index 71cadb68695..f011da14de2 100644 --- a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c +++ b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c @@ -10,7 +10,7 @@ #include #if defined(ANDROID) # include -#elif defined(OHOS) +#elif defined(XP_OHOS) # include #endif @@ -116,7 +116,7 @@ static void OutputDebugStringA(const char* msg) { PR_Write(fd, buf, nb); \ } \ PR_END_MACRO -#elif defined(OHOS) +#elif defined(XP_OHOS) #define _PUT_LOG(fd, buf, nb) \ PR_BEGIN_MACRO \ if (fd == _pr_stderr) { \ @@ -554,7 +554,7 @@ PR_IMPLEMENT(void) PR_Abort(void) { PR_LogPrint("Aborting"); #ifdef ANDROID __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting"); -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n"); #endif abort(); @@ -569,7 +569,7 @@ PR_IMPLEMENT(void) PR_Assert(const char* s, const char* file, PRIntn ln) { #elif defined(ANDROID) __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s, file, ln); -#elif defined(OHOS) +#elif defined(XP_OHOS) (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln); #endif From d2907851189c5b3739354356641e46379f0861c0 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Tue, 18 Nov 2025 20:51:19 +0100 Subject: [PATCH 2/8] Fix indentation Signed-off-by: Jonathan Schwender --- .../patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch | 2 +- mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch index 51ae0eda7c1..3d581c628e4 100644 --- a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch +++ b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch @@ -191,7 +191,7 @@ index 52bd6abc5..781402d56 100644 } \ PR_END_MACRO +#elif defined(XP_OHOS) -+#define _PUT_LOG(fd, buf, nb) \ ++# define _PUT_LOG(fd, buf, nb) \ + PR_BEGIN_MACRO \ + if (fd == _pr_stderr) { \ + char savebyte = buf[nb]; \ diff --git a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c index f011da14de2..85ab016235a 100644 --- a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c +++ b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c @@ -117,7 +117,7 @@ static void OutputDebugStringA(const char* msg) { } \ PR_END_MACRO #elif defined(XP_OHOS) -#define _PUT_LOG(fd, buf, nb) \ +# define _PUT_LOG(fd, buf, nb) \ PR_BEGIN_MACRO \ if (fd == _pr_stderr) { \ char savebyte = buf[nb]; \ From 43fa9ea42392420c45bdaea2899189f5fed21e5a Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Thu, 20 Nov 2025 18:37:52 +0100 Subject: [PATCH 3/8] Avoid name collision by not importing header Assertions .h is also included in `c` files, so using namespaces is not an option to avoid the collision. js::LogLevel, collides with the hilog LogLevel enum. Signed-off-by: Jonathan Schwender --- mozjs-sys/mozjs/mfbt/Assertions.h | 7 ++++--- mozjs-sys/mozjs/mfbt/DbgMacro.h | 5 +++-- mozjs-sys/mozjs/mozglue/misc/Debug.cpp | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mozjs-sys/mozjs/mfbt/Assertions.h b/mozjs-sys/mozjs/mfbt/Assertions.h index 76d92698daa..62795036c97 100644 --- a/mozjs-sys/mozjs/mfbt/Assertions.h +++ b/mozjs-sys/mozjs/mfbt/Assertions.h @@ -93,7 +93,8 @@ MOZ_END_EXTERN_C #ifdef ANDROID # include #elif defined(XP_OHOS) -# include +int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); #endif MOZ_BEGIN_EXTERN_C @@ -130,7 +131,7 @@ MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, /* aMaxFrames */ 0); # endif #elif defined(XP_OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert", + (void) OH_LOG_Print(0, 7 /* LOG_FATAL */, 0, "MOZ_Assert", "Assertion failure: %{public}s, at %{public}s:%{public}d\n", aStr, aFilename, aLine); #else @@ -162,7 +163,7 @@ MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void MOZ_ReportCrash( /* aMaxFrames */ 0); # endif #elif defined(XP_OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH", + (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "MOZ_CRASH", "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", aStr, aFilename, aLine); #else diff --git a/mozjs-sys/mozjs/mfbt/DbgMacro.h b/mozjs-sys/mozjs/mfbt/DbgMacro.h index f3c8e95cf09..fdde9a20ebb 100644 --- a/mozjs-sys/mozjs/mfbt/DbgMacro.h +++ b/mozjs-sys/mozjs/mfbt/DbgMacro.h @@ -21,7 +21,8 @@ class nsTSubstring; #if defined(ANDROID) # include #elif defined(XP_OHOS) -# include + int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); #endif namespace mozilla { @@ -101,7 +102,7 @@ auto&& MozDbg(const char* aFile, int aLine, const char* aExpression, #if defined(ANDROID) __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str()); #elif defined(XP_OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str()); + (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s\n", s.str().c_str()); #else fputs(s.str().c_str(), stderr); #endif diff --git a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp index 5728e233056..dc53909f910 100644 --- a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp +++ b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp @@ -70,6 +70,7 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { } #elif defined(XP_OHOS) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { + // FIXME: format to local buffer first to avoid var_args? (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs); } #elif defined(FUZZING_SNAPSHOT) From 4225d83579bf4972468ef90a74029508630a668d Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Fri, 21 Nov 2025 06:40:37 +0100 Subject: [PATCH 4/8] Fix vprintf impl Signed-off-by: Jonathan Schwender --- mozjs-sys/mozjs/mozglue/misc/Debug.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp index dc53909f910..2372c296fde 100644 --- a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp +++ b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp @@ -70,8 +70,10 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { } #elif defined(XP_OHOS) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { - // FIXME: format to local buffer first to avoid var_args? - (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs); + // OH_LOG_VPrint is available with API-level 18 (19?) or higher. + char buffer[1024]; + VsprintfBuf(buffer, 1024, aFmt, aArgs); + (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", buffer); } #elif defined(FUZZING_SNAPSHOT) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { @@ -115,7 +117,7 @@ MFBT_API void print_stderr(std::stringstream& aStr) { std::string line; while (std::getline(aStr, line)) { # ifdef XP_OHOS - printf_stderr("%{public}s\n", line.c_str()); + (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", line.c_str()); # else printf_stderr("%s\n", line.c_str()); # endif From 79183e7ad0c57309cfbf7139ec8f935c980a9f50 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 24 Nov 2025 08:37:44 +0100 Subject: [PATCH 5/8] Update patches Signed-off-by: Jonathan Schwender --- ...irect_errors_to_hilog_on_OpenHarmony.patch | 25 +++++++++++-------- mozjs-sys/mozjs/mfbt/Assertions.h | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch index 3d581c628e4..2bb49575f56 100644 --- a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch +++ b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch @@ -61,12 +61,13 @@ diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h index 0b7395177..e84d76aba 100644 --- a/mfbt/Assertions.h +++ b/mfbt/Assertions.h -@@ -88,6 +88,8 @@ MOZ_END_EXTERN_C +@@ -88,6 +88,9 @@ MOZ_END_EXTERN_C #endif #ifdef ANDROID # include +#elif defined(XP_OHOS) -+# include ++int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) ++ __attribute__((__format__(os_log, 5, 6))); #endif MOZ_BEGIN_EXTERN_C @@ -75,7 +76,7 @@ index 0b7395177..e84d76aba 100644 /* aMaxFrames */ 0); # endif +#elif defined(XP_OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert", ++ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "MOZ_Assert", + "Assertion failure: %{public}s, at %{public}s:%{public}d\n", + aStr, aFilename, aLine); #else @@ -90,7 +91,7 @@ index 0b7395177..e84d76aba 100644 /* aMaxFrames */ 0); # endif +#elif defined(XP_OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH", ++ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "MOZ_CRASH", + "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n", + aStr, aFilename, aLine); #else @@ -98,7 +99,7 @@ diff --git a/mfbt/DbgMacro.h b/mfbt/DbgMacro.h index 3247b993c..c7039d5f8 100644 --- a/mfbt/DbgMacro.h +++ b/mfbt/DbgMacro.h -@@ -18,8 +18,10 @@ +@@ -18,8 +18,11 @@ template class nsTSubstring; @@ -106,7 +107,8 @@ index 3247b993c..c7039d5f8 100644 +#if defined(ANDROID) # include +#elif defined(XP_OHOS) -+# include ++ int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) ++ __attribute__((__format__(os_log, 5, 6))); #endif namespace mozilla { @@ -118,7 +120,7 @@ index 3247b993c..c7039d5f8 100644 +#if defined(ANDROID) __android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str()); +#elif defined(XP_OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str()); ++ (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s\n", s.str().c_str()); #else fputs(s.str().c_str(), stderr); #endif @@ -139,13 +141,16 @@ index c3a2ca89e..3fea33f4b 100644 static void vprintf_stderr_buffered(const char* aFmt, va_list aArgs) { // Avoid interleaving by writing to an on-stack buffer and then writing in one // go with fputs, as long as the output fits into the buffer. -@@ -66,6 +68,10 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { +@@ -66,6 +68,13 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { __android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs); } +#elif defined(XP_OHOS) +MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { -+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs); ++ // OH_LOG_VPrint is available with API-level 18 (19?) or higher. ++ char buffer[1024]; ++ VsprintfBuf(buffer, 1024, aFmt, aArgs); ++ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", buffer); +} #elif defined(FUZZING_SNAPSHOT) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { @@ -163,7 +168,7 @@ index c3a2ca89e..3fea33f4b 100644 std::string line; while (std::getline(aStr, line)) { +# ifdef XP_OHOS -+ printf_stderr("%{public}s\n", line.c_str()); ++ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", line.c_str()); +# else printf_stderr("%s\n", line.c_str()); +# endif diff --git a/mozjs-sys/mozjs/mfbt/Assertions.h b/mozjs-sys/mozjs/mfbt/Assertions.h index 62795036c97..572224c3a09 100644 --- a/mozjs-sys/mozjs/mfbt/Assertions.h +++ b/mozjs-sys/mozjs/mfbt/Assertions.h @@ -131,7 +131,7 @@ MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, /* aMaxFrames */ 0); # endif #elif defined(XP_OHOS) - (void) OH_LOG_Print(0, 7 /* LOG_FATAL */, 0, "MOZ_Assert", + (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "MOZ_Assert", "Assertion failure: %{public}s, at %{public}s:%{public}d\n", aStr, aFilename, aLine); #else From dbe0949738a660dad075803ae3658a0d0ec046c3 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 24 Nov 2025 08:47:15 +0100 Subject: [PATCH 6/8] Bump mozjs version Signed-off-by: Jonathan Schwender --- mozjs-sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mozjs-sys/Cargo.toml b/mozjs-sys/Cargo.toml index 204e311e703..56567aca9cc 100644 --- a/mozjs-sys/Cargo.toml +++ b/mozjs-sys/Cargo.toml @@ -2,7 +2,7 @@ name = "mozjs_sys" description = "System crate for the Mozilla SpiderMonkey JavaScript engine." repository.workspace = true -version = "0.140.5-3" +version = "0.140.5-4" authors = ["Mozilla", "The Servo Project Developers"] links = "mozjs" license.workspace = true From 8ff2828c0f3ea54fdc77f5b065f1b9bba10e2b63 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 24 Nov 2025 15:03:43 +0100 Subject: [PATCH 7/8] Completely inline function declaration Signed-off-by: Jonathan Schwender --- ...irect_errors_to_hilog_on_OpenHarmony.patch | 41 ++++++++++++------- .../mozjs/memory/mozalloc/mozalloc_abort.cpp | 7 +++- mozjs-sys/mozjs/mfbt/Assertions.h | 2 + mozjs-sys/mozjs/mfbt/DbgMacro.h | 2 + mozjs-sys/mozjs/mozglue/misc/Debug.cpp | 9 ++-- mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c | 11 ++--- 6 files changed, 47 insertions(+), 25 deletions(-) diff --git a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch index 2bb49575f56..456cd8fd27e 100644 --- a/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch +++ b/mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch @@ -30,12 +30,15 @@ diff --git a/memory/mozalloc/mozalloc_abort.cpp b/memory/mozalloc/mozalloc_abort index 3cfc92533..9c487ac45 100644 --- a/memory/mozalloc/mozalloc_abort.cpp +++ b/memory/mozalloc/mozalloc_abort.cpp -@@ -9,6 +9,8 @@ +@@ -9,6 +9,11 @@ #ifdef ANDROID # include +#elif defined(XP_OHOS) -+# include ++ extern "C" { ++ int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) ++ __attribute__((__format__(os_log, 5, 6))); ++ } #endif #ifdef MOZ_WIDGET_ANDROID # include "APKOpen.h" @@ -47,7 +50,7 @@ index 3cfc92533..9c487ac45 100644 +#ifdef ANDROID + __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg); +#elif defined(XP_OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "Gecko", ++ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "Gecko", + "mozalloc_abort: %{public}s\n", msg); +#else fputs(msg, stderr); @@ -61,13 +64,15 @@ diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h index 0b7395177..e84d76aba 100644 --- a/mfbt/Assertions.h +++ b/mfbt/Assertions.h -@@ -88,6 +88,9 @@ MOZ_END_EXTERN_C +@@ -88,6 +88,11 @@ MOZ_END_EXTERN_C #endif #ifdef ANDROID # include +#elif defined(XP_OHOS) ++MOZ_BEGIN_EXTERN_C +int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); ++MOZ_END_EXTERN_C #endif MOZ_BEGIN_EXTERN_C @@ -99,7 +104,7 @@ diff --git a/mfbt/DbgMacro.h b/mfbt/DbgMacro.h index 3247b993c..c7039d5f8 100644 --- a/mfbt/DbgMacro.h +++ b/mfbt/DbgMacro.h -@@ -18,8 +18,11 @@ +@@ -18,8 +18,13 @@ template class nsTSubstring; @@ -107,8 +112,10 @@ index 3247b993c..c7039d5f8 100644 +#if defined(ANDROID) # include +#elif defined(XP_OHOS) ++ MOZ_BEGIN_EXTERN_C + int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); ++ MOZ_END_EXTERN_C #endif namespace mozilla { @@ -128,12 +135,15 @@ diff --git a/mozglue/misc/Debug.cpp b/mozglue/misc/Debug.cpp index c3a2ca89e..3fea33f4b 100644 --- a/mozglue/misc/Debug.cpp +++ b/mozglue/misc/Debug.cpp -@@ -18,9 +18,11 @@ +@@ -18,9 +18,14 @@ #ifdef ANDROID # include +#elif defined(XP_OHOS) -+# include ++ extern "C" { ++ int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) ++ __attribute__((__format__(os_log, 5, 6))); ++ } #endif -#ifndef ANDROID @@ -150,7 +160,7 @@ index c3a2ca89e..3fea33f4b 100644 + // OH_LOG_VPrint is available with API-level 18 (19?) or higher. + char buffer[1024]; + VsprintfBuf(buffer, 1024, aFmt, aArgs); -+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", buffer); ++ (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s", buffer); +} #elif defined(FUZZING_SNAPSHOT) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { @@ -168,7 +178,7 @@ index c3a2ca89e..3fea33f4b 100644 std::string line; while (std::getline(aStr, line)) { +# ifdef XP_OHOS -+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", line.c_str()); ++ (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s", line.c_str()); +# else printf_stderr("%s\n", line.c_str()); +# endif @@ -179,7 +189,7 @@ diff --git a/nsprpub/pr/src/io/prlog.c b/nsprpub/pr/src/io/prlog.c index 52bd6abc5..781402d56 100644 --- a/nsprpub/pr/src/io/prlog.c +++ b/nsprpub/pr/src/io/prlog.c -@@ -8,8 +8,10 @@ +@@ -8,8 +8,11 @@ #include "prenv.h" #include "prprf.h" #include @@ -187,7 +197,8 @@ index 52bd6abc5..781402d56 100644 +#if defined(ANDROID) # include +#elif defined(XP_OHOS) -+# include ++ int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) ++ __attribute__((__format__(os_log, 5, 6))); #endif /* @@ -201,8 +212,8 @@ index 52bd6abc5..781402d56 100644 + if (fd == _pr_stderr) { \ + char savebyte = buf[nb]; \ + buf[nb] = '\0'; \ -+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "PRLog", \ -+ "%{public}s\n", buf); \ ++ (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, \ ++ 0, "PRLog", "%{public}s\n", buf); \ + buf[nb] = savebyte; \ + } else { \ + PR_Write(fd, buf, nb); \ @@ -216,7 +227,7 @@ index 52bd6abc5..781402d56 100644 #ifdef ANDROID __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting"); +#elif defined(XP_OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n"); ++ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "PRLog", "Aborting\n"); #endif abort(); } @@ -225,7 +236,7 @@ index 52bd6abc5..781402d56 100644 __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s, file, ln); +#elif defined(XP_OHOS) -+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", ++ (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "PRLog", + "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln); #endif abort(); diff --git a/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp b/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp index e9e3eb606fe..317b166429b 100644 --- a/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp +++ b/mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp @@ -10,7 +10,10 @@ #ifdef ANDROID # include #elif defined(XP_OHOS) -# include + extern "C" { + int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); + } #endif #ifdef MOZ_WIDGET_ANDROID # include "APKOpen.h" @@ -26,7 +29,7 @@ void mozalloc_abort(const char* const msg) { #ifdef ANDROID __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg); #elif defined(XP_OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "Gecko", + (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "Gecko", "mozalloc_abort: %{public}s\n", msg); #else fputs(msg, stderr); diff --git a/mozjs-sys/mozjs/mfbt/Assertions.h b/mozjs-sys/mozjs/mfbt/Assertions.h index 572224c3a09..d238b3d4fe8 100644 --- a/mozjs-sys/mozjs/mfbt/Assertions.h +++ b/mozjs-sys/mozjs/mfbt/Assertions.h @@ -93,8 +93,10 @@ MOZ_END_EXTERN_C #ifdef ANDROID # include #elif defined(XP_OHOS) +MOZ_BEGIN_EXTERN_C int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) __attribute__((__format__(os_log, 5, 6))); +MOZ_END_EXTERN_C #endif MOZ_BEGIN_EXTERN_C diff --git a/mozjs-sys/mozjs/mfbt/DbgMacro.h b/mozjs-sys/mozjs/mfbt/DbgMacro.h index fdde9a20ebb..8069eceba13 100644 --- a/mozjs-sys/mozjs/mfbt/DbgMacro.h +++ b/mozjs-sys/mozjs/mfbt/DbgMacro.h @@ -21,8 +21,10 @@ class nsTSubstring; #if defined(ANDROID) # include #elif defined(XP_OHOS) + MOZ_BEGIN_EXTERN_C int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) __attribute__((__format__(os_log, 5, 6))); + MOZ_END_EXTERN_C #endif namespace mozilla { diff --git a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp index 2372c296fde..c2e5f48c2f0 100644 --- a/mozjs-sys/mozjs/mozglue/misc/Debug.cpp +++ b/mozjs-sys/mozjs/mozglue/misc/Debug.cpp @@ -19,7 +19,10 @@ #ifdef ANDROID # include #elif defined(XP_OHOS) -# include + extern "C" { + int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); + } #endif #if ! (defined(ANDROID) || defined(XP_OHOS)) @@ -73,7 +76,7 @@ MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { // OH_LOG_VPrint is available with API-level 18 (19?) or higher. char buffer[1024]; VsprintfBuf(buffer, 1024, aFmt, aArgs); - (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", buffer); + (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s", buffer); } #elif defined(FUZZING_SNAPSHOT) MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) { @@ -117,7 +120,7 @@ MFBT_API void print_stderr(std::stringstream& aStr) { std::string line; while (std::getline(aStr, line)) { # ifdef XP_OHOS - (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s", line.c_str()); + (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, 0, "Gecko", "%{public}s", line.c_str()); # else printf_stderr("%s\n", line.c_str()); # endif diff --git a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c index 85ab016235a..96a3401be94 100644 --- a/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c +++ b/mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c @@ -11,7 +11,8 @@ #if defined(ANDROID) # include #elif defined(XP_OHOS) -# include + int OH_LOG_Print(unsigned int type, unsigned int level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); #endif /* @@ -122,8 +123,8 @@ static void OutputDebugStringA(const char* msg) { if (fd == _pr_stderr) { \ char savebyte = buf[nb]; \ buf[nb] = '\0'; \ - (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "PRLog", \ - "%{public}s\n", buf); \ + (void) OH_LOG_Print(0 /* LOG_APP */, 4 /* LOG_INFO */, \ + 0, "PRLog", "%{public}s\n", buf); \ buf[nb] = savebyte; \ } else { \ PR_Write(fd, buf, nb); \ @@ -555,7 +556,7 @@ PR_IMPLEMENT(void) PR_Abort(void) { #ifdef ANDROID __android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting"); #elif defined(XP_OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n"); + (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "PRLog", "Aborting\n"); #endif abort(); } @@ -570,7 +571,7 @@ PR_IMPLEMENT(void) PR_Assert(const char* s, const char* file, PRIntn ln) { __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n", s, file, ln); #elif defined(XP_OHOS) - (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", + (void) OH_LOG_Print(0 /* LOG_APP */, 7 /* LOG_FATAL */, 0, "PRLog", "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln); #endif abort(); From b7c91921e9404ae3f77226421a61db7d475613da Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Mon, 24 Nov 2025 21:15:26 +0100 Subject: [PATCH 8/8] ohos: Add debug-mozjs ci configuration Signed-off-by: Jonathan Schwender --- .github/workflows/build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3b3d898ab6..1a5f56f2c5c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -227,6 +227,7 @@ jobs: strategy: matrix: target: ["aarch64-unknown-linux-ohos", "x86_64-unknown-linux-ohos"] + features: [ "", "--features debugmozjs"] steps: - uses: actions/checkout@v4 - name: Setup OpenHarmony SDK @@ -245,15 +246,15 @@ jobs: env: OHOS_SDK_NATIVE: ${{ steps.setup_sdk.outputs.ohos_sdk_native }} run: | - ./ohos-build cargo +${{ steps.toolchain.outputs.name }} build --target="${{ matrix.target }}" + ./ohos-build cargo +${{ steps.toolchain.outputs.name }} build --target="${{ matrix.target }}" ${{ matrix.features }} - name: Generate artifact attestation uses: actions/attest-build-provenance@v1 - if: ${{ inputs.release }} + if: ${{ inputs.release && matrix.features == '' }} with: subject-path: "./target/libmozjs-${{ matrix.target }}.tar.gz" - name: Upload artifact uses: actions/upload-artifact@v4 - if: ${{ env.NEW_RUST_CHECK == 'false' }} + if: ${{ env.NEW_RUST_CHECK == 'false' && matrix.features == '' }} with: path: ./target/libmozjs-${{ matrix.target }}.tar.gz name: libmozjs-${{ matrix.target }}.tar.gz