Open8
OSを作ろう
知り合いがフルスクラッチでOSを作っていて自分もやりたくなったので、
Webフロントエンド学生がRustでOSを作る。
参考 ( 日本語版あり)
Rustも低レイヤーも全部初心者なので盛大に間違えている可能性大
ビルド用設定
これを設定すればcargo buildで自動的にターゲットを変えてくれるらしい(?)
## .cargo/config.toml
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-nostartfiles"]
[target.'cfg(target_os = "windows")']
rustflags = ["-C", "link-args=/ENTRY:_start /SUBSYSTEM:console"]
[target.'cfg(target_os = "macos")']
rustflags = ["-C", "link-args=-e __start -static -nostartfiles"]
Rustc のバージョンをNightlyに変えないといけないらしいので変える
cargo build --target x86_build.json
エラー
does not exist, unable to build with the standard library, try: rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc
怒られたw
設定を書くを忘れた
x86_build.json
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
"arch": "x86_64",
"target-endian": "little",
"target-pointer-width": 64,
"target-c-int-width": 32,
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"panic-strategy": "abort",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float",
"rustc-abi": "x86-softfloat"
}
追加のコンポーネントを入れる
(なんだこれは...)
rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc
ツールチェインとかも勉強しないと
追加ライブラリのインストール
rustup component add llvm-tools-preview
うごいた!

ちょっと変更
