]> git.proxmox.com Git - rustc.git/blob - src/test/run-make/remap-path-prefix-dwarf/Makefile
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / run-make / remap-path-prefix-dwarf / Makefile
1 # This test makes sure that --remap-path-prefix has the expected effects on paths in debuginfo.
2 # It tests several cases, each of them has a detailed description attached to it.
3
4 # ignore-windows
5
6 SRC_DIR := $(abspath .)
7 SRC_DIR_PARENT := $(abspath ..)
8
9 include ../../run-make-fulldeps/tools.mk
10
11 all: \
12 abs_input_outside_working_dir \
13 rel_input_remap_working_dir \
14 rel_input_remap_working_dir_parent \
15 rel_input_remap_working_dir_child \
16 abs_input_inside_working_dir \
17 abs_input_outside_working_dir
18
19 # The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path *is* within
20 # the working directory of the compiler. We are remapping the path that contains `src`.
21 abs_input_inside_working_dir:
22 # We explicitly switch to a directory that *is* a prefix of the directory our
23 # source code is contained in.
24 cd $(SRC_DIR) && $(RUSTC) $(SRC_DIR)/src/quux.rs -o "$(TMPDIR)/abs_input_inside_working_dir.rlib" -Cdebuginfo=2 --remap-path-prefix $(SRC_DIR)=REMAPPED
25 # We expect the path to the main source file to be remapped.
26 "$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir.rlib | $(CGREP) "REMAPPED/src/quux.rs"
27 # No weird duplication of remapped components (see #78479)
28 "$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir.rlib | $(CGREP) -v "REMAPPED/REMAPPED"
29
30 # The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path is *not* within
31 # the working directory of the compiler. We are remapping both the path that contains `src` and
32 # the working directory to the same thing. This setup corresponds to a workaround that is needed
33 # when trying to remap everything to something that looks like a local path.
34 # Relative paths are interpreted as relative to the compiler's working directory (e.g. in
35 # debuginfo). If we also remap the working directory, the compiler strip it from other paths so
36 # that the final outcome is the desired one again.
37 abs_input_outside_working_dir:
38 # We explicitly switch to a directory that is *not* a prefix of the directory our
39 # source code is contained in.
40 cd $(TMPDIR) && $(RUSTC) $(SRC_DIR)/src/quux.rs -o "$(TMPDIR)/abs_input_outside_working_dir.rlib" -Cdebuginfo=2 --remap-path-prefix $(SRC_DIR)=REMAPPED --remap-path-prefix $(TMPDIR)=REMAPPED
41 "$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_outside_working_dir.rlib | $(CGREP) "REMAPPED/src/quux.rs"
42 # No weird duplication of remapped components (see #78479)
43 "$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_outside_working_dir.rlib | $(CGREP) -v "REMAPPED/REMAPPED"
44
45 # The compiler is called with a *RELATIVE PATH* as input. We are remapping the working directory of
46 # the compiler, which naturally is an implicit prefix of our relative input path. Debuginfo will
47 # expand the relative path to an absolute path and we expect the working directory to be remapped
48 # in that expansion.
49 rel_input_remap_working_dir:
50 cd $(SRC_DIR) && $(RUSTC) src/quux.rs -o "$(TMPDIR)/rel_input_remap_working_dir.rlib" -Cdebuginfo=2 --remap-path-prefix "$(SRC_DIR)=REMAPPED"
51 "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir.rlib" | $(CGREP) "REMAPPED/src/quux.rs"
52 # No weird duplication of remapped components (see #78479)
53 "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir.rlib" | $(CGREP) -v "REMAPPED/REMAPPED"
54
55 # The compiler is called with a *RELATIVE PATH* as input. We are remapping a *SUB-DIRECTORY* of the
56 # compiler's working directory. This test makes sure that that directory is remapped even though it
57 # won't actually show up in this form in the compiler's SourceMap and instead is only constructed
58 # on demand during debuginfo generation.
59 rel_input_remap_working_dir_child:
60 cd $(SRC_DIR) && $(RUSTC) src/quux.rs -o "$(TMPDIR)/rel_input_remap_working_dir_child.rlib" -Cdebuginfo=2 --remap-path-prefix "$(SRC_DIR)/src=REMAPPED"
61 # We expect `src/quux.rs` to have been remapped to `REMAPPED/quux.rs`.
62 "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_child.rlib" | $(CGREP) "REMAPPED/quux.rs"
63 # We don't want to find the path that we just remapped anywhere in the DWARF
64 "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_child.rlib" | $(CGREP) -v "$(SRC_DIR)/src"
65 # No weird duplication of remapped components (see #78479)
66 "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_child.rlib" | $(CGREP) -v "REMAPPED/REMAPPED"
67
68 # The compiler is called with a *RELATIVE PATH* as input. We are remapping a *PARENT DIRECTORY* of
69 # the compiler's working directory.
70 rel_input_remap_working_dir_parent:
71 cd $(SRC_DIR) && $(RUSTC) src/quux.rs -o "$(TMPDIR)/rel_input_remap_working_dir_parent.rlib" -Cdebuginfo=2 --remap-path-prefix "$(SRC_DIR_PARENT)=REMAPPED"
72 # We expect `src/quux.rs` to have been remapped to `REMAPPED/remap-path-prefix-dwarf/src/quux.rs`.
73 "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_parent.rlib" | $(CGREP) "REMAPPED/remap-path-prefix-dwarf/src/quux.rs"
74 # We don't want to find the path that we just remapped anywhere in the DWARF
75 "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_parent.rlib" | $(CGREP) -v "$(SRC_DIR_PARENT)"
76 # No weird duplication of remapped components (see #78479)
77 "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_parent.rlib" | $(CGREP) -v "REMAPPED/REMAPPED"