TelegramMessenger / Telegram-iOS

Telegram-iOS
6.36k stars 1.67k forks source link

Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - broken #1211

Open shivanraptor opened 1 year ago

shivanraptor commented 1 year ago

Checklist

Description

When compiling release-10.1 (no code has been modified, freshly cloned from GitHub) with the following command, the broken CXX compiler error is found and the build IPA process is halted.

USE_BAZEL_VERSION=6.3.2 python3 build-system/Make/Make.py --overrideXcodeVersion --bazel="/usr/local/bin/bazel" --cacheDir="$HOME/telegram-bazel-cache" build --configurationPath="$HOME/telegram-configuration/development-configuration.json" --buildNumber=11601 --configuration=release_arm64 --codesigningInformationPath="$HOME/telegram-configuration/fake-codesigning"

When I run this command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ --version, here is the output:

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Looks like it's working fine.

If I change the configuration to relelase_universal (just like all the releases before), there is another error:

ERROR: /private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/external/local_config_apple_cc/BUILD:39:19: in cc_toolchain_suite rule @local_config_apple_cc//:toolchain: cc_toolchain_suite '@local_config_apple_cc//:toolchain' does not contain a toolchain for cpu 'ios_armv7'
ERROR: /private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/external/local_config_apple_cc/BUILD:39:19: Analysis of target '@local_config_apple_cc//:toolchain' failed
ERROR: Analysis of target '//Telegram:Telegram' failed; build aborted

Expected Behavior

The IPA should be built without a problem.

Actual Behavior

The IPA failed to be built, with the following errors:

-- The C compiler identification is AppleClang 14.0.3.14030022
-- The CXX compiler identification is AppleClang 14.0.3.14030022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - broken
-- Configuring incomplete, errors occurred!
See also "/private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/build/CMakeFiles/CMakeOutput.log".
See also "/private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/build/CMakeFiles/CMakeError.log".
Target //Telegram:Telegram failed to build
ERROR: /Users/adv/Documents/workspace/Xcode/xCodeProjects/telegram/release-10.1/Telegram/BUILD:1106:14 Linking Telegram/TelegramUIFramework_bin_unstripped failed: (Exit 1): bash failed: error executing command (from target //third-party/libjxl:libjxl_build) 

Generation of Xcode project encounters NO error.

Steps to Reproduce

  1. Execute the build IPA command (see above)
  2. The error appears and the IPA build process halted

Environment

Device: macOS Ventura 13.5 (Intel iMac) iOS version: 17.0 (not related) App version: release-10.1 Bazel version: 6.3.2 via bazelisk Xcode version: 14.3.1

shivanraptor commented 1 year ago

Here is the CMakeError.log:

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 
Build flags: -Wall;-arch;arm64;-miphoneos-version-min=11.0;-funwind-tables
Id flags:  

The output was:
1
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ 
Build flags: 
Id flags:  

The output was:
1
ld: library not found for -lc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Detecting CXX compiler ABI info failed to compile with the following output:
Change Dir: /private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_1a8bf/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_1a8bf.dir/build.make CMakeFiles/cmTC_1a8bf.dir/build
Building CXX object CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk   -v -Wl,-v -MD -MT CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o -MF CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o.d -o CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o -c /private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/cmake/cmake-3.23.1-macos-universal/CMake.app/Contents/share/cmake-3.23/Modules/CMakeCXXCompilerABI.cpp
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: warning: -Wl,-v: 'linker' input unused [-Wunused-command-line-argument]
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-ios16.4.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -ffp-contract=on -fno-rounding-math -funwind-tables=2 -target-sdk-version=16.4 -fvisibility-inlines-hidden-static-local-var -target-cpu core2 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=lldb -target-linker-version 857.1 -v -fcoverage-compilation-dir=/private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/build/CMakeFiles/CMakeTmp -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3 -dependency-file CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o.d -skip-unused-modulemap-deps -MT CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o -sys-header-deps -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -fdeprecated-macro -fdebug-compilation-dir=/private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/build/CMakeFiles/CMakeTmp -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -no-opaque-pointers -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o -x c++ /private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/cmake/cmake-3.23.1-macos-universal/CMake.app/Contents/share/cmake-3.23/Modules/CMakeCXXCompilerABI.cpp
clang -cc1 version 14.0.3 (clang-1403.0.22.14.1) default target x86_64-apple-darwin22.6.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/v1
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/include
 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks (framework directory)
End of search list.
Linking CXX executable cmTC_1a8bf
/private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/cmake/cmake-3.23.1-macos-universal/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1a8bf.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -Wl,-headerpad_max_install_names  -v -Wl,-v CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_1a8bf 
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch x86_64 -platform_version ios 16.4.0 16.4 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -o cmTC_1a8bf -headerpad_max_install_names -v CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib/darwin/libclang_rt.ios.a
@(#)PROGRAM:ld  PROJECT:ld64-857.1
BUILD 23:13:24 May  7 2023
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib
Framework search paths:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib/darwin/libclang_rt.ios.a, file is universal (armv7,armv7s,arm64,arm64e) but does not contain the x86_64 architecture: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib/darwin/libclang_rt.ios.a
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libc++.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libc++.tbd (4 slices)
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libSystem.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libSystem.tbd (4 slices)
ld: building for iOS, but linking in object file built for iOS Simulator, file 'CMakeFiles/cmTC_1a8bf.dir/CMakeCXXCompilerABI.cpp.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_1a8bf] Error 1
make: *** [cmTC_1a8bf/fast] Error 2

Determining if the CXX compiler works failed with the following output:
Change Dir: /private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_a41ac/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_a41ac.dir/build.make CMakeFiles/cmTC_a41ac.dir/build
Building CXX object CMakeFiles/cmTC_a41ac.dir/testCXXCompiler.cxx.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -MD -MT CMakeFiles/cmTC_a41ac.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_a41ac.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_a41ac.dir/testCXXCompiler.cxx.o -c /private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_a41ac
/private/var/tmp/_bazel_adv/cca144ca8e1517144ec69637e0fe3f9f/execroot/__main__/bazel-out/ios-arm64-min11.0-applebin_ios-ios_arm64-opt-ST-76ceec7ff599/bin/third-party/libjxl/build_arm64/cmake/cmake-3.23.1-macos-universal/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a41ac.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -Wl,-headerpad_max_install_names CMakeFiles/cmTC_a41ac.dir/testCXXCompiler.cxx.o -o cmTC_a41ac 
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib/darwin/libclang_rt.ios.a, file is universal (armv7,armv7s,arm64,arm64e) but does not contain the x86_64 architecture: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib/darwin/libclang_rt.ios.a
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libc++.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libc++.tbd (4 slices)
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libSystem.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libSystem.tbd (4 slices)
ld: building for iOS, but linking in object file built for iOS Simulator, file 'CMakeFiles/cmTC_a41ac.dir/testCXXCompiler.cxx.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_a41ac] Error 1
make: *** [cmTC_a41ac/fast] Error 2
ali-fareed commented 1 year ago

Intel builds are not functional at the moment.

shivanraptor commented 1 year ago

Intel builds are not functional at the moment.

Noted. Hope it will be supported soon.

maximality commented 1 year ago

Seems like I have similar error on Apple Silicon Mac: https://github.com/TelegramMessenger/Telegram-iOS/issues/1217 Can you check it out please? @ali-fareed

G-200 commented 1 year ago

Intel builds are not functional at the moment.

@ali-fareed I found that this can be fixed by adding CXXFLAGS option in file third-party/libjxl/build-libjxl-bazel.sh. I set it to same value as in CFLAGS and then build succeeded.

maximality commented 1 year ago

Intel builds are not functional at the moment.

@ali-fareed I found that this can be fixed by adding CXXFLAGS option in file third-party/libjxl/build-libjxl-bazel.sh. I set it to same value as in CFLAGS and then build succeeded.

Thanks! It works now!