Skip to content

Commit 5404a69

Browse files
committed
[RFC 3127 - Trim Paths]: Adjust tests for -Zremap-path-scope
1 parent 8add2fa commit 5404a69

File tree

3 files changed

+107
-2
lines changed

3 files changed

+107
-2
lines changed

tests/run-make/remap-path-prefix-dwarf/Makefile

+29
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ include ../tools.mk
1111
all: \
1212
abs_input_outside_working_dir \
1313
rel_input_remap_working_dir \
14+
rel_input_remap_working_dir_scope \
1415
rel_input_remap_working_dir_parent \
1516
rel_input_remap_working_dir_child \
17+
rel_input_remap_working_dir_diagnostics \
1618
abs_input_inside_working_dir \
19+
abs_input_inside_working_dir_scope \
1720
abs_input_outside_working_dir
1821

1922
# The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path *is* within
@@ -27,6 +30,17 @@ abs_input_inside_working_dir:
2730
# No weird duplication of remapped components (see #78479)
2831
"$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir.rlib | $(CGREP) -v "REMAPPED/REMAPPED"
2932

33+
# The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path *is* within
34+
# the working directory of the compiler. We are remapping the path that contains `src`.
35+
abs_input_inside_working_dir_scope:
36+
# We explicitly switch to a directory that *is* a prefix of the directory our
37+
# source code is contained in.
38+
cd $(SRC_DIR) && $(RUSTC) $(SRC_DIR)/src/quux.rs -o "$(TMPDIR)/abs_input_inside_working_dir_scope.rlib" -Cdebuginfo=2 --remap-path-prefix $(SRC_DIR)=REMAPPED -Zremap-path-scope=object
39+
# We expect the path to the main source file to be remapped.
40+
"$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir_scope.rlib | $(CGREP) "REMAPPED/src/quux.rs"
41+
# No weird duplication of remapped components (see #78479)
42+
"$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir_scope.rlib | $(CGREP) -v "REMAPPED/REMAPPED"
43+
3044
# The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path is *not* within
3145
# the working directory of the compiler. We are remapping both the path that contains `src` and
3246
# the working directory to the same thing. This setup corresponds to a workaround that is needed
@@ -52,6 +66,21 @@ rel_input_remap_working_dir:
5266
# No weird duplication of remapped components (see #78479)
5367
"$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir.rlib" | $(CGREP) -v "REMAPPED/REMAPPED"
5468

69+
# The compiler is called with a *RELATIVE PATH* as input. We are remapping the working directory of
70+
# the compiler, which naturally is an implicit prefix of our relative input path. Debuginfo will
71+
# expand the relative path to an absolute path and we expect the working directory to be remapped
72+
# in that expansion.
73+
rel_input_remap_working_dir_scope:
74+
cd $(SRC_DIR) && $(RUSTC) src/quux.rs -o "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" -Cdebuginfo=2 --remap-path-prefix "$(SRC_DIR)=REMAPPED" -Zremap-path-scope=object
75+
"$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) "REMAPPED/src/quux.rs"
76+
# No weird duplication of remapped components (see #78479)
77+
"$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) -v "REMAPPED/REMAPPED"
78+
79+
rel_input_remap_working_dir_diagnostics:
80+
cd $(SRC_DIR) && $(RUSTC) src/quux.rs -o "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" -Cdebuginfo=2 --remap-path-prefix "$(SRC_DIR)=REMAPPED" -Zremap-path-scope=diagnostics
81+
"$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) -v "REMAPPED/src/quux.rs"
82+
"$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) -v "REMAPPED/REMAPPED"
83+
5584
# The compiler is called with a *RELATIVE PATH* as input. We are remapping a *SUB-DIRECTORY* of the
5685
# compiler's working directory. This test makes sure that that directory is remapped even though it
5786
# won't actually show up in this form in the compiler's SourceMap and instead is only constructed

tests/run-make/remap-path-prefix/Makefile

+16
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,19 @@ all:
77
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux --crate-type=lib --emit=metadata auxiliary/lib.rs
88
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
99
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
10+
11+
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=object --crate-type=lib --emit=metadata auxiliary/lib.rs
12+
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
13+
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
14+
15+
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics --crate-type=lib --emit=metadata auxiliary/lib.rs
16+
! grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
17+
grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
18+
19+
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics,object --crate-type=lib --emit=metadata auxiliary/lib.rs
20+
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
21+
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
22+
23+
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=split-debuginfo --crate-type=lib --emit=metadata auxiliary/lib.rs
24+
! grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
25+
grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1

tests/run-make/split-debuginfo/Makefile

+62-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ packed-lto-single:
104104
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
105105
rm $(TMPDIR)/libbaz.rlib
106106

107-
packed-remapped: packed-remapped-split packed-remapped-single
107+
packed-remapped: packed-remapped-split packed-remapped-single packed-remapped-scope packed-remapped-wrong-scope
108108

109109
# - Debuginfo in `.dwo` files
110110
# - `.o` and binary refer to remapped `.dwo` paths which do not exist
@@ -134,6 +134,36 @@ packed-remapped-single:
134134
rm $(TMPDIR)/foo.dwp
135135
rm $(TMPDIR)/$(call BIN,foo)
136136

137+
# - Debuginfo in `.o` files
138+
# - `.o` and binary refer to remapped `.o` paths which do not exist
139+
# - `.o` deleted
140+
# - `.dwo` never created
141+
# - `.dwp` present
142+
packed-remapped-scope:
143+
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
144+
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
145+
-Z remap-path-scope=split-debuginfo-path foo.rs -g
146+
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
147+
ls $(TMPDIR)/*.o && exit 1 || exit 0
148+
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
149+
rm $(TMPDIR)/foo.dwp
150+
rm $(TMPDIR)/$(call BIN,foo)
151+
152+
# - Debuginfo in `.o` files
153+
# - `.o` and binary refer to remapped `.o` paths which do not exist
154+
# - `.o` deleted
155+
# - `.dwo` never created
156+
# - `.dwp` present
157+
packed-remapped-wrong-scope:
158+
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
159+
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
160+
-Z remap-path-scope=macro foo.rs -g
161+
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1
162+
ls $(TMPDIR)/*.o && exit 1 || exit 0
163+
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
164+
rm $(TMPDIR)/foo.dwp
165+
rm $(TMPDIR)/$(call BIN,foo)
166+
137167
packed-crosscrate: packed-crosscrate-split packed-crosscrate-single
138168

139169
# - Debuginfo in `.dwo` files
@@ -230,7 +260,7 @@ unpacked-lto-single:
230260
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
231261
rm $(TMPDIR)/libbaz.rlib
232262

233-
unpacked-remapped: unpacked-remapped-split unpacked-remapped-single
263+
unpacked-remapped: unpacked-remapped-split unpacked-remapped-single unpacked-remapped-scope unpacked-remapped-wrong-scope
234264

235265
# - Debuginfo in `.dwo` files
236266
# - `.o` and binary refer to remapped `.dwo` paths which do not exist
@@ -260,6 +290,36 @@ unpacked-remapped-single:
260290
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
261291
rm $(TMPDIR)/$(call BIN,foo)
262292

293+
# - Debuginfo in `.o` files
294+
# - `.o` and binary refer to remapped `.o` paths which do not exist
295+
# - `.o` present
296+
# - `.dwo` never created
297+
# - `.dwp` never created
298+
unpacked-remapped-scope:
299+
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
300+
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
301+
-Z remap-path-scope=split-debuginfo-path foo.rs -g
302+
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
303+
rm $(TMPDIR)/*.o
304+
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
305+
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
306+
rm $(TMPDIR)/$(call BIN,foo)
307+
308+
# - Debuginfo in `.o` files
309+
# - `.o` and binary refer to remapped `.o` paths which do not exist
310+
# - `.o` present
311+
# - `.dwo` never created
312+
# - `.dwp` never created
313+
unpacked-remapped-wrong-scope:
314+
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
315+
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
316+
-Z remap-path-scope=macro foo.rs -g
317+
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1
318+
rm $(TMPDIR)/*.o
319+
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
320+
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
321+
rm $(TMPDIR)/$(call BIN,foo)
322+
263323
unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single
264324

265325
# - Debuginfo in `.dwo` files

0 commit comments

Comments
 (0)