---
title: Rust编译选项介绍
description: "为了让Rust编译器根据不同的平台使用特定的指令集，可通过环境变量RUSTFLAGS来让编译器生成相应平台的相应指令集代码。通过rustc -C help查看所有的RUSTFLAGS，此处只列出与鲲鹏迁移相关的两条编译选项。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenggrf/codeprtr/kunpengtaishanporting_12_0098.html
sourcePath: /source/zh/kunpenggrf/codeprtr/kunpengtaishanporting_12_0098.html
indexId: 899a214590e25fcba077787784752c081b7199c586a3ec3e9839eaf320f18c9665
---
# Rust编译选项介绍

为了让Rust编译器根据不同的平台使用特定的指令集，可通过环境变量RUSTFLAGS来让编译器生成相应平台的相应指令集代码。通过rustc -C help查看所有的RUSTFLAGS，此处只列出与鲲鹏迁移相关的两条编译选项。

| 编译选项 | 介绍 |
| --- | --- |
| relocation\-model=val | 控制PIC的生成，可以使用\`rustc \-\-print relocation\-models\`命令查看详细信息 |
| target\-cpu=val | 选择CPU类型，可以使用\`rustc \-\-print target\-cpus\`命令查看当前所支持的CPU |
