Re: [PATCH 06/10] Heart of the JIT implementation (was: Re: [PATCH 0/5] Merger of jit branch (v2))
On Fri, 2014-10-17 at 21:52 +, Joseph S. Myers wrote: Does libgccjit.so end up getting linked with -static-libstdc++ -static-libgcc? (sorry for belated reply) It does when built with a bootstrap, but doesn't with --disable-bootstrap. In the former case, the builddir's gcc/Makefile in the final stage has: LDFLAGS = -static-libstdc++ -static-libgcc and we use $(LDFLAGS) in the src's gcc/jit/Make-lang.in in the rule for $(LIBGCCJIT_FILENAME). As far as I can tell, this comes from these lines: if test $poststage1_libs = ; then poststage1_ldflags=-static-libstdc++ -static-libgcc fi]) in the top-level configure.ac's code for: AC_ARG_WITH(boot-ldflags, If so, that could be problematic (are static libstdc++ and libgcc necessarily built as PIC so it's even possible to embed them into a shared library?). It works (on this machine at least); the built libgccjit.so library successfully runs the test suite. Looking at the build logs, I see: -fPIC within the xgcc args in the libgcc build logs, and -prefer-pic within the libtool args in the libstdc++ build, which according to the libtool docs means try to build only PIC objects. Hence I believe although we're currently statically-linking libgcc and libstdc++ into libgccjit.so, they're position-independent. It's certainly not clear that the -static-libstdc++ -static-libgcc default for building the compiler executables is the right one for building libgccjit.so. Agreed, but it's unclear to me what the default should be, and how to go about fixing it. That said, it appears that people who want the libgccjit.so to dynamically-link against libgcc and libstdc++ can already do so, by selecting appropriate configuration flags (though it's not quite clear to me what the incantation is; presumably $poststage1_libs needs to be non-empty to avoid triggering this clause: if test $poststage1_libs = ; then poststage1_ldflags=-static-libstdc++ -static-libgcc fi , right ?) Or maybe I could turn off that clause if the --enable-host-shared has been specified, so it defaults to shared linkage for that setting? Do you have thoughts on how I should address this? Also, given that the code works as-is, is resolving this a blocker for merging the jit branch? (I've been rebasing, and plan to repost the fixed-up patches for review shortly) Thanks Dave The dump file handling appears to have no I/O error checking (no checking for error on fopen, nothing obvious to prevent fwrite to a NULL m_file if fopen did have an error, no checking for error on fclose (or fwrite)). (already addressed in a different reply)
Re: [PATCH 06/10] Heart of the JIT implementation (was: Re: [PATCH 0/5] Merger of jit branch (v2))
On Thu, 30 Oct 2014, David Malcolm wrote: Looking at the build logs, I see: -fPIC within the xgcc args in the libgcc build logs, and That seems to depend on t-libgcc-pic, but that appears to cover most likely hosts (including any where I can be confident PIC is actually needed for shared libraries). It's certainly not clear that the -static-libstdc++ -static-libgcc default for building the compiler executables is the right one for building libgccjit.so. Agreed, but it's unclear to me what the default should be, and how to go about fixing it. That said, it appears that people who want the libgccjit.so to dynamically-link against libgcc and libstdc++ can already do so, by Can do so for libgccjit.so but not the compiler executables? (There are no doubt cases where it makes sense for the compiler executables to be dynamically linked with the shared libraries, but also I think cases for linking only libgccjit.so with the shared libraries.) Do you have thoughts on how I should address this? Also, given that the No. code works as-is, is resolving this a blocker for merging the jit branch? (I've been rebasing, and plan to repost the fixed-up patches for review shortly) I don't see it as a blocker, but I would not be surprised if having the libraries statically linked into libgccjit.so causes problems (is it safe to have two completely separate copies of libstdc++ in the same process? I don't know.). -- Joseph S. Myers jos...@codesourcery.com
Re: [PATCH 06/10] Heart of the JIT implementation (was: Re: [PATCH 0/5] Merger of jit branch (v2))
Does libgccjit.so end up getting linked with -static-libstdc++ -static-libgcc? If so, that could be problematic (are static libstdc++ and libgcc necessarily built as PIC so it's even possible to embed them into a shared library?). It's certainly not clear that the -static-libstdc++ -static-libgcc default for building the compiler executables is the right one for building libgccjit.so. The dump file handling appears to have no I/O error checking (no checking for error on fopen, nothing obvious to prevent fwrite to a NULL m_file if fopen did have an error, no checking for error on fclose (or fwrite)). -- Joseph S. Myers jos...@codesourcery.com
Patches 5-10 of jit merger (was: Re: [PATCH 0/5] Merger of jit branch (v2))
On Mon, 2014-10-13 at 13:45 -0400, David Malcolm wrote: I'd like to merge the JIT branch into trunk: https://gcc.gnu.org/wiki/JIT This is v2 since it incorporates fixes for the various issues identified by Joseph in an earlier submission: https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02056.html I've split up the current diff between trunk and the branch into 5 areas for ease of review (and to allow for early merger of the supporting work, if it's deemed ready): patch 1: exposes an entrypoint in libiberty that I need patch 2: configure and Makefile changes in gcc patch 3: timevar.h: Add an auto_timevar class patch 4: State cleanups in gcc patch 5: Add the jit code itself [this is a diff of trunk r215958 aka e012cdc775868e9922f5fef9068a764546876d93 which is from 2014-10-06, vs jit branch version 75b3ee7acdc6de55354d65bb7d619386463e50a1]. I've successfully bootstrapped and regression-tested the cumulative result of all of the patches against a control build, building them both with --enable-host-shared, and with --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto adding ,jit to the test build (both on x86_64-unknown-linux-gnu; Fedora 20). There were no regressions vs the control build, and the patched build gains a jit.sum, with 4663 passes (and no failures). OK for trunk? Patch 5 seems to have been too large, even compressed, so I'm breaking it up into separate pieces and compressing, giving 10 patches in total Patches 1-4 are as above. Patch 5: remaining JIT-related changes outside of the gcc/jit/ subdir Patch 6: the core of the JIT implementation: the gcc/jit subdir Patch 7: the testsuite: gcc/testsuite/jit.dg Patch 8: sphinx-based documentation: the gcc/jit/docs subdir Patch 9: texinfo documentation autogenerated from the sphinx sources. Patch 10: the ChangeLog.jit logs from the branch.
[PATCH 06/10] Heart of the JIT implementation (was: Re: [PATCH 0/5] Merger of jit branch (v2))
On Tue, 2014-10-14 at 11:09 -0400, David Malcolm wrote: On Mon, 2014-10-13 at 13:45 -0400, David Malcolm wrote: I'd like to merge the JIT branch into trunk: https://gcc.gnu.org/wiki/JIT This is v2 since it incorporates fixes for the various issues identified by Joseph in an earlier submission: https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02056.html I've split up the current diff between trunk and the branch into 5 areas for ease of review (and to allow for early merger of the supporting work, if it's deemed ready): patch 1: exposes an entrypoint in libiberty that I need patch 2: configure and Makefile changes in gcc patch 3: timevar.h: Add an auto_timevar class patch 4: State cleanups in gcc patch 5: Add the jit code itself [this is a diff of trunk r215958 aka e012cdc775868e9922f5fef9068a764546876d93 which is from 2014-10-06, vs jit branch version 75b3ee7acdc6de55354d65bb7d619386463e50a1]. I've successfully bootstrapped and regression-tested the cumulative result of all of the patches against a control build, building them both with --enable-host-shared, and with --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto adding ,jit to the test build (both on x86_64-unknown-linux-gnu; Fedora 20). There were no regressions vs the control build, and the patched build gains a jit.sum, with 4663 passes (and no failures). OK for trunk? Patch 5 seems to have been too large, even compressed, so I'm breaking it up into separate pieces and compressing, giving 10 patches in total Patches 1-4 are as above. Patch 5: remaining JIT-related changes outside of the gcc/jit/ subdir Patch 6: the core of the JIT implementation: the gcc/jit subdir Patch 7: the testsuite: gcc/testsuite/jit.dg Patch 8: sphinx-based documentation: the gcc/jit/docs subdir Patch 9: texinfo documentation autogenerated from the sphinx sources. Patch 10: the ChangeLog.jit logs from the branch. This commit adds the gcc/jit subdirectory, implementing the library, which looks like a frontend named jit from the POV of the rest of the gcc code. gcc/jit/ChangeLog: * Make-lang.in: New. * TODO.rst: New. * config-lang.in: New. * dummy-frontend.c: New. * jit-builtins.c: New. * jit-builtins.h: New. * jit-common.h: New. * jit-playback.c: New. * jit-playback.h: New. * jit-recording.c: New. * jit-recording.h: New. * libgccjit++.h: New. * libgccjit.c: New. * libgccjit.h: New. * libgccjit.map: New. * libgccjit.pc.in: New. * notes.txt: New. 0006-Heart-of-the-JIT-implementation.patch.gz Description: GNU Zip compressed data
[PATCH 07/10] Testsuite for the JIT (Re: Patches 5-10 of jit merger (was: Re: [PATCH 0/5] Merger of jit branch (v2)))
On Tue, 2014-10-14 at 11:09 -0400, David Malcolm wrote: On Mon, 2014-10-13 at 13:45 -0400, David Malcolm wrote: I'd like to merge the JIT branch into trunk: https://gcc.gnu.org/wiki/JIT This is v2 since it incorporates fixes for the various issues identified by Joseph in an earlier submission: https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02056.html I've split up the current diff between trunk and the branch into 5 areas for ease of review (and to allow for early merger of the supporting work, if it's deemed ready): patch 1: exposes an entrypoint in libiberty that I need patch 2: configure and Makefile changes in gcc patch 3: timevar.h: Add an auto_timevar class patch 4: State cleanups in gcc patch 5: Add the jit code itself [this is a diff of trunk r215958 aka e012cdc775868e9922f5fef9068a764546876d93 which is from 2014-10-06, vs jit branch version 75b3ee7acdc6de55354d65bb7d619386463e50a1]. I've successfully bootstrapped and regression-tested the cumulative result of all of the patches against a control build, building them both with --enable-host-shared, and with --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto adding ,jit to the test build (both on x86_64-unknown-linux-gnu; Fedora 20). There were no regressions vs the control build, and the patched build gains a jit.sum, with 4663 passes (and no failures). OK for trunk? Patch 5 seems to have been too large, even compressed, so I'm breaking it up into separate pieces and compressing, giving 10 patches in total Patches 1-4 are as above. Patch 5: remaining JIT-related changes outside of the gcc/jit/ subdir Patch 6: the core of the JIT implementation: the gcc/jit subdir Patch 7: the testsuite: gcc/testsuite/jit.dg Patch 8: sphinx-based documentation: the gcc/jit/docs subdir Patch 9: texinfo documentation autogenerated from the sphinx sources. Patch 10: the ChangeLog.jit logs from the branch. Here's patch 7, the testsuite. 0007-Testsuite-for-the-JIT.patch.gz Description: GNU Zip compressed data
[PATCH 10/10] ChangeLog files (Re: Patches 5-10 of jit merger (was: Re: [PATCH 0/5] Merger of jit branch (v2)))
On Tue, 2014-10-14 at 11:09 -0400, David Malcolm wrote: On Mon, 2014-10-13 at 13:45 -0400, David Malcolm wrote: I'd like to merge the JIT branch into trunk: https://gcc.gnu.org/wiki/JIT This is v2 since it incorporates fixes for the various issues identified by Joseph in an earlier submission: https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02056.html I've split up the current diff between trunk and the branch into 5 areas for ease of review (and to allow for early merger of the supporting work, if it's deemed ready): patch 1: exposes an entrypoint in libiberty that I need patch 2: configure and Makefile changes in gcc patch 3: timevar.h: Add an auto_timevar class patch 4: State cleanups in gcc patch 5: Add the jit code itself [this is a diff of trunk r215958 aka e012cdc775868e9922f5fef9068a764546876d93 which is from 2014-10-06, vs jit branch version 75b3ee7acdc6de55354d65bb7d619386463e50a1]. I've successfully bootstrapped and regression-tested the cumulative result of all of the patches against a control build, building them both with --enable-host-shared, and with --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto adding ,jit to the test build (both on x86_64-unknown-linux-gnu; Fedora 20). There were no regressions vs the control build, and the patched build gains a jit.sum, with 4663 passes (and no failures). OK for trunk? Patch 5 seems to have been too large, even compressed, so I'm breaking it up into separate pieces and compressing, giving 10 patches in total Patches 1-4 are as above. Patch 5: remaining JIT-related changes outside of the gcc/jit/ subdir Patch 6: the core of the JIT implementation: the gcc/jit subdir Patch 7: the testsuite: gcc/testsuite/jit.dg Patch 8: sphinx-based documentation: the gcc/jit/docs subdir Patch 9: texinfo documentation autogenerated from the sphinx sources. Patch 10: the ChangeLog.jit logs from the branch. Finally, patch 10, the ChangeLog files. 0010-ChangeLog-files.patch.gz Description: GNU Zip compressed data
[PATCH 0/5] Merger of jit branch (v2)
I'd like to merge the JIT branch into trunk: https://gcc.gnu.org/wiki/JIT This is v2 since it incorporates fixes for the various issues identified by Joseph in an earlier submission: https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02056.html I've split up the current diff between trunk and the branch into 5 areas for ease of review (and to allow for early merger of the supporting work, if it's deemed ready): patch 1: exposes an entrypoint in libiberty that I need patch 2: configure and Makefile changes in gcc patch 3: timevar.h: Add an auto_timevar class patch 4: State cleanups in gcc patch 5: Add the jit code itself [this is a diff of trunk r215958 aka e012cdc775868e9922f5fef9068a764546876d93 which is from 2014-10-06, vs jit branch version 75b3ee7acdc6de55354d65bb7d619386463e50a1]. I've successfully bootstrapped and regression-tested the cumulative result of all of the patches against a control build, building them both with --enable-host-shared, and with --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto adding ,jit to the test build (both on x86_64-unknown-linux-gnu; Fedora 20). There were no regressions vs the control build, and the patched build gains a jit.sum, with 4663 passes (and no failures). OK for trunk? Overall diffstat follows: ChangeLog.jit | 23 + MAINTAINERS|1 + contrib/ChangeLog.jit | 14 + contrib/jit-coverage-report.py | 67 + gcc/ChangeLog.jit | 323 + gcc/Makefile.in|9 + gcc/cgraph.c | 14 + gcc/cgraph.h |6 + gcc/cgraphunit.c | 20 +- gcc/configure | 54 +- gcc/configure.ac | 11 + gcc/diagnostic.c | 11 +- gcc/doc/install.texi |2 +- gcc/dwarf2out.c| 87 + gcc/dwarf2out.h|2 + gcc/gcse.c |9 + gcc/gcse.h |2 + gcc/ggc-page.c |5 + gcc/input.c|2 +- gcc/ipa-cp.c | 12 + gcc/ipa-pure-const.c | 113 +- gcc/ipa-reference.c| 17 +- gcc/ipa-reference.h|1 + gcc/java/ChangeLog.jit | 14 + gcc/jit/ChangeLog |9 + gcc/jit/ChangeLog.jit | 3252 ++ gcc/jit/Make-lang.in | 297 + gcc/jit/TODO.rst | 119 + gcc/jit/config-lang.in | 42 + gcc/jit/docs/Makefile | 153 + gcc/jit/docs/_build/texinfo/Makefile | 50 + gcc/jit/docs/_build/texinfo/factorial.png | Bin 0 - 183838 bytes gcc/jit/docs/_build/texinfo/libgccjit.texi | 6724 gcc/jit/docs/_build/texinfo/sum-of-squares.png | Bin 0 - 22839 bytes gcc/jit/docs/conf.py | 258 + gcc/jit/docs/examples/install-hello-world.c| 123 + gcc/jit/docs/examples/tut01-square.c | 107 + gcc/jit/docs/examples/tut02-sum-of-squares.c | 172 + gcc/jit/docs/examples/tut03-toyvm/Makefile | 11 + gcc/jit/docs/examples/tut03-toyvm/factorial.toy| 50 + gcc/jit/docs/examples/tut03-toyvm/fibonacci.toy| 66 + gcc/jit/docs/examples/tut03-toyvm/toyvm.c | 861 +++ gcc/jit/docs/index.rst | 50 + gcc/jit/docs/internals/index.rst | 157 + gcc/jit/docs/intro/factorial.png | Bin 0 - 183838 bytes gcc/jit/docs/intro/index.rst | 27 + gcc/jit/docs/intro/install.rst | 227 + gcc/jit/docs/intro/sum-of-squares.png | Bin 0 - 22839 bytes gcc/jit/docs/intro/tutorial01.rst | 349 + gcc/jit/docs/intro/tutorial02.rst | 378 ++ gcc/jit/docs/intro/tutorial03.rst | 1108 gcc/jit/docs/topics/contexts.rst | 315 + gcc/jit/docs/topics/expressions.rst| 524 ++ gcc/jit/docs/topics/functions.rst | 311 + gcc/jit/docs/topics/index.rst | 30 + gcc/jit/docs/topics/locations.rst | 69 + gcc/jit/docs/topics/objects.rst| 86 + gcc/jit/docs/topics/results.rst| 48 + gcc/jit/docs/topics/types.rst | 217 +