bebbo / gcc

Bebbo's gcc-6-branch for m68k-amigaos
GNU General Public License v2.0
33 stars 11 forks source link

graphics.library is been pulled for (seemingly) no reason #184

Closed alexalkis closed 2 years ago

alexalkis commented 2 years ago

graphlib.zip

So, if you do

m68k-amigaos-gcc -mcrt=nix13 -s -Os -o ami13 -Wall cg.c decl.c expr.c gen.c main.c misc.c opt.c scan.c stmt.c sym.c tree.c types.c
m68k-amigaos-gcc -noixemul -s -Os -o ami20 -Wall cg.c decl.c expr.c gen.c main.c misc.c opt.c scan.c stmt.c sym.c tree.c types.c
m68k-amigaos-gcc -mcrt=nix13 -s -Os -o hello hello.c

and you run the executables through vamos, you get:

alex[0]@ubvm bug$ vamos hello
Hello world
alex[0]@ubvm bug$ vamos ami13
graphics.library failed to load
alex[20]@ubvm bug$ vamos ami20
graphics.library failed to load

Something triggers the inclusion of graphics.library which is not needed.

bebbo commented 2 years ago

please try to find such things yourself. Hints:

In your case it's

      type = type_of_typedef(Text, ctype); 

which refers to the graphics function Text. It's not enough to define something extern:

extern_ char Text[TEXTLEN + 1];          // Last identifier scanned

The variable must be instantiated somewhere.

bebbo commented 2 years ago

tip of the day: Don't use variables and functions starting with an uppercase to avoid overlap with AmigaOS stuff.

alexalkis commented 2 years ago

It's instantiated in main.

#include "defs.h"
#define extern_
#include "data.h"
#undef extern_
#include "decl.h"
#include <errno.h>
#include <unistd.h>
bebbo commented 2 years ago

It's instantiated in main.

#include "defs.h"
#define extern_
#include "data.h"
#undef extern_
#include "decl.h"
#include <errno.h>
#include <unistd.h>

No, it isn't. You need some initialization. Only declared:

int x;

Instantiated:

int x = 0;
alexalkis commented 2 years ago

I thought globals are instantianted if declared, but I guess that conflicts with the global library trick that the amiga toolchains needs, huh?

bebbo commented 2 years ago

Not initialized variables end up as common symbols. If a common symbol is not resolved it ends up in bss. In this case it gets resolved since _Text is defined in libamiga.a which then requests GfxBase.

alexalkis commented 2 years ago

Ok, thanks and sorry for the trouble :)