Skip to content

Commit 8dad4bd

Browse files
committed
run-make tests must distinguish between HOST_RPATH and TARGET_RPATH.
Also, some run-make tests just do not work in stage1 at all, and need to be skipped in that context. What this commit does: * Pass both of the (newly introduced) HOST and TARGET rpath setup vars to `maketest.py` * Update `maketest.py` to no longer update the LD_LIBRARY_PATH itself Instead, it passes along the HOST and TARGET rpath setup vars in environment variables `HOST_RPATH_ENV` and `TARGET_RPATH_ENV` * Cleanup: Distinguish in tools.mk between the command to run (`RUN`) and the file to generate to drive that command (`RUN_BINFILE`). The main thing this enables is that `RUN` can now setup the `TARGET_RPATH_ENV` without having to dirty up the runner code in each of the `run-make` Makefiles. * Pass stage to maketest.py; it in turn passes it (via an env var) to run-make tests. This allows the run-make tests to selectively change behavior (e.g. turn themselves off) to deal with incompatibilities with e.g. stage1.
1 parent 05ac7db commit 8dad4bd

File tree

9 files changed

+30
-16
lines changed

9 files changed

+30
-16
lines changed

mk/tests.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,9 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
908908
"$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" \
909909
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
910910
"$$(TESTNAME)" \
911-
"$$(RPATH_VAR$(1)_T_$(2)_H_$(3))"
911+
"$$(HOST_RPATH_VAR$(1)_T_$(2)_H_$(3))" \
912+
"$$(TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3))" \
913+
$(1)
912914
@touch $$@
913915
else
914916
# FIXME #11094 - The above rule doesn't work right for multiple targets

src/etc/maketest.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,27 @@ def putenv(name, value):
3030
value = normalize_path(value)
3131
os.putenv(name, value)
3232

33+
def convert_path_spec(name_and_value):
34+
name = name_and_value.split('=')[0]
35+
value = name_and_value.split('=')[1]
36+
if os.name == 'nt' and name != 'PATH':
37+
value = ":".join(normalize_path(v) for v in value.split(";"))
38+
return (name, value)
39+
40+
def put_delayed_env_setting(carrier_name, setting):
41+
if setting != '':
42+
delayed_name, value = convert_path_spec(setting)
43+
os.putenv(carrier_name, delayed_name + '=' + value)
3344

3445
make = sys.argv[2]
3546
putenv('RUSTC', os.path.abspath(sys.argv[3]))
3647
putenv('TMPDIR', os.path.abspath(sys.argv[4]))
3748
putenv('CC', sys.argv[5])
3849
putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
3950
filt = sys.argv[7]
40-
ldpath = sys.argv[8]
41-
if ldpath != '':
42-
name = ldpath.split('=')[0]
43-
value = ldpath.split('=')[1]
44-
if os.name == 'nt' and name != 'PATH':
45-
value = ":".join(normalize_path(v) for v in value.split(";"))
46-
os.putenv(name, value)
51+
put_delayed_env_setting('HOST_RPATH_ENV', sys.argv[8])
52+
put_delayed_env_setting('TARGET_RPATH_ENV', sys.argv[9])
53+
putenv('RUST_BUILD_STAGE', sys.argv[10])
4754

4855
if not filt in sys.argv[1]:
4956
sys.exit(0)

src/test/run-make/bootstrap-from-c-with-green/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
all:
44
$(RUSTC) lib.rs
55
ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot)
6-
$(CC) main.c -o $(call RUN,main) -lboot
6+
$(CC) main.c -o $(call RUN_BINFILE,main) -lboot
77
$(call RUN,main)
88
rm $(call DYLIB,boot)
99
$(call FAIL,main)

src/test/run-make/bootstrap-from-c-with-native/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
all:
44
$(RUSTC) lib.rs
55
ln -nsf $(call DYLIB,boot-*) $(call DYLIB,boot)
6-
$(CC) main.c -o $(call RUN,main) -lboot
6+
$(CC) main.c -o $(call RUN_BINFILE,main) -lboot
77
$(call RUN,main)
88
rm $(call DYLIB,boot)
99
$(call FAIL,main)

src/test/run-make/c-link-to-rust-dylib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
all:
44
$(RUSTC) foo.rs
55
ln -s $(call DYLIB,foo-*) $(call DYLIB,foo)
6-
$(CC) bar.c -lfoo -o $(call RUN,bar) -Wl,-rpath,$(TMPDIR)
6+
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -Wl,-rpath,$(TMPDIR)
77
$(call RUN,bar)
88
rm $(call DYLIB,foo)
99
$(call FAIL,bar)

src/test/run-make/c-link-to-rust-staticlib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ifneq ($(shell uname),FreeBSD)
1111
all:
1212
$(RUSTC) foo.rs
1313
ln -s $(call STATICLIB,foo-*) $(call STATICLIB,foo)
14-
$(CC) bar.c -lfoo -o $(call RUN,bar) $(EXTRAFLAGS) -lstdc++
14+
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(EXTRAFLAGS) -lstdc++
1515
$(call RUN,bar)
1616
rm $(call STATICLIB,foo*)
1717
$(call RUN,bar)

src/test/run-make/lto-smoke-c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ CC := $(CC:-g=)
1919
all:
2020
$(RUSTC) foo.rs -Z lto
2121
ln -s $(call STATICLIB,foo-*) $(call STATICLIB,foo)
22-
$(CC) bar.c -lfoo -o $(call RUN,bar) $(EXTRAFLAGS) -lstdc++
22+
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(EXTRAFLAGS) -lstdc++
2323
$(call RUN,bar)

src/test/run-make/prefer-dylib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ all:
55
$(RUSTC) foo.rs -C prefer-dynamic
66
$(call RUN,foo)
77
rm $(TMPDIR)/*bar*
8-
$(call FAILS,foo)
8+
$(call FAIL,foo)

src/test/run-make/tools.mk

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ export DYLD_LIBRARY_PATH:=$(TMPDIR):$(DYLD_LIBRARY_PATH)
44
RUSTC := $(RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR)
55
CC := $(CC) -L $(TMPDIR)
66

7-
RUN = $(TMPDIR)/$(1)
8-
FAILS = $(TMPDIR)/$(1) && exit 1 || exit 0
7+
# This is the name of the binary we will generate and run; use this
8+
# e.g. for `$(CC) -o $(RUN_BINFILE)`.
9+
RUN_BINFILE = $(TMPDIR)/$(1)
10+
# This the basic way we will invoke the generated binary. It sets the
11+
# LD_LIBRARY_PATH environment variable before running the binary.
12+
RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
13+
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
914

1015
RLIB_GLOB = lib$(1)*.rlib
1116
STATICLIB = $(TMPDIR)/lib$(1).a

0 commit comments

Comments
 (0)