1
1
# ignore-cross-compile
2
2
include ../tools.mk
3
3
4
+ export HERE := $(shell pwd)
5
+ export REMAPPED_OUT := /my-remapped-out
6
+ export REMAPPED_CWD := /my-remapped-cwd
7
+
4
8
all : off packed unpacked
5
9
6
10
ifeq ($(UNAME ) ,Darwin)
@@ -11,23 +15,200 @@ off:
11
15
[ ! -d $( TMPDIR) /foo.dSYM ]
12
16
13
17
# Packed by default, but only if debuginfo is requested
14
- packed :
15
- rm -rf $(TMPDIR ) /* .dSYM
16
- $(RUSTC ) foo.rs
17
- [ ! -d $( TMPDIR) /foo.dSYM ]
18
- rm -rf $(TMPDIR ) /* .dSYM
19
- $(RUSTC ) foo.rs -g
18
+ packed : packed-remapped-object-scope packed-remapped-macro-scope packed-remapped-split-debuginfo-scope
19
+
20
+ # - Debuginfo in binary file
21
+ # - `.o` deleted
22
+ # - `.dSYM` present
23
+ packed-remapped-object-scope :
24
+ $(RUSTC ) $(UNSTABLEOPTS ) -C split-debuginfo=packed -C debuginfo=2 \
25
+ --remap-path-prefix $(TMPDIR ) =$(REMAPPED_OUT ) \
26
+ --remap-path-prefix $(HERE ) =$(REMAPPED_CWD ) \
27
+ -Z remap-path-scope=object foo.rs -g
28
+ ls $(TMPDIR ) /* .o && exit 1 || exit 0
20
29
[ -d $( TMPDIR) /foo.dSYM ]
21
- rm -rf $(TMPDIR ) /* .dSYM
22
- $(RUSTC ) foo.rs -g -C split-debuginfo=packed
30
+
31
+ # binary contains remapped paths
32
+ # FIXME: As of 2023-12, `OSO` cannot be trimmed. See rust-lang/rust#116948
33
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo) || exit 1
34
+ # FIXME: `SO` in the root debuginfo compile unit didn't get trimed. See rust-lang/rust#116948
35
+ (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1
36
+
37
+ # binary contains no original paths
38
+ # FIXME: As of 2023-12, `OSO` cannot be trimmed. See rust-lang/rust#116948
39
+ grep --text $(TMPDIR) $(TMPDIR)/foo || exit 1
40
+ # FIXME: `SO` in the root debuginfo compile unit didn't get trimed. See rust-lang/rust#116948
41
+ grep --text $(HERE) $(TMPDIR)/foo || exit 1
42
+
43
+ # dSYM bundle contains no remapped paths
44
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.dSYM/Contents/Resources/DWARF/foo) || exit 1
45
+ (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.dSYM/Contents/Resources/DWARF/foo) || exit 1
46
+
47
+ # dSYM bundle contains original paths
48
+ grep --text $(HERE) $(TMPDIR)/foo.dSYM/Contents/Resources/DWARF/foo || exit 1
49
+
50
+ rm -rf $(TMPDIR)/foo.dSYM
51
+ rm $(TMPDIR)/$(call BIN,foo)
52
+
53
+ # - Debuginfo in binary file
54
+ # - `.o` deleted
55
+ # - `.dSYM` present
56
+ packed-remapped-macro-scope :
57
+ $(RUSTC ) $(UNSTABLEOPTS ) -C split-debuginfo=packed -C debuginfo=2 \
58
+ --remap-path-prefix $(TMPDIR ) =$(REMAPPED_OUT ) \
59
+ --remap-path-prefix $(HERE ) =$(REMAPPED_CWD ) \
60
+ -Z remap-path-scope=macro foo.rs -g
61
+ ls $(TMPDIR ) /* .o && exit 1 || exit 0
23
62
[ -d $( TMPDIR) /foo.dSYM ]
24
- rm -rf $(TMPDIR ) /* .dSYM
63
+
64
+ # binary contains no remapped paths
65
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo) || exit 1
66
+ (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1
67
+
68
+ # binary contains original paths
69
+ grep --text $(TMPDIR) $(TMPDIR)/foo || exit 1
70
+ grep --text $(HERE) $(TMPDIR)/foo || exit 1
71
+
72
+ # dSYM bundle contains no remapped paths
73
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.dSYM/Contents/Resources/DWARF/foo) || exit 1
74
+ (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.dSYM/Contents/Resources/DWARF/foo) || exit 1
75
+
76
+ # dSYM bundle contains original paths
77
+ grep --text $(HERE) $(TMPDIR)/foo.dSYM/Contents/Resources/DWARF/foo || exit 1
78
+
79
+ rm -rf $(TMPDIR)/foo.dSYM
80
+ rm $(TMPDIR)/$(call BIN,foo)
81
+
82
+ # - Debuginfo in binary file
83
+ # - `.o` deleted
84
+ # - `.dSYM` present
85
+ packed-remapped-split-debuginfo-scope :
86
+ $(RUSTC ) $(UNSTABLEOPTS ) -C split-debuginfo=packed -C debuginfo=2 \
87
+ --remap-path-prefix $(TMPDIR ) =$(REMAPPED_OUT ) \
88
+ --remap-path-prefix $(HERE ) =$(REMAPPED_CWD ) \
89
+ -Z remap-path-scope=split-debuginfo,split-debuginfo-path foo.rs -g
90
+ ls $(TMPDIR ) /* .o && exit 1 || exit 0
91
+ [ -d $( TMPDIR) /foo.dSYM ]
92
+
93
+ # binary contains no remapped paths
94
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo) || exit 1
95
+ # FIXME: binary contains `N_SO` (SO) in debug symbol, which got remapped.
96
+ nm -pa $(TMPDIR)/foo | grep " SO " | grep $(REMAPPED_CWD) || exit 1
97
+ nm -pa $(TMPDIR)/foo | grep --invert-match " SO " | (! grep $(REMAPPED_CWD)) || exit 1
98
+
99
+ # binary contains original paths
100
+ # FIXME: As of 2023-12, `OSO` cannot be trimmed. See rust-lang/rust#116948
101
+ grep --text $(TMPDIR) $(TMPDIR)/foo || exit 1
102
+ # FIXME: binary contains `N_SO` (SO) in debug symbol, which got remapped.
103
+ (! grep --text $(HERE) $(TMPDIR)/foo) || exit 1
104
+
105
+ # # dSYM bundle contains remapped paths
106
+ grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.dSYM/Contents/Resources/DWARF/foo || exit 1
107
+
108
+ # # dSYM bundle contains no original paths
109
+ (! grep --text $(TMPDIR) $(TMPDIR)/foo.dSYM/Contents/Resources/DWARF/foo) || exit 1
110
+ (! grep --text $(HERE) $(TMPDIR)/foo.dSYM/Contents/Resources/DWARF/foo) || exit 1
111
+
112
+ rm -rf $(TMPDIR)/foo.dSYM
113
+ rm $(TMPDIR)/$(call BIN,foo)
25
114
26
115
# Object files are preserved with unpacked and `dsymutil` isn't run
27
- unpacked :
28
- $(RUSTC ) foo.rs -g -C split-debuginfo=unpacked
116
+ unpacked : unpacked-remapped-object-scope unpacked-remapped-macro-scope unpacked-remapped-split-debuginfo-scope
117
+
118
+ # - Debuginfo in object files
119
+ # - `.o` present
120
+ # - `.dSYM` never created
121
+ unpacked-remapped-object-scope :
122
+ $(RUSTC ) $(UNSTABLEOPTS ) -C split-debuginfo=unpacked -C debuginfo=2 \
123
+ --remap-path-prefix $(TMPDIR ) =$(REMAPPED_OUT ) \
124
+ --remap-path-prefix $(HERE ) =$(REMAPPED_CWD ) \
125
+ -Z remap-path-scope=object foo.rs -g
126
+ ls $(TMPDIR ) /* .o
127
+ [ ! -d $( TMPDIR) /foo.dSYM ]
128
+
129
+ # binary contains remapped paths
130
+ # FIXME: As of 2023-12, `OSO` cannot be trimmed. See rust-lang/rust#116948
131
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo) || exit 1
132
+ # FIXME: `SO` in the root debuginfo compile unit didn't get trimed. See rust-lang/rust#116948
133
+ (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1
134
+
135
+ # binary contains no original paths
136
+ # FIXME: As of 2023-12, `OSO` cannot be trimmed. See rust-lang/rust#116948
137
+ grep --text $(TMPDIR) $(TMPDIR)/foo || exit 1
138
+ # FIXME: `SO` in the root debuginfo compile unit didn't get trimed. See rust-lang/rust#116948
139
+ grep --text $(HERE) $(TMPDIR)/foo || exit 1
140
+
141
+ # object file contains no remapped paths
142
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.*.o) || exit 1
143
+ (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.*.o) || exit 1
144
+
145
+ # object file contains original paths
146
+ grep --text $(HERE) $(TMPDIR)/foo.*.o || exit 1
147
+
148
+ rm $(TMPDIR)/*.o
149
+ rm $(TMPDIR)/$(call BIN,foo)
150
+
151
+ # - Debuginfo in object files
152
+ # - `.o` present,
153
+ # - `.dSYM` never created
154
+ unpacked-remapped-macro-scope :
155
+ $(RUSTC ) $(UNSTABLEOPTS ) -C split-debuginfo=unpacked -C debuginfo=2 \
156
+ --remap-path-prefix $(TMPDIR ) =$(REMAPPED_OUT ) \
157
+ --remap-path-prefix $(HERE ) =$(REMAPPED_CWD ) \
158
+ -Z remap-path-scope=macro foo.rs -g
159
+ ls $(TMPDIR ) /* .o
160
+ [ ! -d $( TMPDIR) /foo.dSYM ]
161
+
162
+ # binary contains no remapped paths
163
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo) || exit 1
164
+ (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo) || exit 1
165
+
166
+ # binary contains original paths
167
+ grep --text $(TMPDIR) $(TMPDIR)/foo || exit 1
168
+ grep --text $(HERE) $(TMPDIR)/foo || exit 1
169
+
170
+ # object file contains no remapped paths
171
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo.*.o) || exit 1
172
+ (! grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.*.o) || exit 1
173
+
174
+ # object file contains original paths
175
+ grep --text $(HERE) $(TMPDIR)/foo.*.o || exit 1
176
+
177
+ rm $(TMPDIR)/*.o
178
+ rm $(TMPDIR)/$(call BIN,foo)
179
+
180
+ # - Debuginfo in object files
181
+ # - `.o` present
182
+ # - `.dSYM` never created
183
+ unpacked-remapped-split-debuginfo-scope :
184
+ $(RUSTC ) $(UNSTABLEOPTS ) -C split-debuginfo=unpacked -C debuginfo=2 \
185
+ --remap-path-prefix $(TMPDIR ) =$(REMAPPED_OUT ) \
186
+ --remap-path-prefix $(HERE ) =$(REMAPPED_CWD ) \
187
+ -Z remap-path-scope=split-debuginfo,split-debuginfo-path foo.rs -g
29
188
ls $(TMPDIR ) /* .o
30
189
[ ! -d $( TMPDIR) /foo.dSYM ]
190
+
191
+ # binary contains no remapped paths
192
+ (! grep --text $(REMAPPED_OUT) $(TMPDIR)/foo) || exit 1
193
+ # FIXME: binary contains `N_SO` (SO) in debug symbol, which got remapped.
194
+ nm -pa $(TMPDIR)/foo | grep " SO " | grep $(REMAPPED_CWD) || exit 1
195
+ nm -pa $(TMPDIR)/foo | grep --invert-match " SO " | (! grep $(REMAPPED_CWD)) || exit 1
196
+
197
+ # binary contains original paths
198
+ grep --text $(TMPDIR) $(TMPDIR)/foo || exit 1
199
+ # FIXME: binary contains `N_SO` (SO) in debug symbol, which got remapped.
200
+ (! grep --text $(HERE) $(TMPDIR)/foo) || exit 1
201
+
202
+ # object file contains remapped paths
203
+ grep --text $(REMAPPED_CWD) $(TMPDIR)/foo.*.o || exit 1
204
+
205
+ # object file contains no original paths
206
+ (! grep --text $(TMPDIR) $(TMPDIR)/foo.*.o) || exit 1
207
+ (! grep --text $(HERE) $(TMPDIR)/foo.*.o) || exit 1
208
+
209
+ rm $(TMPDIR)/*.o
210
+ rm $(TMPDIR)/$(call BIN,foo)
211
+
31
212
else
32
213
ifdef IS_WINDOWS
33
214
# Windows only supports packed debuginfo - nothing to test.
0 commit comments