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

RFC: Handle custom targets #158

Closed
wants to merge 1 commit into from

Conversation

ppannuto
Copy link

For Tock, we use custom target specifications for each supported board. With the merging of rust-lang/rust#35021, when I set up https://github.com/rust-lang-nursery/compiler-builtins for Tock, it invoked cc instead of arm-none-eabi-gcc. I traced that decision back to this crate, where compiler selection logic depends on matching against a list of known targets.

Unfortunately, our custom target causes the TARGET environment variable to be set to something like sam4l.json, which is not a known target. However, we can look inside the specs file at the llvm-target key to pull out the right target.

The PR is a quick proof-of-concept that always tries to treat the TARGET as a specs file, but falls back to treating it as a well-known target string if the file doesn't exist. I think this is a reasonable approach to handle custom targets, but am open to any other ideas you may have.

@alexcrichton
Copy link
Member

Thanks for the PR! I know this is definitely one of the pain points about using custom targets right now.

Unfortunately though I fear that custom target specs are not fleshed out enough for this to use them just yet. For example, as you've found, just finding the target spec is no easy task. It's intended to be relative the cwd of the compiler invocation, which is different than the cwd of the build script invocations. As a result a build script doesn't actually have a way of finding where the target spec even is! While PWD here may work sometimes, I don't think it's a cross platform or tool-friendly solution (I think shells set that env var?)

In that sense I love the idea of making gcc more amenable to custom targets but I fear that we'd need to think through the custom target story more thoroughly before being able to add support :(

@ppannuto
Copy link
Author

With japaric's help, we've managed to get things working in Tock without relying on a custom target any more. While I suspect something like this may be useful someday, I don't have any great solutions to the issues that you've raised and am inclined to just close this for now.

@ppannuto ppannuto closed this May 25, 2017
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

Successfully merging this pull request may close these issues.

2 participants