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

Initial build for aarch64 (raspberry pi and Apple Silicon) #55

Merged
merged 9 commits into from
May 6, 2021

Conversation

jpayne-procella
Copy link
Contributor

This is an inelegant way of solving the lack of upx in Alpine in aarch64. If we're building for that architecture, don't upx compress the files. I considered pulling and building upx, but there's a reason it's not in Alpine.

This doesn't generate multi arch builds, it just lets someone on that architecture build and run locally. A separate PR would be needed for multiarch builds.

@ynohat ynohat self-requested a review April 5, 2021 09:25
@ynohat ynohat marked this pull request as draft April 5, 2021 09:27
@ynohat
Copy link
Contributor

ynohat commented Apr 5, 2021

Hi @jpayne-procella thanks a lot for this PR, this is an important topic. A concern I have with the suggested approach is the amount of if/else overhead incurred.

I wonder if we could make a dummy upx executable available on problematic architectures. I suppose we might even be able to expose an APK repository so that apk add upx installs this dummy executable. This mechanism might also scale nicely to other use cases. Is this something you had considered already, and do you have any thoughts?

@jpayne-procella
Copy link
Contributor Author

Yep - that was my backup approach (not as far as a repository though) :) I went this way to avoid introducing more "code", and hopefully the if/else is temporary... but if the dummy upx is the way we want to go, I can give that a crack.

…my one, copy it over and let apk add overwrite it if it exists.
@ynohat ynohat marked this pull request as ready for review April 14, 2021 20:19
@ynohat
Copy link
Contributor

ynohat commented Apr 14, 2021

Hey @jpayne-procella I saw your commit land, and a cursory look says it's brilliant. I'll do some proper testing in the coming days and we can resume the PR.

@jpayne-procella
Copy link
Contributor Author

one more commit - i missed some cleanup in terraform.Dockerfile previously.

Copy link
Contributor

@ynohat ynohat left a comment

Choose a reason for hiding this comment

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

LGTM

Just tested this on my M1 Mac Mini. The build completed in 10 minutes; I wonder how much of the speedup (compared to roughly 1/2h on travis or on my Intel Mac) can be attributed to Apple silicon, and how much to just not upx'ing :)

@lukaszczerpak I don't see much point in running a dev build of this until we have multi arch build support in Travis, WDYT?

@ynohat ynohat requested a review from lukaszczerpak May 2, 2021 19:48
Copy link
Contributor

@ynohat ynohat left a comment

Choose a reason for hiding this comment

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

Actually, LGTM barring the newly introduced conflict against cli.Dockerfile.

@jpayne-procella can I trouble you to fix that please?

Copy link
Contributor

@lukaszczerpak lukaszczerpak left a comment

Choose a reason for hiding this comment

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

In general looks good! Thanks for the contribution :)

However, the way how UPX is installed produces a phantom error in the output on ARM architectures which in turn can mislead to think something went wrong. One way could be to search for the package and then install if found:

apk search --no-cache | grep -q ^upx && apk add --no-cache upx || apk add --no-cache git \

Unfortunately the original proposal as well as the above one are prone to mask a problem when UPX package changes its name, or doesn't install due to unknown reason. It will NOT be used eventually on platforms where it's supposed to be.

Maybe the following could solve the two minor issues in one shot (arch list to be defined):

apk add --no-cache $(uname -m | grep -qiE "(x86_64|i386|i686)" && echo -n upx) git \

@jpayne-procella
Copy link
Contributor Author

Actually, LGTM barring the newly introduced conflict against cli.Dockerfile.

@jpayne-procella can I trouble you to fix that please?

Done

@jpayne-procella
Copy link
Contributor Author

In general looks good! Thanks for the contribution :)

However, the way how UPX is installed produces a phantom error in the output on ARM architectures which in turn can mislead to think something went wrong. One way could be to search for the package and then install if found:

apk search --no-cache | grep -q ^upx && apk add --no-cache upx || apk add --no-cache git \

Unfortunately the original proposal as well as the above one are prone to mask a problem when UPX package changes its name, or doesn't install due to unknown reason. It will NOT be used eventually on platforms where it's supposed to be.

Maybe the following could solve the two minor issues in one shot (arch list to be defined):

apk add --no-cache $(uname -m | grep -qiE "(x86_64|i386|i686)" && echo -n upx) git \

I'm hoping that upx gets fixed for aarch64 before it changes names which means that the apk search --no-cache | grep -q ^upx approach might be better than trying to list out all architectures that should have upx - if it's supposed to install and doesn't at least we'll have an error to look at. And worst case upx doesn't get used which doesn't break functionality.

The other other option I was thinking of would be adding a upx-builder image to handle the messiness. Maybe a common-builder which could pull in upx, git, curl, etc. In that case, it could even pull in upx 3.95 from alpine3.11 community repo if upx isn't in the default repo.

@lukaszczerpak
Copy link
Contributor

lukaszczerpak commented May 5, 2021

apk search --no-cache | grep -q ^upx && apk add --no-cache upx || apk add --no-cache git \

The above will never stop the build if there was a problem with installation. This may result in no UPX done in case something goes wrong and we will not get any notification about this - as I outlined. So maybe combination of both ;)

apk add --no-cache $(apk search --no-cache | grep -q ^upx && echo -n upx) git \

+ no need to whitelist architectures
+ stops build when error occurs

@jpayne-procella
Copy link
Contributor Author

apk search --no-cache | grep -q ^upx && apk add --no-cache upx || apk add --no-cache git \

The above will never stop the build if there was a problem with installation. This may result in no UPX done in case something goes wrong and we will not get any notification about this - as I outlined. So maybe combination of both ;)

apk add --no-cache $(apk search --no-cache | grep -q ^upx && echo -n upx) git \
  • no need to whitelist architectures

  • stops build when error occurs

done

Copy link
Contributor

@lukaszczerpak lukaszczerpak left a comment

Choose a reason for hiding this comment

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

Many thanks for implementing all suggestions and apologies for going back-and-forth on this. All looks good! Great job!

@lukaszczerpak
Copy link
Contributor

I don't see much point in running a dev build of this until we have multi arch build support in Travis, WDYT?

Agree @ynohat

Copy link
Contributor

@ynohat ynohat left a comment

Choose a reason for hiding this comment

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

LGTM, I'll merge and release tomorrow

@jpayne-procella would you prefer to rebase yourself, or shall I squash and merge?

@jpayne-procella
Copy link
Contributor Author

LGTM, I'll merge and release tomorrow

@jpayne-procella would you prefer to rebase yourself, or shall I squash and merge?

Can you squash and merge please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants