-
Notifications
You must be signed in to change notification settings - Fork 989
cgo: implement support for static functions #2776
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
Conversation
grumble |
I expected this to be necessary for tinygo-org/drivers#401 but apparently it's not. |
Now that #2774 has been merged, this PR should now be able to be moved forward. |
Unfortunately, not. It doesn't work on MacOS yet. I need to work around that somehow. |
I've found this workaround for MacOS, can we use it?
|
2049ce7
to
298ddc6
Compare
@ysoldak thanks for this suggestion! I was aware of the linker feature but didn't know how to use it from C. Unfortunately, the linker we use doesn't support aliases:
Perhaps I can try to add support... |
"the linker we use doesn't support aliases", you mean this?
|
Yes. "symbol of type 10" refers to aliases. |
I've added a workaround for MacOS, let's see whether it works. |
It works on my Mac at least. macOS 12.5.1
and
|
Reminder: this PR is ready for review. |
callInst = "return " + callInst | ||
} | ||
aliasDeclaration := fmt.Sprintf(` | ||
#ifdef __APPLE__ |
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.
😿 oh Apple
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.
The worst part is that the linker actually does support aliases, it's just the compiler that doesn't.
...and I don't feel like creating a Clang patch and pushing for its inclusion.
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.
I am really looking forward to being able to compile some libs that have not been easily importable until now.
Merging!! |
This depends on #2774.
Static functions are used in tinygo.org/x/bluetooth but so far we've mostly just worked around them. This implements proper support for static functions.