gcc plugin on windows cross compiler

Asked by Davide Piombo on 2017-03-16

Hello, I'm using GNU ARM embedded toolchain on windows and I'm interested in developing a gcc plugin to add some custom C++ generalized attributes to compiler parser.
I'm writing since I didn't find the compiler plugin include directory in the window release 6-q1-2017 and I would like to know why.
I checked out installer script, included in source distribution, and I found that in post-building after install of built executable the plugin directory is erased (line 789 in build-toolchain.sh). This fact drives me to think that the plugin feature can have some problem on the windows platform.

Could you please tell me if the gcc plugin feature is available in windows distribution and, if it is, how to correctly set up a toolchain to develop a plugin on that platform?

I also tried to develop such a kind of plugin on linux and it works fine.
 I tried to cross compile the same plugin to windows without success, mingw compiler complains about some sys/xxx.h include files that are missing (that is, as far as I know, correct).
In order to perform the cross compilation I installed the Ubuntu linux suggested in the source code installation guide "The Build Process of (GNU Tools for ARM Embedded Processors 6-2017-q1-update) 2017-02"
If the cross compilation of the plugin from linux is the correct way, could you please give me some directions on how to complete it?

Thanks in advance

Davide

Question information

Language:
English Edit question
Status:
Open
For:
GNU ARM Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
2017-03-17
Last reply:
2017-03-16

Hi Davide,

The removal of the plugin directory is a vestige of when the toolchain was distributed with an optimization plugin. The line was there because the plugin would be copied over from the Linux toolchain as part of the copy_dir just before since the Linux plugin would clearly not work on Windows.

The right way for you would be to delete that rm line and add code to build the plugin using the mingw cross compiler. I cannot help you on the include error without more details, I'd suggest you post a minimal testcase that exibit the include error together with the mingw compile line.

Best regards.

Davide Piombo (davidep) said : #2

Hi Thomas, thanks a lot for your ready answer.

I followed your suggestion and I removed the line erasing the plugin directory in windows build and I rebuilt the compiler.
I tried to build the plugin using the mingw-w64 compiler directly on windows from an eclipse project, but I found the same error experienced with linux cross compiler, the missing "sys/wait.h" include file from gcc-arm-none-eabi-6-2017-q1-update-win32\lib\gcc\arm-none-eabi\6.3.1\plugin\include/system.h

As you probably know the include file is part of the POSIX standard (as far as all includes in sys/ folder) and I think it is correct that it is not found when performing compilation targeted to windows platform.
I found that in the system.h file mentioned above there are some preprocessor #ifdef directives that can exclude POSIX includes, is there a way to build the compiler activating these flags?

In tail of this message I report the result of the plugin build using the cross compiler, but I think that the right solution should be in a different compilation of gcc plugin feature in case cross compiler is addressed to run on windows platform...

Thanks in advance

Davide

"C:\\Win-Builds\\bin\\i686-w64-mingw32-g++.exe" -std=c++0x "-IC:\\GCC-ARM\\gcc-arm-none-eabi-6-2017-q1-update-win32\\lib\\gcc\\arm-none-eabi\\6.3.1\\plugin\\include" "-IC:\\Win-Builds\\include\\c++\\4.8.3" "-IC:\\Win-Builds\\include\\c++\\4.8.3\\backward" "-IC:\\Win-Builds\\include\\c++\\4.8.3\\i686-w64-mingw32" "-IC:\\Win-Builds\\lib\\gcc\\i686-w64-mingw32\\4.8.3\\include" "-IC:\\Win-Builds\\include" -O0 -g3 -Wall -c -fmessage-length=0 -v -fPIC -o XltpGccPlugin.o "..\\XltpGccPlugin.cpp"
Reading specs from c:/win-builds/bin/../lib/gcc/i686-w64-mingw32/4.8.3/specs
COLLECT_GCC=C:\Win-Builds\bin\i686-w64-mingw32-g++.exe
Target: i686-w64-mingw32
Configured with: ../gcc-4.8.3/configure --prefix=/opt/windows_32 --with-sysroot=/opt/windows_32 --libdir=/opt/windows_32/lib --mandir=/opt/windows_32/man --infodir=/opt/windows_32/info --enable-shared --disable-bootstrap --disable-multilib --with-arch=pentium3 --enable-threads=posix --enable-languages=c,c++ --enable-checking=release --enable-libgomp --with-system-zlib --with-python-dir=/lib/python2.7/site-packages --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --with-gnu-ld --verbose --enable-java-home --with-java-home=/opt/windows_32/lib/jvm/jre --with-jvm-root-dir=/opt/windows_32/lib/jvm --with-jvm-jar-dir=/opt/windows_32/lib/jvm/jvm-exports --with-arch-directory=amd64 --with-antlr-jar='/home/adrien/projects/win-builds-1.5/slackware64-current/d/gcc/antlr-*.jar' --disable-java-awt --disable-gtktest --build=x86_64-slackware-linux --host=i686-w64-mingw32 --target=i686-w64-mingw32
Thread model: posix
gcc version 4.8.3 (GCC)
COLLECT_GCC_OPTIONS='-std=c++11' '-I' 'C:\GCC-ARM\gcc-arm-none-eabi-6-2017-q1-update-win32\lib\gcc\arm-none-eabi\6.3.1\plugin\include' '-I' 'C:\Win-Builds\include\c++\4.8.3' '-I' 'C:\Win-Builds\include\c++\4.8.3\backward' '-I' 'C:\Win-Builds\include\c++\4.8.3\i686-w64-mingw32' '-I' 'C:\Win-Builds\lib\gcc\i686-w64-mingw32\4.8.3\include' '-I' 'C:\Win-Builds\include' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-v' '-fPIC' '-o' 'XltpGccPlugin.o' '-shared-libgcc' '-mtune=generic' '-march=pentium3'
 c:/win-builds/bin/../libexec/gcc/i686-w64-mingw32/4.8.3/cc1plus.exe -quiet -v -I C:\GCC-ARM\gcc-arm-none-eabi-6-2017-q1-update-win32\lib\gcc\arm-none-eabi\6.3.1\plugin\include -I C:\Win-Builds\include\c++\4.8.3 -I C:\Win-Builds\include\c++\4.8.3\backward -I C:\Win-Builds\include\c++\4.8.3\i686-w64-mingw32 -I C:\Win-Builds\lib\gcc\i686-w64-mingw32\4.8.3\include -I C:\Win-Builds\include -iprefix c:\win-builds\bin\../lib/gcc/i686-w64-mingw32/4.8.3/ -dD -D_REENTRANT ..\XltpGccPlugin.cpp -quiet -dumpbase XltpGccPlugin.cpp -mtune=generic -march=pentium3 -auxbase-strip XltpGccPlugin.o -g3 -O0 -Wall -std=c++11 -version -fmessage-length=0 -fPIC -IC:/Win-Builds/include -o C:\Users\ADMINI~1\AppData\Local\Temp\ccFq6Uuy.s
GNU C++ (GCC) version 4.8.3 (i686-w64-mingw32)
 compiled by GNU C version 4.8.3, GMP version 5.1.3, MPFR version 3.1.2, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=131007
ignoring duplicate directory "c:/win-builds/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3"
ignoring duplicate directory "c:/win-builds/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3/i686-w64-mingw32"
ignoring duplicate directory "c:/win-builds/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3/backward"
ignoring duplicate directory "c:/win-builds/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/include"
ignoring nonexistent directory "/opt/windows_32/opt/windows_32/lib/gcc/i686-w64-mingw32/4.8.3/../../../../include"
ignoring duplicate directory "c:/win-builds/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/include-fixed"
ignoring duplicate directory "c:/win-builds/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/../../../../i686-w64-mingw32/include"
ignoring nonexistent directory "/opt/windows_32/mingw/include"
ignoring duplicate directory "C:\Win-Builds\include\c++\4.8.3"
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "C:\Win-Builds\include\c++\4.8.3\backward"
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "C:\Win-Builds\include\c++\4.8.3\i686-w64-mingw32"
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "C:\Win-Builds\lib\gcc\i686-w64-mingw32\4.8.3\include"
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "C:/Win-Builds/include"
#include "..." search starts here:
#include <...> search starts here:
 C:\GCC-ARM\gcc-arm-none-eabi-6-2017-q1-update-win32\lib\gcc\arm-none-eabi\6.3.1\plugin\include
 C:\Win-Builds\include
 c:\win-builds\bin\../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3
 c:\win-builds\bin\../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3/i686-w64-mingw32
 c:\win-builds\bin\../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3/backward
 c:\win-builds\bin\../lib/gcc/i686-w64-mingw32/4.8.3/include
 c:\win-builds\bin\../lib/gcc/i686-w64-mingw32/4.8.3/include-fixed
 c:\win-builds\bin\../lib/gcc/i686-w64-mingw32/4.8.3/../../../../i686-w64-mingw32/include
End of search list.
..\XltpGccPlugin.cpp:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]
 /*
 ^
GNU C++ (GCC) version 4.8.3 (i686-w64-mingw32)
 compiled by GNU C version 4.8.3, GMP version 5.1.3, MPFR version 3.1.2, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=131007
Compiler executable checksum: c4fe4d0d4d1dfaca074c710f8d712c81
In file included from C:\GCC-ARM\gcc-arm-none-eabi-6-2017-q1-update-win32\lib\gcc\arm-none-eabi\6.3.1\plugin\include/gcc-plugin.h:28:0,
                 from ..\XltpGccPlugin.cpp:16:
C:\GCC-ARM\gcc-arm-none-eabi-6-2017-q1-update-win32\lib\gcc\arm-none-eabi\6.3.1\plugin\include/system.h:396:22: fatal error: sys/wait.h: No such file or directory
 #include <sys/wait.h>
                      ^
compilation terminated.

Can you help with this problem?

Provide an answer of your own, or ask Davide Piombo for more information if necessary.

To post a message you must log in.