aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit/Make-lang.in
blob: a65f13853ae9bcda85b74cafdb4edc3535a9b9ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# Top level -*- makefile -*- fragment for libgccjit.so.
#   Copyright (C) 2013-2023 Free Software Foundation, Inc.

#This file is part of GCC.

#GCC is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 3, or (at your option)
#any later version.

#GCC is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3.  If not see
# <http://www.gnu.org/licenses/>.

# This file provides the language dependent support in the main Makefile.
# Each language makefile fragment must provide the following targets:
#
# foo.all.cross, foo.start.encap, foo.rest.encap,
# foo.install-common, foo.install-man, foo.install-info, foo.install-pdf,
# foo.install-html, foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall,
# foo.mostlyclean, foo.clean, foo.distclean,
# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
#
# where `foo' is the name of the language.
#
# It should also provide rules for:
#
# - making any compiler driver (eg: g++)
# - the compiler proper (eg: cc1plus)
# - define the names for selecting the language in LANGUAGES.

#
# Define the names for selecting jit in LANGUAGES.
# Note that it would be nice to move the dependency on g++
# into the jit rule, but that needs a little bit of work
# to do the right thing within all.cross.

LIBGCCJIT_VERSION_NUM = 0
LIBGCCJIT_MINOR_NUM = 0
LIBGCCJIT_RELEASE_NUM = 1

ifneq (,$(findstring mingw,$(target)))
LIBGCCJIT_FILENAME = libgccjit-$(LIBGCCJIT_VERSION_NUM).dll
LIBGCCJIT_IMPORT_LIB = libgccjit.dll.a

jit: $(LIBGCCJIT_FILENAME) \
	$(FULL_DRIVER_NAME)

else

ifneq (,$(findstring darwin,$(host)))

LIBGCCJIT_AGE = 1
LIBGCCJIT_BASENAME = libgccjit

LIBGCCJIT_SONAME = \
  ${libdir}/$(LIBGCCJIT_BASENAME).$(LIBGCCJIT_VERSION_NUM).dylib
LIBGCCJIT_FILENAME = $(LIBGCCJIT_BASENAME).$(LIBGCCJIT_VERSION_NUM).dylib
LIBGCCJIT_LINKER_NAME = $(LIBGCCJIT_BASENAME).dylib

# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and
# LD_SONAME_OPTION depending if configure found them, using $(if)
# We have to define a COMMA here, otherwise the commas in the "true"
# result are treated as separators by the $(if).
COMMA := ,
LIBGCCJIT_VERSION_SCRIPT_OPTION = \
	$(if $(LD_VERSION_SCRIPT_OPTION),\
	  -Wl$(COMMA)$(LD_VERSION_SCRIPT_OPTION)$(COMMA)$(srcdir)/jit/libgccjit.map)

LIBGCCJIT_SONAME_OPTION = \
	$(if $(LD_SONAME_OPTION), \
	     -Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))

LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_FILENAME)
LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)

jit: $(LIBGCCJIT_FILENAME) \
	$(LIBGCCJIT_SYMLINK) \
	$(LIBGCCJIT_LINKER_NAME_SYMLINK) \
	$(FULL_DRIVER_NAME)

else

LIBGCCJIT_LINKER_NAME = libgccjit.so
LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME).$(LIBGCCJIT_VERSION_NUM)
LIBGCCJIT_FILENAME = \
  $(LIBGCCJIT_SONAME).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_RELEASE_NUM)

LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_SONAME)

# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and
# LD_SONAME_OPTION depending if configure found them, using $(if)
# We have to define a COMMA here, otherwise the commas in the "true"
# result are treated as separators by the $(if).
COMMA := ,
LIBGCCJIT_VERSION_SCRIPT_OPTION = \
	$(if $(LD_VERSION_SCRIPT_OPTION),\
	  -Wl$(COMMA)$(LD_VERSION_SCRIPT_OPTION)$(COMMA)$(srcdir)/jit/libgccjit.map)

LIBGCCJIT_SONAME_OPTION = \
	$(if $(LD_SONAME_OPTION), \
	     -Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))

jit: $(LIBGCCJIT_FILENAME) \
	$(LIBGCCJIT_SYMLINK) \
	$(LIBGCCJIT_LINKER_NAME_SYMLINK) \
	$(FULL_DRIVER_NAME)

endif
endif

jit.serial = $(LIBGCCJIT_FILENAME)

# Tell GNU make to ignore these if they exist.
.PHONY: jit

jit_OBJS = attribs.o \
	jit/dummy-frontend.o \
	jit/libgccjit.o \
	jit/jit-logging.o \
	jit/jit-recording.o \
	jit/jit-playback.o \
	jit/jit-result.o \
	jit/jit-tempdir.o \
	jit/jit-builtins.o \
	jit/jit-spec.o \
	gcc.o

ifneq (,$(findstring mingw,$(target)))
jit_OBJS += jit/jit-w32.o
endif

# Use strict warnings for this front end.
jit-warn = $(STRICT_WARN)

ifneq (,$(findstring mingw,$(target)))
# Create import library
LIBGCCJIT_EXTRA_OPTS = -Wl,--out-implib,$(LIBGCCJIT_IMPORT_LIB)
else

ifneq (,$(findstring darwin,$(host)))
# TODO : Construct a Darwin-style symbol export file.
LIBGCCJIT_EXTRA_OPTS = -Wl,-compatibility_version,$(LIBGCCJIT_VERSION_NUM) \
	-Wl,-current_version,$(LIBGCCJIT_VERSION_NUM).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_AGE) \
	$(LIBGCCJIT_VERSION_SCRIPT_OPTION) \
	$(LIBGCCJIT_SONAME_OPTION)
else

LIBGCCJIT_EXTRA_OPTS = $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \
	$(LIBGCCJIT_SONAME_OPTION)
endif
endif

# Only link objects from $(EXTRA_GCC_OBJS) that's not already
# included in libbackend.a ($(EXTRA_OBJS)).
EXTRA_GCC_OBJS_EXCLUSIVE = $(foreach _obj1, $(EXTRA_GCC_OBJS), \
	$(if $(filter $(_obj1), $(EXTRA_OBJS)),, $(_obj1)))

# We avoid using $(BACKEND) from Makefile.in in order to avoid pulling
# in main.o
$(LIBGCCJIT_FILENAME): $(jit_OBJS) \
	libbackend.a libcommon-target.a libcommon.a \
	$(CPPLIB) $(LIBDECNUMBER) \
	$(LIBDEPS) $(srcdir)/jit/libgccjit.map \
	$(EXTRA_GCC_OBJS_EXCLUSIVE) $(jit.prev)
	@$(call LINK_PROGRESS,$(INDEX.jit),start)
	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ -shared \
	     $(jit_OBJS) libbackend.a libcommon-target.a libcommon.a \
	     $(CPPLIB) $(LIBDECNUMBER) $(EXTRA_GCC_LIBS) $(LIBS) $(BACKENDLIBS) \
	     $(EXTRA_GCC_OBJS_EXCLUSIVE) \
	     $(LIBGCCJIT_EXTRA_OPTS)
	@$(call LINK_PROGRESS,$(INDEX.jit),end)

# Create symlinks when not building for Windows
ifeq (,$(findstring mingw,$(target)))

ifeq (,$(findstring darwin,$(host)))
# but only one level for Darwin, version info is embedded.
$(LIBGCCJIT_SONAME_SYMLINK): $(LIBGCCJIT_FILENAME)
	ln -sf $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SONAME_SYMLINK)
endif

$(LIBGCCJIT_LINKER_NAME_SYMLINK): $(LIBGCCJIT_SONAME_SYMLINK)
	ln -sf $(LIBGCCJIT_SONAME_SYMLINK) $(LIBGCCJIT_LINKER_NAME_SYMLINK)
endif

#
# Build hooks:

jit.all.cross:
jit.start.encap:
jit.rest.encap:

# Documentation build hooks.
#
# The documentation can be built using the texinfo toolchain, or
# the sphinx toolchain
#
# The jit documentation is authored using Sphinx, which has numerous
# advantages over Texinfo, including:
#
#   * much faster
#
#   * use of CSS and JS to provide less of a 1990s feel in the generated
#     HTML.
#
#   * sane, stable HTML page and anchor names
#
#   * sane HTML navigation: ability to move forward and back in the HTML
#     at every node to read the HTML like a book
#
#   * syntax-coloring of examples
#
#   * the ability to "include" fragments of code inline.  This is used
#     heavily by the jit docs, so that the example code is shared by both
#     the test suite and the documentation to ensure that the examples
#     appearing in the docs actually compile and work
#
# Sphinx is not a "blessed" dependency, and so a prebuilt libgccjit.texinfo
# file built by Sphinx is checked into the source tree to avoid requiring
# everyone to have Sphinx installed.
#
# This prebuilt libgccjit.texinfo has the "include" fragments "baked in",
# and so contains the content from the sphinx toolchain, but lacks the
# syntax-coloring, and the generated HTML is (IMHO) greatly inferior to
# that generated by Sphinx.

# These targets redirect HTML creation and installation to either
# jit.sphinx.(install-)html or jit.texinfo.(install-)html.
jit.html: jit.$(doc_build_sys).html
jit.install-html: jit.$(doc_build_sys).install-html

# For now, use texinfo for pdf, since the sphinx latex toolchain currently
# fails for me deep inside pdflatex (see notes below)
jit.pdf: jit.texinfo.pdf
jit.install-pdf: jit.texinfo.install-pdf

# Hooks for building docs using texinfo
JIT_TEXI_FILES = $(srcdir)/jit/docs/_build/texinfo/libgccjit.texi

jit.info: doc/libgccjit.info
doc/libgccjit.info: $(JIT_TEXI_FILES)
	if test "x$(BUILD_INFO)" = xinfo; then \
	  rm -f doc/libgccjit.info*; \
	  $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
		-I $(gcc_docdir)/include -o $@ $<; \
	else true; fi

jit.install-info: $(DESTDIR)$(infodir)/libgccjit.info

jit.dvi: doc/libgccjit.dvi
doc/libgccjit.dvi: $(JIT_TEXI_FILES)
	$(TEXI2DVI) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<

jit.texinfo.html: $(build_htmldir)/jit/index.html

$(build_htmldir)/jit/index.html: $(srcdir)/jit/docs/_build/texinfo/libgccjit.texi
	$(mkinstalldirs) $(@D)
	rm -f $(@D)/*
	$(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/jit -o $(@D) $<

jit.texinfo.install-html: jit.texinfo.html
	@$(NORMAL_INSTALL)
	test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)"
	@for p in $(build_htmldir)/jit; do \
	  if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; fi; \
	  f=$(html__strip_dir) \
	  if test -d "$$d$$p"; then \
	    echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \
	    $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
	    echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
	    $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \
	  else \
	    echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
	    $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
	  fi; \
	done

jit.texinfo.pdf: doc/libgccjit.pdf

doc/libgccjit.pdf: $(JIT_TEXI_FILES)
	$(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<

jit.texinfo.install-pdf: doc/libgccjit.pdf
	@$(NORMAL_INSTALL)
	test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
	@for p in doc/libgccjit.pdf; do \
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
	  f=$(pdf__strip_dir) \
	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
	  $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
	done

# Hooks for building docs using the Sphinx toolchain:

SPHINX_BUILD_DIR=jit/sphinx-build

jit.sphinx.html:
	$(mkinstalldirs) $(SPHINX_BUILD_DIR)
	(cd $(srcdir)/jit/docs && \
	  make html BUILDDIR=$(PWD)/$(SPHINX_BUILD_DIR) )

jit_htmldir=$(htmldir)/jit

jit.sphinx.install-html: jit.sphinx.html
	@$(NORMAL_INSTALL)
	test -z "$(jit_htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(jit_htmldir)"
	@for f in $(shell cd $(SPHINX_BUILD_DIR)/html && find) ; do \
	  if test -f $(SPHINX_BUILD_DIR)/html/"$$f"; then \
	     $(INSTALL_DATA) $(SPHINX_BUILD_DIR)/html/"$$f" $(DESTDIR)$(jit_htmldir)/"$$f"; \
	  else \
	     mkdir $(DESTDIR)$(jit_htmldir)/"$$f"; \
	  fi; \
	done

# (This one is currently failing deep inside pdflatex for me;
# see https://bugzilla.redhat.com/show_bug.cgi?id=1148845 )
jit.sphinx.pdf: $(SPHINX_BUILD_DIR)/latex/libgccjit.pdf
$(SPHINX_BUILD_DIR)/latex/libgccjit.pdf:
	$(mkinstalldirs) $(SPHINX_BUILD_DIR)
	(cd $(srcdir)/jit/docs && \
	  make latexpdf BUILDDIR=$(PWD)/$(SPHINX_BUILD_DIR) )

jit.sphinx.install-pdf: $(SPHINX_BUILD_DIR)/latex/libgccjit.pdf
	@$(NORMAL_INSTALL)
	test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
	@for p in $(SPHINX_BUILD_DIR)/latex/libgccjit.pdf; do \
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
	  f=$(pdf__strip_dir) \
	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
	  $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
	done

jit.srcinfo:
jit.srcextra:

jit.tags:

jit.man:

jit.srcman:

lang_checks += check-jit
lang_checks_parallelized += check-jit
# This number is somewhat arbitrary.  Two tests are much slower
# than all the others (test-combination.c and test-threads.c) so
# we want them to be placed in different "buckets".
check_jit_parallelize = 10

# No jit-specific selftests
selftest-jit:

#
# Install hooks:
jit.install-headers: installdirs
	$(INSTALL_DATA) $(srcdir)/jit/libgccjit.h \
	  $(DESTDIR)$(includedir)/libgccjit.h
	$(INSTALL_DATA) $(srcdir)/jit/libgccjit++.h \
	  $(DESTDIR)$(includedir)/libgccjit++.h

ifneq (,$(findstring mingw,$(target)))
jit.install-common: installdirs jit.install-headers
# Install import library
	$(INSTALL_PROGRAM) $(LIBGCCJIT_IMPORT_LIB) \
	  $(DESTDIR)$(libdir)/$(LIBGCCJIT_IMPORT_LIB)
# Install DLL file
	$(INSTALL_PROGRAM) $(LIBGCCJIT_FILENAME) \
	  $(DESTDIR)$(bindir)/$(LIBGCCJIT_FILENAME)

else
ifneq (,$(findstring darwin,$(host)))
# but only one level for Darwin

jit.install-common: installdirs jit.install-headers
	$(INSTALL_PROGRAM) $(LIBGCCJIT_FILENAME) \
	  $(DESTDIR)$(libdir)/$(LIBGCCJIT_FILENAME)
	ln -sf \
	  $(LIBGCCJIT_SONAME_SYMLINK)\
	  $(DESTDIR)$(libdir)/$(LIBGCCJIT_LINKER_NAME_SYMLINK)

else
jit.install-common: installdirs jit.install-headers
	$(INSTALL_PROGRAM) $(LIBGCCJIT_FILENAME) \
	  $(DESTDIR)$(libdir)/$(LIBGCCJIT_FILENAME)
	ln -sf \
	  $(LIBGCCJIT_FILENAME) \
	  $(DESTDIR)$(libdir)/$(LIBGCCJIT_SONAME_SYMLINK)
	ln -sf \
	  $(LIBGCCJIT_SONAME_SYMLINK)\
	  $(DESTDIR)$(libdir)/$(LIBGCCJIT_LINKER_NAME_SYMLINK)
endif
endif

jit.install-man:

jit.install-plugin:

jit.uninstall:

#
# Clean hooks:
# A lot of the ancillary files are deleted by the main makefile.
# We just have to delete files specific to us.

jit.mostlyclean:
	-rm -f $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SYMLINK)
	-rm -f $(LIBGCCJIT_LINKER_NAME_SYMLINK) $(FULL_DRIVER_NAME)
	-rm -f $(LIBGCCJIT_SONAME)
	-rm -f $(jit_OBJS)

jit.clean:

jit.distclean:

jit.maintainer-clean:

#
# Stage hooks:
# The main makefile has already created stage?/jit.

jit.stage1: stage1-start
	-mv jit/*$(objext) stage1/jit
jit.stage2: stage2-start
	-mv jit/*$(objext) stage2/jit
jit.stage3: stage3-start
	-mv jit/*$(objext) stage3/jit
jit.stage4: stage4-start
	-mv jit/*$(objext) stage4/jit
jit.stageprofile: stageprofile-start
	-mv jit/*$(objext) stageprofile/jit
jit.stagefeedback: stagefeedback-start
	-mv jit/*$(objext) stagefeedback/jit