rewrite and slightly rename issue-68794-textrel-on-minimal-lib

This commit is contained in:
Oneirical 2024-06-19 11:09:05 -04:00
parent 55b581689d
commit a4f3e5f725
5 changed files with 30 additions and 19 deletions

View File

@ -70,7 +70,6 @@ run-make/issue-37839/Makefile
run-make/issue-40535/Makefile
run-make/issue-47384/Makefile
run-make/issue-47551/Makefile
run-make/issue-68794-textrel-on-minimal-lib/Makefile
run-make/issue-69368/Makefile
run-make/issue-83045/Makefile
run-make/issue-83112-incr-test-moved-file/Makefile

View File

@ -1,18 +0,0 @@
# ignore-cross-compile
# Regression test for issue #68794
#
# Verify that no text relocations are accidentally introduced by linking a
# minimal rust staticlib.
#
# The test links a rust static library into a shared library, and checks that
# the linker doesn't have to flag the resulting file as containing TEXTRELs.
include ../tools.mk
# only-linux
all:
$(RUSTC) foo.rs
$(CC) bar.c $(call STATICLIB,foo) -fPIC -shared -o $(call DYLIB,bar) \
$(EXTRACFLAGS) $(EXTRACXXFLAGS)
readelf -d $(call DYLIB,bar) | grep TEXTREL; test $$? -eq 1

View File

@ -0,0 +1,30 @@
// Verify that no text relocations are accidentally introduced by linking a
// minimal rust staticlib.
// The test links a rust static library into a shared library, and checks that
// the linker doesn't have to flag the resulting file as containing TEXTRELs.
// This bug otherwise breaks Android builds, which forbid TEXTRELs.
// See https://github.com/rust-lang/rust/issues/68794
//@ ignore-cross-compile
//FIXME(Oneirical): check that it works on more than just only-linux
use run_make_support::{
cc, dynamic_lib_name, extra_c_flags, extra_cxx_flags, llvm_readobj, rustc, static_lib_name,
};
fn main() {
rustc().input("foo.rs").run();
cc().input("bar.c")
.input(static_lib_name("foo"))
.out_exe(&dynamic_lib_name("bar"))
.arg("-fPIC")
.arg("-shared")
.args(&extra_c_flags())
.args(&extra_cxx_flags())
.run();
llvm_readobj()
.input(dynamic_lib_name("bar"))
.arg("--dynamic")
.run()
.assert_stdout_not_contains("TEXTREL");
}