8sa1-gcc/gcc/jit/Make-lang.in
Nicolás Bértolo c83027f32d jit: port libgccjit to Windows
2020-05-28  Nicolas Bértolo  <nicolasbertolo@gmail.com>

/ChangeLog:
	* configure.ac: Don't require --enable-host-shared when building
	for Mingw.
	* configure: Regenerate.

2020-05-28  Nicolas Bértolo  <nicolasbertolo@gmail.com>

gcc/ChangeLog:
	* Makefile.in: don't look for libiberty in the "pic" subdirectory
	when building for Mingw. Add dependency on xgcc with the proper
	extension.

2020-05-28  Nicolas Bértolo  <nicolasbertolo@gmail.com>

gcc/c/ChangeLog:
	* Make-lang.in: Remove extra slash.

2020-05-28  Nicolas Bértolo  <nicolasbertolo@gmail.com>

gcc/jit/ChangeLog:
	* Make-lang.in: Remove extra slash. Build libgccjit.dll and its
	import library in Windows.
	* config-lang.in: Update comment about --enable-host-shared.
	* jit-w32.h: New file.
	* jit-w32.c: New file.
	(print_last_error): New function that prints the error
	string corresponding to GetLastError().
	(get_TOKEN_USER_current_user): Helper function used for getting
	the SID belonging to the current user.
	(create_directory_for_current_user): Helper function to create
	a directory with permissions such that only the current user can
	access it.
	(win_mkdtemp): Create a temporary directory using Windows APIs.
	* jit-playback.c: Do not chmod files in Windows. Use LoadLibrary,
	FreeLibrary and GetProcAddress instead of libdl.
	* jit-result.h, jit-result.c: Introduce result::handle_t to
	abstract over the types used for dynamic library handles.
	* jit-tempdir.c: Do not use mkdtemp() in Windows, use
	win_mkdtemp().
2020-05-28 14:43:58 -04:00

367 lines
11 KiB
Makefile
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Top level -*- makefile -*- fragment for libgccjit.so.
# Copyright (C) 2013-2020 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.
ifneq (,$(findstring mingw,$(target)))
LIBGCCJIT_FILENAME = libgccjit.dll
jit: $(LIBGCCJIT_FILENAME) \
$(FULL_DRIVER_NAME)
else
LIBGCCJIT_LINKER_NAME = libgccjit.so
LIBGCCJIT_VERSION_NUM = 0
LIBGCCJIT_MINOR_NUM = 0
LIBGCCJIT_RELEASE_NUM = 1
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
# 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.dll.a
LIBGCCJIT_EXTRA_OPTS = -Wl,--out-implib,$(LIBGCCJIT_FILENAME).a
else
LIBGCCJIT_EXTRA_OPTS = $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \
$(LIBGCCJIT_SONAME_OPTION)
endif
# 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)
+$(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) \
$(LIBGCCJIT_EXTRA_OPTS)
# Create symlinks when not building for Windows
ifeq (,$(findstring mingw,$(target)))
$(LIBGCCJIT_SONAME_SYMLINK): $(LIBGCCJIT_FILENAME)
ln -sf $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SONAME_SYMLINK)
$(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:
mkdir -p $(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:
mkdir -p $(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:
$(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_FILENAME).a \
$(DESTDIR)$(libdir)/$(LIBGCCJIT_FILENAME).a
# Install DLL file
$(INSTALL_PROGRAM) $(LIBGCCJIT_FILENAME) \
$(DESTDIR)$(bindir)/$(LIBGCCJIT_FILENAME)
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
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