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

make pod-install command fails for MacOS Sonoma & Xcode 15 #17682

Closed
siddarthkay opened this issue Oct 19, 2023 · 10 comments · Fixed by #18108
Closed

make pod-install command fails for MacOS Sonoma & Xcode 15 #17682

siddarthkay opened this issue Oct 19, 2023 · 10 comments · Fixed by #18108

Comments

@siddarthkay
Copy link
Contributor

Problem

As reported by @mohsen-ghafouri

On latest develop branch
make pod-install
would fail with
Could not find ffi-1.15.5 in locally installed gems (Bundler::GemNotFound)

when running make nix-update-gems
the key error message was
<internal:/nix/store/wsb2l0f892jfry6inik9kj8swn2bpz00-ruby-3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in require': incompatible library version - /Users/maxghafori/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.bundle `

Screenshots

pod-failure

@siddarthkay
Copy link
Contributor Author

After updating local ruby version, @mohsen-ghafouri also saw this :

# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"

patching file config.sub
checking for a BSD-compatible install... /nix/store/a50l7xr6jrx5jlm8ys5jyi3nvlycq748-coreutils-9.1/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /nix/store/a50l7xr6jrx5jlm8ys5jyi3nvlycq748-coreutils-9.1/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk
checking whether the C compiler works... no
sed: can't read s/\@ac_cv_have_libgflags\@/0/: No such file or directory
sed: can't read s/HAVE_LIB_GFLAGS/HAVE_LIB_GFLAGS_DISABLED/: No such file or directory
/Users/maxghafori/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-166d1/missing: Unknown `--is-lightweight' option
Try `/Users/maxghafori/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-166d1/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/maxghafori/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-166d1':
configure: error: C compiler cannot create executables
See `config.log' for more details

It seems like he is using Xcode 15 and that could be the root cause of this issue.

@shivekkhurana
Copy link
Contributor

I'm having a similar issue. Xcode 15 with ios 17.

My problem is not ruby version though, just a pod (glog) not building properly.

What is the recommended Xcode and ios version ?

@siddarthkay
Copy link
Contributor Author

@shivekkhurana : Xcode 14.3

@siddarthkay siddarthkay changed the title make pod-install command fails for MacOS with local ruby version 3.0 make pod-install command fails for MacOS Sonoma & Xcode 15 Dec 6, 2023
@jakubgs
Copy link
Member

jakubgs commented Dec 6, 2023

We have not changed glog version in ages, so that's not the variable.

- glog (0.3.5)

@siddarthkay
Copy link
Contributor Author

Adding logs from my macbook that runs Sonoma and Xcode 15

Installing fmt (6.2.1)
Installing glog (0.3.5)
[!] /nix/store/jlwqgw3nhd4sjfgpvj7q1panavcaii7g-bash-interactive-5.2-p15/bin/bash -c 
set -e
#!/nix/store/3rm2qr5fmgacq47l4ysr72pfm2vdkp8l-bash-5.2-p15/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e

PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"

if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
    # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
    # it's better to rely on platform name as fallback because architecture differs between simulator and device

    if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
        CURRENT_ARCH="x86_64"
    else
        CURRENT_ARCH="arm64"
    fi
fi

# @lint-ignore-every TXT2 Tab Literal
if [ "$CURRENT_ARCH" == "arm64" ]; then
    cat <<\EOF >>fix_glog_0.3.5_apple_silicon.patch
diff --git a/config.sub b/config.sub
index 1761d8b..43fa2e8 100755
--- a/config.sub
+++ b/config.sub
@@ -1096,6 +1096,9 @@ case $basic_machine in
 		basic_machine=z8k-unknown
 		os=-sim
 		;;
+	arm64-*)
+		basic_machine=$(echo $basic_machine | sed 's/arm64/aarch64/')
+		;;
 	none)
 		basic_machine=none-none
 		os=-none
EOF

    patch -p1 config.sub fix_glog_0.3.5_apple_silicon.patch
fi

export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"

# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
    rm test-driver
fi

# Manually disable gflags include to fix issue https://github.com/facebook/react-native/issues/28446
sed -i.bak -e 's/\@ac_cv_have_libgflags\@/0/' src/glog/logging.h.in && rm src/glog/logging.h.in.bak
sed -i.bak -e 's/HAVE_LIB_GFLAGS/HAVE_LIB_GFLAGS_DISABLED/' src/config.h.in && rm src/config.h.in.bak

./configure --host arm-apple-darwin

cat << EOF >> src/config.h
/* Add in so we have Apple Target Conditionals */
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <Availability.h>
#endif

/* Special configuration for ucontext */
#undef HAVE_UCONTEXT_H
#undef PC_FROM_UCONTEXT
#if defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
#elif defined(__i386__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
#endif
EOF

# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"

patching file config.sub
checking for a BSD-compatible install... /nix/store/a50l7xr6jrx5jlm8ys5jyi3nvlycq748-coreutils-9.1/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /nix/store/a50l7xr6jrx5jlm8ys5jyi3nvlycq748-coreutils-9.1/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk
checking whether the C compiler works... no
/Users/siddarthkumar/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-c5b45/missing: Unknown `--is-lightweight' option
Try `/Users/siddarthkumar/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-c5b45/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/siddarthkumar/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-c5b45':
configure: error: C compiler cannot create executables
See `config.log' for more details

warn Package react-native-blob-util contains invalid configuration: "dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
warn Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Found Xcode workspace "StatusIm.xcworkspace"
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Error: No simulator available with name "iPhone 13"".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v18.16.0
make: *** [run-ios] Error 1

@siddarthkay
Copy link
Contributor Author

I think the key thing to focus would be

configure: error: in `/Users/siddarthkumar/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-c5b45':
configure: error: C compiler cannot create executables
See `config.log' for more details

@siddarthkay
Copy link
Contributor Author

siddarthkay commented Dec 7, 2023

As the error suggests my config.log was present here : /Users/siddarthkumar/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-c5b45/config.log

Inside this log file there are a bunch of clang errors.

clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:3685: $? = 1
configure:3674: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk -qversion >&5
clang: error: unknown argument '-qversion'; did you mean '--version'?
clang: error: no input files
configure:3685: $? = 1
configure:3705: checking whether the C compiler works
configure:3727: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk    conftest.c  >&5
clang: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX' [-Wincompatible-sysroot]
ld: building for 'macOS', but linking in dylib (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libSystem.B.tbd) built for 'iOS'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:3731: $? = 1
configure:3769: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "glog"
| #define PACKAGE_TARNAME "glog"
| #define PACKAGE_VERSION "0.3.5"
| #define PACKAGE_STRING "glog 0.3.5"
| #define PACKAGE_BUGREPORT "[email protected]"
| #define PACKAGE_URL ""
| #define PACKAGE "glog"
| #define VERSION "0.3.5"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3774: error: in `/Users/siddarthkumar/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-c5b45':
configure:3776: error: C compiler cannot create executables

@siddarthkay
Copy link
Contributor Author

Another possible issue could be this message checking whether the C compiler works... no which results as an execution of configure glog script inside react-native here : node_modules/react-native/scripts/ios-configure-glog.sh

ref : https://github.com/facebook/react-native/blob/0.72-stable/packages/react-native/scripts/ios-configure-glog.sh#L57

@siddarthkay
Copy link
Contributor Author

related issues : google/glog#544
possible fix regarding C++ compiler flags : facebook/react-native#34443 (comment) and react-native-community/cli#1194 (comment)

@siddarthkay
Copy link
Contributor Author

I'm having a similar issue. Xcode 15 with ios 17.

My problem is not ruby version though, just a pod (glog) not building properly.

What is the recommended Xcode and ios version ?

your existing environment should be compatible once #18108 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants