-
Notifications
You must be signed in to change notification settings - Fork 459
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
Support custom target-spec #1120
Comments
Yeah that sounds reasonable. Supporting target spec json query though is a bit more complicated, I suppose we can add the API to pass that information to cc, and do the parsing in another crate, since it would require JSON parsing and maybe nightly compiler. |
That could be really helpful! |
Also things like that is not work for target with custom names, definitely. Imagine I'll name my target That things could be good practice to determine by compiler (print), or by cargo (env), or directly from json. Anyway about that concert Wow, just search in the lib.rs for Also |
Yeah it is a bit messy |
I did some research and experiments and here are my thoughts on the topic.
In the case of We have to use all env vars
We have to do translation of values from env vars to names specially for specified (or auto-determined) compiler, you know. Same for Important: if target is already known and set, then vars like Hard partValues from Some notesWe definitely shouldn't try to search for a file in the file system and read it. It's not reliable, fragile. There is no guarantee that we will find it (for example, it can initially be passed to cargo as follows: Open questions
I'm working on proposal and patch for cargo to add new envs that exposes some necessary data for us - "is the requested target is user's spec file json?", "specified CPU" (can be or not), LLVM-target-triple (from json) and maybe path to json-spec (The latter is very dubious). @NobodyXu, |
I think it's pretty good, I recommend to split it into multiple PRs and do it incrementally. |
Firstly I filled proposal-issue rust-lang/cargo/issues 14208. |
I think I understood something. Perhaps we have enough information for a complete configuration of a third-party compiler. We don't need CPU because we have to use minimal-basic-cpu as the base. Kinda generic. Same for llvm-target. We already had abi and arch. We already know all target-features, that only need to be translated for a compiler (clang, gcc, etc..) Also we have data-layout - sizes of pointer and atomics. What about aligning and padding that also have to be known? 🤷🏻♂️ But any info about linking with std and buildins is not available. What we should to do with it? 🤷🏻♂️ Just need to try. |
Well, I'll try to implement some part of it, but I need to make target field optional. |
#1225 does most of the work here, the remaining work is to eliminate usage of |
Could be great to support custom target-specs (json files).
As we all know, env
TARGET
contains rustc's "short target name", not exactly target-triple. It can be triple only if builtin target requested.So
cc
couldn't use it directly if some custom target requested, e.g. for--target=my-spec.json
envTARGET
will be"my-spec"
.How to do it:
target
type - wrap into something likeenum Target { Builtin(...), Custom(...) }
RUSTC
by cargo$RUSTC --print cfg --target {target-short-name}.json
$RUSTC --print target-spec-json --target {target-short-name}.json -Zunstable-options
(nightly only)From this step we can get
llvm-target
But actually we already have almost all we need by cargo's env:
CARGO_CFG_TARGET_ABI
CARGO_CFG_TARGET_ARCH
CARGO_CFG_TARGET_FEATURE
CARGO_CFG_RELOCATION_MODEL
CARGO_CFG_TARGET_
excluding_VENDOR
and_OS
, and probably_ENV
.Note,
CARGO_CFG_TARGET_FEATURE
contains features added in themy-spec.json
too, so it really useful.So, could be great to support target-json-specs, use info from them.
Also to respect and use all available data from vars
CARGO_CFG_TARGET_
- translate and pass to compiler if possible.Example of env vars given by cargo
In my case, my target.json contains
"llvm-target": "thumbv7em-none-eabihf"
, uses it as base target, but overrides features and some more.Probably related issue: #994
The text was updated successfully, but these errors were encountered: