Swift 5.3 on Odroid C2

As promised, here’s the link to the build of Swift for the ODROID C2. This build was done on Ubuntu 20.04. Your results on other platforms/distros will most certainly vary. USE AT YOUR OWN RISK – I provide absolutely NO WARRANTY, implied or otherwise, with this what so ever.

EDIT: 2020-09-22 – You will probably also have to make sure some prerequisites are installed before hand.

    sudo apt update
    sudo apt install python-six
    sudo apt install        \
      clang                 \
      cmake                 \
      git                   \
      icu-devtools          \
      libcurl4-openssl-dev  \
      libedit-dev           \
      libicu-dev            \
      libncurses5-dev       \
      libpython2-dev        \
      libsqlite3-dev        \
      libxml2-dev           \
      ninja-build           \
      pkg-config            \
      python                \
      rsync                 \
      swig                  \
      systemtap-sdt-dev     \
      tzdata                \
      uuid-dev

Installation should be pretty straight forward.

cd /opt
sudo tar xvfz <PATH-TO-DOWNLOADS>/swift5.3-odroid-c2-ubuntu20.04.tar.bz2

Then all you should have to do is add “/opt/swift/bin” folder to your path.

echo "export PATH=\"\$PATH:/opt/swift/bin\"" >> ~/.bashrc

Then to test it out just create a file called “Layout.swift” with the contents below.

import Foundation

print("")
print(" Int8 - size: \(MemoryLayout<Int8>.size); stride: \(MemoryLayout<Int8>.stride); alignment: \(MemoryLayout<Int8>.alignment)")
print("Int16 - size: \(MemoryLayout<Int16>.size); stride: \(MemoryLayout<Int16>.stride); alignment: \(MemoryLayout<Int16>.alignment)")
print("Int32 - size: \(MemoryLayout<Int32>.size); stride: \(MemoryLayout<Int32>.stride); alignment: \(MemoryLayout<Int32>.alignment)")
print("Int64 - size: \(MemoryLayout<Int64>.size); stride: \(MemoryLayout<Int64>.stride); alignment: \(MemoryLayout<Int64>.alignment)")
print("  Int - size: \(MemoryLayout<Int>.size); stride: \(MemoryLayout<Int>.stride); alignment: \(MemoryLayout<Int>.alignment)")
print("")
print(" UInt8 - size: \(MemoryLayout<UInt8>.size); stride: \(MemoryLayout<UInt8>.stride); alignment: \(MemoryLayout<UInt8>.alignment)")
print("UInt16 - size: \(MemoryLayout<UInt16>.size); stride: \(MemoryLayout<UInt16>.stride); alignment: \(MemoryLayout<UInt16>.alignment)")
print("UInt32 - size: \(MemoryLayout<UInt32>.size); stride: \(MemoryLayout<UInt32>.stride); alignment: \(MemoryLayout<UInt32>.alignment)")
print("UInt64 - size: \(MemoryLayout<UInt64>.size); stride: \(MemoryLayout<UInt64>.stride); alignment: \(MemoryLayout<UInt64>.alignment)")
print("  UInt - size: \(MemoryLayout<UInt>.size); stride: \(MemoryLayout<UInt>.stride); alignment: \(MemoryLayout<UInt>.alignment)")
print("")
print("  Float - size:  \(MemoryLayout<Float>.size);  stride: \(MemoryLayout<Float>.stride);  alignment: \(MemoryLayout<Float>.alignment)")
print(" Double - size:  \(MemoryLayout<Double>.size);  stride: \(MemoryLayout<Double>.stride);  alignment: \(MemoryLayout<Double>.alignment)")
print("")
print("timespec - size: \(MemoryLayout<timespec>.size); stride: \(MemoryLayout<timespec>.stride); alignment: \(MemoryLayout<timespec>.alignment)")
print("")

Then run it like this:

swift Layout.swift

You should see the following output.

Enjoy!

Leave a Reply