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

Disable earlyswiftdriver on non-Darwin hosts #38204

Closed
wants to merge 1 commit into from

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Jul 1, 2021

Host toolchains on Linux are not yet capable of building the driver because it depends on the presence of Foundation .cmake files which are not shipped as part of the Linux toolchain.

@artemcm artemcm requested a review from gottesmm July 1, 2021 18:49
@artemcm
Copy link
Contributor Author

artemcm commented Jul 1, 2021

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2021

Build failed
Swift Test Linux Platform
Git Sha - a71c3b6f6c222ab803b0242915124fea284aca2d

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2021

Build failed
Swift Test OS X Platform
Git Sha - a71c3b6f6c222ab803b0242915124fea284aca2d

Host toolchains on Linux are not yet capable of building the driver because it depends on the presence of Foundation .cmake files which are not shipped as part of the Linux toolchain.
@artemcm
Copy link
Contributor Author

artemcm commented Jul 2, 2021

@swift-ci please test

@finagolfin
Copy link
Contributor

Are you sure? It builds fine for me on Fedora Core 33 with the native Swift from their package manager.

@artemcm
Copy link
Contributor Author

artemcm commented Jul 2, 2021

Are you sure? It builds fine for me on Fedora Core 33 with the native Swift from their package manager.

Oh interesting! The Swift package there must ship more than we include in Linux toolchains on Swift.org.
Let me see if we can make that more fine-grained.

@artemcm
Copy link
Contributor Author

artemcm commented Jul 2, 2021

@swift-ci please test Windows platform

@finagolfin
Copy link
Contributor

The Swift package there must ship more than we include in Linux toolchains on Swift.org.

I don't think so, I just checked and it doesn't include any CMake files. I will try building it again this evening and report what I find.

@finagolfin
Copy link
Contributor

finagolfin commented Jul 3, 2021

I just checked out latest trunk and ran ./swift/utils/build-script -R --no-assertions --verbose-build on Fedora Core 33 with the Swift 5.4.1 package installed. It built the early Swift Driver without a problem, and that Fedora Swift package has no .cmake files. I can think of twothree reasons we're seeing different results:

  • I don't run the tests, is that failing for you?
  • I'm not building and installing into the final toolchain with the --swift-driver --install-swift-driver flags, is that failing later?
  • Fedora 33 has CMake 3.19.7 installed, Ubuntu uses a much older CMake package I think.

@artemcm
Copy link
Contributor Author

artemcm commented Jul 6, 2021

On Ubuntu 20.04, using just the latest snapshot toolchain from swift.org (June 12, 2021), I am hitting:

--- Building earlyswiftdriver ---
...
CMake Error at CMakeLists.txt:18 (find_package):
  Could not find a package configuration file provided by "Foundation" with
  any of the following names:
    FoundationConfig.cmake
    foundation-config.cmake

I think out of the reasons you listed above the different CMake version seems likely to me.
This is happening before any kinds of tests are run/built and irrespective of any install options, since those do not affect earlyswiftdriver.

I'll try to see if I can reproduce with a newer CMake.

@finagolfin
Copy link
Contributor

Yeah, that must be a CMake issue. Since you're building trunk and the system CMake is old, doesn't it build CMake from source? If not, you may need to reorder CMake to build first.

@finagolfin
Copy link
Contributor

To be clear what I was talking about with reordering the CMake build, build-script checks the CMake version then builds it from source if the system binary is an older version than the source version, which is currently 3.19.6 for trunk.

It appears that is correctly done before the early swift-driver is built so no reordering is necessary, but either something else is going wrong with getting the right CMake version or it is somehow failing with a recent CMake too for you. Can you check what CMake version is being used when it is failing for you?

@finagolfin
Copy link
Contributor

finagolfin commented Jul 25, 2021

Btw, I just tried building the latest July 24 trunk source snapshot on Fedora core 33 with this early swift driver and while it built fine with the system Swift 5.4.1, it would cause problems later when trying to build the trunk stdlib:

[3/26][ 11%][0.233s] Compiling /home/butta/src/build/Ninja-Release/swift-linux-x86_64/stdlib/public/Platform/LINUX/x86_64/Glibc.o
FAILED: stdlib/public/Platform/LINUX/x86_64/Glibc.o 
cd /home/butta/src/build/Ninja-Release/swift-linux-x86_64/stdlib/public/Platform && /usr/bin/python3.9 /home/butta/src/swift/utils/line-directive @/home/butta/src/build/Ninja-Release/swift-linux-x86_64/stdlib/public/Platform/09ce9cc9baea03bf7ed174c0bb3cb2cb98a16ab9.txt -- /home/butta/src/build/Ninja-Release/swift-linux-x86_64/./bin/swiftc -c -sdk / -target x86_64-unknown-linux-gnu -resource-dir /home/butta/src/build/Ninja-Release/swift-linux-x86_64/./lib/swift -O -D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING -D SWIFT_RUNTIME_OS_VERSIONING -module-cache-path /home/butta/src/build/Ninja-Release/swift-linux-x86_64/./module-cache -no-link-objc-runtime -enable-library-evolution -Xfrontend -enforce-exclusivity=unchecked -module-name Glibc -swift-version 5 -swift-version 5 -autolink-force-load -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements -warn-swift3-objc-inference-complete -Xfrontend -verify-syntax-tree -warn-implicit-overrides -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-distributed-module-import -module-link-name swiftGlibc -whole-module-optimization -parse-as-library -I /home/butta/src/build/Ninja-Release/swift-linux-x86_64/./lib/swift/linux -o /home/butta/src/build/Ninja-Release/swift-linux-x86_64/stdlib/public/Platform/LINUX/x86_64/Glibc.o @/home/butta/src/build/Ninja-Release/swift-linux-x86_64/stdlib/public/Platform/09ce9cc9baea03bf7ed174c0bb3cb2cb98a16ab9.txt
error: unableToFind(tool: "swift-autolink-extract")

Disabling with -skip-early-swift-driver fixes the issue.

Also, if I build the corelibs after disabling the early swift driver then go back and remove that flag to try using it again, now building it fails because it passes in the newly built trunk Foundation directory and that causes a Swift version mismatch with the system Swift 5.4.1, which is fixed by deleting that newly built Foundation. This is because the early swift driver setup assumes the prebuilt host Swift toolchain is the same version as the toolchain being built from source, which shouldn't need to be the case.

None of this is tested by the linux CI as I just checked and it doesn't have a prebuilt host Swift toolchain installed.

@finagolfin
Copy link
Contributor

Looked into the error pasted above, the problem is that you're symlinking against the early swift-driver binary, rather than copying it over into the Swift compiler build directory. This means swift-driver is still in build/Ninja-Release/earlyswiftdriver-linux-x86_64/release/bin/ and since it can't find a Swift compiler in the same directory, it goes looking in the PATH and other places it shouldn't, when we only want it to use the new Swift compiler next to the symlink, ie the one in build/Ninja-Release/swift-linux-x86_64/bin.

This may work fine if the host toolchain used to build the early swift-driver is reasonably similar to the new toolchain being built from source, but it doesn't work when the host toolchain is Fedora's system Swift 5.4.2, which doesn't put swift-autolink-extract in its path (Fedora puts the Swift toolchain in /usr/libexec/swift instead and only places symlinks for swift/c in /usr/bin, to avoid conflicting with other Fedora packages like clang). Anyway, early swift-driver should only be using the new compiler, not rummaging in the path.

You could fix this by copying the early swift-driver binaries over instead, as is done later on in the build with --install-swift-driver.

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.

None yet

3 participants