rewrite target-cpu-native to rmake

This commit is contained in:
Oneirical 2024-07-04 11:28:16 -04:00
parent 5cddb156d1
commit e45d72dee0
2 changed files with 16 additions and 20 deletions

View File

@ -1,20 +0,0 @@
include ../tools.mk
# only-linux
# only-x86_64
#
# I *really* don't want to deal with a cross-platform way to compare file sizes,
# tests in `make` sort of are awful
all: $(TMPDIR)/out.log
# Make sure no warnings about "unknown CPU `native`" were emitted
if [ "$$(wc -c $(TMPDIR)/out.log | cut -d' ' -f 1)" = "0" ]; then \
echo no warnings generated; \
else \
exit 1; \
fi
$(TMPDIR)/out.log:
$(RUSTC) foo.rs -C target-cpu=native 2>&1 | tee $(TMPDIR)/out.log
$(call RUN,foo)

View File

@ -0,0 +1,16 @@
// target-cpu is a codegen flag that generates code for the processor of the host machine
// running the compilation. This test is a sanity test that this flag does not cause any
// warnings when used, and that binaries produced by it can also be successfully executed.
// See https://github.com/rust-lang/rust/pull/23238
// FIXME(Oneirical): only-linux only-x86_64
use run_make_support::{run, rustc};
fn main() {
let out = rustc().input("foo.rs").arg("-Ctarget-cpu=native").run().stderr_utf8();
run("foo");
// There should be zero warnings emitted - the bug would cause "unknown CPU `native`"
// to be printed out.
assert_eq!(out.len(), 0);
}