Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue building plugin #513

Open
labba opened this issue Jun 30, 2020 · 18 comments
Open

issue building plugin #513

labba opened this issue Jun 30, 2020 · 18 comments

Comments

@labba
Copy link

labba commented Jun 30, 2020

now that i know how to compile the environment, i have added to the configuration "--enable-plugin" and recompiled it successfully.

to create plugin there is a need to compile it as follow:

first need to locate the plugin dir:

g++ -print-file-name=plugin
C:/msys64/home/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/plugin

after locating the plugin dir, i have converted the "/" to "\" and compile a plugin example:
while set the plugin dir to the variable ${PLUGIN_DIR}

g++ -I${PLUGIN_DIR}/include -fPIC -shared -Wl,--export-all-symbols my_first_gcc_plugin.cc -o
 my_plugin.dll  ${PLUGIN_DIR}\cc1.exe.a

you can see the source code for the example here:
https://raw.githubusercontent.com/rofirrim/gcc-plugins/master/01_first/my_first_gcc_plugin.cc

the error i'm getting is:


In file included from C:/msys64/home/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/plugin
/include/gcc-plugin.h:28,
                 from my_first_gcc_plugin.cc:4:
C:/msys64/home/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/plugin/include/system.h:687:
10: fatal error: gmp.h: No such file or directory
 #include <gmp.h>
          ^~~~~~~
compilation terminated.

i seen that when i use some other distribution that also have plugin enable it's working fine:
I used one of the already compiled version from: https://gcc-mcf.lhmouse.com/
i have used the mingw-w64-gcc-mcf_20200324_9.3.1_x86

i couldn't understand what is the main difference between those 2 builds that make success build only on lhmouse but fail on this compilation..

@niXman
Copy link
Owner

niXman commented Jul 1, 2020

I think there is some kind of patch that is not used here...
or diff binutils/gcc options used...

@labba
Copy link
Author

labba commented Jul 1, 2020

this is the configuration of GCC i dont know how to get the configuration of binutils (if you will let me know i will post them as well):

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Users/labba/Downloads/mingw-w64-gcc-mcf_20200324_9.3.1_x86/mingw32/bin/../lib/gcc/i686-w64-mingw32/9.3.1/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../gcc-git/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --enable-bootstrap --with-arch=i686 --with-tune=nocona --enable-languages=c,lto,c++ --enable-shared --enable-static --enable-threads=mcf --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-libstdcxx-filesystem-ts=yes --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --enable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw32 --with-mpfr=/mingw32 --with-mpc=/mingw32 --with-isl=/mingw32 --with-pkgversion='GCC with MCF thread model, built by LH_Mouse.' --with-bugurl=https://gcc-mcf.lhmouse.com/ --with-gnu-as --with-gnu-ld --disable-tls --enable-plugin --enable-sjlj-exceptions
Thread model: mcf
gcc version 9.3.1 20200323 (GCC with MCF thread model, built by LH_Mouse.)

i don't believe that the thread model is the one that makes the difference ..

when searching for "gmp.h" in the LH Mouse project i do locate it here:
"mingw-w64-gcc-mcf_20200324_9.3.1_x86\mingw32\include\gmp.h"

but in your project when i search for the same file, i fail in locating it in the final package ..
also when i look on the overall files inside of the "mingw-gcc-8.3.0\x86_64-830-win32-sjlj-rt_v7\mingw64\include" its very slim and missing a lot of includes ...

why is that ?

@niXman
Copy link
Owner

niXman commented Jul 1, 2020

when searching for "gmp.h" in the LH Mouse project i do locate it here:
"mingw-w64-gcc-mcf_20200324_9.3.1_x86\mingw32\include\gmp.h"

because he delivers these files in the final archive, but I do not. you are the first who need these files.

why is that ?

because you comparing the two diff folders: the first is the archive with the final build, but the second - is the temporary directory used during the build process.

@labba
Copy link
Author

labba commented Jul 1, 2020

thanks!
apparently,it is mandatory when developing plugins ..

what do i need to change in order to do all the copying of all the includes from all the packages to the include folder?

this is the lhmouse folder content:

mingw-w64-gcc-mcf_20200324_9.3.1_x86\mingw32\include

<DIR>          .
<DIR>          ..
         2,383 autosprintf.h
<DIR>          binutils
<DIR>          boost
         7,187 bzlib.h
<DIR>          c++
<DIR>          editline
        41,473 expat.h
         3,959 expat_config.h
         5,528 expat_external.h
         8,941 fakemysql.h
         1,189 fakepq.h
         6,496 fakesql.h
<DIR>          gdb
        15,557 gettext-po.h
        83,940 gmp.h
       129,113 gmpxx.h
         2,912 gnumake.h
         9,271 iconv.h
<DIR>          isl
         5,515 itcl.h
         1,888 itcl2TclOO.h
         7,176 itclDecls.h
        37,046 itclInt.h
        43,298 itclIntDecls.h
         2,929 itclMigrate2TclCore.h
         1,719 itclTclIntStubsFcn.h
         1,513 libcharset.h
<DIR>          libiberty
        16,674 libintl.h
         3,700 libmangle.h
        15,408 libtasn1.h
         6,059 localcharset.h
<DIR>          lzma
         9,866 lzma.h
<DIR>          mcfgthread
        12,898 mpc.h
        39,825 mpdecimal.h
         6,645 mpf2mpfr.h
        51,562 mpfr.h
         5,629 mysqlStubs.h
<DIR>          ncurses
<DIR>          ncursesw
         5,051 odbcStubs.h
<DIR>          openssl
<DIR>          p11-kit-1
        31,718 pcre.h
        26,529 pcrecpp.h
         6,783 pcrecpparg.h
         5,452 pcreposix.h
         6,600 pcre_scanner.h
         6,312 pcre_stringpiece.h
<DIR>          pdcurses
            29 pdcurses.h
         3,584 pqStubs.h
<DIR>          python3.8
<DIR>          readline
           548 regex.h
       576,161 sqlite3.h
        34,802 sqlite3ext.h
        94,627 tcl.h
<DIR>          tcl8.6
       171,296 tclDecls.h
         4,282 tclOO.h
         9,123 tclOODecls.h
         3,279 tclPlatDecls.h
           821 tclThread.h
        30,282 tclTomMath.h
        25,923 tclTomMathDecls.h
         1,682 tdbc.h
         1,497 tdbcDecls.h
           934 tdbcInt.h
         1,640 termcap.h
        58,060 tk.h
<DIR>          tk8.6
        76,176 tkDecls.h
        62,937 tkIntXlibDecls.h
         5,565 tkPlatDecls.h
<DIR>          tre
<DIR>          unicode
<DIR>          X11
        16,316 zconf.h
        96,239 zlib.h

@labba
Copy link
Author

labba commented Jul 2, 2020

copying the needed include won't be enough .. even when i copy the required missing header it's still give me the same error that it's not found .. any idea why ?

@niXman
Copy link
Owner

niXman commented Jul 2, 2020

I don’t remember what to copy and where, I need to figure it out myself, but I don’t have time now, sorry...

@niXman
Copy link
Owner

niXman commented Jul 2, 2020

@labba can you provide me an archive of the build directory? I think it is $HOME/mingw-gcc-8.3.0

@labba
Copy link
Author

labba commented Jul 3, 2020

thanks for the help!

i have uploaded it here: https://mega.nz/file/nkhkQAzB#ZLuspa19Qvqrx8nTriChm6Wm4nJtiW2SSUVEAo8h7fk

@labba
Copy link
Author

labba commented Jul 10, 2020

hi,
any luck with what i have uploaded ?

@niXman
Copy link
Owner

niXman commented Jul 10, 2020

sorry, was on vacation.

will check in the morning.

@niXman
Copy link
Owner

niXman commented Jul 12, 2020

I think you need to copy the headers from /mingw-gcc-8.3.0/prerequisites/x86_64-w64-mingw32-static/include into target mingw64/x86_64-w64-mingw32/include and libs from /mingw-gcc-8.3.0/prerequisites/x86_64-w64-mingw32-static/lib into target mingw64/x86_64-w64-mingw32/lib

@labba
Copy link
Author

labba commented Jul 13, 2020

i will give it a try and will update
Thanks!

@labba
Copy link
Author

labba commented Jul 13, 2020

ok it did worked but i gotten a warning that i have never gotten before:

In file included from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/plugin/include/gcc-plugin.h:28,
                 from basic_plugin.c:7:
C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/plugin/include/system.h:1108: warning: "CONST_CAST2" redefined
 #define CONST_CAST2(TOTYPE,FROMTYPE,X) (const_cast<TOTYPE> (X))

In file included from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/x86_64-w64-mingw32/bits/gthr.h:148,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/ext/atomicity.h:35,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/bits/ios_base.h:39,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/ios:42,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/ostream:38,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/iostream:39,
                 from basic_plugin.c:1:
C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:33: note: this is the location of the previous definition
 #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)



usually in the other compilation environment i never get any warnings .

@niXman
Copy link
Owner

niXman commented Jul 13, 2020

please provide me the source code of your plugin and command line you use for compiling it.

@labba
Copy link
Author

labba commented Jul 13, 2020

i gave everything in the very first post of the question the source and the commands i have done.
re-posting it again:

to create plugin there is a need to compile it as follow:

first need to locate the plugin dir:

g++ -print-file-name=plugin
C:/msys64/home/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/plugin

now that we have the plugin dir we can use it so i saved it to a var named: ${PLUGIN_DIR}
and now we can compile the plugin

you can see the source code for the example here:
https://raw.githubusercontent.com/rofirrim/gcc-plugins/master/01_first/my_first_gcc_plugin.cc

and this is the command we need to invoke:

g++ -I${PLUGIN_DIR}/include -fPIC -shared -Wl,--export-all-symbols my_first_gcc_plugin.cc -o
 my_plugin.dll  ${PLUGIN_DIR}/cc1.exe.a

the error i'm getting is:


C:\gcc\mingw-gcc-8.3.0\x86_64-830-win32-sjlj-rt_v7\mingw64\home>gcc -print-file-name=plugin
C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/plugin

C:\gcc\mingw-gcc-8.3.0\x86_64-830-win32-sjlj-rt_v7\mingw64\home>g++ -IC:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/plugin/include -fPIC -shared -Wl,--export-all-symbols my_first_gcc_plugin.cc -o my_plugin.dll C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/plugin/cc1.exe.a
In file included from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/plugin/include/gcc-plugin.h:28,
                 from my_first_gcc_plugin.cc:4:
C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/plugin/include/system.h:1108: warning: "CONST_CAST2" redefined
 #define CONST_CAST2(TOTYPE,FROMTYPE,X) (const_cast<TOTYPE> (X))

In file included from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/x86_64-w64-mingw32/bits/gthr.h:148,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/ext/atomicity.h:35,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/bits/ios_base.h:39,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/ios:42,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/ostream:38,
                 from C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/iostream:39,
                 from my_first_gcc_plugin.cc:1:
C:/gcc/mingw-gcc-8.3.0/x86_64-830-win32-sjlj-rt_v7/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:33: note: this is the location of the previous definition
 #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)

@labba
Copy link
Author

labba commented Jul 18, 2020

any luck reproducing the issue ?

@labba
Copy link
Author

labba commented Sep 1, 2020

sorry for bothering on this again , but it's been a while i i thought maybe it was forgotten ..

@niXman
Copy link
Owner

niXman commented Sep 7, 2020

the easiest way is to set the compiler you built as the default compiler.
after that configure and build (configure ... && make && make install) the required libraries by specifying the required prefix.
for example: configure --prefix=/my_mingw_root/x86_64-w64-mingw32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants