MINGW-packages icon indicating copy to clipboard operation
MINGW-packages copied to clipboard

gcc: Rewriting of "Enable shared gnat implib" in progress

Open stahta01 opened this issue 1 year ago • 53 comments

I am starting work on replace GCC change "0011-Enable-shared-gnat-implib.patch"

Edit: This thread is an attempt to avoid two people working on a solution at the same time.

Reason: Enabling GCC Ada and GCC Plugin support with this patch exceeds memory size supported.

I know of no reason for GCC Plugin support to be used under MinGW; so, this will be a very back burner project.

If anyone knows of an GCC plugin that is useful under MinGW please link to it in this thread.

If anyone knows how to test my future replacement changes of "0011-Enable-shared-gnat-implib.patch"; please post them also in this thread.

I am going to go with two patch files and two def files as my default long term solution. The hard work will be figuring out what goes into the two def files.

Tim S.

stahta01 avatar Aug 21 '22 16:08 stahta01

dragonegg maybe ? would be a nice one to have :)

revelator avatar Aug 22 '22 11:08 revelator

I see no sign that dragonegg ever worked under MinGW GCC.

Tim S.

stahta01 avatar Aug 22 '22 12:08 stahta01

it did once i worked together with one of the mingw-w64 devs way back on it and we managed to port it, sadly it newer made it into the public as such because using the plugin was rather irksome on windows :/

revelator avatar Aug 22 '22 12:08 revelator

Okay, nice to know; but, I would prefer a plugin that is know to work when trying to get our GCC to support plugins once more.

Tim S.

stahta01 avatar Aug 22 '22 12:08 stahta01

understandable not even sure if our port works with later versions of gcc as development on dragonegg halted around gcc-4.8... strangely gcc-9 had working plugin support but later versions seems to grouch on ordinals being to large.

revelator avatar Aug 22 '22 12:08 revelator

understandable not even sure if our port works with later versions of gcc as development on dragonegg halted around gcc-4.8... strangely gcc-9 had working plugin support but later versions seems to grouch on ordinals being to large.

That is because MinGW is second class and it uses export all symbols instead of just the needed symbols; my current testing is not show progress. But, I hope if I create enough def files to export a sub-set of symbols the ordinals will no longer be to large. I had one test run that implied even without Ada being enable the number of ordinals was over 64K which I think is the max allowed before it error out. I just disable Ada support to confirm the issue still exists.

Tim S.

stahta01 avatar Aug 22 '22 12:08 stahta01

I have decide to use the GCC plugin "ODB: C++ Object-Relational Mapping (ORM)" for testing my changes. I still have to get GCC to compile with gcc plugin enabled; I may have to revert back to GCC version 9/8/7 to get that to work and proceed to later versions once I get a version that used to work building and running.

Edit: My computer is extra slow today; it is still building GCC 12.x.y

Tim S.

stahta01 avatar Aug 22 '22 13:08 stahta01

sounds like a worthy goal :) maybe we can even get lucky and get the gcc-xml plugin working.

revelator avatar Aug 22 '22 13:08 revelator

Turns out 12.1.1 builds with gcc plugin enabled and without Ada support.

Tim S.

stahta01 avatar Aug 22 '22 15:08 stahta01

understandable not even sure if our port works with later versions of gcc as development on dragonegg halted around gcc-4.8... strangely gcc-9 had working plugin support but later versions seems to grouch on ordinals being to large.

That is because MinGW is second class and it uses export all symbols instead of just the needed symbols; my current testing is not show progress. But, I hope if I create enough def files to export a sub-set of symbols the ordinals will no longer be to large. I had one test run that implied even without Ada being enable the number of ordinals was over 64K which I think is the max allowed before it error out. I just disable Ada support to confirm the issue still exists.

Tim S.

FWIW LLVM has recently gained support to use symbol visibility on Windows: https://reviews.llvm.org/D130121 (essentially this maps __attribute__((visibility("X"))) to decide whether DLLEXPORT symbol or not). Sounds like implementing it in GCC could be helpful for this.

mati865 avatar Aug 22 '22 17:08 mati865

that might indeed help :)

so plugins build again in gcc-12.1.1 Oo was not aware of that but cool :)

revelator avatar Aug 22 '22 18:08 revelator

I had to comment out a lot of configure options that was needed back in GCC 8 and 9 to get it to build with GCC plugin support. It might have run-time issues.

stahta01 avatar Aug 22 '22 20:08 stahta01

ouch :S

revelator avatar Aug 24 '22 07:08 revelator

I am now building gcc11-git package and seeing what error I get; if it works I will try to use the same type of changes in gcc12-git. GCC git master was broken a week or so back by adding things that are not defined under MinGW CRT headers. I am expecting errors; but, I do not remember ever trying this exact GCC configuration. Edit: It takes several hours on my Win10 PC to build GCC. So, takes a lot of time to test ideas. Edit2: Decided to see if I can get D lang. support to build using GCC 11 since it needs D Lang. to build D Lang. starting with GCC 12. Going to try that in the future if I can not make progress on GCC Ada with GCC Plugin problem.

Tim S.

stahta01 avatar Aug 25 '22 20:08 stahta01

could leave out the bootstrap step if testing, should make things a little faster :)

revelator avatar Aug 25 '22 21:08 revelator

D lang would be great but i think it will be pretty hard porting it, quite a lot of changes nessesary and from what i could glean you need a patched version of libphobos replacing the one that comes with gcc. If you manage it ill salute you :)

revelator avatar Aug 25 '22 21:08 revelator

could leave out the bootstrap step if testing, should make things a little faster :)

I am doing that already using MinGW64 for testing. I have decided to try using older version of GCC if I can get that to work in the next three days. I have tried to get Ada to build on older versions of GCC and always failed. After it fails this time, I will work on getting GCC Plugin to work using GCC 12 without Ada. If I can not get that to work will likely give up on getting GCC Plugin to work; but, if I get it to work will go bad to getting Ada and GCC 12 Plugin to work together.

NOTE: UCRT64 does not like non bootstrap builds. Not tried MinGW32 lately; but, it used to work okay.

Tim S.

stahta01 avatar Aug 26 '22 19:08 stahta01

D lang would be great but i think it will be pretty hard porting it, quite a lot of changes nessesary and from what i could glean you need a patched version of libphobos replacing the one that comes with gcc. If you manage it ill salute you :)

Then, sounds like D Lang is too much for me to try at present. Tim S.

stahta01 avatar Aug 26 '22 19:08 stahta01

you need an older binutils as well if trying with an older gcc model, the new version goes bonkers with the old dwarf2 exception model found that out the hard way :S

revelator avatar Aug 26 '22 19:08 revelator

to bad about Dlang but yeah will probably be to hard for one man, sadly im not fluent in D programming though i do know its creator :)

revelator avatar Aug 26 '22 20:08 revelator

Found directions on how to do an Ada GCC plugin: Ada directions. I plan to use GCC 8 git branch and after I get that to work will try GCC 9 or 12 git branch.

GCC 8 was reported on the Internet as the first time MinGW GCC Plugins worked.

So, I hope all I need to do is port the Ada GCC plugin directions to MinGW. I already have gotten GCC Ada version 8 to build.

Tim S.

stahta01 avatar Sep 09 '22 12:09 stahta01

nice :)

revelator avatar Sep 09 '22 12:09 revelator

interresting about clang in that article though a few pitfalls i noticed early on if using that approach, ada is a nogo since you need a working ada compiler to bootstrap gnat (no exceptions i know of). i can allready bootstrap gcc itself with clang if i leave out ada, not sure if it nets any benefits besides better error checking in the bootstrap. gnat is pretty cool but does not seem to be used a lot on windows :/ and gtkada seems to be broken atleast i could newer get it working maybe due to lacking the correct opengl output library which seems to be patched out in our version but should really be changed to link to libopengl32.a instead of libgl.a. it does build if doing that but im still having problems getting the gui up.

revelator avatar Sep 09 '22 12:09 revelator

Edit: I started with gcc-ada for version 10 I found in my local package folder. I have already reversed boot strap Ada down to GCC 6; I am working on trying to install the GCC to /opt subfolders and that is failing; will try to install to /opt for a few hours. If it fails will revert back to normal /mingw64 like install locations. One of my long term projects is to revert bootstrap Ada to GCC 4.6. I will see if gtkada works for me at some future time. I remember installing it; but, I have no idea why I installed it.

stahta01 avatar Sep 09 '22 13:09 stahta01

on my personal build i use /usr/local for the crosscompiler :) so far without any problems though at some point i feared it might collide with the real mingw compilers it has not been so fortunatly.

my own problems bootstrapping gnat with clang/gcc was mostly down to clang having no notion of ada at all while gcc can atleast redirect ada input to the correct compiler clang has no mechanism to do this yet.

revelator avatar Sep 09 '22 15:09 revelator

So, it is clang64/32 that is having the problem; I did not understand that. I am not really doing an GCC cross-compiler; just an local GCC with a different major version. Are you trying to make "mingw-w64-clang-x86_64-gcc-ada" package? That is what I would try in order to make progress on an clang Ada. Edit: I might use mingw-w64-ucrt-x86_64-gcc-ada because that is likely closer to clang CRT. Edit2: Looks like "mingw-w64-clang-x86_64-gcc" is just a wrapper around clang; so, my idea was not a good one. Edit3: Found gnat-llvm; but, the Makefile looks like it needs a complete re-write to work with msys2/clang64/ucrt64.

Tim S.

stahta01 avatar Sep 09 '22 19:09 stahta01

aye that was my intent :) though so far no luck.

revelator avatar Sep 10 '22 04:09 revelator

gnat-llvm tried this some years back and yeah though they provide instructions for a windows build i suspect it to be for msvc :S cause following it to the letter with gcc fails.

revelator avatar Sep 10 '22 04:09 revelator

i have a ready to use bootstrap compiler based on gcc-11.3.0 if you need one ?, it uses static libgmp isl mpfr mpc zlib winpthreads and zstd so does not rely on any externals.

revelator avatar Sep 10 '22 05:09 revelator

i have a ready to use bootstrap compiler based on gcc-11.3.0 if you need one ?, it uses static libgmp isl mpfr mpc zlib winpthreads and zstd so does not rely on any externals.

I have no need for it.

Tim S.

stahta01 avatar Sep 10 '22 13:09 stahta01