I’m attempting to create a snap for Swift. Here is my snapcraft.yaml:
name: swift # you probably want to 'snapcraft register <name>'
version: '3.1.1-1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Swift install for development
description: |
All of the binaries necessary to use and develop with swift on Ubuntu Linux
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
apps:
swift:
command: bin/swift
parts:
swift:
source: https://swift.org/builds/swift-3.1.1-release/ubuntu1610/swift-3.1.1-RELEASE/swift-3.1.1-RELEASE-ubuntu16.10.tar.gz
stage-packages:
- clang
plugin: dump
When I install the snap with sudo snap try --devmode prime, I get a swift command that gives me the following error:
vinay@host:~/swift$ swift -v
Swift version 3.1.1 (swift-3.1.1-RELEASE)
Target: x86_64-unknown-linux-gnu
/snap/swift/x1/bin/lldb "--repl=-disable-objc-interop -color-diagnostics"
error: failed to stop process at REPL breakpoint
However, if I run the swift executable directly, it works just fine:
vinay@host:~/swift$ ./prime/bin/swift
Welcome to Swift version 3.1.1 (swift-3.1.1-RELEASE). Type :help for assistance.
1>
Also, if I run the command listed in the verbose output, it works:
vinay@host:~/swift$ /snap/swift/x1/bin/lldb "--repl=disable-objc-interop -color-diagnostics"
Welcome to Swift version 3.1.1 (swift-3.1.1-RELEASE). Type :help for assistance.
1>
I was looking for other language compilers on Github and found a snap for the D language. It looks like they compile the compiler & frameworks from source. I wonder if that might be necessary here.
This error happens whenever if you install these binaries as they recommend. One has to change the permission for the files within the lib/swift directory to be modifiable by swiftc… Hope this helps, a swift snap is sorely needed, please continue with the good work…
sudo snap install swift-language
snap alias swift-language.swift swift
Now I noticed that the snap is not accessing system libraries. So for example, if I try to get the swift version with swift --version it works ok, but when I try to compile something it complains about not finding glibc. Take this very simple example:
git clone https://github.com/JohnSundell/Marathon.git
cd Marathon
swift build -c release
Will result in:
/snap/swift-language/1/bin/swift-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by /snap/swift-language/1/lib/x86_64-linux-gnu/libcrypt.so.1)
But libc.so.6 is installed:
└─λ ls /lib/x86_64-linux-gnu/libc.so*
/lib/x86_64-linux-gnu/libc.so.6
How can I allow the snap to get access to the system? Should I create it with the classic flag?
you rather want ls -l /snap/core/current/lib/x86_64-linux-gnu/libc.so* the host libc is not involved at all here …
did you use snapcraft cleanbuild to create this snap ? it looks like it uses libs linked against a too new libc (2.25) … while snaps need to use 2.23 (the version from xenial) which cleanbuild ensures.
the need of 2.23 comes from the fact that all snaps run on top of the core snap by default, to stay binary compatible they need to use the libc shipped in core … the core snap in turn is based on 16.04, your latest source: entry in your snapcraft.yaml points to a binary built for 16.10 … try the following:
I expected this to work, but I get a similar error. Is there a way of cleaning existing files, should I be worried that the previous revision interferes with this one?
Snapcraft run smoothly, but upon trying to run swift I get:
└─λ swift-language.swift --version
/snap/swift-language/x1/bin/swift: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by /snap/swift-language/x1/lib/x86_64-linux-gnu/libuuid.so.1)
I couldn’t release in stable channel due to executable stack, below is the error:
Found files with executable stack. This adds PROT_EXEC to mmap(2) during mediation which may cause security denials. Either adjust your program to not require an executable stack, strip it with 'execstack --clear-execstack ...' or remove the affected file from your snap. Affected files: usr/lib/arm-linux-gnueabihf/libBlocksRuntime.so.0.0.0 functional-snap-v2_execstack
Can someone suggest the best course of action in this case? Can I disable this file during the snap creation process?