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

Fat parser should fail on file with 0 architectures #449

Merged
merged 4 commits into from Mar 20, 2022

Conversation

apainintheneck
Copy link
Contributor

This PR is related to issue #139.

I added a new exception called ZeroArchitectureError that gets thrown every time the permissive option is not set and nfat_arch == 0.

The only question I have is how you'd like to test for this exception. I just grabbed the llvm binary that you linked to in the original post and threw it in the test/bin/llvm/ folder and used that for testing. Is that what you were thinking? Also, that probably means that we should include some sort of llvm license in that directory.

@@ -346,6 +348,11 @@ def populate_fat_header
# formats.
raise JavaClassFileError if fh.nfat_arch > 30

# Rationale: fat Mach-0 files with no internal slices should
# return an error unless the permissive option is set.
permissive = options.fetch(:permissive, false)
Copy link
Member

Choose a reason for hiding this comment

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

IMO we can remove the permissive check here: there's very little a user can do with an empty universal binary, so we should fail unconditionally if we have no architecture slices.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense.

@woodruffw
Copy link
Member

Is that what you were thinking? Also, that probably means that we should include some sort of llvm license in that directory.

Yep, that's what I had in mind. Re: licensing: it should be sufficient to put a license notice in the top-level README, noting that we use binaries taking from the LLVM project for the test suite.

@apainintheneck
Copy link
Contributor Author

Copy and pasting the entire license would be a bit much for the top level README though, wouldn't it? Their Apache license is significantly longer than the current README. How about I just drop it in the llvm folder and then link to it from the README?

@woodruffw
Copy link
Member

How about I just drop it in the llvm folder and then link to it from the README?

Yep, that works.

Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

LGTM modulo adding the license notice. Thanks!

@apainintheneck
Copy link
Contributor Author

Okay, I added the license notice.

@woodruffw woodruffw merged commit 8700955 into Homebrew:master Mar 20, 2022
@apainintheneck apainintheneck deleted the fail-zero-nfat-arch branch March 31, 2022 01:07
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants