Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When target_family is None, rustc sets it to unix. #38187

Closed
parched opened this issue Dec 6, 2016 · 6 comments
Closed

When target_family is None, rustc sets it to unix. #38187

parched opened this issue Dec 6, 2016 · 6 comments

Comments

@parched
Copy link
Contributor

parched commented Dec 6, 2016

See

let fam = if let Some(ref fam) = sess.target.target.options.target_family {
Symbol::intern(fam)
} else if sess.target.target.options.is_like_windows {
Symbol::intern("windows")
} else {
Symbol::intern("unix")
};

This is very unhelpful for bare-metal targets where there is no target family. Is there code that relies on it defaulting to unix if it is unspecified?

CC @arcnmx

@arcnmx
Copy link
Contributor

arcnmx commented Dec 6, 2016

All of the built-in librustc_back targets probably do, but that's easy to fix. The problem is that unix has always been the default, most custom user target specs probably rely on it (as the option was added more recently; a year ago is recent, right?). I'm certainly not a fan of there being any particular default. but I'm not sure that it can be changed if we want custom target specs to be backwards-compatible.

For embedded targets I'd suggest using a new target_family like "none" or whatever best describes the platform; that's why the option was added in the first place!

(see also #29551)

@parched
Copy link
Contributor Author

parched commented Dec 6, 2016

Ok yes, changing it would break backwards compatibility. Although I wonder how many non unix target specs out there will break when they hit a crate with #[cfg(unix)] if we leave it as is (like happened to me with the rustc builtin *-none-eabi targets).

If we leave it as is, we should add target_family = "none" to the builtin *-none-eabi targets and also add a comment for target_family that it defaults to unix.

@parched
Copy link
Contributor Author

parched commented Dec 6, 2016

Also related are os, vendor and env, currently you get the following

$ rustc --target=thumbv6m-none-eabi --print cfg
target_env=""
target_family="unix"
target_os="none"
target_vendor=""

they should consistently all be None of some form, whether that's "none" or "" I'm not sure.

CC @japaric

@japaric
Copy link
Member

japaric commented Dec 23, 2016

This should have been fixed (the target_family part) in #38401.

@parched
Copy link
Contributor Author

parched commented Dec 26, 2016

OK, yes that is my preferred fix, but it will probably break some custom target specs as @arcnmx mentions.

@parched parched closed this as completed Dec 26, 2016
@FenrirWolf
Copy link
Contributor

FenrirWolf commented Jan 18, 2017

I think a project of mine got hit by the fallout of this. Though what's more interesting is that manually setting the target_family field back to unix in my custom json spec doesn't seem to have any effect.

Edit: Scratch that. It helps to use the proper syntax in the config file!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants