rustcc / writing-an-os-in-rust Goto Github PK
View Code? Open in Web Editor NEW《使用Rust编写操作系统》
License: Other
《使用Rust编写操作系统》
License: Other
error: the legacy LLVM-style asm! syntax is no longer supported
--> /Users/zhouxiaogang/.cargo/registry/src/github.com-1ecc6299db9ec823/x86_64-0.8.3/src/registers/mod.rs:13:9
|
13 | asm!(
| ^---
| |
| help: replace with: llvm_asm!
| |
14 | | "lea (%rip), $0"
15 | | : "=r"(rip) ::: "volatile"
16 | | );
| |_^
|
= note: consider migrating to the new asm! syntax specified in RFC 2873
= note: alternatively, switch to llvm_asm! to keep your code working as it is
之前阅读了Writing an OS in Rust,发现有些文章是翻译成了中文简体的,有些没有。本来想翻译一下的,后来发现在这里几乎都已经翻译完了,不知道有没有计划把翻译的这些简体中文提交到phil-opp/blog_os里去呢?
OS: Windows 10
rustc: rustc 1.32.0 (9fda7c223 2019-01-16)
toolchain: stable-x86_64-pc-windows-msvc (default), nightly-x86_64-pc-windows-msvc
c++构建工具: VS2017 Community
# cargo.toml
[package]
name = "blog_os"
version = "0.1.0"
authors = ["huangjj27 <[email protected]>"]
edition = "2018"
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[dependencies]
// main.rs
#![no_std]
#![no_main]
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
// 由于在Windows环境下编译, 故只摘抄Windows所需函数
#[no_mangle]
pub extern "C" fn mainCRTStartUp() -> ! {
main();
}
#[no_mangle]
pub extern "C" fn main() -> ! {
loop {}
}
error: linking with `link.exe` failed: exit code: 1120
|
= note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\34937\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\34937\\Desktop\\learning-rust\\blog_os\\target\\debug\\deps\\blog_os-d19438c79a36ae28.4gg7n8zj6teng6ow.rcgu.o" "/OUT:C:\\Users\\34937\\Desktop\\learning-rust\\blog_os\\target\\debug\\deps\\blog_os-d19438c79a36ae28.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\34937\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\34937\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\34937\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:C:\\Users\\34937\\Desktop\\learning-rust\\blog_os\\target\\debug\\deps" "/LIBPATH:C:\\Users\\34937\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\34937\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-78a7055b7313c664.rlib" "C:\\Users\\34937\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-b9ee21a1be63ac89.rlib" "C:\\Users\\34937\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-82c426bab9a155a3.rlib"
= note: Non-UTF-8 output: LINK : error LNK2001: \xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xb7\xfb\xba\xc5 mainCRTStartup\r\nC:\\Users\\34937\\Desktop\\learning-rust\\blog_os\\target\\debug\\deps\\blog_os-d19438c79a36ae28.exe : fatal error LNK1120: 1 \xb8\xf6\xce\xde\xb7\xa8\xbd\xe2\xce\xf6\xb5\xc4\xcd\xe2\xb2\xbf\xc3\xfc\xc1\xee\r\n
error: aborting due to previous error
error: Could not compile `blog_os`.
To learn more, run the command again with --verbose.
错误信息出现原因请参考: https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2001?view=vs-2017
另外找到了 可能 类似的rust连接c问题rust-lang/rust#31233
https://stackoverflow.com/questions/40548334/rust-code-cannot-link-with-a-c-library-compiled-on-windows-because-there-is-an-u
从第二章起旧版示例代码已经无法使用最新rust发行版编译,原书示例代码已经更新,需要同步更新一下。
包括第二章去除xbuild依赖以及第三章打印字符range的写法修改
如题。非常期待。
原文
On function entry, the stack pointer is adjusted to make room on the stack for the return address and the local variables.
译文
两个指令(instruction)将栈指针调节到合适的位置,以便为返回地址(return address)和局部变量提供内存空间
看上去原文并没有提到 译文 中的两个指令
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.