nodejs-mobile / nodejs-mobile

Full-fledged Node.js on Android and iOS
https://nodejs-mobile.github.io
Other
458 stars 44 forks source link

iOS Framework build fails: library 'base64_sse42' not found #80

Open tcobbs-bentley opened 4 months ago

tcobbs-bentley commented 4 months ago

Version

v18.16.1

Platform

Darwin M7NP0941YH 22.6.0 Darwin Kernel Version 22.6.0: Tue Nov 7 21:40:08 PST 2023; root:xnu-8796.141.3.702.9~2/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

Run ./tools/ios_framework_prepare.sh.

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Build should succeed

What do you see instead?

 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -application_extension -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -dylib -dylib_compatibility_version 1 -dylib_current_version 1 -arch arm64 -dylib_install_name @rpath/NodeMobile.framework/NodeMobile -all_load -dead_strip -platform_version ios 13.0.0 17.2 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk -Os -o /Users/travis/src/nodejs-mobile/out_ios/iphoneos-arm64/Release-iphoneos/NodeMobile.framework/NodeMobile -L/Users/travis/src/nodejs-mobile/out_ios/iphoneos-arm64/EagerLinkingTBDs/Release-iphoneos -L/Users/travis/src/nodejs-mobile/out_ios/iphoneos-arm64/Release-iphoneos -L/Users/travis/src/nodejs-mobile/tools/ios-framework/bin -reproducible -filelist /Users/travis/src/nodejs-mobile/out_ios/iphoneos-arm64/NodeMobile.build/Release-iphoneos/NodeMobile.build/Objects-normal/arm64/NodeMobile.LinkFileList -rpath @executable_path/Frameworks -rpath @loader_path/Frameworks -object_path_lto /Users/travis/src/nodejs-mobile/out_ios/iphoneos-arm64/NodeMobile.build/Release-iphoneos/NodeMobile.build/Objects-normal/arm64/NodeMobile_lto.o -lc++ -lbase64_sse42 -lbase64_avx -lv8_compiler -lv8_snapshot -lngtcp2 -lhistogram -lbase64_ssse3 -lllhttp -lv8_initializers -lv8_libplatform -lbrotli -luvwasi -lv8_zlib -lv8_libbase -lv8_base_without_compiler -lnghttp3 -framework CoreFoundation -lsimdutf -lcares -lnghttp2 -lbase64_neon64 -lada -lnode -lbase64_sse41 -lopenssl -lbase64 -lbase64_avx2 -luv -lzlib_inflate_chunk_simd -lzlib -dependency_info /Users/travis/src/nodejs-mobile/out_ios/iphoneos-arm64/NodeMobile.build/Release-iphoneos/NodeMobile.build/Objects-normal/arm64/NodeMobile_dependency_info.dat -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.ios.a -F/Users/travis/src/nodejs-mobile/out_ios/iphoneos-arm64/EagerLinkingTBDs/Release-iphoneos -F/Users/travis/src/nodejs-mobile/out_ios/iphoneos-arm64/Release-iphoneos
ld: warning: ignoring duplicate libraries: '-lc++'
ld: library 'base64_sse42' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Additional information

It appears obvious why it can't find the library: that's an x86_64 library and it's trying to build for arm64. However, I have no idea why it is trying to link an x86_64-only library into the arm64 build, and I have no idea how the released binaries were created.

tcobbs-bentley commented 4 months ago

Note: the bug report template asked for the output from node -v, and I provided that. However, the problem is happening for me while trying to build from the main branch of the git repository. I don't think the Mac's node version should be contributing to the problem.

tcobbs-bentley commented 4 months ago

It looks like this broken when x86_64 support was added. I have a fix that I am testing that involves creating a new NodeMobile-x64 target for the x86_64 build in NodeMobile.xcodeproj and then tweaking ios_framework_prepare.sh to reflect the changes that introduces.

Note: the new target will not include libbase64_neon64.a and libzlib_inflate_chunk_simd.a, which are arm64-specific, and the existing target will not include the x64-only libraries. Assuming everything works, I will submit a PR with my fixes.

tcobbs-bentley commented 4 months ago

I submitted a PR with a fix for this:

https://github.com/nodejs-mobile/nodejs-mobile/pull/81