Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/dmd.wasm-c-main-mangle.dd

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DMD has no WASM target, so this changelog entry shouldn't be here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So even though the change was upstreamed, it shouldn't be logged?

What about #23293 and #23294?


Either way, this particular one has already been merged. Do you need me to open a PR to delete it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be logged in LDC's release notes, but the changelog in this repo gets published with dmd releases so users are aware of what changed when upgrading dmd.

Newly reserved version WASI identifiers affect dmd because version = WASIp1 is something dmd now rejects. core.stdc updates for WASM could be relevant if anyone used dmd's bundled druntime sources with LDC, but that sounds very niche so I don't think it's worth mentioning. New mangling of WASM main is irrelevant/confusing for dmd users because it is incapable of generating any WASM code. I would delete it indeed.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
`extern(C) main` now mangled correctly on WebAssembly

D now matches the mangling behavior of Clang for C `main` on Wasm targets.

`main` is mangled as either `__main_void` or `__main_argc_argv` as appropriate (unless overriden by `pragma(mangle)`)

This change is useful for both WASI and Emscripten targets, which both expect this.
17 changes: 17 additions & 0 deletions compiler/src/dmd/mangle/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,23 @@ public:
buf.writestring(fd.ident.toString());
return;
}

version (IN_LLVM)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @ibuclaw for whatever the GCC logic should be

{
import gen.llvmhelpers : isTargetWasm;
bool isWasm = isTargetWasm();
}
else bool isWasm = false;

if (fd.isCMain() && isWasm)
{
if (fd.parameters)
buf.writestring("__main_argc_argv");
else
buf.writestring("__main_void");
return;
}

visit(cast(Declaration)fd);
}

Expand Down
Loading