From f7a3f20947943bfcf874390db3b6ee400bc4f142 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Sun, 27 Feb 2022 13:12:48 -0700
Subject: [PATCH] Cleanup of rust configs

---
 .cargo/config              |  9 ---------
 mk/aarch64-unknown-uefi.mk |  4 ++--
 mk/x86-unknown-none.mk     | 23 +++++++++++++++++++++--
 mk/x86_64-unknown-uefi.mk  |  4 ++--
 4 files changed, 25 insertions(+), 15 deletions(-)
 delete mode 100644 .cargo/config

diff --git a/.cargo/config b/.cargo/config
deleted file mode 100644
index 20ee1ec..0000000
--- a/.cargo/config
+++ /dev/null
@@ -1,9 +0,0 @@
-[build]
-rustflags = [
-  # Kernel should preserve floating-point registers
-  "-Csoft-float",
-]
-
-[unstable]
-build-std = ["core", "alloc", "compiler_builtins"]
-build-std-features = ["panic-unwind"]
diff --git a/mk/aarch64-unknown-uefi.mk b/mk/aarch64-unknown-uefi.mk
index aa36a9f..9a98e2b 100644
--- a/mk/aarch64-unknown-uefi.mk
+++ b/mk/aarch64-unknown-uefi.mk
@@ -5,6 +5,7 @@ all: $(BUILD)/bootloader.efi
 
 $(BUILD)/bootloader.efi: Cargo.lock Cargo.toml $(shell find src -type f)
 	mkdir -p $(BUILD)
+	env RUSTFLAGS="-C soft-float" \
 	cargo rustc \
 		-Z build-std=core,alloc \
 		-Z build-std-features=compiler-builtins-mem \
@@ -12,11 +13,11 @@ $(BUILD)/bootloader.efi: Cargo.lock Cargo.toml $(shell find src -type f)
 		--bin bootloader \
 		--release \
 		-- \
-		-C soft-float \
 		--emit link=$@
 
 $(BUILD)/bootloader-live.efi: Cargo.lock Cargo.toml $(shell find src -type f)
 	mkdir -p $(BUILD)
+	env RUSTFLAGS="-C soft-float" \
 	cargo rustc \
 		-Z build-std=core,alloc \
 		-Z build-std-features=compiler-builtins-mem \
@@ -25,7 +26,6 @@ $(BUILD)/bootloader-live.efi: Cargo.lock Cargo.toml $(shell find src -type f)
 		--release \
 		--features live \
 		-- \
-		-C soft-float \
 		--emit link=$@
 
 $(BUILD)/esp.bin: $(BUILD)/bootloader.efi
diff --git a/mk/x86-unknown-none.mk b/mk/x86-unknown-none.mk
index 790d274..c44a34b 100644
--- a/mk/x86-unknown-none.mk
+++ b/mk/x86-unknown-none.mk
@@ -7,7 +7,16 @@ all: $(BUILD)/bootloader.bin
 
 $(BUILD)/libbootloader.a: Cargo.lock Cargo.toml $(shell find src -type f)
 	mkdir -p $(BUILD)
-	cargo rustc --lib --target $(TARGET) --release -- -C soft-float -C debuginfo=2 --emit link=$@
+	env RUSTFLAGS="-C soft-float" \
+	cargo rustc \
+		-Z build-std=core,alloc \
+		-Z build-std-features=compiler-builtins-mem \
+		--target $(TARGET) \
+		--lib \
+		--release \
+		-- \
+		-C debuginfo=2 \
+		--emit link=$@
 
 $(BUILD)/bootloader.elf: linkers/$(TARGET).ld $(BUILD)/libbootloader.a
 	mkdir -p $(BUILD)
@@ -21,7 +30,17 @@ $(BUILD)/bootloader.bin: $(BUILD)/bootloader.elf $(shell find asm/$(TARGET) -typ
 
 $(BUILD)/libbootloader-live.a: Cargo.lock Cargo.toml $(shell find src -type f)
 	mkdir -p $(BUILD)
-	cargo rustc --lib --target $(TARGET) --release --features live -- -C soft-float -C debuginfo=2 --emit link=$@
+	env RUSTFLAGS="-C soft-float" \
+	cargo rustc \
+		-Z build-std=core,alloc \
+		-Z build-std-features=compiler-builtins-mem \
+		--target $(TARGET) \
+		--lib \
+		--release \
+		--features live \
+		-- \
+		-C debuginfo=2 \
+		--emit link=$@
 
 $(BUILD)/bootloader-live.elf: linkers/$(TARGET).ld $(BUILD)/libbootloader-live.a
 	mkdir -p $(BUILD)
diff --git a/mk/x86_64-unknown-uefi.mk b/mk/x86_64-unknown-uefi.mk
index 49332e4..640ba1a 100644
--- a/mk/x86_64-unknown-uefi.mk
+++ b/mk/x86_64-unknown-uefi.mk
@@ -5,6 +5,7 @@ all: $(BUILD)/bootloader.efi
 
 $(BUILD)/bootloader.efi: Cargo.lock Cargo.toml $(shell find src -type f)
 	mkdir -p $(BUILD)
+	env RUSTFLAGS="-C soft-float" \
 	cargo rustc \
 		-Z build-std=core,alloc \
 		-Z build-std-features=compiler-builtins-mem \
@@ -12,11 +13,11 @@ $(BUILD)/bootloader.efi: Cargo.lock Cargo.toml $(shell find src -type f)
 		--bin bootloader \
 		--release \
 		-- \
-		-C soft-float \
 		--emit link=$@
 
 $(BUILD)/bootloader-live.efi: Cargo.lock Cargo.toml $(shell find src -type f)
 	mkdir -p $(BUILD)
+	env RUSTFLAGS="-C soft-float" \
 	cargo rustc \
 		-Z build-std=core,alloc \
 		-Z build-std-features=compiler-builtins-mem \
@@ -25,7 +26,6 @@ $(BUILD)/bootloader-live.efi: Cargo.lock Cargo.toml $(shell find src -type f)
 		--release \
 		--features live \
 		-- \
-		-C soft-float \
 		--emit link=$@
 
 $(BUILD)/esp.bin: $(BUILD)/bootloader.efi
-- 
GitLab