hippy
Posts: 6697
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Swift RPi

Sat Nov 23, 2019 7:18 pm

John_Spikowski wrote:
Sun Nov 17, 2019 8:17 am
I was able to install Swift as a pre-built binary distribution for the RPi.
Do you have a How To guide. I installed it with the following ...

Code: Select all

cd ~
mkdir swift
cd swift
wget https://github.com/uraimo/buildSwiftOnARM/releases/download/5.1.1/swift-5.1.1-armv6-RPi01234-RaspbianBuster.tgz
tar -zxvf swift-5.1.1-armv6-RPi01234-RaspbianBuster.tgz
And that executes, and runs my "fibo.swift" Fibo(24) as expected -

Code: Select all

[email protected]:~/swift $ ./usr/bin/swift --version
Swift version 5.1.1 (swift-5.1.1-RELEASE)
Target: armv6-unknown-linux-gnueabihf

Code: Select all

[email protected]:~/swift $ ./usr/bin/swift fibo.swift
46368
But can't get the compiler to work -

Code: Select all

[email protected]:~/swift $ ./usr/bin/swiftc fibo.swift -o fibo
<unknown>:0: error: unable to execute command: <unknown>

Heater
Posts: 14429
Joined: Tue Jul 17, 2012 3:02 pm

Re: Swift RPi

Sat Nov 23, 2019 7:44 pm

hippy,
Are you sure ?
Oops, sorry, I read your post wrong. You are correct. I realized and deleted that comment as you were quoting it...
Memory in C++ is a leaky abstraction .

shaymanjohn
Posts: 7
Joined: Tue Nov 12, 2019 8:32 pm

Re: Swift RPi

Sun Nov 24, 2019 7:43 pm

To install Swift, I found this site:
https://swift-arm.com/

And somewhere on there found this command to run:
curl -s https://packagecloud.io/install/reposit ... ipt.deb.sh

And finally:
sudo apt-get install swift5=5.0.2-v0.4
(this was a few months back, 5.1 is now available)

Works fine for me, no problem with swiftc (or the run time).

Heater
Posts: 14429
Joined: Tue Jul 17, 2012 3:02 pm

Re: Swift RPi

Sun Nov 24, 2019 8:53 pm

I get nervous about running random scripts from random unknown web servers.

Who knows what malware is coming down the pipe?
Memory in C++ is a leaky abstraction .

ejolson
Posts: 4247
Joined: Tue Mar 18, 2014 11:47 am

Re: Swift RPi

Tue Nov 26, 2019 4:04 am

Heater wrote:
Sun Nov 24, 2019 8:53 pm
I get nervous about running random scripts from random unknown web servers.

Who knows what malware is coming down the pipe?
It's worth pointing out--especially after the XcodeGhost incident--that supply-chain hacking has become more popular in recent times. In my opinion, one reason for this is that developers more and more frequently install software development tools in their own home directories that don't enjoy the privilege separation which comes from similar tools installed at the system level.

Unlike a paid system administrator, the merit of a software engineer is seldom gauged by how carefully they set their computer up. As a result, a surprising recklessness can be shown by people just trying to get the compiler to work. This reminder to be careful is particularly relevant for the Raspberry Pi, because very few of those are maintained by paid system administrators.

Heater
Posts: 14429
Joined: Tue Jul 17, 2012 3:02 pm

Re: Swift RPi

Tue Nov 26, 2019 7:35 am

ejolson,
In my opinion, one reason for this is that developers more and more frequently install software development tools in their own home directories that don't enjoy the privilege separation which comes from similar tools installed at the system level.
I don't see how it is preferable to install untrusted code, potential malware, as root rather that a regular user.

I would argue that installing malware a root gives it far more opportunity to hide itself, install further malware components into your system and do more dangerous things.

One should strive for lesser privileges for untrusted code than more. Ideally one would install and run it as a user other than ones normal account. One would use it in a sandbox like Docker, BSD chroot jails or Solaris zones. Or in a virtual machine.

I would much rather install and use things like node.js, Rust, Swift etc into a user account than opening up my whole system by installing it with system privs, Luckily that is how they work.

Malware aside, as a practical matter, if I install broken code and libraries into my system, perhaps with a broken installer, it can hose my entire system. Which is a lot more of a pain to recreate than if a few files in a user account get messed up.

I don't want anything running as root on my Pi unless it came from Raspbian.
Memory in C++ is a leaky abstraction .

ejolson
Posts: 4247
Joined: Tue Mar 18, 2014 11:47 am

Re: Swift RPi

Tue Nov 26, 2019 4:01 pm

Heater wrote:
Tue Nov 26, 2019 7:35 am
I don't see how it is preferable to install untrusted code, potential malware, as root rather that a regular user.
You are right that privilege separation doesn't help if what you started with is already infected with malware. However, assuming that the compiler as originally downloaded did not contain malware, then the privilege separation provided by not being user writable when installed at the system level helps avoid subsequent virus infection of the development tool chain by a user-level mistake, for example, while running a web browser.

One of the original limitations of the Unix, Windows and Linux permission systems is that they provide no way for a user to create and run their own processes with less than full user privileges. As a result, if development tools are installed at the user level, the operating system can't protect them.

Huge amounts of disk space has led to tools like conda (see also miniconda), which can install any programming tool you want (including swift) into your home directory (and other places). The convenience of installing and updating a compiler using user-level permissions, however, makes it possible for those tools to be accidently corrupted by other tasks running with user-level privileges. While this would appear no worse than MSDOS, as supply-chain hacking becomes more popular in an Internet-connected world, I would recommend not installing swift or any other software development tool with user-level read-write permissions in your own home directory.

Return to “Other programming languages”