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

feat: replace reqwest with attohttpc #999

Merged
merged 6 commits into from Mar 15, 2020
Merged

feat: replace reqwest with attohttpc #999

merged 6 commits into from Mar 15, 2020

Conversation

davidkna
Copy link
Member

@davidkna davidkna commented Mar 11, 2020

Description

reqwest is a heavy dependency. Replace it with the lighter alternative attohttpc (-35% binary size on windows release build).

Also (fixes #933):
Opt to use native-tls instead of rustls on cpu architectures not supported by rustls (architectures other than ARM and x86) and on MacOS/iOS and Windows because it's shrinks binary size (at least on Windows) and doesn't appear to cause any trouble there.

Motivation and Context

Context #844 #895

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Screenshots (if appropriate):

How Has This Been Tested?

  • I have tested using MacOS
  • I have tested using Linux
  • I have tested using Windows

Checklist:

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

@hmble
Copy link

hmble commented Mar 12, 2020

reqwest is already an optional dependency. See PR 979

@davidkna
Copy link
Member Author

reqwest is already an optional dependency. See PR 979

True and I made that pull request myself but lightening the load when https is enabled in is still beneficial.

Cargo.toml Outdated
unicode-width = "0.1.7"
textwrap = "0.11.0"
term_size = "0.3.1"

# OpenSSL causes problems when building a MUSL release.
Copy link
Member

Choose a reason for hiding this comment

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

Oof that's hairy. I wish there was a more concise way to address this. 😰

Copy link
Member Author

Choose a reason for hiding this comment

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

In #933 @q66 mentions everything builds fine for them with MUSL. Is the trouble related with MUSL and openssl related to the CI setup or is it something else?

Should I start a test run to see if MUSL builds fine with openssl on CI now? Beyond that do you know how well the rust openssl crate handles different openssl library versions and locations across different systems these days? I remember having trouble with that back in the day.

Copy link

@q66 q66 Mar 13, 2020

Choose a reason for hiding this comment

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

yes, no issues building on musl (x86_64 or any other architecture) on my system when using openssl-sys, it just dynamically links against that and works fine

i think the issue for you might be that upstream rust musl builds prefer static linkage by default, while we override this in Void to use dynamic linkage by default; that may result in the openssl crate building its own openssl rather than linking system's...

so, maybe make the condition something like cfg(target_feature = "crt-static")? if using crt-static, use rustls, otherwise use native-tls... then see if it builds on CI, and I can test if it builds here.

Ideally, it'd be good to make this overridable too, to force either of these options even if the default is different.

Copy link
Member Author

Choose a reason for hiding this comment

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

i think the issue for you might be that upstream rust musl builds prefer static linkage by default, while we override this in Void to use dynamic linkage by default; that may result in the openssl crate building its own openssl rather than linking system's...

Well I just tried cross-compiling to FreeBSD and I just the same error as when I tried to compile to MUSL (Could not find directory of OpenSSL installation which apparently means it needs a cross-compiled openssl). This means that the error is likely not related to crt-static (and isn't that anly about the c runtime and not other dependencies?). I suppose vendoring openssl could be a fix as opposed it to being the issue.

Ideally, it'd be good to make this overridable too, to force either of these options even if the default is different.

Not sure how this could be solved. Is it possible to do feature-aware dependency specification?

Copy link

Choose a reason for hiding this comment

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

Yes, if you cross compile you obviously need OpenSSL/libressl for target in the cross root, that works fine though (we build all ARM packages as crosscompiled in Void and there are no issues)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the MUSL builds here are mainly intended for maximum platform compablity so I guess vendoring works fine here.

Copy link

Choose a reason for hiding this comment

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

It makes sense as an option, i don't think musl is otherwise special though

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I added a disabled-by-default tls-vendored feature in the recent commits that gets enabled only in the CI MUSL release builds.

@hmble
Copy link

hmble commented Mar 13, 2020

Oopsie my bad. Sorrry I did not saw your name in that PR @davidkna

Copy link

@q66 q66 left a comment

Choose a reason for hiding this comment

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

tested building this on void-ppc's ppc configurations (both glibc and musl, both LE and BE) and it seems to be fine.

@matchai
Copy link
Member

matchai commented Mar 15, 2020

Thank you both, @davidkna and @q66! 😄
LGTM! 👍

@matchai matchai merged commit fef8cc8 into starship:master Mar 15, 2020
dagbrown pushed a commit to dagbrown/starship that referenced this pull request Oct 22, 2021
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.

Dependency on ring breaks build on non-x86/ARM systems, even after going back to reqwest
4 participants