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

build error on macos+gcc #8846

Closed
egorpugin opened this issue May 13, 2022 · 6 comments
Closed

build error on macos+gcc #8846

egorpugin opened this issue May 13, 2022 · 6 comments
Labels

Comments

@egorpugin
Copy link

@egorpugin egorpugin commented May 13, 2022

There is a long history of this issue.
https://github.com/curl/curl/issues?q=is%3Aissue+SecTrustEvaluateAsync+is%3Aclosed

curl 7.83.1
macos sdk12.3, gcc11 from homebrew

Error:

[org.sw.demo.badger.curl.libcurl-7.83.1]/lib/vtls/sectransp.c
/Users/egor/.sw/storage/pkg/3e/f5/47f6/src/sdir/lib/vtls/sectransp.c: In function 'collect_server_cert':
/Users/egor/.sw/storage/pkg/3e/f5/47f6/src/sdir/lib/vtls/sectransp.c:2967:6: error: 'SecTrustEvaluateAsync' undeclared (first use in this function); did you mean 'SecTrustEvaluate'?
 2967 |   if(SecTrustEvaluateAsync) {
      |      ^~~~~~~~~~~~~~~~~~~~~
      |      SecTrustEvaluate

Changing it to SecTrustEvaluateWithError (not deprecated) fixes the issue.
You can compare OS version support with SecTrustEvaluateAsync.
SecTrustEvaluate works as well, but it's also deprecated.

@egorpugin
Copy link
Author

@egorpugin egorpugin commented May 13, 2022

Changing it to SecTrustEvaluateWithError (not deprecated) fixes the issue.
You can compare OS version support with SecTrustEvaluateAsync.

Versions overlap, so compile check or something like this may fix the issue reliably.

@bagder bagder added the build label May 13, 2022
@bagder
Copy link
Member

@bagder bagder commented May 13, 2022

Sorry, I don't understand at all. Neither why this suddenly is a problem somewhere nor what the proposed fix is.

@egorpugin
Copy link
Author

@egorpugin egorpugin commented May 14, 2022

There is a build error.
Symbol is deprecated.
Possible fix is a replacement with the newer one.

@nickzman
Copy link
Member

@nickzman nickzman commented May 14, 2022

You can't build the Secure Transport code with GCC, because GCC (so far as I understand) does not support Grand Central Dispatch, and both SecTrustEvaluateAsync() and its replacement function SecTrustEvaluateAsyncWithError() require Grand Central Dispatch support to be present in the compiler.

If you build it with LLVM, then it will work.

If you want to patch this so it'll build using non-GCD-supporting compilers, then please file a pull request, and I'll review it. Thanks.

@egorpugin
Copy link
Author

@egorpugin egorpugin commented May 14, 2022

  1. How do I check for GCD support in gcc?
  2. SecTrustEvaluateAsync is not called anywhere https://github.com/curl/curl/blob/master/lib/vtls/sectransp.c#L2967=

@nickzman
Copy link
Member

@nickzman nickzman commented May 15, 2022

The FSF's GCC does not support GCD at all. There may be third-party forks that have support; if they do, then __BLOCKS__ will be defined as true.

And now I remember why I had to do that: the code uses old-school availability checks (that is, checking to see if the function is defined at runtime) for weak-linking purposes, and not the newer __builtin_available function (which I do not think is supported by GCC), and we couldn't check for SecTrustGetCertificateAtIndex() because that function was private API prior to macOS 10.7. Let me see if I can quickly fix that.

nickzman added a commit to nickzman/curl that referenced this issue May 15, 2022
SecTrustEvaluateAsync() is defined in the macOS 10.7 SDK, but it
requires Grand Central Dispatch to be supported by the compiler, and
some third-party macOS compilers do not support Grand Central Dispatch.
SecTrustCopyPublicKey() is not present in macOS 10.6, so this shouldn't
adversely affect anything.

Fixes curl#8846
Reported-by: Egor Pugin
@bagder bagder closed this as completed in e0b43c8 May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants