-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Haiku: Add Haiku support for CoreCLR/PAL #93907
base: main
Are you sure you want to change the base?
Conversation
f98a038
to
3ff7e01
Compare
sprintf(name, "/shm-dotnet-%d", getpid()); | ||
name[sizeof(name) - 1] = '\0'; | ||
shm_unlink(name); | ||
int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600); | ||
#else // TARGET_FREEBSD |
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.
I would prefer the #elif defined(TARGET_LINUX) here and final #else with the posix fallback instead of hierarchical ifdef.
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.
Done. The final #else
assigns the fd
variable to -1
instead of doing the POSIX fallback itself, in case any of the platform-specific functions above return an error.
This should solve #72192 from the .NET 7 era.
// unreachable | ||
abort(); | ||
return Error_SUCCESS; | ||
return Error_EINVAL; |
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.
Should we keep the old aborting code as a fallback and add separate #if for HAIKU instead? I am not familiar enough with the contract of this function though.
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.
I've added back the abort()
logic, as an assertion that the function is unreachable.
This is true because on unsupported platforms, the higher-level C# libraries should already throw while trying to construct a network events socket.
Returning Error_SUCCESS
does not make much sense though.
790029d
to
2131127
Compare
Strange, I'm not modifying any FreeBSD-related codepaths, what's wrong with the FreeBSD build? |
FreeBSD build error is:
I guess you have introduced it by changing conditions around some of the includes. |
This is suspicious:
I wonder how I could get more detailed CMake logs for the CI runs. |
ed1af42
to
4a8cc01
Compare
When looking at other files, it seems like This time, instead of checking for this header during configuration as in #86391, a FreeBSD |
0a97fb8
to
f1f4369
Compare
// POSIX fallback | ||
if (fd == -1) | ||
{ | ||
char name[24]; | ||
sprintf(name, "/shm-dotnet-%d", getpid()); | ||
name[sizeof(name) - 1] = '\0'; | ||
shm_unlink(name); | ||
fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600); | ||
shm_unlink(name); | ||
} |
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.
Shouldn't this block be in #else
?
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.
No, it should not, as stated in #93907 (comment).
Even for OSes with platform-specific ways to get a special memory file open, should their method fail, we can still always use the POSIX fallback.
src/coreclr/gc/unix/numasupport.cpp
Outdated
#ifdef TARGET_LINUX | ||
#include <sys/syscall.h> | ||
#endif |
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 used by other Unix systems?
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.
No, it is only used on Linux:
runtime/src/coreclr/gc/unix/numasupport.cpp
Lines 52 to 63 in e5c631d
#ifdef TARGET_LINUX | |
if (syscall(__NR_get_mempolicy, NULL, NULL, 0, 0, 0) < 0 && errno == ENOSYS) | |
return; | |
int highestNumaNode = GetNodeNum("/sys/devices/system/node", false); | |
// we only use this implementation when there are two or more NUMA nodes available | |
if (highestNumaNode < 1) | |
return; | |
g_numaAvailable = true; | |
g_highestNumaNode = highestNumaNode; | |
#endif |
and
runtime/src/coreclr/gc/unix/numasupport.cpp
Lines 81 to 83 in e5c631d
#ifdef TARGET_LINUX | |
return syscall(__NR_mbind, (long)start, len, 1, (long)nodemask, maxnode, 0); | |
#else |
src/coreclr/pal/inc/pal_mstypes.h
Outdated
#define _SIZE_T_DEFINED | ||
#endif // !PAL_STDCPP_COMPAT |
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.
What's the impact range of this?
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.
What do you mean by "impact range"?
The line should affect all platforms. However, I believe that this is how things should be, since with PAL_STDCPP_COMPAT
the header should not define things that potentially mess up system headers.
Also, CoreCLR builds are working, so it should not break the definition on any other platforms.
Some more comments about this change here: #55803 (comment)
f1f4369
to
72e7cc3
Compare
Since this is a large change, would it be possible to split the PR info smaller component PRs for PAL, hosting, libraries etc. so relevant teams can review the changes? Thx |
d9bb4e0
to
e7b3c85
Compare
@trungnt2910 Are you still working on this? |
Not right now (I'm too busy). I'm still tracking it though, so if there are small specific issues I can resolve, I can fix it. |
As @mangod9 suggested above, this needs to be split into multiple smaller PRs per area to make it reviewable. I am going to switch it to draft for now. |
To me, this PR seems like a pretty atomic change (misc insertions needed to allow native components to start building on Haiku). How should I split it? Maybe |
Yes, that would work. |
e7b3c85
to
a7afb88
Compare
I have edited this pull request to include only files in |
a7afb88
to
c11ed1a
Compare
Latest Haiku builds are failing with this error:
Seems like whoever included According to the POSIX Standard, however:
What should I do in this case? Removing |
Does anything break if our local wcsnlen implementation is deleted? |
This contains a part of the code required to build CoreCLR and get `paltests` to pass on Haiku. This commit covers `src/coreclr/pal/**`. Co-authored-by: Jessica Hamilton <[email protected]>
This conflicts with the standard one already included through `wctype.h` in some POSIX OSes like Haiku.
ed24de7
to
56ff51f
Compare
Hasn't broken my local Linux build and moved my local Haiku build to a different error. Let the CI inform the rest of the answer. |
The next Haiku error is:
Currently I am solving this by adding these lines to #include "mdfileformat.h"
#include "stgpooli.h"
+#ifdef _EXPORT
+#undef _EXPORT
+#endif
+#ifdef _IMPORT
+#undef _IMPORT
+#endif
#endif I wonder whether these lines should be put directly to |
Hey @trungnt2910, what is the status of this PR. Are you continuing to work on it? |
There's still an unanswered question from me above. When we have a solution for those macros, I can proceed to resolving the conflicts and the PR is ready for further review. |
ok, so the question is about whether to add the undefs in |
Yes, the question is related to where I should add the
Yeah. This has been waiting for quite a few months now, waiting a few more weeks wouldn't hurt. |
adding @janvorli on advise on #undefs in pal.h. |
This contains the code required to build this repo's native components and get
paltests
to pass on Haiku.Most implementation details related to this commit are documented here.
Part of #55803.