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
Fix runtime problems on MacOS using M1 chips #2579
Conversation
Ok, I ran this and got the following. Went from 137 test failures to 7. |
… vsnpritf call using CVarList, C ... equivalent is not supported in Scala Native, the tests on other platforms were passing only thanks to the pure luck
finally out.close() | ||
try { | ||
val copyResult = copy(in, out) | ||
// Make sure that created file has correct permissions |
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.
On MacOS M1 the files created by copying were given empty permissions, this should match the permission of files created by the JVM
// The +1 accounts for the null char at the end of the name | ||
#ifdef __APPLE__ | ||
#include <sys/posix_sem.h> | ||
#define SEM_MAX_LENGTH PSEMNAMLEN + 1 | ||
#else | ||
#include <limits.h> | ||
#define SEM_MAX_LENGTH _POSIX_PATH_MAX + 1 |
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.
This is and creation of semaphore is copy-pasted from Phase.c in Commix impl. In both cases this is needed due to problems on MacOs - usage of sem_create would return -1 and errno would mention not implemented error.
Also because previous dispatch_semaphore_t
was leading to deadlocks on Arm64 we do replace both linux and mac implementation with shared named semaphore
private def toCVarArgList_Arm64_MacOS( | ||
varargs: Seq[CVarArg] | ||
)(implicit z: Zone) = { | ||
val alignedArgs = varargs.map { arg => | ||
arg.value match { | ||
case value: Byte => | ||
value.toLong: CVarArg | ||
case value: Short => | ||
value.toLong: CVarArg | ||
case value: Int => | ||
value.toLong: CVarArg | ||
case value: UByte => | ||
value.toULong: CVarArg | ||
case value: UShort => | ||
value.toULong: CVarArg | ||
case value: UInt => | ||
value.toULong: CVarArg | ||
case value: Float => | ||
value.toDouble: CVarArg | ||
case o => arg | ||
} | ||
} |
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.
This implementation is exactly the same as for the x86 (in 32bit support branch), the only difference comes from mapping to Int64 instead of Int32
This PR is aimed to fix #2494 and other runtime issues when using macOS with M1 (arm64) chips. Because currently, we can't have any self-hosted Mac/M1 based machines that could be used in the CI all of the introduced changes are being tested only locally on the M1 host.
dispatch_semapthore
was leading to deadlocks, we replace it with named semaphores that would be used in both Mac and Linux.TMPDIR
env to determinatejava.io.tmpdir
system property - on MacOs 12 wiht M1 files created in/tmp
directory have wrong permissions. We should create them in the path described byTMPDIR
...)
, where positional args are being passed.