From 56d0227a73f1660eb4286caab42dbef7d4ffa4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Thu, 30 May 2024 14:57:00 +0200 Subject: [PATCH] wasm: prepend underscore for invalid EXPORT_NAMEs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JS identifiers may not start with a digit: em++: error: EXPORT_NAME is not a valid JS identifier: `2dpainting_entry` Change the regex to match leading digits as well (note it is inverted). Prepend an underscore instead of replacing the invalid character; this makes sure we don't create new conflicts between for example "2dpainting" and "3dpainting". Change-Id: If78a87e7ed352b88bc99aee7c5829facf1fc35a0 Reviewed-by: Piotr WierciƄski (cherry picked from commit a3ab79ec8cab51255b108646f475c5796448d1a1) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/Qt6WasmMacros.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/Qt6WasmMacros.cmake b/src/corelib/Qt6WasmMacros.cmake index 38722d1b17c..989f3dde50e 100644 --- a/src/corelib/Qt6WasmMacros.cmake +++ b/src/corelib/Qt6WasmMacros.cmake @@ -135,8 +135,12 @@ function(_qt_internal_wasm_export_name_for_target out target) if(export_name) set(${out} "${export_name}" PARENT_SCOPE) else() - string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" target "${target}") - set(${out} "${target}_entry" PARENT_SCOPE) + string(REGEX MATCH "[^a-zA-Z_]" has_invalid_char "${target}") + if(has_invalid_char) + set(${out} "_${target}_entry" PARENT_SCOPE) + else() + set(${out} "${target}_entry" PARENT_SCOPE) + endif() endif() endfunction()