Skip to content

Commit

Permalink
customize MacOS building and installation
Browse files Browse the repository at this point in the history
  • Loading branch information
laris authored and dylanmckay committed May 17, 2020
1 parent 8405b30 commit eb77ef4
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,44 @@ First make sure you've installed all dependencies for building, as specified in
the main Rust repository [here](https://github.com/rust-lang/rust/#building-from-source).
Then use the following commands:

### Unix/Linux/*nix

``` bash
# Grab the avr-rust sources
git clone https://github.com/avr-rust/rust.git --recursive

# Create a directory to place built files in
mkdir build && cd build

# Generate Makefile using settings suitable for an experimental compiler
../rust/configure \
--enable-debug \
--disable-docs \
--enable-llvm-assertions \
--enable-debug-assertions \
--enable-optimize \
--enable-llvm-release-debuginfo \
--experimental-targets=AVR \
--prefix=/opt/avr-rust

# Build the compiler, optionally install it to /opt/avr-rust
make
make install

# Register the toolchain with rustup
rustup toolchain link avr-toolchain $(realpath $(find . -name 'stage2'))

# Optionally enable the avr toolchain globally
rustup default avr-toolchain
```
### Notes for macOS

The conventional install directory for macOS is `/usr/local/avr-rust` rather than the Linux default `/opt/avr-rust`, so before the steps below, you must:

1. Edit `build/config.toml` to set `prefix = '/usr/local/avr-rust'`.
2. Ensure `/usr/local/avr-rust` exists and has the correct permissions: `sudo mkdir /usr/local/avr-rust && sudo chown $USER:admin /usr/local/avr-rust`
1. ~~Edit `build/config.toml` to set `prefix = '/usr/local/avr-rust'`.~~
2. Ensure `/usr/local/avr-rust` exists and has the correct permissions: `sudo mkdir /usr/local/avr-rust && sudo chown ${USER}:admin /usr/local/avr-rust`

Finally, `realpath` isn't included by default on macOS but is included in GNU Coreutils, so you can either `brew install coreutils` so the `rustup toolchain...` step works properly, or just use the explicit path (`rustup toolchain link avr-toolchain /usr/local/avr-rust`).

``` bash
# Grab the avr-rust sources
git clone https://github.com/avr-rust/rust.git --recursive
Expand All @@ -50,14 +79,14 @@ mkdir build && cd build
--enable-optimize \
--enable-llvm-release-debuginfo \
--experimental-targets=AVR \
--prefix=/opt/avr-rust
--prefix=/usr/local/avr-rust

# Build the compiler, optionally install it to /opt/avr-rust
# Build the compiler, install it to /usr/local/avr-rust
make
make install

# Register the toolchain with rustup
rustup toolchain link avr-toolchain $(realpath $(find . -name 'stage2'))
rustup toolchain link avr-toolchain /usr/local/avr-rust

# Optionally enable the avr toolchain globally
rustup default avr-toolchain
Expand Down

0 comments on commit eb77ef4

Please sign in to comment.