mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add ld_classic flag to Hermes when building for Xcode 15 (#39516)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39516 With Xcode15, Apple rewrote the C++ linker. This is a breaking change that does not work with weak symbols. As a workaround, apple is suggesting to add `-ld_classic` to the linker in order to readd support for weak symbols. The flag does not exists for Xcode 14.3 or lower, so we need to add it conditionally. With this change, we introduce a couple of checks in the Hermes build logic: 1. Detect the version of Xcode that is used 2. Add the new flag to `HERMES_EXTRA_LINKER_FLAGS` if Xcode version is 15. [Internal] - Make hermes build properly with Xcode 15 Reviewed By: cortinico, dmytrorykun Differential Revision: D49368675 fbshipit-source-id: 62d8ed81855c426f56ed94b6a2d6da2eb882b355
This commit is contained in:
committed by
Thibault Malbranche
parent
740c40187f
commit
5f4a091a2f
@@ -35,7 +35,7 @@ function build_host_hermesc {
|
||||
|
||||
# Utility function to configure an Apple framework
|
||||
function configure_apple_framework {
|
||||
local build_cli_tools enable_bitcode
|
||||
local build_cli_tools enable_bitcode xcode_15_flags xcode_major_version
|
||||
|
||||
if [[ $1 == iphoneos || $1 == catalyst ]]; then
|
||||
enable_bitcode="true"
|
||||
@@ -48,7 +48,14 @@ function configure_apple_framework {
|
||||
build_cli_tools="false"
|
||||
fi
|
||||
|
||||
xcode_15_flags=""
|
||||
xcode_major_version=$(xcodebuild -version | grep -oE '[0-9]*' | head -n 1)
|
||||
if [[ $xcode_major_version -ge 15 ]]; then
|
||||
xcode_15_flags="LINKER:-ld_classic"
|
||||
fi
|
||||
|
||||
cmake -S . -B "build_$1" \
|
||||
-DHERMES_EXTRA_LINKER_FLAGS="$xcode_15_flags" \
|
||||
-DHERMES_APPLE_TARGET_PLATFORM:STRING="$1" \
|
||||
-DCMAKE_OSX_ARCHITECTURES:STRING="$2" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="$3" \
|
||||
|
||||
Reference in New Issue
Block a user