Stream: general

Topic: Print default target?

RalfJ (May 27 2019 at 09:26, on Zulip):

Is there a good way to ask rustc for the default target?

RalfJ (May 27 2019 at 09:28, on Zulip):

the best I got is

rustc --print target-spec-json -Z unstable-options | jq '.["llvm-target"]' -r
Luca Barbato (May 27 2019 at 10:44, on Zulip):

it would be interesting to me as well :)

RalfJ (May 27 2019 at 12:57, on Zulip):

argh, and of course mac's won't have jq. and "grep" can't show capture groups. wow this is awful.

RalfJ (May 27 2019 at 12:58, on Zulip):
rustc --print target-spec-json -Z unstable-options | grep llvm-target | cut -d '"' -f 4

technology is amazing...

Luca Barbato (May 27 2019 at 13:18, on Zulip):

rustc --print cfg doesn't provide the same information in a grep friendly way?

RalfJ (May 27 2019 at 13:22, on Zulip):


Luca Barbato (May 27 2019 at 13:27, on Zulip):

it is all split and reassembling isn't the nicest thing I guess

RalfJ (May 27 2019 at 13:29, on Zulip):

also, is it always $ARCH-$VENDOR-$OS-$ENV?

Luca Barbato (May 27 2019 at 15:00, on Zulip):

shoud be

nagisa (May 28 2019 at 23:23, on Zulip):

It is not always $ARCH-$VENDOR-$OS-$ENV. You can get the target triple from rustc --version --verbose as well.

RalfJ (May 29 2019 at 06:59, on Zulip):

hm, interesting. that looks slightly easier to grep for.

RalfJ (May 29 2019 at 07:34, on Zulip):

that would be

rustc --version --verbose | grep "^host:" | cut -d ' ' -f 2
Last update: Jul 16 2020 at 14:55UTC