about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-07-08 14:57:07 -0400
committerOneirical <manchot@videotron.ca>2024-07-17 15:33:07 -0400
commitf7d67d6b6855d0f3880668f2f2d0dabc02caef31 (patch)
tree37ba00a0491ca748f18f9dba7dc9d81e25c87d5d
parentbde91785dc4de27787ac20074f3fda70ec47c88d (diff)
downloadrust-f7d67d6b6855d0f3880668f2f2d0dabc02caef31.tar.gz
rust-f7d67d6b6855d0f3880668f2f2d0dabc02caef31.zip
rewrite extern-fn-with-packed-struct to rmake
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/extern-fn-with-packed-struct/Makefile6
-rw-r--r--tests/run-make/extern-fn-with-packed-struct/rmake.rs17
3 files changed, 17 insertions, 7 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index fde065b929b..1c6fc57bd81 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -27,7 +27,6 @@ run-make/extern-flag-disambiguates/Makefile
 run-make/extern-fn-generic/Makefile
 run-make/extern-fn-mangle/Makefile
 run-make/extern-fn-reachable/Makefile
-run-make/extern-fn-with-packed-struct/Makefile
 run-make/extern-fn-with-union/Makefile
 run-make/extern-multiple-copies/Makefile
 run-make/extern-multiple-copies2/Makefile
diff --git a/tests/run-make/extern-fn-with-packed-struct/Makefile b/tests/run-make/extern-fn-with-packed-struct/Makefile
deleted file mode 100644
index 3cbbf383996..00000000000
--- a/tests/run-make/extern-fn-with-packed-struct/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-all: $(call NATIVE_STATICLIB,test)
-	$(RUSTC) test.rs
-	$(call RUN,test) || exit 1
diff --git a/tests/run-make/extern-fn-with-packed-struct/rmake.rs b/tests/run-make/extern-fn-with-packed-struct/rmake.rs
new file mode 100644
index 00000000000..e6d8cecd24a
--- /dev/null
+++ b/tests/run-make/extern-fn-with-packed-struct/rmake.rs
@@ -0,0 +1,17 @@
+// Packed structs, in C, occupy less bytes in memory, but are more
+// vulnerable to alignment errors. Passing them around in a Rust-C foreign
+// function interface (FFI) would cause unexpected behavior, until this was
+// fixed in #16584. This test checks that a Rust program with a C library
+// compiles and executes successfully, even with usage of a packed struct.
+// See https://github.com/rust-lang/rust/issues/16574
+
+//@ ignore-cross-compile
+// Reason: the compiled binary is executed
+
+use run_make_support::{build_native_static_lib, run, rustc};
+
+fn main() {
+    build_native_static_lib("test");
+    rustc().input("test.rs").run();
+    run("test");
+}