Skip to content

Commit 0609a72

Browse files
kanavintaiki-e
authored andcommitted
When building for linux, replace all vendors with 'unknown'
Some build systems such as the Yocto project define custom rust targets, of the form 'arch-somevendor-linux-gnu/musl' (only the 'somevendor' part is custom, the rest matches rust's definitions). This causes mismatches with crossbeam's lists of targets which are built from the standard rust target list, and always have 'unknown' as the vendor. This change simply replaces such custom vendors with 'unknown' when the third component of the target is 'linux'.
1 parent bebc6d5 commit 0609a72

File tree

9 files changed

+25
-4
lines changed

9 files changed

+25
-4
lines changed

build-common.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// The target triplets have the form of 'arch-vendor-system'.
2+
//
3+
// When building for Linux (e.g. the 'system' part is
4+
// 'linux-something'), replace the vendor with 'unknown'
5+
// so that mapping to rust standard targets happens correctly.
6+
fn convert_custom_linux_target(target: String) -> String {
7+
let mut parts: Vec<&str> = target.split('-').collect();
8+
let system = parts[2];
9+
if system == "linux" {
10+
parts[1] = "unknown";
11+
};
12+
parts.join("-")
13+
}

crossbeam-epoch/build-common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../build-common.rs

crossbeam-epoch/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
use std::env;
1616

1717
include!("no_atomic.rs");
18+
include!("build-common.rs");
1819

1920
fn main() {
2021
let target = match env::var("TARGET") {
21-
Ok(target) => target,
22+
Ok(target) => convert_custom_linux_target(target),
2223
Err(e) => {
2324
println!(
2425
"cargo:warning={}: unable to get TARGET environment variable: {}",

crossbeam-queue/build-common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../build-common.rs

crossbeam-queue/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
use std::env;
1616

1717
include!("no_atomic.rs");
18+
include!("build-common.rs");
1819

1920
fn main() {
2021
let target = match env::var("TARGET") {
21-
Ok(target) => target,
22+
Ok(target) => convert_custom_linux_target(target),
2223
Err(e) => {
2324
println!(
2425
"cargo:warning={}: unable to get TARGET environment variable: {}",

crossbeam-skiplist/build-common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../build-common.rs

crossbeam-skiplist/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
use std::env;
1616

1717
include!("no_atomic.rs");
18+
include!("build-common.rs");
1819

1920
fn main() {
2021
let target = match env::var("TARGET") {
21-
Ok(target) => target,
22+
Ok(target) => convert_custom_linux_target(target),
2223
Err(e) => {
2324
println!(
2425
"cargo:warning={}: unable to get TARGET environment variable: {}",

crossbeam-utils/build-common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../build-common.rs

crossbeam-utils/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
use std::env;
2828

2929
include!("no_atomic.rs");
30+
include!("build-common.rs");
3031

3132
fn main() {
3233
let target = match env::var("TARGET") {
33-
Ok(target) => target,
34+
Ok(target) => convert_custom_linux_target(target),
3435
Err(e) => {
3536
println!(
3637
"cargo:warning={}: unable to get TARGET environment variable: {}",

0 commit comments

Comments
 (0)