https://github.com/hmelder updated https://github.com/llvm/llvm-project/pull/169043
>From a07542b0e2274e36a9276ce034697ebcd0d0fee8 Mon Sep 17 00:00:00 2001 From: hmelder <[email protected]> Date: Fri, 21 Nov 2025 10:42:47 +0000 Subject: [PATCH 1/5] [clang] Whitelist wasm when targeting GNUstep 2.x --- clang/lib/Driver/ToolChains/Clang.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 30d3e5293a31b..6cbec5e17ae1a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -8001,7 +8001,8 @@ ObjCRuntime Clang::AddObjCRuntimeArgs(const ArgList &args, if ((runtime.getKind() == ObjCRuntime::GNUstep) && (runtime.getVersion() >= VersionTuple(2, 0))) if (!getToolChain().getTriple().isOSBinFormatELF() && - !getToolChain().getTriple().isOSBinFormatCOFF()) { + !getToolChain().getTriple().isOSBinFormatCOFF() && + !getToolChain().getTriple().isOSBinFormatWasm()) { getToolChain().getDriver().Diag( diag::err_drv_gnustep_objc_runtime_incompatible_binary) << runtime.getVersion().getMajor(); >From 90a6ea80ab587a670040c6ec7c574ae29419fb02 Mon Sep 17 00:00:00 2001 From: hmelder <[email protected]> Date: Fri, 21 Nov 2025 10:50:35 +0000 Subject: [PATCH 2/5] [CodeGen][ObjC] Mangle public symbols for wasm Emscripten requires that exported symbols. See https://github.com/emscripten-core/emscripten/pull/23563. --- clang/lib/CodeGen/CGObjCGNU.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 06643d4bdc211..d86aed0d977fa 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -179,8 +179,15 @@ class CGObjCGNU : public CGObjCRuntime { (R.getVersion() >= VersionTuple(major, minor)); } - std::string ManglePublicSymbol(StringRef Name) { - return (StringRef(CGM.getTriple().isOSBinFormatCOFF() ? "$_" : "._") + Name).str(); + const std::string ManglePublicSymbol(StringRef Name) { + auto triple = CGM.getTriple(); + + // Exported symbols in Emscripten must be a valid Javascript identifier. + if (triple.isOSBinFormatCOFF() || triple.isOSBinFormatWasm()) { + return (StringRef("$_") + Name).str(); + } else { + return (StringRef("._") + Name).str(); + } } std::string SymbolForProtocol(Twine Name) { >From c1b0453c01e3a1a4f41b413eb6b1c6dfd61dc828 Mon Sep 17 00:00:00 2001 From: hmelder <[email protected]> Date: Fri, 21 Nov 2025 13:04:33 +0000 Subject: [PATCH 3/5] [CodeGen][ObjC] Fix class_registerAlias_np signature --- clang/lib/CodeGen/CGObjCGNU.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index d86aed0d977fa..3b9f9f306829d 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -4113,8 +4113,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { if (!ClassAliases.empty()) { llvm::Type *ArgTypes[2] = {PtrTy, PtrToInt8Ty}; llvm::FunctionType *RegisterAliasTy = - llvm::FunctionType::get(Builder.getVoidTy(), - ArgTypes, false); + llvm::FunctionType::get(BoolTy, ArgTypes, false); llvm::Function *RegisterAlias = llvm::Function::Create( RegisterAliasTy, llvm::GlobalValue::ExternalWeakLinkage, "class_registerAlias_np", >From 0233bd22d901de804558cd40435a7c6c0fa770c7 Mon Sep 17 00:00:00 2001 From: hmelder <[email protected]> Date: Fri, 21 Nov 2025 13:07:10 +0000 Subject: [PATCH 4/5] [Wasm] HACK: Do not export hidden symbols --- llvm/lib/MC/WasmObjectWriter.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 15590b31fd07f..d882146e21b8a 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -1794,9 +1794,6 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm, Flags |= wasm::WASM_SYMBOL_UNDEFINED; if (WS.isNoStrip()) { Flags |= wasm::WASM_SYMBOL_NO_STRIP; - if (isEmscripten()) { - Flags |= wasm::WASM_SYMBOL_EXPORTED; - } } if (WS.hasImportName()) Flags |= wasm::WASM_SYMBOL_EXPLICIT_NAME; >From 1b37875e1c00259731d4099c1ae2c9a89681060d Mon Sep 17 00:00:00 2001 From: Hugo Melder <[email protected]> Date: Fri, 28 Nov 2025 14:09:55 +0100 Subject: [PATCH 5/5] Update clang/lib/CodeGen/CGObjCGNU.cpp Co-authored-by: David Chisnall <[email protected]> --- clang/lib/CodeGen/CGObjCGNU.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 3b9f9f306829d..1427cc40d2914 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -180,14 +180,13 @@ class CGObjCGNU : public CGObjCRuntime { } const std::string ManglePublicSymbol(StringRef Name) { - auto triple = CGM.getTriple(); + StringRef prefix = "._" // Exported symbols in Emscripten must be a valid Javascript identifier. + auto triple = CGM.getTriple(); if (triple.isOSBinFormatCOFF() || triple.isOSBinFormatWasm()) { - return (StringRef("$_") + Name).str(); - } else { - return (StringRef("._") + Name).str(); - } + prefix = "$_"; + return (prefix + Name).str(); } std::string SymbolForProtocol(Twine Name) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
