Rollup merge of #136608 - kulst:ptx_target_features, r=bjorn3
Pass through of target features to llvm-bitcode-linker and handling them When using the llvm-bitcode-linker (`linker-flavor=llbc`) target-features are not passed through and are not handled by it. The llvm-bitcode-linker is mainly used as a self contained linker to link llvm bitcode for the nvptx64 target. It uses `llvm-link`, `opt` and `llc` internally. To produce a `.ptx` file of a specific ptx-version it is necessary to pass the version to llc with the `--mattr` option. Without explicitly setting it, the emitted `.ptx`-version is the minimum supported version of the `--target-cpu`. I would like to be able to explicitly set the ptx version as [some llvm problems only occur in earlier `.ptx`-versions](https://github.com/llvm/llvm-project/issues/112998). Therefore this pull request adds support for passing target features to llvm-bitcode-linker and handling them. I was not quite sure if adding these features to `rustc_target/src/target_features.rs` is necessary or not. If so I will gladly add these. r? ``@kjetilkjeka``
This commit is contained in:
commit
6d74563b20
5 changed files with 26 additions and 2 deletions
|
@ -2519,6 +2519,12 @@ fn add_order_independent_options(
|
|||
"--target-cpu",
|
||||
&codegen_results.crate_info.target_cpu,
|
||||
]);
|
||||
if codegen_results.crate_info.target_features.len() > 0 {
|
||||
cmd.link_arg(&format!(
|
||||
"--target-feature={}",
|
||||
&codegen_results.crate_info.target_features.join(",")
|
||||
));
|
||||
}
|
||||
} else if flavor == LinkerFlavor::Ptx {
|
||||
cmd.link_args(&["--fallback-arch", &codegen_results.crate_info.target_cpu]);
|
||||
} else if flavor == LinkerFlavor::Bpf {
|
||||
|
|
|
@ -915,6 +915,7 @@ impl CrateInfo {
|
|||
let n_crates = crates.len();
|
||||
let mut info = CrateInfo {
|
||||
target_cpu,
|
||||
target_features: tcx.global_backend_features(()).clone(),
|
||||
crate_types,
|
||||
exported_symbols,
|
||||
linked_symbols,
|
||||
|
|
|
@ -190,6 +190,7 @@ impl From<&cstore::NativeLib> for NativeLib {
|
|||
#[derive(Debug, Encodable, Decodable)]
|
||||
pub struct CrateInfo {
|
||||
pub target_cpu: String,
|
||||
pub target_features: Vec<String>,
|
||||
pub crate_types: Vec<CrateType>,
|
||||
pub exported_symbols: UnordMap<CrateType, Vec<String>>,
|
||||
pub linked_symbols: FxIndexMap<CrateType, Vec<(String, SymbolExportKind)>>,
|
||||
|
@ -230,6 +231,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
crate::base::provide(providers);
|
||||
crate::target_features::provide(providers);
|
||||
crate::codegen_attrs::provide(providers);
|
||||
providers.queries.global_backend_features = |_tcx: TyCtxt<'_>, ()| vec![];
|
||||
}
|
||||
|
||||
/// Checks if the given filename ends with the `.rcgu.o` extension that `rustc`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue