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

cpp.ansi, em_m2: include correct prototype for sprint( ). #317

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

tkchia
Copy link
Contributor

@tkchia tkchia commented Oct 28, 2024

This should mostly fix the crashes which were observed on GitHub CI (e.g. https://github.com/davidgiven/ack/actions/runs/11410639087/job/31753347141) when building ACK for a macOS host on 64-bit ARM.

It turns out that Apple's ARM64 ABI handles variable arguments in variadic functions differently from named arguments
(https://developer.apple.com/documentation/xcode/application-binary-interfaces). Thus callees which want to call the variadic function sprint( ) must declare the correct prototype, otherwise they will pass arguments to it wrongly.

This should mostly fix the crashes which were observed on GitHub CI (e.g.
https://github.com/davidgiven/ack/actions/runs/11410639087/job/31753347141)
when building ACK for a macOS host on 64-bit ARM.

It turns out that Apple's ARM64 ABI handles variable arguments in variadic
functions differently from named arguments
(developer.apple.com/documentation/xcode/application-binary-interfaces).
Thus callees which want to call the variadic function sprint( ) must declare
the correct prototype, otherwise they will pass arguments to it wrongly.
@tkchia tkchia marked this pull request as ready for review October 28, 2024 11:48
@davidgiven
Copy link
Owner

Fantastic, thank you. I did wonder if ARM64 might be the issue, but I don't have an Apple ARM64 device, and it worked fine on Linux due to the different ABI.

At some stage someone (probably me) needs to bite the bullet and add the flag to error out on undeclared functions...

@davidgiven davidgiven merged commit 90ed7aa into davidgiven:default Oct 28, 2024
3 checks passed
@tkchia
Copy link
Contributor Author

tkchia commented Oct 28, 2024

Hello @davidgiven,

Thank you! I guess one issue is that the sprint( ) was not exactly undeclared — it was declared, but using a K&R-style prototype extern char* sprint();.

And unfortunately there seem to be quite a lot of these old-style thingies in the ACK source code (freely mixed with code that uses new-style prototypes...). 😓

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.

2 participants