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

v1.49.x -- Ruby: Output a single binary file per platform-specific gem #30934

Closed

Conversation

johnnyshields
Copy link
Contributor

@johnnyshields johnnyshields commented Sep 10, 2022

In #30933, I discovered the Ruby UCRT gem attempting to load the MSVCRT binary, and failing because that binary file is a zero-byte placeholder. Specifically, the gem root dir looks like this:

grpc_c.32-msvcrt.ruby - 0 KB
grpc_c.64-msvcrt.ruby - 0 KB
grpc_c.64-ucrt.ruby - 9,650 KB

It would be possible to fix the reference so the UCRT binary is loaded (probably a C build flag issue), however...

Rather than having 3 binaries files (1 real + 2 placeholders), the most elegant solution is to only create 1 binary file for each platform-specific, named grpc_c.ruby, which is:

  • On Windows: the correct binary file for the given Windows architecture
  • On Linux/Mac: a 0-byte placeholder

For reference, the UCRT gem root dir will now look like this:

grpc_c.ruby - 9,650 KB

This solution unambiguously avoids loading the wrong binary, and also gets rid of a lot of cruft in the build code at the same time. Obviously we'll never need more than one grpc_c binary for any given platform gem.

@johnnyshields
Copy link
Contributor Author

@apolcyn ready for your review.

@johnnyshields johnnyshields changed the title v1.49.x -- Build a single binary file per Ruby platform-specific gem. v1.49.x -- Ruby: Build a single binary file per platform-specific gem Sep 10, 2022
@johnnyshields johnnyshields changed the title v1.49.x -- Ruby: Build a single binary file per platform-specific gem v1.49.x -- Ruby: Output a single binary file per platform-specific gem Sep 11, 2022
@apolcyn apolcyn added kokoro:force-run release notes: yes Indicates if PR needs to be in release notes labels Sep 12, 2022
@johnnyshields
Copy link
Contributor Author

@apolcyn any update on this?

@apolcyn
Copy link
Contributor

apolcyn commented Sep 16, 2022

Thanks for the investigation, @johnnyshields.

This PR looks reasonable to me. But given the size of this PR, and the fragility of the windows build, I'm a little apprehensive to merge this on 1.49. We'd need to release this change straight into a 1.49.1 patch release, without a pre-release, so we'd have more risk of breaking the whole windows build.

So I'd prefer to fix the build issue, which seems to not be setting the macro correctly, if possible. That said if it's very hard, I'm fine with this as a fall back.

Do you have any idea what's wrong there? The current extconf.rb code looks right w.r.t. detection of the ucrt platform, and I checked that rake-compiler-dock does fill in x64-mingw-ucrt as the RUBY_PLATFORM when running that code.

@johnnyshields
Copy link
Contributor Author

johnnyshields commented Sep 17, 2022

@apolcyn unfortunately I've exhausted my bandwidth I can spend investigating this issue. Re: "fragility of Windows build", this PR makes it significantly less fragile IMHO by reducing complexity.

I'm fine to get this either in 1.49.1 or 1.50.0. Perhaps you could cut a pre-release of a tiny version v1.49.1-pre1. I'm glad to test on all Windows versions when you have a gem cut either way.

@apolcyn
Copy link
Contributor

apolcyn commented Sep 19, 2022

I think I've found the cflags issue - opened #31051. I'm backporting that and aiming to get that into 1.49.1

@johnnyshields
Copy link
Contributor Author

@apolcyn thank you. I'm closing this PR (1.49.x backport) however will leave the PR for master open.

@johnnyshields johnnyshields deleted the 1.49.x-ruby-ucrt-fix branch September 20, 2022 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants