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

Implement flexible target specification #16156

Merged
merged 7 commits into from
Nov 4, 2014
Merged

Implement flexible target specification #16156

merged 7 commits into from
Nov 4, 2014

Conversation

emberian
Copy link
Member

@emberian emberian commented Aug 1, 2014

See commit message.

@emberian
Copy link
Member Author

emberian commented Aug 1, 2014

Still trying to figure out a bug where executables aren't getting the executable bit set...

@emberian
Copy link
Member Author

emberian commented Aug 1, 2014

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"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who installs to /etc/rustc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature may want to remain unimplemented for now due to some open questions here, but it probably doesn't matter too much.

@huonw
Copy link
Member

huonw commented Aug 1, 2014

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 rustc --target=foo-bar-baz --emit=asm ... with a custom target that disables stack checks, and then grep for stack checks.)

@emberian
Copy link
Member Author

emberian commented Aug 1, 2014

Another issue: probably needs to allow specifying target_os instead of taking it from the target triple. I'm not actually sure this is a good idea, though, and it seems MUCH more clear that the target_os comes from the triple name itself. But we'd need to rename "osx" to "darwin", which I feel is almost a lie? Not really sure. Need feedback.

@emberian
Copy link
Member Author

emberian commented Aug 1, 2014

(The RFC specifies taking it from the target)

@emberian
Copy link
Member Author

emberian commented Aug 1, 2014

@huonw how do those docs look?

@emberian
Copy link
Member Author

emberian commented Aug 1, 2014

Hm, glaringly obvious problem: linker should probably include a target triple prefix, for cross compiling. ie, x86_64-unknown-linux-gnu-cc.

@errordeveloper
Copy link
Contributor

@farcaller we should try this with arm-none-eabi

@emberian
Copy link
Member Author

emberian commented Aug 1, 2014

Be warned that this isn't quite working yet. My current status is:

LLVM ERROR: not a number, or does not fit in an unsigned int

@emberian
Copy link
Member Author

emberian commented Aug 1, 2014

(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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a story for interacting with cargo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, no.

@mneumann
Copy link
Contributor

mneumann commented Aug 1, 2014

When compiling this on DragonFly I run into these problems:

/home/mneumann/rust/src/liblibc/lib.rs:2943:47: 2943:53 error: unresolved import
 `types::os::arch::c95::c_uint`. Could not find `arch` in `types::os`.
/home/mneumann/rust/src/liblibc/lib.rs:2943             use types::os::arch::c95
::{c_int, c_uint};

          ^~~~~~
/home/mneumann/rust/src/liblibc/lib.rs:2965:17: 2965:44 error: unresolved import
 `types::os::arch::c95::c_int`. Could not find `arch` in `types::os`.
/home/mneumann/rust/src/liblibc/lib.rs:2965             use types::os::arch::c95
::c_int;
                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mneumann/rust/src/liblibc/lib.rs:2966:17: 2966:49 error: unresolved import
 `types::os::arch::posix88::mode_t`. Could not find `arch` in `types::os`.
/home/mneumann/rust/src/liblibc/lib.rs:2966             use types::os::arch::pos
ix88::mode_t;
                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mneumann/rust/src/liblibc/lib.rs:3209:17: 3209:44 error: unresolved import
 `types::os::arch::c95::c_int`. Could not find `arch` in `types::os`.
/home/mneumann/rust/src/liblibc/lib.rs:3209             use types::os::arch::c95
::c_int;
                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mneumann/rust/src/liblibc/lib.rs:150:54: 150:58 error: unresolved import (
maybe you meant `stat::*`?)
/home/mneumann/rust/src/liblibc/lib.rs:150 pub use funcs::posix88::stat_::{chmod
, fstat, mkdir, stat};

                ^~~~
error: aborting due to 115 previous errors
gmake: *** [x86_64-unknown-dragonfly/stage1/lib/rustlib/x86_64-unknown-dragonfly
/lib/stamp.libc] Error 101

Maybe the target_os is incorrectly determined?


pub fn target() -> Target {
Target {
function_sections: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false => true ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nevermind, it would be nice to preserve the comments in the source code to this target specification about why this is false

@emberian
Copy link
Member Author

If someone else wants to take over this PR I wouldn't be offended, I know this feature is sorely needed.

"-Wl,--enable-long-section-names".to_string(),
// Mark all dynamic libraries and executables as compatible with the larger 4GiB
// address space available to x86 Windows binaries on x86_64.
"-Wl,--large-address-aware".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like x86_64 linker doesn't understand this option, but i686 does.

@vadimcn
Copy link
Contributor

vadimcn commented Oct 30, 2014

Rebased, fixed, squashed: https://github.com/vadimcn/rust/tree/flextarget. Passes tests on Windows.
@cmr: Do you want me to submit it?

@aturon
Copy link
Member

aturon commented Oct 31, 2014

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- $gnu_t=$(to_gnu_triple $t)
+ gnu_t=$(to_gnu_triple $t)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, @klutzy is absolutely right! I guess this doesn't break stuff unless LLVM needs to be rebuilt...

@vadimcn
Copy link
Contributor

vadimcn commented Nov 2, 2014

Darn it! What's going on here???

@emberian
Copy link
Member Author

emberian commented Nov 3, 2014

I can't replicate the android failure locally. @alexcrichton do you know what API level the emulators are using?

@alexcrichton
Copy link
Member

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]
bors added a commit that referenced this pull request Nov 4, 2014
@bors bors merged commit 61aeab4 into rust-lang:master Nov 4, 2014
@vadimcn
Copy link
Contributor

vadimcn commented Nov 4, 2014

@cmr Congrats! :-)

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.