Skip to content

Commit

Permalink
add needs-relocation-model-pic to compiletest
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Sep 29, 2023
1 parent b8536c1 commit 90f317b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ pub struct TargetCfg {
pub(crate) sanitizers: Vec<Sanitizer>,
#[serde(rename = "supports-xray", default)]
pub(crate) xray: bool,
#[serde(default = "default_reloc_model")]
pub(crate) relocation_model: String,
}

impl TargetCfg {
Expand All @@ -592,6 +594,10 @@ fn default_os() -> String {
"none".into()
}

fn default_reloc_model() -> String {
"pic".into()
}

#[derive(Eq, PartialEq, Clone, Debug, Default, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum Endian {
Expand Down
5 changes: 5 additions & 0 deletions src/tools/compiletest/src/header/needs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ pub(super) fn handle_needs(
condition: config.target_cfg().dynamic_linking,
ignore_reason: "ignored on targets without dynamic linking",
},
Need {
name: "needs-relocation-model-pic",
condition: config.target_cfg().relocation_model == "pic",
ignore_reason: "ignored on targets without PIC relocation model",
},
];

let (name, comment) = match ln.split_once([':', ' ']) {
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/abi/relocation_model_pic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// run-pass
// compile-flags: -C relocation-model=pic
// ignore-emscripten no pic
// ignore-wasm
// needs-relocation-model-pic

#![feature(cfg_relocation_model)]

Expand Down

0 comments on commit 90f317b

Please sign in to comment.