Skip to content

The new swift-driver doesn't seem to work properly when it's used through a symbolic link #70932

@kkebo

Description

@kkebo

Description

SSWG's swiftly installs a Swift toolchain under $SWIFTLY_BIN_DIR (e.g. $HOME/.local/bin).

In fact, they are just symbolic links to executables under $SWIFTLY_HOME_DIR/toolchains/*/usr/bin.

$ ls -l $SWIFT_BIN_DIR total 55116 lrwxrwxrwx 1 kebo kebo 81 Jan 16 22:20 clang -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/clang lrwxrwxrwx 1 kebo kebo 83 Jan 16 22:20 clang++ -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/clang++ lrwxrwxrwx 1 kebo kebo 84 Jan 16 22:20 clang-17 -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/clang-17 lrwxrwxrwx 1 kebo kebo 87 Jan 16 22:20 clang-cache -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/clang-cache lrwxrwxrwx 1 kebo kebo 84 Jan 16 22:20 clang-cl -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/clang-cl lrwxrwxrwx 1 kebo kebo 85 Jan 16 22:20 clang-cpp -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/clang-cpp lrwxrwxrwx 1 kebo kebo 82 Jan 16 22:20 clangd -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/clangd lrwxrwxrwx 1 kebo kebo 80 Jan 16 22:20 docc -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/docc lrwxrwxrwx 1 kebo kebo 84 Jan 16 22:20 ld64.lld -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/ld64.lld lrwxrwxrwx 1 kebo kebo 82 Jan 16 22:20 ld.lld -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/ld.lld lrwxrwxrwx 1 kebo kebo 79 Jan 16 22:20 lld -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/lld lrwxrwxrwx 1 kebo kebo 80 Jan 16 22:20 lldb -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/lldb lrwxrwxrwx 1 kebo kebo 90 Jan 16 22:20 lldb-argdumper -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/lldb-argdumper lrwxrwxrwx 1 kebo kebo 87 Jan 16 22:20 lldb-server -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/lldb-server lrwxrwxrwx 1 kebo kebo 84 Jan 16 22:20 lld-link -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/lld-link lrwxrwxrwx 1 kebo kebo 83 Jan 16 22:20 llvm-ar -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/llvm-ar lrwxrwxrwx 1 kebo kebo 84 Jan 16 22:20 llvm-cov -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/llvm-cov lrwxrwxrwx 1 kebo kebo 89 Jan 16 22:20 llvm-profdata -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/llvm-profdata lrwxrwxrwx 1 kebo kebo 82 Jan 16 22:20 plutil -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/plutil lrwxrwxrwx 1 kebo kebo 86 Jan 16 22:20 repl_swift -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/repl_swift lrwxrwxrwx 1 kebo kebo 92 Jan 16 22:20 sdk-module-lists -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/sdk-module-lists lrwxrwxrwx 1 kebo kebo 89 Jan 16 22:20 sourcekit-lsp -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/sourcekit-lsp lrwxrwxrwx 1 kebo kebo 81 Jan 16 22:20 swift -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift lrwxrwxrwx 1 kebo kebo 96 Jan 16 22:20 swift-api-checker.py -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-api-checker.py lrwxrwxrwx 1 kebo kebo 94 Jan 16 22:20 swift-api-digester -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-api-digester lrwxrwxrwx 1 kebo kebo 93 Jan 16 22:20 swift-api-extract -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-api-extract lrwxrwxrwx 1 kebo kebo 98 Jan 16 22:20 swift-autolink-extract -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-autolink-extract lrwxrwxrwx 1 kebo kebo 87 Jan 16 22:20 swift-build -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-build lrwxrwxrwx 1 kebo kebo 102 Jan 16 22:20 swift-build-sdk-interfaces -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-build-sdk-interfaces lrwxrwxrwx 1 kebo kebo 92 Jan 16 22:20 swift-build-tool -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-build-tool lrwxrwxrwx 1 kebo kebo 82 Jan 16 22:20 swiftc -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swiftc lrwxrwxrwx 1 kebo kebo 92 Jan 16 22:20 swift-cache-tool -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-cache-tool lrwxrwxrwx 1 kebo kebo 96 Jan 16 22:20 swiftc-legacy-driver -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swiftc-legacy-driver lrwxrwxrwx 1 kebo kebo 90 Jan 16 22:20 swift-demangle -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-demangle lrwxrwxrwx 1 kebo kebo 88 Jan 16 22:20 swift-driver -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-driver lrwxrwxrwx 1 kebo kebo 98 Jan 16 22:20 swift-experimental-sdk -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-experimental-sdk lrwxrwxrwx 1 kebo kebo 90 Jan 16 22:20 swift-frontend -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-frontend lrwxrwxrwx 1 kebo kebo 86 Jan 16 22:20 swift-help -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-help lrwxrwxrwx 1 kebo kebo 95 Jan 16 22:20 swift-legacy-driver -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-legacy-driver -rwxr-xr-x 1 kebo kebo 56245488 Jan 7 17:18 swiftly lrwxrwxrwx 1 kebo kebo 89 Jan 16 22:20 swift-package -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-package lrwxrwxrwx 1 kebo kebo 100 Jan 16 22:20 swift-package-collection -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-package-collection lrwxrwxrwx 1 kebo kebo 98 Jan 16 22:20 swift-package-registry -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-package-registry lrwxrwxrwx 1 kebo kebo 95 Jan 16 22:20 swift-plugin-server -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-plugin-server lrwxrwxrwx 1 kebo kebo 85 Jan 16 22:20 swift-run -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-run lrwxrwxrwx 1 kebo kebo 101 Jan 16 22:20 swift-symbolgraph-extract -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-symbolgraph-extract lrwxrwxrwx 1 kebo kebo 86 Jan 16 22:20 swift-test -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/swift-test lrwxrwxrwx 1 kebo kebo 83 Jan 16 22:20 wasm-ld -> /home/kebo/.local/share/swiftly/toolchains/main-snapshot-2024-01-15/usr/bin/wasm-ld

Recently, the main snapshot toolchain began actively using the new swift-driver.

However, the new swift-driver doesn't seem to work properly when it's used through a symbolic link, such as the one swiftly installs.

related issue: swiftlang/swiftly#92

Reproduction

Prerequisites:

  • swiftly
    • make sure that swiftly is found in $PATH

Steps to reproduce:

$ swiftly install main-snapshot-2024-01-15 $ swiftly use main-snapshot-2024-01-15 $ mkdir example $ cd example $ swift package init --type executable Creating executable package: example Creating Package.swift Creating .gitignore Creating Sources/ Creating Sources/main.swift $ swift build error: 'example': Invalid manifest (compiled with: ["/home/kebo/.local/bin/swiftc", "-vfsoverlay", "/tmp/TemporaryDirectory.3n5WU3/vfs.yaml", "-L", "/home/kebo/.local/bin", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/home/kebo/.local/bin", "-swift-version", "5", "-I", "/home/kebo/.local/bin", "-package-description-version", "5.11.0", "/home/kebo/example/Package.swift", "-Xfrontend", "-disable-implicit-concurrency-module-import", "-Xfrontend", "-disable-implicit-string-processing-module-import", "-o", "/tmp/TemporaryDirectory.H0UxHI/example-manifest"]) error: fatalError /home/kebo/example/Package.swift:4:8: error: no such module 'PackageDescription' import PackageDescription  ^

Expected behavior

$ swift build Building for debugging... [8/8] Linking example Build complete! (1.73s)

Environment

$ swiftly list Installed release toolchains ---------------------------- Installed snapshot toolchains ----------------------------- main-snapshot-2024-01-15 (in use) $ which swift /home/kebo/.local/bin/swift $ swift --version Swift version 5.11-dev (LLVM e2b71339d3295a4, Swift 8ae3ee998f408c4) Target: aarch64-unknown-linux-gnu $ cat /etc/os-release NAME="Arch Linux ARM" PRETTY_NAME="Arch Linux ARM" ID=archarm ID_LIKE=arch BUILD_ID=rolling ANSI_COLOR="38;2;23;147;209" HOME_URL="https://archlinuxarm.org/" DOCUMENTATION_URL="https://archlinuxarm.org/wiki" SUPPORT_URL="https://archlinuxarm.org/forum" BUG_REPORT_URL="https://github.com/archlinuxarm/PKGBUILDs/issues" LOGO=archlinux-logo $ uname -a Linux Brown-rhinoceros-beetle 6.5.0-asahi-15-1-ARCH #1 SMP PREEMPT_DYNAMIC Thu, 12 Oct 2023 08:22:22 +0000 aarch64 GNU/Linux

Additional information

After following "Steps to reproduce", you can success to build in the following two ways.

  1. Using the legacy swift-driver
$ swift build -Xswiftc -disallow-use-new-driver Building for debugging... <unknown>:0: warning: legacy driver is now deprecated; consider avoiding specifying '-disallow-use-new-driver' <unknown>:0: warning: legacy driver is now deprecated; consider avoiding specifying '-disallow-use-new-driver' [7/7] Linking example Build complete! (1.76s)
  1. Using executables directly
$ export PATH=$SWIFTLY_HOME_DIR/toolchains/main-snapshot-2024-01-15/usr/bin:$PATH $ swift build Building for debugging... [8/8] Linking example Build complete! (1.69s)

Thus, I believe that the combination of the new swift-driver and symbolic links is the cause.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions