Mercurial > hg > truffle
comparison make/linux/makefiles/adlc.make @ 475:284d0af00d53
6771309: debugging AD files is difficult without #line directives in generated code
Summary: more and better #line and #define directives in the generated code; ADLC itself accepts #line directives
Reviewed-by: never, kvn
author | jrose |
---|---|
date | Tue, 09 Dec 2008 12:41:26 -0800 |
parents | d1605aabd0a1 |
children | 0fbdb4381b99 dbbe28fc66b5 |
comparison
equal
deleted
inserted
replaced
474:7a018855d2f0 | 475:284d0af00d53 |
---|---|
52 | 52 |
53 # set INCLUDES for C preprocessor | 53 # set INCLUDES for C preprocessor |
54 Src_Dirs_I = ${Src_Dirs} $(GENERATED) | 54 Src_Dirs_I = ${Src_Dirs} $(GENERATED) |
55 INCLUDES += $(Src_Dirs_I:%=-I%) | 55 INCLUDES += $(Src_Dirs_I:%=-I%) |
56 | 56 |
57 # set flags for adlc compilation | |
58 CPPFLAGS = $(SYSDEFS) $(INCLUDES) | |
59 | |
57 # Force assertions on. | 60 # Force assertions on. |
58 SYSDEFS += -DASSERT | 61 CPPFLAGS += -DASSERT |
59 CPPFLAGS = $(SYSDEFS) $(INCLUDES) | |
60 | 62 |
61 # CFLAGS_WARN holds compiler options to suppress/enable warnings. | 63 # CFLAGS_WARN holds compiler options to suppress/enable warnings. |
62 # Suppress warnings (for now) | 64 # Suppress warnings (for now) |
63 CFLAGS_WARN = -w | 65 CFLAGS_WARN = -w |
64 CFLAGS += $(CFLAGS_WARN) | 66 CFLAGS += $(CFLAGS_WARN) |
123 | 125 |
124 # Get a unique temporary directory name, so multiple makes can run in parallel. | 126 # Get a unique temporary directory name, so multiple makes can run in parallel. |
125 # Note that product files are updated via "mv", which is atomic. | 127 # Note that product files are updated via "mv", which is atomic. |
126 TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$) | 128 TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$) |
127 | 129 |
128 ADLCFLAGS = -q -T | 130 # Pass -D flags into ADLC. |
131 ADLCFLAGS += $(SYSDEFS) | |
132 | |
133 # Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO. | |
134 ADLCFLAGS += -q -T | |
135 | |
136 # Normally, debugging is done directly on the ad_<arch>*.cpp files. | |
137 # But -g will put #line directives in those files pointing back to <arch>.ad. | |
138 #ADLCFLAGS += -g | |
129 | 139 |
130 ifdef LP64 | 140 ifdef LP64 |
131 ADLCFLAGS += -D_LP64 | 141 ADLCFLAGS += -D_LP64 |
132 else | 142 else |
133 ADLCFLAGS += -U_LP64 | 143 ADLCFLAGS += -U_LP64 |
138 # used to selectively update generated adlc files. This should | 148 # used to selectively update generated adlc files. This should |
139 # provide a nice compilation speed improvement. | 149 # provide a nice compilation speed improvement. |
140 # | 150 # |
141 ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS) | 151 ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS) |
142 ADLC_UPDATER = adlc_updater | 152 ADLC_UPDATER = adlc_updater |
153 $(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER) | |
154 $(QUIETLY) cp $< $@; chmod +x $@ | |
143 | 155 |
144 # This action refreshes all generated adlc files simultaneously. | 156 # This action refreshes all generated adlc files simultaneously. |
145 # The way it works is this: | 157 # The way it works is this: |
146 # 1) create a scratch directory to work in. | 158 # 1) create a scratch directory to work in. |
147 # 2) if the current working directory does not have $(ADLC_UPDATER), copy it. | 159 # 2) if the current working directory does not have $(ADLC_UPDATER), copy it. |
148 # 3) run the compiled adlc executable. This will create new adlc files in the scratch directory. | 160 # 3) run the compiled adlc executable. This will create new adlc files in the scratch directory. |
149 # 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files. | 161 # 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files. |
150 # 5) If we actually updated any files, echo a notice. | 162 # 5) If we actually updated any files, echo a notice. |
151 # | 163 # |
152 refresh_adfiles: $(EXEC) $(SOURCE.AD) | 164 refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER) |
153 @rm -rf $(TEMPDIR); mkdir $(TEMPDIR) | 165 @rm -rf $(TEMPDIR); mkdir $(TEMPDIR) |
154 $(QUIETLY) [ -f $(ADLC_UPDATER) ] || ( cp $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER) . ; chmod +x $(ADLC_UPDATER) ) | |
155 $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \ | 166 $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \ |
156 -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \ | 167 -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \ |
157 || { rm -rf $(TEMPDIR); exit 1; } | 168 || { rm -rf $(TEMPDIR); exit 1; } |
158 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) | 169 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) |
159 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) | 170 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) |
172 | 183 |
173 | 184 |
174 # ######################################################################### | 185 # ######################################################################### |
175 | 186 |
176 $(SOURCE.AD): $(SOURCES.AD) | 187 $(SOURCE.AD): $(SOURCES.AD) |
177 $(QUIETLY) cat $(SOURCES.AD) > $(SOURCE.AD) | 188 $(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD) |
189 | |
190 #PROCESS_AD_FILES = cat | |
191 # Pass through #line directives, in case user enables -g option above: | |
192 PROCESS_AD_FILES = awk '{ \ | |
193 if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \ | |
194 if (need_lineno && $$0 !~ /\/\//) \ | |
195 { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \ | |
196 print }' | |
178 | 197 |
179 $(OUTDIR)/%.o: %.cpp | 198 $(OUTDIR)/%.o: %.cpp |
180 @echo Compiling $< | 199 @echo Compiling $< |
181 $(QUIETLY) $(REMOVE_TARGET) | 200 $(QUIETLY) $(REMOVE_TARGET) |
182 $(QUIETLY) $(COMPILE.CC) -o $@ $< $(COMPILE_DONE) | 201 $(QUIETLY) $(COMPILE.CC) -o $@ $< $(COMPILE_DONE) |