-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix warnings about the native
target-cpu
#53642
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
@bors r+ |
📌 Commit 744c6c822d9b936631f796c0d454d5d1750ce616 has been approved by |
Wait, this doesn't have a test test please @bors r- |
unsafe { | ||
let mut len = 0; | ||
let ptr = llvm::LLVMRustGetHostCPUName(&mut len); | ||
str::from_utf8_unchecked(slice::from_raw_parts(ptr as *const u8, len)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also a bit annoyed that you are using from_utf8_unchecked
here instead of from_utf8.unwrap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not that I think this failing is unlikely, except for API bugs, but minus 5 points for every use of unchecked
.
744c6c8
to
69b6ad1
Compare
@bors: r=arielb1 |
📌 Commit 69b6ad1ee44f66dfe621daec5ef076793ce23406 has been approved by |
@bors r- |
$(call RUN,foo) | ||
# Make sure no warnings about "unknown CPU `native`" were emitted | ||
if grep 'is not a recognized processor' $(TMPDIR)/out.log; then exit 1; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to check that no warnings at all are emitted (i.e. that out.log
is empty), to avoid this recurring with a different error message.
I don't think the compiler should ever emit garbage when compiling an empty file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there platforms where the compiler is always chatty? If then, I would check that the compiler is not chatty on all the other platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I basically hate writing tests in bash, do you know how to test a file is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use wc
and count the number of characters?
wc --chars file | cut -d' ' -f1
should be 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you test against 0 though? (I'm really bad at bash...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#!/bin/bash
touch file
if [ $(wc --chars file | cut -d' ' -f1) == 0 ]; then
echo "it's zero!"
else
echo "it's not zero!"
fi
should work :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't -s FILE
work? "True if FILE exists and has a size greater than zero."
r=me with test changed. |
69b6ad1
to
715d2cc
Compare
@bors: r=arielb1 |
📌 Commit 715d2cc has been approved by |
Fix warnings about the `native` target-cpu This fixes a regression from #53031 where specifying `-C target-cpu=native` is printing a lot of warnings from LLVM about `native` being an unknown CPU. It turns out that `native` is indeed an unknown CPU and we have to perform a mapping to an actual CPU name, but this mapping is only performed in one location rather than all locations we inform LLVM about the target CPU. This commit centralizes the mapping of `native` to LLVM's value of the native CPU, ensuring that all locations we inform LLVM about the `target-cpu` it's never `native`. Closes #53322
💔 Test failed - status-travis |
Fix warnings about the `native` target-cpu This fixes a regression from #53031 where specifying `-C target-cpu=native` is printing a lot of warnings from LLVM about `native` being an unknown CPU. It turns out that `native` is indeed an unknown CPU and we have to perform a mapping to an actual CPU name, but this mapping is only performed in one location rather than all locations we inform LLVM about the target CPU. This commit centralizes the mapping of `native` to LLVM's value of the native CPU, ensuring that all locations we inform LLVM about the `target-cpu` it's never `native`. Closes #53322
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This fixes a regression from rust-lang#53031 where specifying `-C target-cpu=native` is printing a lot of warnings from LLVM about `native` being an unknown CPU. It turns out that `native` is indeed an unknown CPU and we have to perform a mapping to an actual CPU name, but this mapping is only performed in one location rather than all locations we inform LLVM about the target CPU. This commit centralizes the mapping of `native` to LLVM's value of the native CPU, ensuring that all locations we inform LLVM about the `target-cpu` it's never `native`. Closes rust-lang#53322
12e33bf
to
1fd45a1
Compare
@bors: r=arielb1 |
📌 Commit 1fd45a1 has been approved by |
⌛ Testing commit 1fd45a1 with merge fe357694fbbc9bab93870e2c3a3f28195d1ff75d... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors: retry |
Fix warnings about the `native` target-cpu This fixes a regression from #53031 where specifying `-C target-cpu=native` is printing a lot of warnings from LLVM about `native` being an unknown CPU. It turns out that `native` is indeed an unknown CPU and we have to perform a mapping to an actual CPU name, but this mapping is only performed in one location rather than all locations we inform LLVM about the target CPU. This commit centralizes the mapping of `native` to LLVM's value of the native CPU, ensuring that all locations we inform LLVM about the `target-cpu` it's never `native`. Closes #53322
☀️ Test successful - status-appveyor, status-travis |
This fixes a regression from #53031 where specifying
-C target-cpu=native
isprinting a lot of warnings from LLVM about
native
being an unknown CPU. Itturns out that
native
is indeed an unknown CPU and we have to perform amapping to an actual CPU name, but this mapping is only performed in one
location rather than all locations we inform LLVM about the target CPU.
This commit centralizes the mapping of
native
to LLVM's value of the nativeCPU, ensuring that all locations we inform LLVM about the
target-cpu
it'snever
native
.Closes #53322