Skip to content

Conversation

mattico
Copy link
Contributor

@mattico mattico commented Sep 8, 2017

Fixes #44393

@rust-highfive
Copy link
Contributor

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@carols10cents carols10cents added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 11, 2017
@mattico
Copy link
Contributor Author

mattico commented Sep 12, 2017

Bump

@arielb1
Copy link
Contributor

arielb1 commented Sep 13, 2017

Is there an easy way to add the current native CPU. i.e., to make the message look like:

    native - Select the CPU of the current host (currently core2).

@arielb1
Copy link
Contributor

arielb1 commented Sep 13, 2017

I'm ok with r+-ing this PR as it is, but I think the change above could be an improvement.

@mattico
Copy link
Contributor Author

mattico commented Sep 13, 2017

Another idea: If we're cross compiling then we probably don't want to print this info, since it'll be wrong/misleading.

@mattico
Copy link
Contributor Author

mattico commented Sep 13, 2017

λ build\x86_64-pc-windows-msvc\stage1\bin\rustc -C target-cpu=help
Available CPUs for this target:
    native         - Select the CPU of the current host (currently haswell).
    amdfam10       - Select the amdfam10 processor.
    athlon         - Select the athlon processor.
<snip>
λ build\x86_64-pc-windows-msvc\stage1\bin\rustc -C target-cpu=help --target arm-unknown-linux-gnueabi
Available CPUs for this target:
    arm1020e      - Select the arm1020e processor.
    arm1020t      - Select the arm1020t processor.
<snip>

@mattico
Copy link
Contributor Author

mattico commented Sep 13, 2017

r? @arielb1

@rust-highfive rust-highfive assigned arielb1 and unassigned aturon Sep 13, 2017
@arielb1
Copy link
Contributor

arielb1 commented Sep 14, 2017

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 14, 2017

📌 Commit e04c54e has been approved by arielb1

@bors
Copy link
Collaborator

bors commented Sep 14, 2017

⌛ Testing commit e04c54e86d899e9a213cfef006c2f7d4268db0b7 with merge 81922065dcf1e86ce4929112535f352f698dfcbf...

@bors
Copy link
Collaborator

bors commented Sep 14, 2017

💔 Test failed - status-travis

@kennytm
Copy link
Member

kennytm commented Sep 14, 2017

Failed to build rustc_llvm on dist-x86_64-linux alt.

[00:07:21] cargo:warning=../rustllvm/PassWrapper.cpp: In function 'void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef)':
[00:07:21] cargo:warning=../rustllvm/PassWrapper.cpp:310:55: error: cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string<char>}' through '...'
[00:07:21] cargo:warning=       MaxCPULen, "native", sys::getHostCPUName().str());
[00:07:21] cargo:warning=                                                       ^
[00:07:21] cargo:warning=../rustllvm/PassWrapper.cpp:310:55: warning: format '%s' expects argument of type 'char*', but argument 4 has type 'std::string {aka std::basic_string<char>}' [-Wformat=]

const ArrayRef<SubtargetFeatureKV> CPUTable = MCInfo->getCPUTable();
unsigned MaxCPULen = getLongestEntryLength(CPUTable);

printf("Available CPUs for this target:\n");
if (HostArch == TargetArch)
printf(" %-*s - Select the CPU of the current host (currently %s).\n",
MaxCPULen, "native", sys::getHostCPUName().data());
Copy link
Contributor

@hanna-kruppe hanna-kruppe Sep 14, 2017

Choose a reason for hiding this comment

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

StringRefs are not guaranteed to be null terminated. Use %.*s and pass the length as well, as in

// These unsigned->signed casts could theoretically overflow, but
// realistically never will (and even if, the result is implementation
// defined rather plain UB).
printf("%15.*s - %.*s\n", (int)PassArg.size(), PassArg.data(),
(int)PassName.size(), PassName.data());

@alexcrichton
Copy link
Member

@bors: r=arielb1

@bors
Copy link
Collaborator

bors commented Sep 19, 2017

📌 Commit 824fb38 has been approved by arielb1

@arielb1 arielb1 added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2017
@bors
Copy link
Collaborator

bors commented Sep 20, 2017

⌛ Testing commit 824fb38 with merge 4cdb362...

bors added a commit that referenced this pull request Sep 20, 2017
Add 'native' to -C target-cpu=help

Fixes #44393
@bors
Copy link
Collaborator

bors commented Sep 20, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: arielb1
Pushing 4cdb362 to master...

@bors bors merged commit 824fb38 into rust-lang:master Sep 20, 2017
@mattico mattico deleted the print-native-cpu branch September 20, 2017 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants