Implement flexible target specification #16156
Conversation
|
Still trying to figure out a bug where executables aren't getting the executable bit set... |
|
Seems to have resolved itself with a rebase ¯_(ツ)_/¯ |
| let mut paths = os::split_paths(target_path.as_slice()); | ||
| // FIXME: should be relative to the prefix rustc is installed in, and do something | ||
| // different for Windows. | ||
| paths.push(Path::new("/etc/rustc")); |
huonw
Aug 1, 2014
Member
Who installs to /etc/rustc?
Who installs to /etc/rustc?
alexcrichton
Aug 1, 2014
Member
This feature may want to remain unimplemented for now due to some open questions here, but it probably doesn't matter too much.
This feature may want to remain unimplemented for now due to some open questions here, but it probably doesn't matter too much.
|
Can you write a run-make test that checks the compiler is correctly searching for, parsing and using external specifications? (E.g. it could run |
|
Another issue: probably needs to allow specifying |
|
(The RFC specifies taking it from the target) |
|
@huonw how do those docs look? |
|
Hm, glaringly obvious problem: |
|
@farcaller we should try this with |
|
Be warned that this isn't quite working yet. My current status is:
|
|
(Already fixed I think, still building..) |
| //! will be given. `RUST_TARGET_PATH` includes `/etc/rustc` as its last entry, to be searched by | ||
| //! default. | ||
| //! | ||
| //! Projects defining their own targets should use `--target=path/to/my-awesome-platform.json` |
huonw
Aug 1, 2014
Member
Do we have a story for interacting with cargo?
Do we have a story for interacting with cargo?
emberian
Aug 1, 2014
Author
Member
Not yet, no.
Not yet, no.
| pub code_model: String, | ||
| /// Do not emit code that uses the "red zone", if the ABI has one. Defaults to true. | ||
| pub disable_redzone: bool, | ||
| /// String to use as the `target_endian` `cfg` variable. Must be specified. |
huonw
Aug 1, 2014
Member
Is it crazy to reorder these so that the required fields are together at the start of the definition?
Is it crazy to reorder these so that the required fields are together at the start of the definition?
| //! Targets are defined using [JSON](http://json.org/). The `Target` struct in this module defines | ||
| //! the format the JSON file should take, though each underscore in the field names should be | ||
| //! replaced with a hyphen (`-`) in the JSON file. Some fields are required in every target | ||
| //! specification, such as `data-layout`, `llvm-target`, `target-endian`, `target-word-size`, and |
huonw
Aug 1, 2014
Member
Could you explicitly state that most fields are optional?
Could you explicitly state that most fields are optional?
| sess.abort_if_errors(); | ||
| } | ||
| if sess.target.target.is_like_osx && sess.opts.debuginfo != NoDebugInfo { | ||
| match Command::new("dsymutil").arg(out_filename).status() { |
alexcrichton
Aug 1, 2014
Member
status => output
status => output
| } | ||
| let mut v = b"-Wl,-force_load,".to_vec(); | ||
| v.push_all(morestack.as_vec()); | ||
| cmd.arg(v.as_slice()); | ||
| } |
alexcrichton
Aug 1, 2014
Member
This seems to have lost the fall-through case?
This seems to have lost the fall-through case?
| Some(..) => false, | ||
| None => { *slot = Some(true); true } | ||
| } | ||
| } |
alexcrichton
Aug 1, 2014
Member
This seems backwards?
This seems backwards?
emberian
Aug 1, 2014
Author
Member
Is parse_bool also backwards, then?
Is parse_bool also backwards, then?
alexcrichton
Aug 1, 2014
Member
Ah nevermind, I remember what this is doing now. No worries!
Ah nevermind, I remember what this is doing now. No worries!
| abi::Mips => ("big", "mips", "32"), | ||
| abi::Mipsel => ("little", "mipsel", "32") | ||
| }; | ||
| let re = Regex::new("([^-]+)-([^-]+)-([^-]+)(-.*)?").unwrap(); |
alexcrichton
Aug 1, 2014
Member
While a regex certainly makes sense here, can we avoid pulling in the entire regex crate just for this one use case?
While a regex certainly makes sense here, can we avoid pulling in the entire regex crate just for this one use case?
| abi::Mipsel => ("little", "mipsel", "32") | ||
| }; | ||
| let re = Regex::new("([^-]+)-([^-]+)-([^-]+)(-.*)?").unwrap(); | ||
| let matches = re.captures(sess.opts.target_triple.as_slice()).expect("invalid target triple!"); |
alexcrichton
Aug 1, 2014
Member
This is dealing with user input so it should probably gracefully fail instead of ICE
This is dealing with user input so it should probably gracefully fail instead of ICE
| abi::Mips => mips::get_target_strs(target_triple, os), | ||
| abi::Mipsel => mipsel::get_target_strs(target_triple, os) | ||
| let target = Target::search(sopts.target_triple.as_slice()) | ||
| .expect("Couldn't find target specification, handle this better"); |
alexcrichton
Aug 1, 2014
Member
Just a reminder to handle this better
Just a reminder to handle this better
| } | ||
| fn dylibname(&self) -> Option<(String, String)> { | ||
| let t = &self.sess.target.target; | ||
| Some((t.dll_prefix.clone(), t.dll_suffix.clone())) | ||
| } |
alexcrichton
Aug 1, 2014
Member
This seems like a lossy transformation, why return Option when it's always Some?
This seems like a lossy transformation, why return Option when it's always Some?
| "x86_64" => cabi_x86_64::compute_abi_info(ccx, atys, rty, ret_def), | ||
| "arm" => cabi_arm::compute_abi_info(ccx, atys, rty, ret_def), | ||
| "mips" => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def), | ||
| a => fail!("unrecognized arch \"{}\" in target descriptor, handle this better", a) |
alexcrichton
Aug 1, 2014
Member
Reminder to handle this better
Reminder to handle this better
| match fn_ty.abi.for_target(ccx.sess().targ_cfg.os, | ||
| ccx.sess().targ_cfg.arch) { | ||
| Some(Rust) | Some(RustCall) => { | ||
| match fn_ty.abi { |
alexcrichton
Aug 1, 2014
Member
How come this stopped calling for_target?
How come this stopped calling for_target?
|
When compiling this on DragonFly I run into these problems:
Maybe the |
|
|
||
| pub fn target() -> Target { | ||
| Target { | ||
| function_sections: false, |
alexcrichton
Aug 1, 2014
Member
false => true ?
false => true ?
alexcrichton
Aug 1, 2014
Member
Ah nevermind, it would be nice to preserve the comments in the source code to this target specification about why this is false
Ah nevermind, it would be nice to preserve the comments in the source code to this target specification about why this is false
|
|
||
| pub fn target() -> Target { | ||
| Target { | ||
| function_sections: false, |
alexcrichton
Aug 1, 2014
Member
Was this disabled originally for dragonfly?
Was this disabled originally for dragonfly?
|
|
||
| pub fn target() -> Target { | ||
| Target { | ||
| function_sections: false, |
alexcrichton
Aug 1, 2014
Member
This should be enabled for freebsd?
This should be enabled for freebsd?
| executables: true, | ||
| disable_stack_checking: false, | ||
| has_rpath: true, | ||
| relocation_model: "default".to_string(), |
alexcrichton
Aug 1, 2014
Member
Why is this different than "pic"?
Why is this different than "pic"?
| arch: "x86".to_string(), | ||
| .. super::freebsd_base::target() | ||
| } | ||
| } |
alexcrichton
Aug 1, 2014
Member
I don't think split-stacks are supported on 32-bit freebsd, why add this triple?
I don't think split-stacks are supported on 32-bit freebsd, why add this triple?
|
Rebased, fixed, squashed: https://github.com/vadimcn/rust/tree/flextarget. Passes tests on Windows. |
|
Revived, yay! |
| @@ -1100,12 +1123,15 @@ do | |||
|
|
|||
| if [ ${do_reconfigure} -ne 0 ] | |||
| then | |||
| msg "configuring LLVM for $t" | |||
| # LLVM's configure doesn't recognize the new Windows triples yet | |||
| $gnu_t=$(to_gnu_triple $t) | |||
klutzy
Nov 1, 2014
Contributor
- $gnu_t=$(to_gnu_triple $t)
+ gnu_t=$(to_gnu_triple $t)
- $gnu_t=$(to_gnu_triple $t)
+ gnu_t=$(to_gnu_triple $t)
vadimcn
Nov 1, 2014
Contributor
Yup, @klutzy is absolutely right! I guess this doesn't break stuff unless LLVM needs to be rebuilt...
Yup, @klutzy is absolutely right! I guess this doesn't break stuff unless LLVM needs to be rebuilt...
|
Darn it! What's going on here??? |
|
I can't replicate the android failure locally. @alexcrichton do you know what API level the emulators are using? |
|
Looks like #17448, but I think that we're using api version 19 maybe? |
Removes all target-specific knowledge from rustc. Some targets have changed during this, but none of these should be very visible outside of cross-compilation. The changes make our targets more consistent. iX86-unknown-linux-gnu is now only available as i686-unknown-linux-gnu. We used to accept any value of X greater than 1. i686 was released in 1995, and should encompass the bare minimum of what Rust supports on x86 CPUs. The only two windows targets are now i686-pc-windows-gnu and x86_64-pc-windows-gnu. The iOS target has been renamed from arm-apple-ios to arm-apple-darwin. A complete list of the targets we accept now: arm-apple-darwin arm-linux-androideabi arm-unknown-linux-gnueabi arm-unknown-linux-gnueabihf i686-apple-darwin i686-pc-windows-gnu i686-unknown-freebsd i686-unknown-linux-gnu mips-unknown-linux-gnu mipsel-unknown-linux-gnu x86_64-apple-darwin x86_64-unknown-freebsd x86_64-unknown-linux-gnu x86_64-pc-windows-gnu Closes #16093 [breaking-change]
This comment has been minimized.
This comment has been minimized.
|
saw approval from alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
merging cmr/rust/target-spec = 87a753e into auto |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
saw approval from alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
merging cmr/rust/target-spec = 61aeab4 into auto |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
fast-forwarding master to auto = 3a8f4ec |
|
@cmr Congrats! :-) |
See commit message.