-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Add "Posix" global version conditional for Emscripten targets #4738
Conversation
I managed to build ldc from source, and i managed to produce a wasm file with that:
import std;
extern(C) void _start()
{
writeln("hi");
} I'll try to do the same with druntime and phobos |
// Emscripten reimplements Posix APIs | ||
VersionCondition::addPredefinedGlobalIdent("linux"); | ||
VersionCondition::addPredefinedGlobalIdent("Posix"); | ||
VersionCondition::addPredefinedGlobalIdent("CRuntime_Musl"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this correct? Musl? that is more than just posix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emscripten uses musl, musl is POSIX compliant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm interesting. Do you have a link to confirm this? I found emscripten-core/emscripten#13006 which seems to support this.
The proper place to add the musl-compatible predefined versions is
Lines 921 to 923 in dd0ff1e
case llvm::Triple::Emscripten: | |
VersionCondition::addPredefinedGlobalIdent("Emscripten"); | |
break; |
VersionCondition::addPredefinedGlobalIdent("linux"); | ||
VersionCondition::addPredefinedGlobalIdent("Posix"); | ||
VersionCondition::addPredefinedGlobalIdent("CRuntime_Musl"); | ||
VersionCondition::addPredefinedGlobalIdent("X86_Any"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
X86 for sure is wrong
VersionCondition::addPredefinedGlobalIdent("WebAssembly"); | ||
if (triple.getOS() == llvm::Triple::Emscripten) { | ||
// Emscripten reimplements Posix APIs | ||
VersionCondition::addPredefinedGlobalIdent("linux"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linux
probably also incorrect?
Superseded by #4750. |
I just had this thought after seeing this: https://forum.dlang.org/post/odqtqqravqlfcqjgfywo@forum.dlang.org
Haven't tested yet, but i submit the PR otherwise i'll forget
And i can't compile ldc from source:
cmake -G Ninja ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/../install-ldc