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

Port openmcx to macOS #18

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

Conversation

robincaloudis
Copy link

@robincaloudis robincaloudis commented Jan 14, 2024

Why

Currently, openmcx cannot be build on a macOS machine due to platform-specific code.

What

  • Identify effected code
  • Provide macOS-specific alternatives to Linux/Windows-specific code
  • Rename directory from linux to unix if underlying source code is common to Linux and macOS
  • As openmcx does not have a test-pipeline in place, the changes were tested by running all available examples under /examples

Tested on Apple Silicon M2.

@robincaloudis robincaloudis changed the title Port openmcx to macOS Make openmcs availabe on macOS Jan 14, 2024
@robincaloudis robincaloudis changed the title Make openmcs availabe on macOS Make openmcx availabe on macOS Jan 14, 2024
`__mcx_dll_load()` makes use of the function
`dlopen()`, which has a flag parameter. On
Linux one uses `RTLD_DEEPBIND` to ensure that
a library uses its own symbols rather than
those provided by other loaded libraries. On
MacOS there is not a direct equivalent
available.

Signed-off-by: Robin Caloudis <[email protected]>
Signed-off-by: Robin Caloudis <[email protected]>
When openmcx gets compiled on a Apple machine,
it requires two additional headers to be present.
My assumption is that these headers find its way
into the compilation unit transitively on Linux
and Windows machines, which they do not on Apple
machines.

Signed-off-by: Robin Caloudis <[email protected]>
@robincaloudis robincaloudis changed the title Make openmcx availabe on macOS Build and run openmcx on macOS Jan 14, 2024
@robincaloudis robincaloudis changed the title Build and run openmcx on macOS Build openmcx on macOS Jan 14, 2024
@robincaloudis robincaloudis changed the title Build openmcx on macOS Porting openmcx to macOS Jan 14, 2024
@robincaloudis robincaloudis changed the title Porting openmcx to macOS Port openmcx to macOS Jan 14, 2024
@robincaloudis robincaloudis force-pushed the rc-apple branch 2 times, most recently from 22c0c30 to 5262e95 Compare January 14, 2024 22:19
@Kamal-Nabhan-mcw
Copy link

Kamal-Nabhan-mcw commented Jan 17, 2024

Hi, I'm working porting a Linux specific repo to MacOs Catalina. I have some queries on it. Is it possible to reach out to you on dm and have a discussion on the same.

Apologise as the message is not relevant to this posting.

@robincaloudis
Copy link
Author

Hi @Kamal-Nabhan-mcw, sure. You can reach me via my mail [email protected]. Happy to hear from you.

const void *second) {
#else
static int ObjectContainerElementCmp(const void * first, const void * second,
void * ctx) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The indentation contains spaces and tabs. Please just use spaces.

Copy link
Author

Choose a reason for hiding this comment

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

Totally right. Messed up my editor configs. Corrected it. Thank you.

#if(__APPLE__)
void mcx_sort(void *base, size_t nmemb, size_t size,
int (*compar)(void *, const void *, const void *), void *arg);
#else
Copy link
Contributor

@klausschuch klausschuch Jan 23, 2024

Choose a reason for hiding this comment

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

Strange that the arg argument comes first in the apple implementation. We should add a comment to the source code to point this out.

Copy link
Author

Choose a reason for hiding this comment

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

Added a comment 👍

Copy link
Author

@robincaloudis robincaloudis left a comment

Choose a reason for hiding this comment

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

@klausschuch, thanks for your review! Fixed all of your mentioned concerns. Please re-review.

#if(__APPLE__)
void mcx_sort(void *base, size_t nmemb, size_t size,
int (*compar)(void *, const void *, const void *), void *arg);
#else
Copy link
Author

Choose a reason for hiding this comment

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

Added a comment 👍

const void *second) {
#else
static int ObjectContainerElementCmp(const void * first, const void * second,
void * ctx) {
Copy link
Author

Choose a reason for hiding this comment

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

Totally right. Messed up my editor configs. Corrected it. Thank you.

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.

3 participants