gcc47: Fix plugin mechanism
authorJohn Marino <draco@marino.st>
Sat, 2 Feb 2013 15:29:40 +0000 (16:29 +0100)
committerJohn Marino <draco@marino.st>
Sat, 2 Feb 2013 16:04:21 +0000 (17:04 +0100)
There were two problems with gcc 4.7 LTO plugin:
1) It needed a number of object files from libiberty.
   Unfortunately the previous object files couldn't be used as they need
   to be built with -fPIC and libiberty is only an internal (non-pic) lib.
2) The plugin header directory was missing completely, as seen with
   gcc -print-file-name=plugin only returning "plugin".

etc/mtree/BSD.usr.dist
gnu/usr.bin/cc47/liblto_plugin/Makefile
gnu/usr.bin/cc47/liblto_plugin/Makefile.headers [new file with mode: 0644]

index 120bf9c..8dcccff 100644 (file)
             ..
         ..
         gcc47
+            plugin
+                include
+                    c-family
+                    ..
+                    objc
+                    ..
+                    config
+                        i386
+                        ..
+                    ..
+                    cp
+                    ..
+                ..
+            ..
             profile
             ..
         ..
index 12bf3b5..5ba62dd 100644 (file)
@@ -1,6 +1,11 @@
 GCC_NO_LIBS=   # defined
+.include "Makefile.headers"
 .include "../Makefile.inc"
 .PATH: ${GCCDIR}/lto-plugin
+.PATH: ${GCCDIR}/libiberty
+.PATH: ${GCCDIR}/include
+.PATH: ${GCCDIR}/gcc/cp
+.PATH: ${GCCDIR}/libcpp/include
 
 LIB=           lto_plugin
 
@@ -11,8 +16,45 @@ NOINSTALLLIB=        yes
 # GCC driver looks for LTO plugin library in libexec, not lib
 TARGET_SHLIBDIR=       /usr/libexec/gcc47
 
+# Plugin support file locations
+PLUGIN_RESOURCE_DIR=   /usr/lib/gcc47/plugin
+PLUGIN_HEADER_DIR=     ${PLUGIN_RESOURCE_DIR}/include
+
 CFLAGS+=       -I${GCCDIR}/include
+CFLAGS+=       -I${GCCDIR}/libiberty
 CFLAGS+=       -DHAVE_CONFIG_H
 SRCS=          lto-plugin.c
+SRCS+=         hashtab.c \
+               xmalloc.c \
+               simple-object.c \
+               simple-object-elf.c \
+               simple-object-mach-o.c \
+               simple-object-coff.c \
+               xstrerror.c \
+               pex-unix.c \
+               pex-common.c \
+               argv.c \
+               safe-ctype.c \
+               xexit.c \
+               xstrdup.c \
+               make-temp-file.c \
+               concat.c
+
+INCSGROUPS+=   LVL1_ LVL2_ LVL2_1_ LVL2_2_ LVL2_3_ LVL2_4_ LVL2_5_
+LVL1_DIR=      ${PLUGIN_RESOURCE_DIR}
+LVL2_DIR=      ${PLUGIN_HEADER_DIR}
+LVL2_1_DIR=    ${PLUGIN_HEADER_DIR}/c-family
+LVL2_2_DIR=    ${PLUGIN_HEADER_DIR}/cp
+LVL2_3_DIR=    ${PLUGIN_HEADER_DIR}/objc
+LVL2_4_DIR=    ${PLUGIN_HEADER_DIR}/config
+LVL2_5_DIR=    ${PLUGIN_HEADER_DIR}/config/i386
+
+LVL1_=         ${.OBJDIR}/../cc_tools/tools/gtype.state
+LVL2_=         ${PLUGIN_HEADERS}
+LVL2_1_=       ${PLUGIN_HEADERS_CFAMILY}
+LVL2_2_=       ${PLUGIN_HEADERS_CP}
+LVL2_3_=       ${PLUGIN_HEADERS_OBJC}
+LVL2_4_=       ${PLUGIN_HEADERS_CONFIG}
+LVL2_5_=       ${PLUGIN_HEADERS_CONFIG_I386}
 
 .include <bsd.lib.mk>
diff --git a/gnu/usr.bin/cc47/liblto_plugin/Makefile.headers b/gnu/usr.bin/cc47/liblto_plugin/Makefile.headers
new file mode 100644 (file)
index 0000000..de03000
--- /dev/null
@@ -0,0 +1,159 @@
+# The logic to define PLUGIN_HEADERS is filled with dozens of variables that
+# is impossible for a human to wade through.  To keep this simple, generate
+# a list manually from a vendor-built and installed version of gcc (below)
+
+PLUGIN_HEADERS= \
+       alias.h \
+       all-tree.def \
+       alloc-pool.h \
+       ansidecl.h \
+       auto-host.h \
+       basic-block.h \
+       bitmap.h \
+       builtins.def \
+       bversion.h \
+       c-tree.h \
+       cfghooks.h \
+       cfgloop.h \
+       cgraph.h \
+       cif-code.def \
+       config.h \
+       configargs.h \
+       coretypes.h \
+       cppdefault.h \
+       cpplib.h \
+       debug.h \
+       defaults.h \
+       diagnostic-core.h \
+       diagnostic.def \
+       diagnostic.h \
+       double-int.h \
+       emit-rtl.h \
+       except.h \
+       filenames.h \
+       fixed-value.h \
+       flag-types.h \
+       flags.h \
+       function.h \
+       gcc-plugin.h \
+       genrtl.h \
+       ggc.h \
+       gimple-pretty-print.h \
+       gimple.def \
+       gimple.h \
+       gsstruct.def \
+       gtm-builtins.def \
+       gtype-desc.h \
+       hard-reg-set.h \
+       hashtab.h \
+       highlev-plugin-common.h \
+       hwint.h \
+       incpath.h \
+       input.h \
+       insn-constants.h \
+       insn-flags.h \
+       insn-modes.h \
+       insn-notes.def \
+       internal-fn.def \
+       internal-fn.h \
+       intl.h \
+       ipa-prop.h \
+       ipa-ref-inline.h \
+       ipa-ref.h \
+       ipa-reference.h \
+       ipa-utils.h \
+       langhooks.h \
+       libiberty.h \
+       line-map.h \
+       machmode.h \
+       md5.h \
+       mode-classes.def \
+       obstack.h \
+       omp-builtins.def \
+       options.h \
+       opts.h \
+       output.h \
+       params.def \
+       params.h \
+       plugin-api.h \
+       plugin-version.h \
+       plugin.def \
+       plugin.h \
+       pointer-set.h \
+       predict.def \
+       predict.h \
+       prefix.h \
+       pretty-print.h \
+       real.h \
+       realmpfr.h \
+       reg-notes.def \
+       rtl.def \
+       rtl.h \
+       safe-ctype.h \
+       sbitmap.h \
+       splay-tree.h \
+       statistics.h \
+       symtab.h \
+       sync-builtins.def \
+       system.h \
+       target-hooks-macros.h \
+       target.def \
+       target.h \
+       timevar.def \
+       timevar.h \
+       tm-preds.h \
+       tm.h \
+       tm_p.h \
+       toplev.h \
+       tree-check.h \
+       tree-dump.h \
+       tree-flow-inline.h \
+       tree-flow.h \
+       tree-inline.h \
+       tree-iterator.h \
+       tree-pass.h \
+       tree-pretty-print.h \
+       tree-ssa-alias.h \
+       tree-ssa-operands.h \
+       tree-ssa-sccvn.h \
+       tree.def \
+       tree.h \
+       treestruct.def \
+       vec.h \
+       vecir.h \
+       vecprim.h \
+       version.h
+
+PLUGIN_HEADERS_CFAMILY= \
+       c-common.def \
+       c-common.h \
+       c-objc.h \
+       c-pragma.h \
+       c-pretty-print.h
+
+PLUGIN_HEADERS_CP= \
+       cp-tree.def \
+       cp-tree.h \
+       cxx-pretty-print.h \
+       name-lookup.h
+
+PLUGIN_HEADERS_OBJC= \
+       objc/objc-tree.def
+
+PLUGIN_HEADERS_CONFIG= \
+       dragonfly-stdint.h \
+       dragonfly.h \
+       dbxelf.h \
+       initfini-array.h \
+       vxworks-dummy.h \
+       elfos.h
+
+PLUGIN_HEADERS_CONFIG_I386= \
+       x86-64.h \
+       biarch64.h \
+       dragonfly.h \
+       i386-opts.h \
+       i386-protos.h \
+       i386.h \
+       unix.h \
+       att.h