-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
rust-lang/rust
#64254Labels
C-bugCategory: bugCategory: bug

Description
Problem
Invoking cargo build
from an Xcode project targeting iOS or iOS Simulator fails to build any crate with a custom build script, because the wrong linker is invoked for the custom build script. This is because Xcode sets SDKROOT
for the target platform (the build script must be built for the host platform instead)
Steps
git clone [email protected]:rust-lang/libc.git && cd libc
SDKROOT=`xcrun --sdk iphonesimulator --show-sdk-path` cargo +nightly build --target x86_64-apple-ios -vv
or
SDKROOT=`xcrun --sdk iphoneos --show-sdk-path` cargo +nightly build --target x86_64-apple-ios -vv
- The custom build script is built with the iPhoneSimulator SDK linker instead of the MacOSX SDK linker, which causes the build to fail with undefined symbols
Possible Solution(s)
Invoking rustc
for the custom build script should always use the SDK for the host platform instead of the target platform (that is, ignore the SDKROOT
environment variable set by the user or Xcode). This can be achieved, for example, by Cargo prepending the rustc
invocation with SDKROOT=""
Notes
Output of cargo version
: cargo 1.37.0 (9edd089 2019-08-02)
Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bug