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

Initial fixes for macOS <10.9 and PowerPC #21655

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

barracuda156
Copy link

Feedback is welcome.

These fixes are needed, but not sufficient. However this is good enough for the first PR, I believe.
Current status of the build on macOS PPC in the issue link below.

@marek-safar This fixes errors reported in #21649

@susematz Please review r11/r12 commit. Initially I thought to make defines to switch these registers in the code, but then decided to put Darwin code into separate chunks – this will make it easier to modify it as needed without affecting anything else.

@NattyNarwhal If you could take a look too, please.

@barracuda156
Copy link
Author

@dotnet-policy-service agree

kern_return_t mach_ret;

if (pid == getpid ()) {
/* task_for_pid () doesn't work on ios, even for the current process */
Copy link
Contributor

Choose a reason for hiding this comment

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

could be simplified unless you also want to target legacy iOS

Copy link
Author

Choose a reason for hiding this comment

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

iOS is not my concern, so how better to rewrite this chunk?

@@ -3706,41 +3785,76 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
*/
g_assert (!cfg->method->save_lmf);
/*
* Note: we can use ppc_r12 here because it is dead anyway:
* we're leaving the method.
* Note: we can use ppc_r12 (ppc_r11 on Darwin) here because it is dead
Copy link
Contributor

Choose a reason for hiding this comment

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

i think instead of ifdef on every site where r11/r12 is referenced, it would be best to put this as a define ifdef'd on OS and use that for the simple r11 vs. r12 cases, and save ifdef for the more complex ABI differences

Copy link
Author

Choose a reason for hiding this comment

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

Let’s perhaps see what upstream says. That was my initial idea, but then I thought it may introduce extra complications down the road.

* (C) 2023 Xamarin, Inc.
*/

/* The code below assumes 10.5.x or 10.6.x (10A190 or Rosetta).
Copy link
Contributor

Choose a reason for hiding this comment

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

i'll note my previous half-hearted attempt was on 10.4, so this might explain why you had better success :)

Copy link
Author

Choose a reason for hiding this comment

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

@NattyNarwhal Tiger is painful to develop for. I have a 10.4.11 set-up to run builds or test, but don’t really have motivation or time to work on it. 10.5.8 and 10A190/10.6.8 are reasonably homogeneous, on the other hand.

Copy link
Author

Choose a reason for hiding this comment

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

(Registers are not prefixed on Tiger, so to support it here we need to add defines which would add __ on >10.4, but not on <10.5. This is not hard, just extra code, but I have no idea if the rest of the code needs extra modifications.)

* (C) 2023 Xamarin, Inc.
*/

/* The code below assumes 10.5.x.
Copy link
Contributor

Choose a reason for hiding this comment

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

comment could be dropped; IIRC ppc64 was introduced in 10.5

Copy link
Author

Choose a reason for hiding this comment

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

AFAIK 10.4.11 does support ppc64, at least to some extent.

@barracuda156
Copy link
Author

Rebased to fix a typo in mono-threads-mach.c (duplicate elif).

@vargaz
Copy link
Contributor

vargaz commented May 14, 2023

Note that active development of mono is done in the dotnet/runtime repository.

@barracuda156
Copy link
Author

Note that active development of mono is done in the dotnet/runtime repository.

So should I open a new PR there and close this one, or this can be rebased?

@vargaz
Copy link
Contributor

vargaz commented May 15, 2023

It would be better to submit to dotnet/runtime and later backport here, we have better CI there.

@akoeplinger
Copy link
Member

For the general PPC code I agree dotnet/runtime would be better, but I don't think we'll want to take any macOS <10.9 fixes there since a lot of that repo assumes much newer macOS.

@barracuda156
Copy link
Author

For the general PPC code I agree dotnet/runtime would be better, but I don't think we'll want to take any macOS <10.9 fixes there since a lot of that repo assumes much newer macOS.

@akoeplinger @vargaz So what should I do? :)
I am finally returning to the matter.

@@ -3148,8 +3148,13 @@ emit_reserve_param_area (MonoCompile *cfg, guint8 *code)
if (ppc_is_imm16 (-size)) {
ppc_stwu (code, ppc_r0, -size, ppc_sp);
} else {
#if defined(__POWERPC__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed ? Its a mips file.

@@ -2763,6 +2763,40 @@ arch_emit_imt_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)

code = buf;

#if defined(TARGET_OSX)
/* Load the mscorlib got address */
Copy link
Contributor

Choose a reason for hiding this comment

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

Can all these changes be simplified by defining a tmp_reg or something which is r11 on apple and r12 elsewhere ?

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.

None yet

4 participants