Closed mauliknshah closed 3 years ago
the same issue as here https://github.com/apple/swift-nio-ssl/issues/254
@Lukasa my pr were solving this
This remains a clang bug: the header file is well formatted.
I just performed a fresh install and followed these steps. Big Sur 11.0.1, Xcode 12.2. I do not see this error, everything compiles cleanly.
At this stage I recommend filing a report with Apple via Feedback Assistant. Can you then paste the report number here?
here you go https://feedbackassistant.apple.com/feedback/8925072 @Lukasa
This build failure reproduces on latest swift trunk 2020-12-05:
$ which swift
/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-12-05-a.xctoolchain/usr/bin/swift
$ swift --version
Apple Swift version 5.3-dev (LLVM 389c6ea22592d7c, Swift 65db86ba034403f)
Target: x86_64-apple-darwin20.1.0
$ swift build
Fetching https://github.com/apple/swift-nio.git
Cloning https://github.com/apple/swift-nio.git
Resolving https://github.com/apple/swift-nio.git at 2.25.0
In file included from /Users/xander/dev/swift-nio-ssl/Sources/CNIOBoringSSL/ssl/tls_record.cc:109:
In file included from /Users/xander/dev/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_ssl.h:149:
In file included from /Users/xander/dev/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_pem.h:67:
In file included from /Users/xander/dev/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_x509.h:76:
In file included from /Users/xander/dev/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_obj.h:62:
In file included from /Users/xander/dev/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_bytestring.h:20:
/Users/xander/dev/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_span.h:139:7: error: missing '#include <stdlib.h>'; 'abort' must be declared before it is used
abort();
^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/include/stdlib.h:131:7: note: declaration here is not visible
void abort(void) __cold __dead2;
^
...
macOS 11.0.1. Xcode 12.2 beta 3.
Note that it's specific to macOS. This does not reproduce when building on Linux.
Including the workaround described here until the complier bug is fixed would be helpful to developers using NIO.
This seems increasingly like the Big Sur SDK is incompatible with the version of clang being used by S4T and currently present on Swift master. I'll continue to chase this up, we should really be pressing the Swift folks to resolve this. If it lasts too much longer we'll be forced to work around this, which would really be a shame.
Can you attach the output of running the same clang
command that's failing and adding -v
to it? That will print the list of include directories that Clang is searching, and I believe it will make it easier to troubleshoot the problem. Looking at swift build --help
, I believe running like this would do the trick:
swift build -v -Xcxx -v
(run swift build
as verbose, and pass -v
to the compiler)
macOS 11.0.1:
$ git log
commit c585b79ac062b3a41a51335722500734aa6c9eb9 (HEAD -> main, origin/main, origin/HEAD)
Author: Sercan Karaoglu <sercan_karaoglu@yahoo.com>
Date: Wed Dec 2 15:28:37 2020 +0100
change cxx language standard (#260)
$ which swift
/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-12-05-a.xctoolchain/usr/bin/swift
$ swift --version
Apple Swift version 5.3-dev (LLVM 389c6ea22592d7c, Swift 65db86ba034403f)
Target: x86_64-apple-darwin20.1.0
$ rm -rf .build
$ swift build -v -Xcxx -v
Full output here
Thanks a lot. Here's a one line reproducer:
cat <<EOF | /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-12-12-a.xctoolchain/usr/bin/clang -xc++ - -isysroot $(xcrun --show-sdk-path) -fmodules -fmodule-name=CNIOBoringSSL -fsyntax-only
#include <cstdlib>
int main() { abort(); }
EOF
Gives:
<stdin>:2:14: error: missing '#include <stdlib.h>'; 'abort' must be declared before it is used
int main() { abort(); }
^
<SDKROOT>/usr/include/stdlib.h:131:7: note: declaration here is not visible
void abort(void) __cold __dead2;
^
1 error generated.
If I change to std::abort()
, it works. Basically, you're using <cstdlib>
and then using ::abort()
. However, the <cstdlib>
module defines std::abort()
, not ::abort()
. Those are different declarations because they are in different namespaces. Changing to std::abort()
should fix your problem -- I believe Clang is correct (albeit perhaps a bit pedantic) here.
I think, I didn't add one crucial piece of information, which is I am working on the "Swift for Tenserflow 0.12 Release" toolchain. I am sorry for the late response.
@mauliknshah Swift for Tensorflow forks each release off of Swift dev trunk. Hence it's the same issue on both toolchains.
@Lukasa are you able to make the minor change that @ldionne suggested?
The code in question is BoringSSL and it has been compiling correctly for months. The only change is clang’s enforcement. If you believe clang is right and Boring is wrong, we should report this bug upstream.
The code in question is BoringSSL and it has been compiling correctly for months.
Compiling for months doesn't mean much. Sometimes the compiler changes or improves diagnostics and code that was seemingly valid forever starts breaking. It's just the way it is, and it's impossible to make things better without sometimes breaking a few things.
The only change is clang’s enforcement. If you believe clang is right and Boring is wrong, we should report this bug upstream.
Yes, I believe that would be the best way forward.
Out of curiosity, trunk of both clang and GCC do not consider this a problem, at least according to godbolt: https://godbolt.org/z/Mz5G8a. This seems like to be a clang and macOS specific issue?
You're not compiling with modules enabled.
Sure, but there's no error even if I enable modules: https://godbolt.org/z/5jPsbo.
Irregardless I'm fine with not litigating it, happy to push this upstream to Boring.
Why do you use BoringSSL btw, especially looking at here, it doesn't sound good:
Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is. We don't recommend that third parties depend upon it. Doing so is likely to be frustrating because there are no guarantees of API or ABI stability.
We discussed this in 2018 on the Swift forums: https://forums.swift.org/t/rfc-moving-swiftnio-ssl-to-boringssl/18280
Okay I see it thanks, looks like pure Swift crypto implementation would have been more future proof but wasn't possible due to the effort required at that time. Self contained SSL also sounds good
Should be fixed by #261, if you get a moment I'd love to have you test with the relevant branch to confirm it fixes your problem.
Huge thanks @Lukasa! I'm traveling at the moment and will be able to test it tomorrow.
Inflight wifi managed to do a git pull! I successfully built swift-nio-ssl latest main commit 62bf5083df970e67c886210fa5b857eacf044b7c
using both Swift trunk snapshot 2020-12-05 and Swift For TensorFlow 0.12. The issue appears to be resolved! Thank you! Could you roll a new release so that downstream projects can peg their swift-nio-ssl dependency to this fix?
Yup, we're doing our release validation at the moment. Hopefully should be in the next 24 hours or so.
Should be resolved by 2.10.2. Thanks for your patience here folks!
/Users/Maulik/Library/Developer/Xcode/DerivedData/TestFluentPostgres-gjwkxowtrhpkuzdpxewtalgpeaqq/SourcePackages/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_span.h:139:7: Missing '#include'; 'abort' must be declared before it is used
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The compiler would throw Error as stated in the first line.
Environment
Swift-Nio-SSL version: 2.10.0 Swift-Nio version: 2.24.0 XCode Version: 11.7 or higher(Same error with XCode 12.3 Beta)
macOS Version: 11.0.1 (Big Sur)
Additional context
Seems like before updating the OS, it was working fine.