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

[curl] Support disabling IPv6 #35834

Closed
BewareMyPower opened this issue Dec 22, 2023 · 7 comments
Closed

[curl] Support disabling IPv6 #35834

BewareMyPower opened this issue Dec 22, 2023 · 7 comments
Assignees
Labels
category:question This issue is a question

Comments

@BewareMyPower
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When linking the static library of curl (libcurl.a) on macOS, some frameworks need to be linked.

Reproduce (on macOS m1 13.6.3):

./vcpkg install 'curl[core]'

Create a simple main.c:

#include <curl/curl.h>
 
int main(void)
{
  curl_global_init(CURL_GLOBAL_ALL);
  curl_global_cleanup();
  return 0;
}

Then built it via clang directly:

$ clang main.c -I./installed/arm64-osx/include ./installed/arm64-osx/lib/libcurl.a -lz
Undefined symbols for architecture arm64:
  "_CFRelease", referenced from:
      _Curl_macos_init in libcurl.a(macos.c.o)
  "_SCDynamicStoreCopyProxies", referenced from:
      _Curl_macos_init in libcurl.a(macos.c.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have to add the -framework SystemConfiguration -framework CoreFoundation flags to make it succeed.

Proposed solution

Add an ipv6 feature as a default feature.

Actually this feature is not supported on UWP, see https://github.com/microsoft/vcpkg/blob/f30434939d5516ce764c549ab04e3d23d312180a/ports/curl/portfile.cmake#L59C26-L59C26

Describe alternatives you've considered

No response

Additional context

No response

@BewareMyPower BewareMyPower added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label Dec 22, 2023
@dg0yt
Copy link
Contributor

dg0yt commented Dec 22, 2023

When linking the static library of curl (libcurl.a) on macOS, some frameworks need to be linked.

This is normal for static linkage.

I have to add the -framework SystemConfiguration -framework CoreFoundation flags to make it succeed.

Right. Or you ask pkg-config for libcurl libs. Or you ask CMake for CURL. This is how the port is consumed by other ports in vcpkg.

Proposed solution

Add an ipv6 feature as a default feature.

I don't think an ipv6 changes anything about the fact that you have to supply all direct and transitive link libraries when linking executables with static libs. In the right order.

@Cheney-W Cheney-W added category:question This issue is a question and removed category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist labels Dec 25, 2023
@wucaizi
Copy link

wucaizi commented Dec 27, 2023

Have you solved this problem

@wucaizi
Copy link

wucaizi commented Dec 27, 2023

Have you solved this problem

"_CFRelease", referenced from:
_Curl_macos_init in libcurl.a(macos.c.o)
"_SCDynamicStoreCopyProxies", referenced from:
_Curl_macos_init in libcurl.a(macos.c.o)

@dg0yt
Copy link
Contributor

dg0yt commented Dec 27, 2023

@wucaizi #35834 (comment)

@BewareMyPower
Copy link
Contributor Author

I don't think an ipv6 changes anything about the fact that you have to supply all direct and transitive link libraries when linking executables with static libs. In the right order.

The frameworks are only required when the IPv6 is enabled, that's one point. Another point is, if you're going to provide a fat bundled library that gathers all static libraries, you have to tell users to link the extra frameworks as well.

For example, I have to build the curl from source like:

cmake -B build \
  -DENABLE_IPV6=OFF \
  -DCURL_ENABLE_SSL=OFF \
  -DUSE_LIBIDN2=OFF \
  -DCURL_USE_LIBPSL=OFF \
  -DCURL_USE_LIBSSH2=OFF \
  -DENABLE_UNIX_SOCKETS=OFF \
  -DBUILD_TESTING=OFF \
  -DBUILD_CURL_EXE=OFF \
  -DBUILD_STATIC_LIBS=ON \
  -DBUILD_SHARED_LIBS=OFF
cmake --build build -j8

Then I can build an executable like:

g++ main.cc -I ./include build/lib/libcurl.a -lz

Only the ZLib dependency is required. This compile command works both for Linux and macOS.

However, if I installed curl via vcpkg, I have to add -framework SystemConfiguration -framework CoreFoundation on macOS, while it's not required on Linux.

@dg0yt
Copy link
Contributor

dg0yt commented Dec 28, 2023

However, if I installed curl via vcpkg, I have to add -framework SystemConfiguration -framework CoreFoundation on macOS, while it's not required on Linux.

The key question is whether we want add a feature to control IPv6 support. In 2024.
This is not a feature to promote "convenient linking" - convenient linking is handled by CMake and pkg-config.
This is not a feature to reduce third-party dependencies - the frameworks are provided by the system.

@BewareMyPower
Copy link
Contributor Author

I got your points now. From my perspective, the core point is that the frameworks are provided by the system and no extra dependencies are involved with the IPv6 support.

Let's close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:question This issue is a question
Projects
None yet
Development

No branches or pull requests

4 participants