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编译出的可以执行文件,反汇编出来的东东有点晦涩难懂

原文地址:https://www.cnblogs.com/dzqdzq/p/12886864.html