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

Add support for linking with C libraries #4

Merged
merged 7 commits into from Sep 10, 2021

Conversation

sunfishcode
Copy link
Owner

This adds an option to initialize the C runtime, so that it's (relatively) safe to call C libraries.

Fixes #2.

@sunfishcode sunfishcode force-pushed the sunfishcode/initialize-c-runtime branch 4 times, most recently from 2b96a71 to 8c8d91f Compare September 9, 2021 07:21
@sunfishcode sunfishcode force-pushed the sunfishcode/initialize-c-runtime branch 2 times, most recently from bf9ecad to 2433ebe Compare September 9, 2021 08:07
@sunfishcode sunfishcode force-pushed the sunfishcode/initialize-c-runtime branch from 2433ebe to f38116c Compare September 9, 2021 08:19
@bjorn3
Copy link
Contributor

bjorn3 commented Sep 9, 2021

I think the setjmp/longjmp in this PR will interfere with the one in glibc during libc initialization in some cases: https://github.com/lattera/glibc/blob/895ef79e04a953cac1493863bcae29ad85657ee1/csu/libc-start.c#L291-L309

@sunfishcode
Copy link
Owner Author

Wow, good catch. It's tempting to say that if mustang ever wants to support pthread cancellation, it will need to have complete enough libc emulation that all libc calls made by C libraries are handled, so that it no longer needs initialize-c-runtime at all.

@sunfishcode
Copy link
Owner Author

I'm inclined to go with this for now, and we'll see how far it goes.

@sunfishcode sunfishcode merged commit 33cd85b into main Sep 10, 2021
@sunfishcode sunfishcode deleted the sunfishcode/initialize-c-runtime branch September 10, 2021 06:43
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.

Linking with C libraries
2 participants