rust 代碼生成選項



Available codegen options:

-C ar=val -- this option is deprecated and does nothing
-C linker=val -- system linker to link outputs with
-C link-arg=val -- a single extra argument to append to the linker invocation (can be used several times)
-C link-args=val -- extra arguments to append to the linker invocation (space separated)
-C link-dead-code -- don't let linker strip dead code (turning it on can be used for code coverage)
-C lto=val -- perform LLVM link-time optimizations
-C target-cpu=val -- select target processor (`rustc --print target-cpus` for details)
-C target-feature=val -- target specific attributes. (`rustc --print target-features` for details). This feature is unsafe.
-C passes=val -- a list of extra LLVM passes to run (space separated)
-C llvm-args=val -- a list of arguments to pass to LLVM (space separated)
-C save-temps -- save all temporary output files during compilation
-C rpath -- set rpath values in libs/exes
-C overflow-checks=val -- use overflow checks for integer arithmetic
-C no-prepopulate-passes -- don't pre-populate the pass manager with a list of passes
-C no-vectorize-loops -- don't run the loop vectorization optimization passes
-C no-vectorize-slp -- don't run LLVM's SLP vectorization pass
-C soft-float -- use soft float ABI (*eabihf targets only)
-C prefer-dynamic -- prefer dynamic linking to static linking
-C no-integrated-as -- use an external assembler rather than LLVM's integrated one
-C no-redzone=val -- disable the use of the redzone
-C relocation-model=val -- choose the relocation model to use (`rustc --print relocation-models` for details)
-C code-model=val -- choose the code model to use (`rustc --print code-models` for details)
-C metadata=val -- metadata to mangle symbol names with
-C extra-filename=val -- extra data to put in each output filename
-C codegen-units=val -- divide crate into N units to optimize in parallel
-C remark=val -- print remarks for these optimization passes (space separated, or "all")
-C no-stack-check -- the `--no-stack-check` flag is deprecated and does nothing
-C debuginfo=val -- debug info emission level, 0 = no debug info, 1 = line tables only, 2 = full debug info with variable and type information
-C opt-level=val -- optimize with possible levels 0-3, s, or z
-C force-frame-pointers=val -- force use of the frame pointers
-C debug-assertions=val -- explicitly enable the `cfg(debug_assertions)` directive
-C inline-threshold=val -- set the threshold for inlining a function (default: 225)
-C panic=val -- panic strategy to compile crate with
-C incremental=val -- enable incremental compilation
-C default-linker-libraries=val -- allow the linker to link its default libraries
-C linker-flavor=val -- linker flavor
-C linker-plugin-lto=val -- generate build artifacts that are compatible with linker-based LTO.
-C profile-generate=val -- compile the program with profiling instrumentation
-C profile-use=val -- use the given `.profdata` file for profile-guided optimization

 

學習了一下rustc, 了解到這個編譯器僅僅是編譯rs代碼,將代碼轉成llvm可以編譯的中間代碼。  也就是說llvm支持多少架構,它就支持多少架構。

比如要生成可以調試的二進制代碼:

rustc src/hello.rs -C debuginfo=2 -o hello_debug

這樣就可以調試了。

通過rustc編譯出的可以執行文件,反匯編出來的東東有點晦澀難懂

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM