Committed to branch dmalcolm/jit: gcc/ChangeLog.jit: * Makefile.in (pkgconfigdir): New. (installdirs): Add creation of $(DESTDIR)$(pkgconfigdir). * configure.ac (gcc_version): Expose this value for use via AC_SUBST, since we need it within the new file libgccjit.pc.in. * configure: Regenerate.
gcc/jit/ChangeLog.jit: * Make-lang.in (jit.install-common): Install libgccjit.pc to "$(DESTDIR)/$(libdir)/pkgconfig". * config-lang.in (outputs): Define this, adding jit/libgccjit.pc so that it makes it into AC_CONFIG_FILES and is thus generated from jit/libgccjit.pc.in at configure time. * docs/intro/install.rst ("Hello world"): Add discussion about the use of pkg-config when building against an install in a non-standard location. * docs/_build/texinfo/libgccjit.texi: Regenerate. * libgccjit.pc.in: New. --- gcc/ChangeLog.jit | 8 +++++++ gcc/Makefile.in | 3 +++ gcc/configure | 6 +++-- gcc/configure.ac | 1 + gcc/jit/ChangeLog.jit | 13 +++++++++++ gcc/jit/Make-lang.in | 2 ++ gcc/jit/config-lang.in | 4 ++++ gcc/jit/docs/_build/texinfo/libgccjit.texi | 35 +++++++++++++++++++++++++----- gcc/jit/docs/intro/install.rst | 33 +++++++++++++++++++++++----- gcc/jit/libgccjit.pc.in | 11 ++++++++++ 10 files changed, 102 insertions(+), 14 deletions(-) create mode 100644 gcc/jit/libgccjit.pc.in diff --git a/gcc/ChangeLog.jit b/gcc/ChangeLog.jit index d29232d..8c8d5ab 100644 --- a/gcc/ChangeLog.jit +++ b/gcc/ChangeLog.jit @@ -1,3 +1,11 @@ +2014-09-18 David Malcolm <dmalc...@redhat.com> + + * Makefile.in (pkgconfigdir): New. + (installdirs): Add creation of $(DESTDIR)$(pkgconfigdir). + * configure.ac (gcc_version): Expose this value for use via + AC_SUBST, since we need it within the new file libgccjit.pc.in. + * configure: Regenerate. + 2014-09-10 David Malcolm <dmalc...@redhat.com> * cgraph.c (cgraph_c_finalize): Update to reflect the movement of diff --git a/gcc/Makefile.in b/gcc/Makefile.in index e86382f..f56fa96 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -585,6 +585,8 @@ bindir = @bindir@ libdir = @libdir@ # Directory in which GCC puts its executables. libexecdir = @libexecdir@ +# Directory in which to install .pc files for pkgconfig +pkgconfigdir = @libdir@/pkgconfig # -------- # UNSORTED @@ -3144,6 +3146,7 @@ installdirs: $(mkinstalldirs) $(DESTDIR)$(infodir) $(mkinstalldirs) $(DESTDIR)$(man1dir) $(mkinstalldirs) $(DESTDIR)$(man7dir) + $(mkinstalldirs) $(DESTDIR)$(pkgconfigdir) PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ toplev.h $(DIAGNOSTIC_CORE_H) $(BASIC_BLOCK_H) $(HASH_TABLE_H) \ diff --git a/gcc/configure b/gcc/configure index fc78f42..c1922ac 100755 --- a/gcc/configure +++ b/gcc/configure @@ -824,6 +824,7 @@ build_os build_vendor build_cpu build +gcc_version target_alias host_alias build_alias @@ -3040,6 +3041,7 @@ ac_config_headers="$ac_config_headers auto-host.h:config.in" gcc_version=`cat $srcdir/BASE-VER` + # Determine the host, build, and target systems ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do @@ -18033,7 +18035,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18036 "configure" +#line 18038 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18139,7 +18141,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18142 "configure" +#line 18144 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index c7f0e6a..6164cc2 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -29,6 +29,7 @@ AC_CONFIG_SRCDIR(tree.c) AC_CONFIG_HEADER(auto-host.h:config.in) gcc_version=`cat $srcdir/BASE-VER` +AC_SUBST(gcc_version) # Determine the host, build, and target systems AC_CANONICAL_BUILD diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit index a9a556f..b557cc2 100644 --- a/gcc/jit/ChangeLog.jit +++ b/gcc/jit/ChangeLog.jit @@ -1,5 +1,18 @@ 2014-09-18 David Malcolm <dmalc...@redhat.com> + * Make-lang.in (jit.install-common): Install libgccjit.pc to + "$(DESTDIR)/$(libdir)/pkgconfig". + * config-lang.in (outputs): Define this, adding jit/libgccjit.pc + so that it makes it into AC_CONFIG_FILES and is thus generated from + jit/libgccjit.pc.in at configure time. + * docs/intro/install.rst ("Hello world"): Add discussion about the + use of pkg-config when building against an install in + a non-standard location. + * docs/_build/texinfo/libgccjit.texi: Regenerate. + * libgccjit.pc.in: New. + +2014-09-18 David Malcolm <dmalc...@redhat.com> + * docs/index.rst: Split index out into two new files... * docs/intro/index.rst: New file. * docs/topics/index.rst: New file. diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in index ce0cdc5..bf017f7 100644 --- a/gcc/jit/Make-lang.in +++ b/gcc/jit/Make-lang.in @@ -117,6 +117,8 @@ jit.install-common: installdirs $(DESTDIR)/$(includedir)/libgccjit.h $(INSTALL_PROGRAM) $(srcdir)/jit/libgccjit++.h \ $(DESTDIR)/$(includedir)/libgccjit++.h + $(INSTALL_PROGRAM) jit/libgccjit.pc \ + $(DESTDIR)/$(libdir)/pkgconfig/libgccjit.pc jit.install-man: diff --git a/gcc/jit/config-lang.in b/gcc/jit/config-lang.in index a804c62..7128c3b 100644 --- a/gcc/jit/config-lang.in +++ b/gcc/jit/config-lang.in @@ -36,3 +36,7 @@ gtfiles="\$(srcdir)/jit/dummy-frontend.c" # Hence to get the jit, one must configure with: # --enable-host-shared --enable-languages=jit build_by_default="no" + +# Ensure that libgccjit.pc is built from libgccjit.pc.in +# via AC_CONFIG_FILES in gcc/configure.ac +outputs="jit/libgccjit.pc" diff --git a/gcc/jit/docs/_build/texinfo/libgccjit.texi b/gcc/jit/docs/_build/texinfo/libgccjit.texi index 3706a24..d379b1d 100644 --- a/gcc/jit/docs/_build/texinfo/libgccjit.texi +++ b/gcc/jit/docs/_build/texinfo/libgccjit.texi @@ -421,7 +421,9 @@ $ find $PREFIX/lib/libgccjit.* @subsection "Hello world" -Here's a trivial "hello world" program that uses the library to synthesize +Let's look at how to build and run programs that use the library. + +Here's a toy "hello world" program that uses the library to synthesize a call to @cite{printf} and use it to write a message to stdout. @quotation @@ -554,22 +556,43 @@ hello world @noindent -If building against an locally-built install (to $PREFIX), specify the -include and library paths with -I and -L: +If building against an locally-built install (to @cite{$PREFIX}), you can use +pkg-config@footnote{http://www.freedesktop.org/wiki/Software/pkg-config/} to +specify the compilation and linkage flags: @example +$ export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig $ gcc \ jit-hello-world.c \ -o jit-hello-world \ - -lgccjit \ - -I$PREFIX/include -L$PREFIX/lib + $(pkg-config libgccjit --cflags --libs) +@end example + +@noindent + +and ensure that @cite{LD_LIBRARY_PATH} is set appropriate when running the +built program, so that it can locate and dynamically link against +@cite{libgccjit.so}: + +@example +# Run the built program: +$ export LD_LIBRARY_PATH=$PREFIX/lib +$ ./jit-hello-world +hello world @end example @noindent -and when running, specify the dynamic linkage path via LD_LIBRARY_PATH: +This is equivalent to handcoding the include and library paths with @cite{-I} +and @cite{-L} and specifying @cite{-lgccjit} (i.e. linkage against libgccjit): @example +$ gcc \ + jit-hello-world.c \ + -o jit-hello-world \ + -lgccjit \ + -I$PREFIX/include -L$PREFIX/lib + $ LD_LIBRARY_PATH=$PREFIX/lib ./jit-hello-world hello world @end example diff --git a/gcc/jit/docs/intro/install.rst b/gcc/jit/docs/intro/install.rst index 1a39192..18065a1 100644 --- a/gcc/jit/docs/intro/install.rst +++ b/gcc/jit/docs/intro/install.rst @@ -152,7 +152,9 @@ and the library within the `lib` subdirectory: "Hello world" ============= -Here's a trivial "hello world" program that uses the library to synthesize +Let's look at how to build and run programs that use the library. + +Here's a toy "hello world" program that uses the library to synthesize a call to `printf` and use it to write a message to stdout. .. literalinclude:: ../examples/install-hello-world.c @@ -174,20 +176,39 @@ To build it with prebuilt packages, use: hello world -If building against an locally-built install (to $PREFIX), specify the -include and library paths with -I and -L: +If building against an locally-built install (to `$PREFIX`), you can use +`pkg-config <http://www.freedesktop.org/wiki/Software/pkg-config/>`_ to +specify the compilation and linkage flags: .. code-block:: console + $ export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig $ gcc \ jit-hello-world.c \ -o jit-hello-world \ - -lgccjit \ - -I$PREFIX/include -L$PREFIX/lib + $(pkg-config libgccjit --cflags --libs) + +and ensure that `LD_LIBRARY_PATH` is set appropriate when running the +built program, so that it can locate and dynamically link against +`libgccjit.so`: + +.. code-block:: console + + # Run the built program: + $ export LD_LIBRARY_PATH=$PREFIX/lib + $ ./jit-hello-world + hello world -and when running, specify the dynamic linkage path via LD_LIBRARY_PATH: +This is equivalent to handcoding the include and library paths with `-I` +and `-L` and specifying `-lgccjit` (i.e. linkage against libgccjit): .. code-block:: console + $ gcc \ + jit-hello-world.c \ + -o jit-hello-world \ + -lgccjit \ + -I$PREFIX/include -L$PREFIX/lib + $ LD_LIBRARY_PATH=$PREFIX/lib ./jit-hello-world hello world diff --git a/gcc/jit/libgccjit.pc.in b/gcc/jit/libgccjit.pc.in new file mode 100644 index 0000000..faafea5 --- /dev/null +++ b/gcc/jit/libgccjit.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libgccjit +Description: Library for embedding GCC for Just-In-Time compilation +URL: https://gcc.gnu.org/wiki/JIT +Version: @gcc_version@ +Cflags: -I${includedir} +Libs: -lgccjit -L${libdir} -- 1.7.11.7