freemint / m68k-atari-mint-gcc

Fork of GNU's gcc with support for the m68k-atari-mint target
https://github.com/freemint/m68k-atari-mint-gcc/wiki
Other
26 stars 7 forks source link

Should we remove -DNO_ASM from GMP/MPFR for native builds? #45

Open mikrosk opened 5 months ago

mikrosk commented 5 months ago

Makefile.def / Makefile.in explicitly disable compiling in any assembly notifications: https://github.com/freemint/m68k-atari-mint-gcc/blob/772057988f53c00c90b897a58bcba1d941efabe7/Makefile.def#L51-L65 Both mpfr and gmp have a few bits of m68k asm code available (gmp even specifically for 020+ CPUs).

I'm torn on this one. On one hand, native m68k executables can use every spare CPU cycle available, on othe ther hand there may be a risk that something goes wrong as those are disabled by default and therefore not that much tested.

Also, there's a bit of work required as our config.sub handling doesn't differentiate between 68000, 68020+ and m5475 CPUs (it's always just "m68k").

There is even a bug in gcc7: passing "none-atari-mint" from gcc to gmp (gcc's way to tell gmp to disable CPU optimisations) doesn't work as expected (it is still evaluated as "m68k-atari-mint"), therefore the CPU is detected as "m68k" and therefore it adds -m68000 to the command line even when compiling ColdFire, silently producing a wrong library. Fortunately our official gcc-7.5.0 release (and executables) doesn't suffer from it, I had --disable-assembly patched in explicitly.

th-otto commented 5 months ago

Those flags are only used when you have explicitly setup to compile in-tree versions of gmp & mpfr.. Did you do that in your scripts?

Also, the libraries compiled this way are only used by the compiler, they are not installed, so it doesn't matter much whether they use assembly versions or not.

Generally, it would be simpler just to use precompiled versions, that would also avoid quirks like compiling the coldfire version with wrong flags.

mikrosk commented 5 months ago

Did you do that in your scripts?

Indeed. ./contrib/download_prerequisites is my favourite way of installing gmp/mpfr/mpc.

they are not installed, so it doesn't matter much whether they use assembly versions or not.

Well, they are linked to the final gcc executable, which hopefully results in a faster compilation or whatever they are used for.

avoid quirks like compiling the coldfire version with wrong flags

True but then you depend on the flags used by the packager.

th-otto commented 5 months ago

whatever they are used for.

If i'm not wrong they are mainly used to convert floating point constants.

True but then you depend on the flags used by the packager.

Why? If you don't use intree versions of them, it will just use already installed versions. If that would not work, it would also use wrong versions of mintlib and fdlibm.

mikrosk commented 5 months ago

If that would not work, it would also use wrong versions of mintlib and fdlibm.

But that's not the question here. The question is usage of optimised libgmp/libmpfr. So when the packager decides to ship them without the asm optimisations, you can't do anything about it. In-tree gmp/mpfr is more flexible in this matter.

th-otto commented 5 months ago

Yes, ok. Given that i was recently wrong with my assumption that --enable-checking does not make much difference, i guess the only way to tell whether a gmp library with/without NO_ASM makes a difference, is to build both versions, then doing some runtime tests.