Skip to content

Commit 2713ea3

Browse files
authored
Use Clang rather than GCC for assembly. (#2377)
This avoids the hack for using aarch64-linux-gnu on Linux, and also removes a dependency. Also switched to using `cargo-objcopy`, as we require `cargo-binutils` already and it makes the Makefiles simpler.
1 parent f64edfc commit 2713ea3

File tree

5 files changed

+8
-29
lines changed

5 files changed

+8
-29
lines changed

src/bare-metal.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ To get started, install some tools we'll need later. On gLinux or Debian:
2929
<!-- mdbook-xgettext: skip -->
3030

3131
```bash
32-
sudo apt install gcc-aarch64-linux-gnu gdb-multiarch libudev-dev picocom pkg-config qemu-system-arm
32+
sudo apt install gdb-multiarch libudev-dev picocom pkg-config qemu-system-arm
3333
rustup update
3434
rustup target add aarch64-unknown-none thumbv7em-none-eabihf
3535
rustup component add llvm-tools-preview
@@ -54,7 +54,6 @@ On MacOS:
5454
```bash
5555
xcode-select --install
5656
brew install gdb picocom qemu
57-
brew install --cask gcc-aarch64-embedded
5857
rustup update
5958
rustup target add aarch64-unknown-none thumbv7em-none-eabihf
6059
rustup component add llvm-tools-preview

src/bare-metal/aps/examples/Makefile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
UNAME := $(shell uname -s)
16-
ifeq ($(UNAME),Linux)
17-
TARGET = aarch64-linux-gnu
18-
else
19-
TARGET = aarch64-none-elf
20-
endif
21-
OBJCOPY = $(TARGET)-objcopy
22-
2315
.PHONY: build qemu qemu_logger qemu_minimal qemu_psci
2416

2517
all: minimal.bin improved.bin logger.bin
@@ -28,13 +20,13 @@ build:
2820
cargo build
2921

3022
improved.bin: build
31-
$(OBJCOPY) -O binary target/aarch64-unknown-none/debug/improved $@
23+
cargo objcopy --bin improved -- -O binary $@
3224
logger.bin: build
33-
$(OBJCOPY) -O binary target/aarch64-unknown-none/debug/logger $@
25+
cargo objcopy --bin logger -- -O binary $@
3426
minimal.bin: build
35-
$(OBJCOPY) -O binary target/aarch64-unknown-none/debug/minimal $@
27+
cargo objcopy --bin minimal -- -O binary $@
3628
psci.bin: build
37-
$(OBJCOPY) -O binary target/aarch64-unknown-none/debug/psci $@
29+
cargo objcopy --bin psci -- -O binary $@
3830

3931
qemu: improved.bin
4032
qemu-system-aarch64 -machine virt -cpu max -serial mon:stdio -display none -kernel $< -s

src/bare-metal/aps/examples/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ use cc::Build;
1616
use std::env;
1717

1818
fn main() {
19-
#[cfg(target_os = "linux")]
20-
env::set_var("CROSS_COMPILE", "aarch64-linux-gnu");
21-
#[cfg(not(target_os = "linux"))]
2219
env::set_var("CROSS_COMPILE", "aarch64-none-elf");
20+
env::set_var("CC", "clang");
2321

2422
Build::new()
2523
.file("entry.S")

src/exercises/bare-metal/rtc/Makefile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
UNAME := $(shell uname -s)
16-
ifeq ($(UNAME),Linux)
17-
TARGET = aarch64-linux-gnu
18-
else
19-
TARGET = aarch64-none-elf
20-
endif
21-
OBJCOPY = $(TARGET)-objcopy
22-
2315
.PHONY: build qemu_minimal qemu qemu_logger
2416

2517
all: rtc.bin
@@ -28,7 +20,7 @@ build:
2820
cargo build
2921

3022
rtc.bin: build
31-
$(OBJCOPY) -O binary target/aarch64-unknown-none/debug/rtc $@
23+
cargo objcopy -- -O binary $@
3224

3325
qemu: rtc.bin
3426
qemu-system-aarch64 -machine virt,gic-version=3 -cpu max -serial mon:stdio -display none -kernel $< -s

src/exercises/bare-metal/rtc/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ use cc::Build;
1616
use std::env;
1717

1818
fn main() {
19-
#[cfg(target_os = "linux")]
20-
env::set_var("CROSS_COMPILE", "aarch64-linux-gnu");
21-
#[cfg(not(target_os = "linux"))]
2219
env::set_var("CROSS_COMPILE", "aarch64-none-elf");
20+
env::set_var("CC", "clang");
2321

2422
Build::new()
2523
.file("entry.S")

0 commit comments

Comments
 (0)