Skip to content

Cannot build Swift compiler due to error: 'swift/shims/Visibility.h' file not found #79024

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

Closed
ethanc8 opened this issue Jan 29, 2025 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Linux Platform: Linux openSUSE Platform: openSUSE platform support

Comments

@ethanc8
Copy link

ethanc8 commented Jan 29, 2025

Description

When building swift-6.0.3-RELEASE on openSUSE Tumbleweed, I get:

/home/ethan/Projects/GNUstep/Swift/swift-project/swift/include/swift/Runtime/Config.h:179:10: error: 'swift/shims/Visibility.h' file not found
177 | 
178 | // Bring in visibility attribute macros
179 | #include "swift/shims/Visibility.h"
    |          `- error: 'swift/shims/Visibility.h' file not found
180 | 
181 | // Temporary definitions to allow compilation on clang-15.

Attempting to run

utils/build-script --release-debuginfo --extra-cmake-options="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" -j 4 --extra-cmake-options="-DSWIFT_EXPERIMENTAL_EXTRA_FLAGS=-Xcc -I -Xcc /home/ethan/Projects/GNUstep/Swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/stdlib/public/SwiftShims/swift/shims/"

does not seem to add the specified compiler flags to the command line.

When running with -j 1, you can see that it occurs while

[1/511][  0%][8.903s] Building swift module SIL

and results in

/home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/ApplySite.swift:13:8: error: could not build C module 'SILBridging'
 11 | //===----------------------------------------------------------------------===//
 12 | 
 13 | import SILBridging
    |        `- error: could not build C module 'SILBridging'
 14 | 
 15 | /// Argument conventions indexed on an apply's operand.
ninja: build stopped: subcommand failed.
ERROR: command terminated with a non-zero exit status 1, aborting

Reproduction

utils/build-script --release-debuginfo --extra-cmake-options="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" -j 4

Expected behavior

The Swift compiler builds, and Visibility.h is on the include path.

Environment

$ swiftc --version
Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: x86_64-unknown-linux-gnu

The host Swift toolchain was installed from the Amazon Linux 2 binaries onto an openSUSE Tumbleweed system, using the following commands:

curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash
swiftly install 6.0.3
mkdir -p ~/.local/lib/swift/linux/x86_64/
ln -s "$HOME/.local/share/swiftly/toolchains/6.0.3/usr/lib/swift/linux/x86_64/swiftrt.o" ~/.local/lib/swift/linux/x86_64/swiftrt.o

The Swift sources were retrieved using:

utils/update-checkout --tag swift-6.0.3-RELEASE
cd ..
git clone https://github.com/swiftlang/swift-syntax --branch swift-6.0.3-RELEASE
cd swift

Additional information

In order to reproduce this on Tumbleweed, you will need to additionally install Swift's dependencies:

sudo zypper install binutils binutils-gold gcc git gzip glibc-static libbsd-devel libedit libedit-devel libicu-devel libstdc++-devel pkg-config python2 sqlite
sudo zypper in \
  cmake \
  libcurl-devel \
  curl \
  gcc gcc-c++ \
  git \
  glibc-devel \
  libstdc++-devel \
  libbsd-devel     \
  libedit-devel    \
  libicu-devel     \
  libuuid-devel    \
  libxml2-devel    \
  ncurses-devel    \
  ninja \
  python313-pexpect          \
  pkgconfig        \
  python313-pkgconfig \
  python313-six       \
  python313-pip      \
  python313-devel    \
  python313-psutil   \
  rsync            \
  sqlite-devel     \
  swig             \
  python313-tzdata           \
  unzip            \
  uuid-devel       \
  wget             \
  which            \
  zip              \
  chrpath
sudo ln -s /usr/lib64/libncurses.so /usr/lib64/libcurses.so
@ethanc8 ethanc8 added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jan 29, 2025
@finagolfin finagolfin added Linux Platform: Linux openSUSE Platform: openSUSE platform support and removed triage needed This issue needs more specific labels labels Feb 1, 2025
@finagolfin
Copy link
Member

--extra-cmake-options="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"

You don't need that, I see that there is a build-script flag --export-compile-commands that sets that for you.

Why add the symbolic link in your installed toolchain and clone swift-syntax separately? Neither will cause this failure, just asking what those changes are for.

Ninja dumps out the full compilation command and error on build failure: it would help if you posted that here or on a github gist so we can examine it.

@ethanc8
Copy link
Author

ethanc8 commented Feb 1, 2025

--extra-cmake-options="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"

You don't need that, I see that there is a build-script flag --export-compile-commands that sets that for you.

Oh, great!

Why add the symbolic link in your installed toolchain and clone swift-syntax separately? Neither will cause this failure, just asking what those changes are for.

The symbolic link regarding ncurses is because openSUSE does not package libcurses.so in their repos, and I know that Debian-like distributions symlink libcurses.so to libncurses.so. I believe swift-llbuild requires libcurses.so.

I'm not sure why swiftrt.o is necessary, but I installed the toolchain using swiftly and it complained it couldn't find swiftrt.o during the build (I don't remember at which step), so I symlinked it to the location that it expected. See also swiftlang/swiftly#143.

I cloned swift-syntax separately because utils/update-checkout --tag swift-6.0.3-RELEASE did not clone swift-syntax when I ran it; maybe there is a separate bug, or maybe it is because my computer fell into sleep mode and disconnected from network during the first time I tried to run update-checkout (but later runs of update-checkout didn't fix it so idk).

Ninja dumps out the full compilation command and error on build failure: it would help if you posted that here or on a github gist so we can examine it.

oops! it's

Full compilation command
cd /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources && /home/ethan/.local/bin/swiftc -c -o /home/ethan/Projects/GNUstep/Swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/SwiftCompilerSources/SIL.o -I /home/ethan/.local/bin/../lib -I /usr/lib -target x86_64-unknown-linux-gnu -module-name SIL -emit-module -emit-module-path /home/ethan/Projects/GNUstep/Swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/SwiftCompilerSources/SIL.swiftmodule -parse-as-library /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/ApplySite.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Argument.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/BasicBlock.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Builder.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Effects.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/ForwardingInstruction.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Function.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/FunctionConvention.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/GlobalVariable.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Instruction.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Location.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Operand.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Registration.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/SILStage.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/SubstitutionMap.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Type.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Value.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/VTable.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/WitnessTable.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Utilities/AccessUtils.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Utilities/SequenceUtilities.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Utilities/SmallProjectionPath.swift /home/ethan/Projects/GNUstep/Swift/swift-project/swift/SwiftCompilerSources/Sources/SIL/Utilities/WalkUtils.swift -wmo -color-diagnostics -Xfrontend -validate-tbd-against-ir=none -Xfrontend -disable-target-os-checking -Xcc -std=c++17 -Xcc -DCOMPILED_WITH_SWIFT -Xcc -DSWIFT_TARGET -Xcc -UIBOutlet -Xcc -UIBAction -Xcc -UIBInspectable -cxx-interoperability-mode=default -O -cross-module-optimization -Xcc -UNDEBUG -Xcc -I -Xcc /home/ethan/Projects/GNUstep/Swift/swift-project/llvm-project/llvm/include -Xcc -I -Xcc /home/ethan/Projects/GNUstep/Swift/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-linux-x86_64/include -Xcc -I -Xcc /home/ethan/Projects/GNUstep/Swift/swift-project/llvm-project/clang/include -Xcc -I -Xcc /home/ethan/Projects/GNUstep/Swift/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-linux-x86_64/tools/clang/include -Xcc -I -Xcc /home/ethan/Projects/GNUstep/Swift/swift-project/swift/include -Xcc -I -Xcc /home/ethan/Projects/GNUstep/Swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/SwiftCompilerSources/../include -I /home/ethan/Projects/GNUstep/Swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/SwiftCompilerSources

If you need more of the log I'll have to run the build again.

@finagolfin
Copy link
Member

it complained it couldn't find swiftrt.o during the build (I don't remember at which step),

It would help to know when, this seems like a bug.

maybe it is because my computer fell into sleep mode and disconnected from network during the first time I tried to run update-checkout (but later runs of update-checkout didn't fix it so idk).

Could be, I don't think subsequent runs will check out repos again unless some flag is added to force it.

If you need more of the log I'll have to run the build again.

It appears it is looking for that file at /home/ethan/.local/bin/../lib/swift/shims/Visibility.h, not there? If so, the highly non-standard layout of Swiftly may be screwing with this build. I suggest you just manually download the AL2 toolchain in that case, and add it to your PATH.

@ethanc8
Copy link
Author

ethanc8 commented Feb 2, 2025

Installation steps for swift-6.0.3 on openSUSE

Install the dependencies using zypper as specified in my original message.

mkdir -p ~/Applications && cd ~/Applications
wget https://download.swift.org/swift-6.0.3-release/amazonlinux2/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-amazonlinux2.tar.gz
tar xzf swift-6.0.3-RELEASE-amazonlinux2.tar.gz
cat <<EOF >>~/.bashrc
export PATH="$HOME/Applications/swift-6.0.3-RELEASE-amazonlinux2/usr/bin:${PATH}"
EOF

I am building with utils/build-script --release-debuginfo --export-compile-commands --clean -j 4 right now.

@ethanc8
Copy link
Author

ethanc8 commented Feb 2, 2025

Yes, removing the Swiftly toolchain and using the AL2 toolchain directly from the tarball allowed Swift to be built.

@ethanc8 ethanc8 closed this as completed Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Linux Platform: Linux openSUSE Platform: openSUSE platform support
Projects
None yet
Development

No branches or pull requests

2 participants