Skip to content

Conversation

@neonichu
Copy link
Contributor

In many cases, we're directly executing swiftc which means we are relying on the old driver. This switches us to calling swift-driver --driver-mode=swiftc instead if available.

@neonichu neonichu self-assigned this Oct 25, 2022
throw StringError("empty commandline for Swift compilation")
}

// TODO: `--driver-mode=swiftc` needs to be the first argument, but going through `SwiftCompilerTool` does not allow that
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix this we'd need to move off llbuild's built-in tool and instead create a shell command (which is probably better anyway).

@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

extraFlags.swiftCompilerFlags
}

private static func commandLineForCompilation(compilerPath: AbsolutePath, fileSystem: FileSystem) -> [String] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: reverse order of arguments

}

/// Helper function to determine whether serialized diagnostics work properly in the current environment.
public func supportsSerializedDiagnostics(otherSwiftFlags: [String] = []) -> Bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the hope/goal since this was needed because we were using the old driver in CI contexts (which apparently has a bug triggered by some of our tests).

@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

Looks like right now we're not even installing the driver, so we'd need to change that in the preset / CI job first.

@neonichu
Copy link
Contributor Author

swiftlang/swift#61766
@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

swiftlang/swift#61766
@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

swiftlang/swift#61766
@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

Doesn't look like swift-driver is present inside the toolchain installation directory?

--- bootstrap: note: Symlinking /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/toolchain-macosx-x86_64/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver
--- bootstrap: note: Available executables: ['swift-api-extract', 'swift-build-tool', 'swift-symbolgraph-extract', 'clang', 'llvm-cov', 'swift-demangle', 'clangd', 'clang-13', 'swift-frontend', 'clang-cl', 'dsymutil', 'clang-cache', 'sdk-module-lists', 'swift-stdlib-tool', 'swift-api-checker.py', 'swift', 'clang++', 'swiftc', 'clang-cpp', 'llvm-profdata', 'swift-autolink-extract', 'swift-api-digester']

@finagolfin
Copy link
Member

What happened to the integrated swift driver that was added last year, #2736, did that not work out? Seems a waste to include that when building SPM and then not use it.

@neonichu
Copy link
Contributor Author

What happened to the integrated swift driver that was added last year, #2736, did that not work out? Seems a waste to include that when building SPM and then not use it.

I'm not 100% sure (cc @artemcm), but either way we cannot use it for manifest compilation / plugin loading since they happen separately from the build system.

@neonichu
Copy link
Contributor Author

neonichu commented Nov 1, 2022

I think my Swift PR might be incorrect and install swift-driver after building SwiftPM, so that's why it is missing here.

@finagolfin
Copy link
Member

Yes, SPM is built and installed first because it is then used to build and install swift-driver, at least on linux and Android.

@neonichu
Copy link
Contributor Author

neonichu commented Nov 2, 2022

swiftlang/swift#61766
@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

neonichu commented Nov 3, 2022

OK, I added a install-swift-driver before swiftpm in the preset, but it doesn't seem to have affected things a whole lot? Still doesn't seem to be present in the installation directory.

--- bootstrap: note: Symlinking /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/toolchain-macosx-x86_64/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver
--- bootstrap: note: Available executables: ['swift-api-extract', 'swift-build-tool', 'swift-symbolgraph-extract', 'clang', 'llvm-cov', 'swift-demangle', 'clangd', 'clang-13', 'swift-frontend', 'clang-cl', 'dsymutil', 'clang-cache', 'sdk-module-lists', 'swift-stdlib-tool', 'swift-api-checker.py', 'swift', 'clang++', 'swiftc', 'clang-cpp', 'llvm-profdata', 'swift-autolink-extract', 'swift-api-digester']

@finagolfin
Copy link
Member

The order of the flags is irrelevant, as SPM is used to build swift-driver, so it is always built and tested before.

@neonichu
Copy link
Contributor Author

neonichu commented Nov 3, 2022

The order of the flags is irrelevant, as SPM is used to build swift-driver, so it is always built and tested before.

Ah interesting, that seems unfortunate. We're actually already building the driver as part of the first bootstrapping stage, maybe we can just change things to re-use the built products from that.

@finagolfin
Copy link
Member

Only the macOS CI builds the early swift-driver, the linux CI doesn't as it doesn't have a prebuilt Swift compiler installed.

@finagolfin
Copy link
Member

Oh, if you mean when bootstrapping SPM itself, not sure what executables that generates.

@neonichu
Copy link
Contributor Author

neonichu commented Nov 3, 2022

So I think a viable path here could be:

  • add the ability to specify a custom swift-driver (@compnerd also asked for this) and point it to the one anyway produced by building swift-driver with CMake during bootstrap
  • tell the driver to use the swiftc we're already using (might already be happening)

neonichu added a commit that referenced this pull request Nov 8, 2022
This tries to use the swift-driver built during the first-stage for the "fake" toolchain we're constructing for bootstrapping. Basically a variation on #5842.

Trying first whether it is sufficient to just have the symlink, if not we should be able to combine the approach from #5842 and this together.
In many cases, we're directly executing `swiftc` which means we are relying on the old driver. This switches us to calling `swift-driver --driver-mode=swiftc` instead if available.
@neonichu
Copy link
Contributor Author

neonichu commented Nov 9, 2022

@swift-ci please smoke test

1 similar comment
@neonichu
Copy link
Contributor Author

neonichu commented Dec 8, 2022

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

neonichu commented Dec 8, 2022

Probably time to abandon this, actually. Failures on self-hosted are proving that even explicitly using swift-driver doesn't help us:

Using compiler command line: ["/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver", "--driver-mode=swiftc"]

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

Successfully merging this pull request may close these issues.

3 participants