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

shims: add curl-config shim to fix curl-config http2 report issue for ventura builds #18773

Closed
wants to merge 1 commit into from

Conversation

chenrui333
Copy link
Member

@chenrui333 chenrui333 commented Nov 14, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

seeing some ventura build linkage failure due to curl-config reporting issue, adding the shim as result per @Bo98's suggestion.

@chenrui333 chenrui333 requested a review from Bo98 November 14, 2024 21:30
… ventura builds

Signed-off-by: Rui Chen <rui@chenrui.dev>
Comment on lines +16 to +24
# Check if HTTP2 is missing but supported
if [[ ! "${output}" =~ HTTP2 ]]
then
curl_version="$("${HOMEBREW_CURL:-curl}" -V)"
if [[ "${curl_version}" =~ HTTP/2 ]]
then
output="${output} HTTP2"
fi
fi
Copy link
Member

Choose a reason for hiding this comment

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

It might be easier and cheaper to just add an append_to_cccfg here: https://github.com/Homebrew/brew/blob/main/Library/Homebrew/extend/os/mac/extend/ENV/super.rb#L161 gated to >= 10.13 && < 14, using a letter that isn't already used like h or C or something. Then here you can check if [[ "${HOMEBREW_CCCFG}" = *h* ]] before running most of the code here.

Also makes it more obvious we can remove it if we drop < macOS 14 support in the far future and means none of the hacks will run in macOS 14 and later which is safer in case there's edge cases we've missed.

Copy link
Member Author

Choose a reason for hiding this comment

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

make sense 👍

fi

# Fall back to executing the original curl-config
try_exec_non_system "${curl_config_exec}" "$@"
Copy link
Member

@Bo98 Bo98 Nov 14, 2024

Choose a reason for hiding this comment

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

Move this before the code above - it should not apply to non-system curl-config as only system curl-config is bugged.

The bug wasn't because of curl - it was because Apple shipped their own custom curl-config that they neglected to update for a while.

Comment on lines +7 to +9

# Check if HOMEBREW_CURL_CONFIG is set, fallback to system curl-config if not.
curl_config_exec="${HOMEBREW_CURL_CONFIG:-/usr/bin/curl-config}"
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to introduce HOMEBREW_CURL_CONFIG.

Suggested change
# Check if HOMEBREW_CURL_CONFIG is set, fallback to system curl-config if not.
curl_config_exec="${HOMEBREW_CURL_CONFIG:-/usr/bin/curl-config}"

if you move the try_exec_non_system high enough you can hardcode /usr/bin/curl-config (or /usr/bin/${SHIM_FILE}) elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to introduce HOMEBREW_CURL_CONFIG.

Agreed.

Comment on lines +32 to +35
safe_exec "/usr/bin/curl-config" "$@"

echo "Could not execute curl-config. Try HOMEBREW_FORCE_BREWED_CURL_CONFIG=1" >&2
exit 1
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
safe_exec "/usr/bin/curl-config" "$@"
echo "Could not execute curl-config. Try HOMEBREW_FORCE_BREWED_CURL_CONFIG=1" >&2
exit 1
exec "/usr/bin/curl-config" "$@"

HOMEBREW_FORCE_BREWED_CURL_CONFIG doesn't exist

@Bo98
Copy link
Member

Bo98 commented Nov 14, 2024

Thanks! Looks good overall.

curl_version="$("${HOMEBREW_CURL:-curl}" -V)"
if [[ "${curl_version}" =~ HTTP/2 ]]
then
output="${output} HTTP2"
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why we'd want to claim HTTP2 support is present when curl says its not?

Copy link
Member Author

Choose a reason for hiding this comment

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

curl-config --features did not report HTTP2 prior to macOS 14

even though curl does support http2

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, thanks. I'd be tempted to just use Homebrew's curl in that case rather than have a shim. Can we use uses_from_macos "curl", since: instead to handle macOS 13 and below?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, that should also work.

Copy link
Member Author

Choose a reason for hiding this comment

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

@MikeMcQuaid that hack (uses_from_macos "curl", since: :sonoma) would actually enable the linkage against system curl, see this build log.

In other words, I still feel like it is better to patch the curl-config report. I know this would be only for ventura builds. Let me know what you think.

cc @Bo98

(we have already merged the linked PRs on the homebrew-core side)

Copy link
Member

Choose a reason for hiding this comment

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

@MikeMcQuaid that hack (uses_from_macos "curl", since: :sonoma) would actually enable the linkage against system curl, see this build log.

@chenrui333 on which macOS versions would it link against/not link against system curl? Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

I know this would be only for ventura builds.

For one, non-latest macOS version this seems overkill, personally, but I'm open to thoughts from other maintainers.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, this only happens for ventura builds, for sonoma/sequoia builds, it works fine.

Copy link
Member

Choose a reason for hiding this comment

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

@chenrui333 Thanks, not worth doing for a single OS version IMO, sorry.

Copy link
Member Author

Choose a reason for hiding this comment

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

understand. 👍 😄

@chenrui333
Copy link
Member Author

also trying to use brewed curl for ventura builds.

@chenrui333 chenrui333 closed this Nov 23, 2024
@chenrui333
Copy link
Member Author

close as the issues got sorted out in the core tap side.

@chenrui333 chenrui333 deleted the add-curl-config-shim branch November 23, 2024 16:31
@MikeMcQuaid
Copy link
Member

Thanks @chenrui333 ❤️

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.

3 participants