Skip to content

Templatize _d_arraysetcapacity hook #4913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

aneiosi
Copy link

@aneiosi aneiosi commented Apr 24, 2025

I added the changes of this pull from dmd #21143

I also added version (D_BetterC) checks to core.internal.dassert.d, core.lifetime.d and core.internal.array.construction.d to bypass the try catch blocks present in those files.

The overall aim is to make the core library entirely useable with betterC so as to have viable support for WebAssembly.

If these changes get approved, more will follow :)

@kinke
Copy link
Member

kinke commented Apr 24, 2025

We'll get that change automatically when that hits DMD stable; I don't see a good reason to cherry-pick this early.

I also added version (D_BetterC) checks … The overall aim is to make the core library entirely useable with betterC so as to have viable support for WebAssembly.

I hate -betterC, and attempts to uglify druntime/Phobos code (dummy-templatizing without good reason etc.) to make it work somewhat 'better' (and so making the whole mess even worse), crippled as it is. - For wasm specifically, I think the way to go is to make parts of druntime compile for emscripten, and use that subset as sort of a minimal druntime for now / in the future. wasm doesn't have to remain -betterC-crippled, that's just a hack for now.

@kinke
Copy link
Member

kinke commented Apr 24, 2025

Some more context specific to the try-catch workarounds for -betterC / -fno-exceptions: dlang/dmd#19970 - these shouldn't be necessary in the first place, if the compiler had better support for this no-exceptions mode.

And there's a more specific predefined version to use in workarounds - D_Exceptions (not set when compiling with -fno-exceptions, one of the -betterC effects). Used e.g. here: https://github.com/dlang/dmd/blob/bdd45686de74cad5986694810a360b4deae18f3d/druntime/src/core/exception.d#L12-L20

@aneiosi
Copy link
Author

aneiosi commented Apr 25, 2025

We'll get that change automatically when that hits DMD stable; I don't see a good reason to cherry-pick this early.

OK, my bad, then :)

I hate -betterC, and attempts to uglify druntime/Phobos code (dummy-templatizing without good reason etc.) to make it work somewhat 'better' (and so making the whole mess even worse), crippled as it is. - For wasm specifically, I think the way to go is to make parts of druntime compile for emscripten, and use that subset as sort of a minimal druntime for now / in the future. wasm doesn't have to remain -betterC-crippled, that's just a hack for now.

I think this comment is kinda funny because I'm at the exact opposite end of the spectrum. I think it's emscipten that is a hack and I'm very intentionally trying to avoid it. My goal is to compile for WASI which I think is the correct middle ground between native and browser environments. Humans are diverse, i guess :)

@kinke
Copy link
Member

kinke commented Apr 25, 2025

I don't think we're on separate ends of the spectrum at all - targeting WASI directly would still require dropping the -betterC hack, and link a proper druntime. I just think emscripten would be much simpler, because they wrap WASI in a libc interface AFAIU, which druntime is based on. Edit: https://forum.dlang.org/post/wwyeiypaonxgzccaiqoz@forum.dlang.org

If you haven't seen it already: a WASI port was already attempted some time ago:

@aneiosi
Copy link
Author

aneiosi commented Apr 25, 2025

Closing this in favor of dmd#21302 which is a lot cleaner.

@aneiosi aneiosi closed this by deleting the head repository Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants