Skip to content
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

Enable mono cross-build on SunOS-like OS #37560

Merged
merged 1 commit into from
Jun 22, 2020
Merged

Enable mono cross-build on SunOS-like OS #37560

merged 1 commit into from
Jun 22, 2020

Conversation

am11
Copy link
Member

@am11 am11 commented Jun 7, 2020

Summary:

  • wire $(Compiler) in mono.proj, that comes from eng/build.sh.
  • add configurations for illumos cross-compilation.
  • set -Werror=strict-prototypes for madvise and posix_madvise introspection, which is used during the compilation.
  • implement mono-threads-sunos.c.
  • add some solaris-specific thread priority levels.

With this set of changes, dotnet hwapp.dll works with mono flavored System.Private.CoreLib.dll and libcoreclr.so on SmartOS 2020.

Contributes to: #34944.

@am11
Copy link
Member Author

am11 commented Jun 7, 2020

cc @akoeplinger

@am11
Copy link
Member Author

am11 commented Jun 15, 2020

Any chance this PR also gets a review? (trying to avoid upcoming merge conflicts from other PRs) :)

@CoffeeFlux
Copy link
Contributor

I'll take a look later today.

Copy link
Member

@akoeplinger akoeplinger left a comment

Choose a reason for hiding this comment

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

One suggestion, looks good otherwise. Sorry for the long delay :)

src/mono/mono.proj Show resolved Hide resolved
src/mono/mono.proj Outdated Show resolved Hide resolved
Copy link
Member

@akoeplinger akoeplinger left a comment

Choose a reason for hiding this comment

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

Found one more issue with the autoconf checks :)

src/mono/configure.ac Show resolved Hide resolved
src/mono/mono.proj Show resolved Hide resolved
@am11
Copy link
Member Author

am11 commented Jun 17, 2020

Failures are unrelated to changes:

Copy link
Contributor

@CoffeeFlux CoffeeFlux left a comment

Choose a reason for hiding this comment

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

Sorry the review took so long! Looked at the runtime bits and there were a couple minor things. Thanks for this!

case SCHED_FSS:
#endif
#ifdef SCHED_FX
case SCHED_FX:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these all unique to illumos? Maybe leave a comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

illumos and Solaris at least. Is there a way to tell for sure which platform support which flag? The existing #ifdef SCHED_BATCH is also without a comment, I guess because it is self-explanatory feature detection.

src/mono/mono/utils/mono-threads-sunos.c Outdated Show resolved Hide resolved
guint64
mono_native_thread_os_id_get (void)
{
return (guint64)pthread_self ();
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is intended to return the actual TID, a pid_t, not the results of pthread_self (). This needs to be the sunos gettid syscall equivalent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup and this is what I have found as an equivalent. Also, saw the same thing happening in coreclr against gettid unavailability on SunOS:

#else
#define PlatformGetCurrentThreadId() (SIZE_T)pthread_self()
#endif

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see. And I guess the value from thr_self () is no better than the POSIX thread ID... What a mess. Can you leave a comment so it's clear this isn't just a mistake? Otherwise I suspect I'll see this code 6 months down the line and, having forgotten about this conversation, look into it all over again. 😄

Copy link
Member Author

@am11 am11 Jun 17, 2020

Choose a reason for hiding this comment

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

@CoffeeFlux, I understand your position. and tbh, I am also not 100% sure whether to use light weight process (lwp) ID or pthread_self in this case as we are doing different things with this returned value at the call site (some places are using pthread library, others are making syscalls etc.). As far as I have read, POSIX does not provide strict specifications for process/thread related IDs and their relation with platform native threads, hence the disparity across all platforms and makes it difficult for devs to figure out the exact semantics (which we can see in all mono-threads-{platform}.c files). I only made sure that the hello world is working without violating any assertion i.e. changes in threads.c were the result of assertion violation on run time.

It is not exactly straight-forward to port dotnet/runtime to a new Unix platform, and test it all in one go. The eng side is quite a work to pull and lots of (ever changing) moving parts to learn. That's the reason why I am currently pushing changes to get this semi-ready state checked, to be able to get SDK to work, and then port libraries and run tests on the host Sun-like platforms.

Added a TODO comment to that effect. So far, this is just-working. We will get more information, when we will be able to execute related libraries tests to exercise this code thoroughly, and it might get changed to lwpId, something else or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me, and thanks for the detailed response. I'm happy with a just-working state on this PR; I just want to make sure we're attempting to capture that context somewhere in the code instead of buried in a Github issue. Appreciate your efforts to get this working!

As far as I have read, POSIX does not provide strict specifications for process/thread related IDs and their relation with platform native threads, hence the disparity across all platforms

Yep. 😢

guint64
mono_native_thread_os_id_get (void)
{
return (guint64)pthread_self ();
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me, and thanks for the detailed response. I'm happy with a just-working state on this PR; I just want to make sure we're attempting to capture that context somewhere in the code instead of buried in a Github issue. Appreciate your efforts to get this working!

As far as I have read, POSIX does not provide strict specifications for process/thread related IDs and their relation with platform native threads, hence the disparity across all platforms

Yep. 😢

@am11
Copy link
Member Author

am11 commented Jun 20, 2020

@CoffeeFlux, @akoeplinger, resolved merged conflict in configure.ac and rebased with master. If there are no other comments, can this be merged? Thanks! :)

@CoffeeFlux
Copy link
Contributor

Yep, the wasm failure on the Mono side is a known issue. Thanks again!

@CoffeeFlux CoffeeFlux merged commit dbc2d36 into dotnet:master Jun 22, 2020
@am11 am11 deleted the feature/sunos/enable-mono-build branch June 22, 2020 14:23
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants