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

The linker specified in $LD is used, even when a specific linker is needed for the build #72

Open
jp-hoehmann opened this issue Nov 11, 2024 · 1 comment

Comments

@jp-hoehmann
Copy link

jp-hoehmann commented Nov 11, 2024

When I try to build any project using sweetpad, the build fails with an error unknown option: -XLinker from ld. Checking man, it seems that that isn't an option of ld at all, but rather an option of clang.

Environment:

  • macOS 14.7.1
  • XCode 16.1
  • iOS 18.1
  • Sweetpad 0.1.41

Steps taken:

  • Launch XCode
  • File -> New -> Project…
  • iOS -> App
  • Choose interface SwiftUI, language Swift
  • Launch VSCode
  • Build using Sweetpad

Observed error:

/usr/bin/ld -Xlinker -reproducible -target arm64-apple-ios18.1-simulator -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.1.sdk -O0 -L/Users/jean-pierre/Library/Developer/Xcode/DerivedData/hello-cqxmeaanyfjkveblntpnmewtpaxd/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/jean-pierre/Library/Developer/Xcode/DerivedData/hello-cqxmeaanyfjkveblntpnmewtpaxd/Build/Products/Debug-iphonesimulator -F/Users/jean-pierre/Library/Developer/Xcode/DerivedData/hello-cqxmeaanyfjkveblntpnmewtpaxd/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/jean-pierre/Library/Developer/Xcode/DerivedData/hello-cqxmeaanyfjkveblntpnmewtpaxd/Build/Products/Debug-iphonesimulator -filelist /Users/jean-pierre/Library/Developer/Xcode/DerivedData/hello-cqxmeaanyfjkveblntpnmewtpaxd/Build/Intermediates.noindex/hello.build/Debug-iphonesimulator/hello.build/Objects-normal/arm64/hello.LinkFileList -install_name @rpath/hello.debug.dylib -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/jean-pierre/Library/Developer/Xcode/DerivedData/hello-cqxmeaanyfjkveblntpnmewtpaxd/Build/Intermediates.noindex/hello.build/Debug-iphonesimulator/hello.build/Objects-normal/arm64/hello_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -Xlinker -debug_variant -fobjc-link-runtime -fprofile-instr-generate -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/jean-pierre/Library/Developer/Xcode/DerivedData/hello-cqxmeaanyfjkveblntpnmewtpaxd/Build/Intermediates.noindex/hello.build/Debug-iphonesimulator/hello.build/Objects-normal/arm64/hello.swiftmodule -Xlinker -alias -Xlinker _main -Xlinker ___debug_main_executable_dylib_entry_point -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/jean-pierre/Library/Developer/Xcode/DerivedData/hello-cqxmeaanyfjkveblntpnmewtpaxd/Build/Intermediates.noindex/hello.build/Debug-iphonesimulator/hello.build/Objects-normal/arm64/hello_dependency_info.dat -o /Users/jean-pierre/Library/Developer/Xcode/DerivedData/hello-cqxmeaanyfjkveblntpnmewtpaxd/Build/Products/Debug-iphonesimulator/hello.app/hello.debug.dylib
ld: warning: -rpath missing <path>
ld: unknown option: -Xlinker
@jp-hoehmann
Copy link
Author

Digging a little bit further, the problem doesn't occur, when the LD environment variable isn't set. The above output was produced with LD=/usr/bin/ld. With LD unset, it seems to pass these arguments to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang instead.

As a workaround, LD can be unset, but this is liable to cause problems with other tools that need to know the correct linker to use when building for the system (which in the case of macOS should typically be /usr/bin/ld). If clang needs to be run as a linker instead of ld when building for iOS, I think it would be nice if Sweetpad would ignore the environment variable (which is also what XCode does).

@jp-hoehmann jp-hoehmann changed the title -XLinker passed as option to ld The linker specified in $LD is used, even when a specific linker is needed for the build Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant