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

Batch mode in swift-driver passes wrong object name #1664

Open
rjmansfield opened this issue Jun 13, 2024 · 0 comments
Open

Batch mode in swift-driver passes wrong object name #1664

rjmansfield opened this issue Jun 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@rjmansfield
Copy link
Contributor

rjmansfield commented Jun 13, 2024

Description

Using -enable-batch-mode results in a link failure as wrong object file name is used.

Reproduction

$ swiftc -enable-batch-mode ~/hw.swift 
error: link command failed with exit code 1 (use -v to see invocation)
clang: error: no such file or directory: '/var/folders/cl/z48nl9xx18307rwb9l42n2yr0000gn/T/TemporaryDirectory.u1TWon/hw-1.o'
clang: error: no input files
error: fatalError

The frontend generates /var/folders/cl/z48nl9xx18307rwb9l42n2yr0000gn/T/TemporaryDirectory.IYWkMJ/hw-2.o but then tries to link /var/folders/cl/z48nl9xx18307rwb9l42n2yr0000gn/T/TemporaryDirectory.IYWkMJ/hw-1.o

$  SWIFT_EXEC=/Users/ryan_mansfield/swift/build/Ninja-RelWithDebInfoAssert/swiftdriver-macosx-arm64/arm64-apple-macosx10.14/release/bin/swiftc SWIFT_DRIVER_SWIFT_FRONTEND_EXEC=~/swift/build/Ninja-ReleaseAssert/swift-macosx-arm64/bin/swift-frontend swiftc -enable-batch-mode ~/hw.swift -v
Swift version 6.0-dev (LLVM 57177aa1b91540b, Swift 85c0555c89e568d)
Target: arm64-apple-macosx14.0
/Users/ryan_mansfield/swift/build/Ninja-ReleaseAssert/swift-macosx-arm64/bin/swift-frontend -frontend -c -primary-file /Users/ryan_mansfield/hw.swift -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -color-diagnostics -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/ryan_mansfield/swift/build/Ninja-ReleaseAssert/swift-macosx-arm64/lib/swift -module-name hw -disable-clang-spi -target-sdk-version 14.4 -target-sdk-name macosx14.4 -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/bin/swift-plugin-server' -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/bin/swift-plugin-server' -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server' -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server' -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /var/folders/cl/z48nl9xx18307rwb9l42n2yr0000gn/T/TemporaryDirectory.IYWkMJ/hw-2.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang /var/folders/cl/z48nl9xx18307rwb9l42n2yr0000gn/T/TemporaryDirectory.IYWkMJ/hw-1.o --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk --target=arm64-apple-macosx14.0 -L /Users/ryan_mansfield/swift/build/Ninja-ReleaseAssert/swift-macosx-arm64/lib/swift/macosx -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/swift -o hw
error: link command failed with exit code 1 (use -v to see invocation)
clang: error: no such file or directory: '/var/folders/cl/z48nl9xx18307rwb9l42n2yr0000gn/T/TemporaryDirectory.IYWkMJ/hw-1.o'
clang: error: no input files
error: fatalError

Using the older driver works:

$ SWIFT_USE_OLD_DRIVER=1  SWIFT_EXEC=/Users/ryan_mansfield/swift/build/Ninja-RelWithDebInfoAssert/swiftdriver-macosx-arm64/arm64-apple-macosx10.15/release/bin/swiftc SWIFT_DRIVER_SWIFT_FRONTEND_EXEC=~/swift/build/Ninja-ReleaseAssert/swift-macosx-arm64/bin/swift-frontend swiftc -enable-batch-mode ~/hw.swift 
<unknown>:0: warning: legacy driver is now deprecated; consider avoiding specifying 'SWIFT_USE_OLD_DRIVER'
$ echo $?
0

Expected behavior

Link executable successfully.

Environment

Swift version 6.0-dev (LLVM 57177aa1b91540b, Swift 85c0555c89e568d)

Additional information

No response

@rjmansfield rjmansfield added the bug Something isn't working label Jun 13, 2024
@hborla hborla transferred this issue from swiftlang/swift Jul 14, 2024
@artemcm artemcm self-assigned this Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants