<<

Rust on FreeBSD

Luca Pizzamiglio [email protected] 2018-11-08 Rust on FreeBSD

● whoami(1)

● Luca Pizzamiglio

● FreeBSD user since 2009

● FreeBSD contributor since 2011

● FreeBSD port committer since 2017 ● The program of today:

● FreeBSD: what is this?

● Rust on FreeBSD: state of the art

● How to build a FreeBSD package for a Rust project

2 Rust Cologne 11/8/18 1969 Unnamed PDP-7 1969 Open source 1971 to 1973 1971 to 1973 Version 1 to 4 Mixed/shared source 1974 to 1975 Unix 1974 to 1975 Version 5 to 6 PWB/Unix Closed source 1978 1978 BSD 1.0 to 2.0 Unix 1979 Version 7 1979

Unix/32V 1980 1980 BSD 3.0 to 4.1 1981 System III 1981 1.0 to 2.3 1982 1982 Xenix 3.0 1983 BSD 4.2 SunOS 1983 1 to 1.1 System V R1 to R2 1984 SCO Xenix 1984 Unix 1985 Version 8 SCO Xenix 1985 AIX V/286 System V 1986 Unix-like systems BSD 4.3 1.0 R3 HP-UX 1986 SunOS 1.0 to 1.2 1.2 to 3.0 SCO Xenix 1987 Unix 1987 9 and 10 V/386 (last versions HP-UX 1988 BSD 4.3 System V 2.0 to 3.0 1988 from Tahoe R4 1989 ) SCO Xenix 1989 BSD Net/1 V/386 BSD 4.3 1990 Reno 1990 BSD Net/2 1991 0.0.1 1991 SunOS 4 386BSD 1.x NexTSTEP/ 1992 OPENSTEP HP-UX 1992 1.0 to 4.0 NetBSD 6 to 11 Linux BSD 0.8 to 1.0 1993 SCO UNIX UnixWare 1993 0.95 to 1.2.x 4.4-Lite 3.2.4 1.x to 2.x & 1994 FreeBSD (System V 1994 1.0 to Lite Release 2 R4.2) 1995 2.2.x NetBSD 1995 OpenBSD OpenServer 1.1 to 1.2 1.0 to 2.2 Solaris 1996 5.0 to 5.04 2.1 to 9 1996 1997 1997 NetBSD 1.3 1998 FreeBSD 1998 3.0 to 3.2 Minix OpenServer 1999 Mac OS X AIX 5.0.5 to 5.0.7 1999 2.x 2000 3.0-7.2 2000

2001 to 2004 2001 to 2004 Linux 2005 2.x UnixWare 2005 7.x 2006 to 2007 (System V 2006 to 2007 OpenBSD R5) 2008 2.3-6.1 Solaris 2008 Mac OS X, FreeBSD NetBSD 10 OS X, 3.3-11.x 1.3-7.1 OpenServer HP-UX 2009 macOS 6.x 11i+ 2009 10.0 to 10.12 DragonFly Minix BSD 2010 3.1.0-3.4.0 (Darwin 2010 1.2.1 to 17) 1.0 to 4.8 OpenSolaris 2011 & derivatives 2011 (, etc.) 2012 to 2015 Linux 2012 to 2015 3.x Solaris 2016 11.0-11.3 2016 Linux 4.x OpenServer 2017 10.x 2017 FreeBSD: what is this?

FreeBSD Linux

Kernel + boot loader Kernel World ● System libraries Installer ● Toolchain (C,C++) Packages ● ● Services and utilities System libraries ● ● Installer Toolchain (C,C++) ● Services and utilities ● Web servers ● Other languages/toolchains Ports (packages) ● X11 and graphics ● Web servers ● Databases ● Other languages/toolchains ● X11 and graphics ● Databases

4 Rust Cologne 11/8/18 Rust on FreBSD: status

● lang/rust: rust stable, available as package

● Everything you need: rustc, cargo, standard library

● Useful to build other Rust packages ● Rustup support for FreeBSD

● Everything is available

● Clippy-preview ● rustfmt-preview ● Editor/IDE

● No ofcial support for electron (a long story, so no atom or VSCode

● I use vim+rust.vim+YouCompleteMe+syntastic

5 Rust Cologne 11/8/18 FreeBSD package: ports?

● FreeBSD Package: the binary blob that you just install ● FreeBSD Port: the recipe to install the software and/or build the package ● The Port Collection counts ~29K ports ● The Port Collection build system is Makefle based

● Meta build specifcation to support every language/build mechanism

● Autotools, cmake, ninja, maven ● C, C++, , go, Rust, python, perl, R, Haskell... ● One structure to build ‘em all

6 Rust Cologne 11/8/18 FreeBSD Port

autotools ports(7)

make fetch make checksum make extract make patch ./configure make configure make make build make install make stage make install/package

7 Rust Cologne 11/8/18 FreeBSD ports & cargo

ports(7)

make fetch => fetch crates make checksum => checksum on crates make extract => tells cargo to use the make patch downloaded crates make configure make build => use cargo to build make stage => use cargo to install make install

8 Rust Cologne 11/8/18 FreeBSD ports & cargo: cargo.mk

● USES= cargo

● make cargo-crates

● An additional target to help maintainer to get the list of crates that has to be added in the Makefle ● make makesum

● A target to automatically compute the source’s checksum ● It takes care of crates as well ● “Hard-to-build” crates are pre-confgured

● The ports collection prefers shared library

9 Rust Cologne 11/8/18 FreeBSD ports & cargo

Real example and code: Easy example: sysutils/potnet Where the magic happens: Mk/Uses/cargo.mk FreeBSD philosophy at work: devel/sccache

10 Rust Cologne 11/8/18 Rust on FreeBSD

THANKS

11 Rust Cologne 11/8/18 Rust on FreeBSD

Questions?

12 Rust Cologne 11/8/18 Rust on FreeBSD

Further questions? me at [email protected]

Image credits: https://commons.wikimedia.org/wiki/File:Unix_history-simple.svg Released under CC Attribution-Share Alike 3.0 Unported license Source: Levenez Unix History Diagram, Information on the history of IBM's AIX on .com Authors: Eraserhead1, Infnity0, Sav_vas

13 Rust Cologne 11/8/18