Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Doesn't support JSON targets #145

Closed
thejpster opened this issue Oct 27, 2018 · 2 comments · Fixed by #304
Closed

Doesn't support JSON targets #145

thejpster opened this issue Oct 27, 2018 · 2 comments · Fixed by #304

Comments

@thejpster
Copy link
Contributor

If you supply a target as a JSON file, the build.rs can't detect the target. This is because target is a full path - in my case starts this starts C:\, which != thumbv.

I think the fix is to take the file_stem() of the path and use that. This should work for both JSON targets and built-in targets (that don't contain .). If the built-in target does use . (e.g. thumbv8-m.base) we'll need to be a bit cleverer.

@japaric
Copy link
Member

japaric commented Oct 30, 2018

I think the fix is to take the file_stem() of the path and use that.

This doesn't always work. There's no guarantee the file name matches the LLVM name or it's even a proper triple, e.g. foo.json is a valid name for a custom specification file. The proper way is to run rustc --print cfg --target $TARGET and then parse the output. However, on beta / stable the output doesn't contain enough information to discern ARM Linux from ARM Cortex-M. For example, target_feature="mclass" only appears in the nightly output of rustc --print cfg --target thumbv7m-none-eabi and it's not stable, i.e. it may disappear on any nightly update.

If we want to "support" custom targets the documentation should state that this is best effort support and than nightly updates may break things.

@thejpster
Copy link
Contributor Author

I agree it requires the user to name their JSON file correctly, but at least they have that option. Currently, cortex-m and cortex-m-rt don't work at all with a JSON target file (i.e. thumbv8m)

bors bot added a commit that referenced this issue Jan 8, 2021
304: Allow using the crate with custom target JSON specs r=adamgreig a=jonas-schievink

This should fix #145 (cc @thejpster)

Co-authored-by: Jonas Schievink <[email protected]>
@bors bors bot closed this as completed in 3a2ae35 Jan 8, 2021
@bors bors bot closed this as completed in #304 Jan 8, 2021
adamgreig pushed a commit to rust-embedded/cortex-m that referenced this issue Jan 12, 2022
304: Allow using the crate with custom target JSON specs r=adamgreig a=jonas-schievink

This should fix rust-embedded/cortex-m-rt#145 (cc @thejpster)

Co-authored-by: Jonas Schievink <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants