From a55de2b28f2ac862f07bf678447a025d3a051c59 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 23 Jan 2024 17:29:47 -0500 Subject: [PATCH] test: verify current remap rules on Linux When `--remap-path-scope=object` is specified, user expect that there is no local path embedded in final executables. Under `object` scope, the current implementation only remap debug symbols if debug info is splitted into its own file. In other words, when `split-debuginfo=packed|unpacked` is set, rustc assumes there is no embedded path in the final executable needing to be remapped. However, this doesn't work on Linux. On Linux, the root `DW_AT_comp_dir` of a compile unit seems to go into the binary binary executables. This commit demonstrates the case, and hope there is a fix soon. --- tests/run-make/split-debuginfo/Makefile | 394 ++++++++++++++++++++++-- 1 file changed, 364 insertions(+), 30 deletions(-) diff --git a/tests/run-make/split-debuginfo/Makefile b/tests/run-make/split-debuginfo/Makefile index 80557f335735b..60729482b9d2f 100644 --- a/tests/run-make/split-debuginfo/Makefile +++ b/tests/run-make/split-debuginfo/Makefile @@ -285,7 +285,9 @@ packed-lto-single: ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/libbaz.rlib -packed-remapped: packed-remapped-split packed-remapped-single packed-remapped-scope packed-remapped-wrong-scope +packed-remapped: packed-remapped-split packed-remapped-single \ + packed-remapped-object-scope packed-remapped-macro-scope \ + packed-remapped-split-debuginfo-scope # - Debuginfo in `.dwo` files # - `.o` and binary refer to remapped `.dwo` paths which do not exist @@ -294,52 +296,160 @@ packed-remapped: packed-remapped-split packed-remapped-single packed-remapped-sc # - `.dwp` present packed-remapped-split: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ - -Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 + -Z split-dwarf-kind=split \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + foo.rs -g + + # binary contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo || exit 1 + grep --text $(REMAPPED_CWD) $(TMPDIR)/foo || exit 1 + + # binary contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo) || exit 1 + + # dwp contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.dwp || exit 1 + + # dwp contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo.dwp) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo.dwp) || exit 1 + ls $(TMPDIR)/*.o && exit 1 || exit 0 ls $(TMPDIR)/*.dwo && exit 1 || exit 0 rm $(TMPDIR)/foo.dwp rm $(TMPDIR)/$(call BIN,foo) -# - Debuginfo in `.o` files +# - Debuginfo in `.dwp` files # - `.o` and binary refer to remapped `.o` paths which do not exist # - `.o` deleted # - `.dwo` never created # - `.dwp` present packed-remapped-single: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 + -Z split-dwarf-kind=single \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + foo.rs -g + + # binary contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo || exit 1 + grep --text $(REMAPPED_CWD) $(TMPDIR)/foo || exit 1 + + # binary contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo) || exit 1 + + # dwp contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.dwp || exit 1 + + # dwp contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo.dwp) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo.dwp) || exit 1 + ls $(TMPDIR)/*.o && exit 1 || exit 0 ls $(TMPDIR)/*.dwo && exit 1 || exit 0 rm $(TMPDIR)/foo.dwp rm $(TMPDIR)/$(call BIN,foo) -# - Debuginfo in `.o` files +# - Debuginfo in `.dwp` files # - `.o` and binary refer to remapped `.o` paths which do not exist # - `.o` deleted # - `.dwo` never created # - `.dwp` present -packed-remapped-scope: +packed-remapped-object-scope: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ - -Z remap-path-scope=split-debuginfo-path foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + -Z remap-path-scope=object foo.rs -g + + # binary contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo || exit 1 + # FIXME: binary contains `DW_AT_comp_dir` in debug symbol, which should be remapped. + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1 + + # binary contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + # FIXME: bnary contains `DW_AT_comp_dir` in debug symbol, which should be remapped. + readelf -wi $(TMPDIR)/foo | grep "DW_AT_comp_dir" | grep $(HERE) || exit 1 + readelf -wi $(TMPDIR)/foo | grep --invert-match "DW_AT_comp_dir" | (! grep $(HERE)) || exit 1 + + # dwp contains no remapped paths + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.dwp) || exit 1 + # FIXME: dwp contains `DW_AT_GNU_dwo_name` in debug symbol, which got remapped. + readelf -wi $(TMPDIR)/foo.dwp | grep "DW_AT_GNU_dwo_name" | grep $(REMAPPED_OUT) || exit 1 + readelf -wi $(TMPDIR)/foo.dwp | grep --invert-match "DW_AT_GNU_dwo_name" | (! grep $(REMAPPED_OUT)) || exit 1 + + # dwp contains original paths + # FIXME: dwp contains `DW_AT_GNU_dwo_name` in debug symbol, which got remapped. + (! grep --text $(TMPDIR) $(TMPDIR)/foo.dwp) || exit 1 + ls $(TMPDIR)/*.o && exit 1 || exit 0 ls $(TMPDIR)/*.dwo && exit 1 || exit 0 rm $(TMPDIR)/foo.dwp rm $(TMPDIR)/$(call BIN,foo) -# - Debuginfo in `.o` files +# - Debuginfo in `.dwp` files # - `.o` and binary refer to remapped `.o` paths which do not exist # - `.o` deleted # - `.dwo` never created # - `.dwp` present -packed-remapped-wrong-scope: +packed-remapped-macro-scope: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ -Z remap-path-scope=macro foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1 + + # binary contains no remapped paths + (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo) || exit 1 + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1 + + # binary contains original paths + grep --text $(TMPDIR) $(TMPDIR)/foo || exit 1 + grep --text $(HERE) $(TMPDIR)/foo || exit 1 + + # dwp contains no remapped paths + (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.dwp) || exit 1 + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.dwp) || exit 1 + + # dwp contains original paths + grep --text $(TMPDIR) $(TMPDIR)/foo.dwp || exit 1 + + ls $(TMPDIR)/*.o && exit 1 || exit 0 + ls $(TMPDIR)/*.dwo && exit 1 || exit 0 + rm $(TMPDIR)/foo.dwp + rm $(TMPDIR)/$(call BIN,foo) + +# - Debuginfo in `.dwp` files +# - `.o` deleted +# - `.dwo` never created +# - `.dwp` present +packed-remapped-split-debuginfo-scope: + $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + -Z remap-path-scope=split-debuginfo,split-debuginfo-path foo.rs -g + + # binary contains remapped dwo path + readelf -wi $(TMPDIR)/foo | grep "DW_AT_GNU_dwo_name" | grep $(REMAPPED_OUT) || exit 1 + readelf -wi $(TMPDIR)/foo | grep --invert-match "DW_AT_GNU_dwo_name" | (! grep $(REMAPPED_OUT)) || exit 1 + # FIXME: binary contains `DW_AT_comp_dir` in debug symbol, which got remapped. + readelf -wi $(TMPDIR)/foo | grep "DW_AT_comp_dir" | grep $(REMAPPED_CWD) || exit 1 + readelf -wi $(TMPDIR)/foo | grep --invert-match "DW_AT_comp_dir" | (! grep $(REMAPPED_CWD)) || exit 1 + + # binary contains no original --out-dir (DW_AT_GNU_dwo_name was remapped) + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + # FIXME: binary contains `DW_AT_comp_dir` in debug symbol, which got remapped. + (! grep --text $(HERE) $(TMPDIR)/foo) || exit 1 + + # dwp contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.dwp || exit 1 + + # dwp contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo.dwp) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo.dwp) || exit 1 + ls $(TMPDIR)/*.o && exit 1 || exit 0 ls $(TMPDIR)/*.dwo && exit 1 || exit 0 rm $(TMPDIR)/foo.dwp @@ -441,66 +551,290 @@ unpacked-lto-single: ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/libbaz.rlib -unpacked-remapped: unpacked-remapped-split unpacked-remapped-single unpacked-remapped-scope unpacked-remapped-wrong-scope +unpacked-remapped: unpacked-remapped-split unpacked-remapped-single \ + unpacked-remapped-object-scope unpacked-remapped-macro-scope \ + unpacked-remapped-split-debuginfo-scope # - Debuginfo in `.dwo` files -# - `.o` and binary refer to remapped `.dwo` paths which do not exist # - `.o` deleted # - `.dwo` present # - `.dwp` never created unpacked-remapped-split: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ - -Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 + -Z split-dwarf-kind=split \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + foo.rs -g + + # binary contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo || exit 1 + grep --text $(REMAPPED_CWD) $(TMPDIR)/foo || exit 1 + + # binary contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo) || exit 1 + + # dwo contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.*.dwo || exit 1 + + # dwo contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo.*.dwo) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo.*.dwo) || exit 1 + ls $(TMPDIR)/*.o && exit 1 || exit 0 rm $(TMPDIR)/*.dwo ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/$(call BIN,foo) # - Debuginfo in `.o` files -# - `.o` and binary refer to remapped `.o` paths which do not exist # - `.o` present # - `.dwo` never created # - `.dwp` never created unpacked-remapped-single: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 + -Z split-dwarf-kind=single \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + foo.rs -g + + # binary contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo || exit 1 + grep --text $(REMAPPED_CWD) $(TMPDIR)/foo || exit 1 + + # binary contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo) || exit 1 + + # object file contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.*.o || exit 1 + grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.*.o || exit 1 + + # object file contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo.*.o) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo.*.o) || exit 1 + rm $(TMPDIR)/*.o ls $(TMPDIR)/*.dwo && exit 1 || exit 0 ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/$(call BIN,foo) +unpacked-remapped-object-scope: unpacked-remapped-object-scope-split unpacked-remapped-object-scope-single + +# - Debuginfo in `.dwo` files +# - `.o` and binary refer to remapped `.dwo` paths which do not exist +# - `.o` deleted +# - `.dwo` present +# - `.dwp` never created +unpacked-remapped-object-scope-split: + $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ + -Z split-dwarf-kind=split \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + -Z remap-path-scope=object foo.rs -g + + # binary contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo || exit 1 + # FIXME: binary should contains no cwd but now it got `DW_AT_comp_dir` + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1 + + # binary contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + # FIXME: binary contains `DW_AT_comp_dir` in debug symbol, which didn't get remapped. + readelf -wi $(TMPDIR)/foo | grep "DW_AT_comp_dir" | grep $(HERE) || exit 1 + readelf -wi $(TMPDIR)/foo | grep --invert-match "DW_AT_comp_dir" | (! grep $(HERE)) || exit 1 + + # dwo contains no remapped paths + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.*.dwo) || exit 1 + # FIXME: dwo contains `DW_AT_GNU_dwo_name` in debug symbol, which got remapped. + readelf -wi $(TMPDIR)/foo.*.dwo | grep "DW_AT_GNU_dwo_name" | grep $(REMAPPED_OUT) || exit 1 + readelf -wi $(TMPDIR)/foo.*.dwo | grep --invert-match "DW_AT_GNU_dwo_name" | (! grep $(REMAPPED_OUT)) || exit 1 + + # dwo contains original paths + # FIXME: dwo contains `DW_AT_GNU_dwo_name` in debug symbol, which got remapped. + (! grep --text $(TMPDIR) $(TMPDIR)/foo.*.dwo) || exit 1 + + ls $(TMPDIR)/*.o && exit 1 || exit 0 + rm $(TMPDIR)/*.dwo + ls $(TMPDIR)/*.dwp && exit 1 || exit 0 + rm $(TMPDIR)/$(call BIN,foo) + # - Debuginfo in `.o` files # - `.o` and binary refer to remapped `.o` paths which do not exist # - `.o` present # - `.dwo` never created # - `.dwp` never created -unpacked-remapped-scope: +unpacked-remapped-object-scope-single: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ - -Z remap-path-scope=split-debuginfo-path foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 + -Z split-dwarf-kind=single \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + -Z remap-path-scope=object foo.rs -g + + # binary contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo || exit 1 + # FIXME: binary should contains no cwd but now it got `DW_AT_comp_dir` + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1 + + # binary contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + # FIXME: binary contains `DW_AT_comp_dir` in debug symbol, which didn't get remapped. + readelf -wi $(TMPDIR)/foo | grep "DW_AT_comp_dir" | grep $(HERE) || exit 1 + readelf -wi $(TMPDIR)/foo | grep --invert-match "DW_AT_comp_dir" | (! grep $(HERE)) || exit 1 + + # object file contains no remapped paths + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.*.o) || exit 1 + # FIXME: object file contains `DW_AT_GNU_dwo_name` in debug symbol, which got remapped. + readelf -wi $(TMPDIR)/foo.*.o | grep "DW_AT_GNU_dwo_name" | grep $(REMAPPED_OUT) || exit 1 + readelf -wi $(TMPDIR)/foo.*.o | grep --invert-match "DW_AT_GNU_dwo_name" | (! grep $(REMAPPED_OUT)) || exit 1 + + # object file contains original paths + grep --text $(HERE) $(TMPDIR)/foo.*.o || exit 1 + # FIXME: object file contains `DW_AT_GNU_dwo_name` in debug symbol, which got remapped. + (! grep --text $(TMPDIR) $(TMPDIR)/foo.*.o) || exit 1 + rm $(TMPDIR)/*.o ls $(TMPDIR)/*.dwo && exit 1 || exit 0 ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/$(call BIN,foo) +unpacked-remapped-macro-scope: unpacked-remapped-macro-scope-split unpacked-remapped-macro-scope-single + +# - Debuginfo in `.dwo` files +# - `.o` deleted +# - `.dwo` present +# - `.dwp` never created +unpacked-remapped-macro-scope-split: + $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ + -Z split-dwarf-kind=split \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + -Z remap-path-scope=macro foo.rs -g + + # binary contains no remapped paths + (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo) || exit 1 + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1 + + # binary contains original paths + grep --text $(TMPDIR) $(TMPDIR)/foo || exit 1 + grep --text $(HERE) $(TMPDIR)/foo || exit 1 + + # dwo contains no remapped paths + (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.*.dwo) || exit 1 + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.*.dwo) || exit 1 + + # dwo contains original paths + grep --text $(TMPDIR) $(TMPDIR)/foo.*.dwo || exit 1 + + ls $(TMPDIR)/*.o && exit 1 || exit 0 + rm $(TMPDIR)/*.dwo + ls $(TMPDIR)/*.dwp && exit 1 || exit 0 + rm $(TMPDIR)/$(call BIN,foo) + # - Debuginfo in `.o` files -# - `.o` and binary refer to remapped `.o` paths which do not exist # - `.o` present # - `.dwo` never created # - `.dwp` never created -unpacked-remapped-wrong-scope: +unpacked-remapped-macro-scope-single: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ + -Z split-dwarf-kind=single \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ -Z remap-path-scope=macro foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1 + + # binary contains no remapped paths + (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo) || exit 1 + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1 + + # binary contains original paths + grep --text $(TMPDIR) $(TMPDIR)/foo || exit 1 + grep --text $(HERE) $(TMPDIR)/foo || exit 1 + + # object file contains no remapped paths + (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.*.o) || exit 1 + (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.*.o) || exit 1 + + # object file contains original paths + grep --text $(TMPDIR) $(TMPDIR)/foo.*.o || exit 1 + grep --text $(HERE) $(TMPDIR)/foo.*.o || exit 1 + rm $(TMPDIR)/*.o ls $(TMPDIR)/*.dwo && exit 1 || exit 0 ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/$(call BIN,foo) +unpacked-remapped-split-debuginfo-scope: unpacked-remapped-split-debuginfo-scope-split \ + unpacked-remapped-split-debuginfo-scope-single + +# - Debuginfo in `.dwo` files +# - `.o` deleted +# - `.dwo` present +# - `.dwp` never created +unpacked-remapped-split-debuginfo-scope-split: + $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ + -Z split-dwarf-kind=split \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + -Z remap-path-scope=split-debuginfo,split-debuginfo-path foo.rs -g + + # binary contains remapped dwo path + readelf -wi $(TMPDIR)/foo | grep "DW_AT_GNU_dwo_name" | grep $(REMAPPED_OUT) || exit 1 + readelf -wi $(TMPDIR)/foo | grep --invert-match "DW_AT_GNU_dwo_name" | (! grep $(REMAPPED_OUT)) || exit 1 + # FIXME: binary contains `DW_AT_comp_dir` in debug symbol, which got remapped. + readelf -wi $(TMPDIR)/foo | grep "DW_AT_comp_dir" | grep $(REMAPPED_CWD) || exit 1 + readelf -wi $(TMPDIR)/foo | grep --invert-match "DW_AT_comp_dir" | (! grep $(REMAPPED_CWD)) || exit 1 + + # binary contains no original --out-dir (DW_AT_GNU_dwo_name was remapped) + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + # FIXME: binary contains `DW_AT_comp_dir` in debug symbol, which got remapped. + (! grep --text $(HERE) $(TMPDIR)/foo) || exit 1 + + # dwo contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.*.dwo || exit 1 + + # dwo contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo.*.dwo) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo.*.dwo) || exit 1 + + ls $(TMPDIR)/*.o && exit 1 || exit 0 + rm $(TMPDIR)/*.dwo + ls $(TMPDIR)/foo.dwp && exit 1 || exit 0 + rm $(TMPDIR)/$(call BIN,foo) + +# - Debuginfo in `.o` files +# - `.o` present +# - `.dwo` never created +# - `.dwp` never created +unpacked-remapped-split-debuginfo-scope-single: + $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ + -Z split-dwarf-kind=single \ + --remap-path-prefix $(TMPDIR)=$(REMAPPED_OUT) \ + --remap-path-prefix $(HERE)=$(REMAPPED_CWD) \ + -Z remap-path-scope=split-debuginfo,split-debuginfo-path foo.rs -g + + # binary contains remapped dwo path + readelf -wi $(TMPDIR)/foo | grep "DW_AT_GNU_dwo_name" | grep $(REMAPPED_OUT) || exit 1 + readelf -wi $(TMPDIR)/foo | grep --invert-match "DW_AT_GNU_dwo_name" | (! grep $(REMAPPED_OUT)) || exit 1 + # FIXME: binary contains `DW_AT_comp_dir` in debug symbol, which got remapped. + readelf -wi $(TMPDIR)/foo | grep "DW_AT_comp_dir" | grep $(REMAPPED_CWD) || exit 1 + readelf -wi $(TMPDIR)/foo | grep --invert-match "DW_AT_comp_dir" | (! grep $(REMAPPED_CWD)) || exit 1 + + # binary contains no original --out-dir (DW_AT_GNU_dwo_name was remapped) + (! grep --text $(TMPDIR) $(TMPDIR)/foo) || exit 1 + # FIXME: binary contains `DW_AT_comp_dir` in debug symbol, which got remapped. + (! grep --text $(HERE) $(TMPDIR)/foo) || exit 1 + + # object file contains remapped paths + grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.*.o || exit 1 + + # object file contains no original paths + (! grep --text $(TMPDIR) $(TMPDIR)/foo.*.o) || exit 1 + (! grep --text $(HERE) $(TMPDIR)/foo.*.o) || exit 1 + + rm $(TMPDIR)/*.o + ls $(TMPDIR)/*.dwo && exit 1 || exit 0 + ls $(TMPDIR)/foo.dwp && exit 1 || exit 0 + rm $(TMPDIR)/$(call BIN,foo) + unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single # - Debuginfo in `.dwo` files