bebbo / amiga-gcc

The GNU C-Compiler with Binutils and other useful tools for cross development for Amiga
GNU General Public License v2.0
312 stars 66 forks source link

std::abs(int) requires mathieeedoubbas.library #315

Closed claudeha closed 1 year ago

claudeha commented 1 year ago

Many thanks for your work on amiga-gcc.

I'm targetting 68000 without FPU (currently 2.04, possibly 1.3 later) and aiming for minimal dependencies. This short program requires mathieeedoubbas.library for some reason I don't understand:

#include <cmath>

int main(int argc, char **argv)
{
  (void) argv;
  return std::abs(argc);
}

Writing my own abs replacement with x < 0 ? -x : x works fine without needing the library (INT_MIN is an edge case that I don't really care about in my situation).

I check needed libraries by strings ./binary | grep library.

bebbo commented 1 year ago

Many thanks for your work on amiga-gcc.

I'm targetting 68000 without FPU (currently 2.04, possibly 1.3 later) and aiming for minimal dependencies.

Then don't use c++, or at least don't use std:: ... this pulls in a ton of dependencies... ... and use -noixemul the default newlib also is not minimal.

__gnu_cxx::__enable_if<std::__is_integer<int>::__value, double>::__type std::abs<int>(int)

uses ___floatsidf which needs tha math lib^^

claudeha commented 1 year ago

Don't worry, the only std I'm using are abs calloc fopen free fseek fwrite malloc max memset min and I should be able to replace the FILE with dos.library calls, the memory with exec.library calls, and the rest are easy.