bazelbuild / rules_swift

Bazel rules to build Swift on Apple and Linux platforms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiling Sources/CNIOBoringSSL/ssl/tls_method.cc failed in rules_swift 1.11.0

tinder-kaijing opened this issue · comments

See this error when try to upgrade rules_xcodeproj for Xcode 15 beta-8. first time to see this error since rules_xcodeproj 1.8.0. then continue having it 1.8.1, 1.9.0, .....

ERROR: /private/var/tmp/_bazel_kaijing/6f2f3b67c4b9fe332bff126887cb2a4e/external/com_github_apple_swift_nio_ssl/BUILD.bazel:38:11: Compiling Sources/CNIOBoringSSL/ssl/tls_method.cc failed: (Exit 1): wrapped_clang_pp failed: error executing command (from target @com_github_apple_swift_nio_ssl//:CNIOBoringSSL) 
  (cd /private/var/tmp/_bazel_kaijing/6f2f3b67c4b9fe332bff126887cb2a4e/execroot/__main__ && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=14.0 \
    PATH=/bin:/usr/bin:/usr/local/bin \
    SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.3SYOogSe1O/Listeners \
    XCODE_VERSION_OVERRIDE=15.0.0.15A5229m \
    ZERO_AR_DATE=1 \
  external/local_config_cc/wrapped_clang_pp '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' 'DEBUG_PREFIX_MAP_PWD=.' -iquote external/com_github_apple_swift_nio_ssl -iquote bazel-out/darwin_arm64-fastbuild/bin/external/com_github_apple_swift_nio_ssl -isystem external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include -MD -MF bazel-out/darwin_arm64-fastbuild/bin/external/com_github_apple_swift_nio_ssl/_objs/CNIOBoringSSL/tls_method.d '-DBAZEL_CURRENT_REPOSITORY="com_github_apple_swift_nio_ssl"' '-frandom-seed=bazel-out/darwin_arm64-fastbuild/bin/external/com_github_apple_swift_nio_ssl/_objs/CNIOBoringSSL/tls_method.o' -isysroot __BAZEL_XCODE_SDKROOT__ -F__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/MacOSX.platform/Developer/Library/Frameworks -no-canonical-prefixes -pthread -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -target arm64-apple-macosx13.4 -c external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/ssl/tls_method.cc -o bazel-out/darwin_arm64-fastbuild/bin/external/com_github_apple_swift_nio_ssl/_objs/CNIOBoringSSL/tls_method.o)
# Configuration: 8ac78d2aa080c43adf2108aeb55e7e4a4beeb96bb9a35241947a7525efc09ab2
# Execution platform: @local_config_platform//:host
In file included from external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/ssl/tls_method.cc:57:
In file included from external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_ssl.h:147:
In file included from external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_bio.h:66:
In file included from external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_ex_data.h:114:
external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_stack.h:514:32: error: no member named 'enable_if_t' in namespace 'std'
struct DeleterImpl<Stack, std::enable_if_t<StackTraits<Stack>::kIsConst>> {
                          ~~~~~^
external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_stack.h:514:73: error: expected unqualified-id
struct DeleterImpl<Stack, std::enable_if_t<StackTraits<Stack>::kIsConst>> {
                                                                        ^
external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_stack.h:521:32: error: no member named 'enable_if_t' in namespace 'std'
struct DeleterImpl<Stack, std::enable_if_t<!StackTraits<Stack>::kIsConst>> {
                          ~~~~~^
external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_stack.h:521:74: error: expected unqualified-id
struct DeleterImpl<Stack, std::enable_if_t<!StackTraits<Stack>::kIsConst>> {
                                                                         ^
external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_stack.h:572:10: error: no template named 'enable_if_t' in namespace 'std'
    std::enable_if_t<StackTraits<Stack>::kIsStack, StackIteratorImpl<Stack>>;
    ~~~~~^
external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_stack.h:579:13: error: no template named 'enable_if_t' in namespace 'std'
inline std::enable_if_t<!internal::StackTraits<Stack>::kIsConst, bool>
       ~~~~~^
external/com_github_apple_swift_nio_ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL_stack.h:594:24: error: no template named 'StackIterator' in namespace 'bssl::internal'; did you mean 'StackIteratorImpl'?

When specifying the rules_swift 1.11.0, and rules_apple 2.5.0 before loading rules_xcodeproj 1.7.1, still can see this error. Seems something is from rules_swift.

WORKSPACE:

http_archive(
    name = "build_bazel_rules_swift",
    sha256 = "f7ab777e1b246cebed185417bffd93135be806e45248c57fd34e0f676bfb1c65",
    url = "https://github.com/bazelbuild/rules_swift/releases/download/1.11.0/rules_swift.1.11.0.tar.gz",
)

http_archive(
    name = "build_bazel_rules_apple",
    sha256 = "8ac4c7997d863f3c4347ba996e831b5ec8f7af885ee8d4fe36f1c3c8f0092b2c",
    url = "https://github.com/bazelbuild/rules_apple/releases/download/2.5.0/rules_apple.2.5.0.tar.gz",
)

http_archive(
    name = "rules_xcodeproj",
    sha256 = "f836d2a516a911dc0ace44b1f51aa575613f149a934f4be1e7bd551a549672ff",
    url = "https://github.com/MobileNativeFoundation/rules_xcodeproj/releases/download/1.7.1/release.tar.gz",
)

A different user reported to me that when they bisected something similar, they believe it was 329d00a that broke it for them.

@brentleyjones Now even if we try to use bzlmod, and still get above error. Any idea how to fix it?

bazel_dep(name = "apple_support", version = "1.11.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
bazel_dep(name = "rules_apple", version = "2.5.0", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_swift", version = "1.7.1", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_xcodeproj", version = "1.7.1", repo_name = "rules_xcodeproj")
bazel_dep(name = "protobuf", version = "3.19.0", repo_name = "com_google_protobuf")

Likely protobuf depends on rules_swift, and version is 1.9.1

It would be helpful if you could bisect down to the commit in rules_swift that breaks it for you (e.g. 329d00a). Or if you can create a small repro, we can debug on that.

x

It would be helpful if you could bisect down to the commit in rules_swift that breaks it for you (e.g. 329d00a). Or if you can create a small repro, we can debug on that.

Thanks. Let me bisect down to the commit first.

@brentleyjones Thanks again to help about the issue. Finally, find the root cause, need to add the below build options into .bazelrc file, to use apple_support Xcode toolchain, to fix the compilation error

build --apple_crosstool_top=@local_config_apple_cc//:toolchain
build --crosstool_top=@local_config_apple_cc//:toolchain
build --host_crosstool_top=@local_config_apple_cc//:toolchain