Jump to content
IGNORED

C compilers?


zezba9000

Recommended Posts

On 9/5/2019 at 10:14 AM, SCPCD said:

Hi !

 

I'm currently working on an C app with multiple files and I'm using "m68k-atari-mint-gcc".

It works great, but after adding some more variables, I got an issue where a variable in BSS segment are not aligned with what I need :

 

When using gcc, all variable are aligned in word boundaries, but for specific ones, I need those to be longword aligned.

I tried to add " __attribute__((aligned(4)))" to have something as "u8_t toto[1024]  __attribute__((aligned(4)))" but at build time gcc give me the warning "warning: alignment of 'toto' is greater than maximum object file alignment.  Using 2 [enabled by default]" and finally the variable is not aligned to a longword.

 

Why gcc don't take account of the attribute and how to resolve the issue ?

 

Thanks

 

 

You align arrays in gcc (m68k) like this

 

unsigned char __attribute__((aligned(16))) rom_hdr[256];

 

This has always worked fine for me.

 

  • Like 2
Link to comment
Share on other sites

  • 4 months later...

There's something wrong with my linker setup? I've some weird issues, I have an assert to check if I call to build the sprite list several times in a frame (sort of), the flag it's defined as static int16_t _building = 0; (It's data or bss?) but if I write a couple lines of code (actually two in a particle system) the assert it's triggered at the start of the execution(The init code builds an empty sprite list) !!!! WTF!? 

 

Or maybe there's something wrong/mismatch with the compiler flags for the game and the library?

	ENTRY(_start)

	MEMORY {
	       rom (rx) : org = 0x802000, len = 2M-0x2000
	       ram (rx) : org = 0x004000, len = 2M-0x4000
	}

	stack_top = ORIGIN(ram)-4;
	_end = ADDR(.heap);

	SECTIONS {
	   .text : {
	      KEEP(*(.init))
	      *boot.o(.init)
	      *.o(.text)
	      . = ALIGN(4);
	     /* needed for cstartup */
	      __section_init = .;
	   } > ram

	   .data ALIGN(8) : {
	      *(.data)
	      . = ALIGN(8);
	   } > ram

	   .bss ALIGN(8) : {
	      *(.bss)
	      . = ALIGN(8);
	   } > ram

	   .heap ALIGN(32) : {
	   } > ram
	}

 

Edited by swapd0
Link to comment
Share on other sites

I've been looking at the makefiles and I think that it's the -flto flag (link time optimization)(again...), I removed it from the library and from Classic Kong long time ago, but this game it's using it...

 

Copy&paste bug :D

Edited by swapd0
Link to comment
Share on other sites

-flto is such a pain. Because of that I doubt rln will ever fully support linking with ELF objects. I mean, we can add ELF object files easily but if people link against any gcc compiled library which is compiled with -flto then who knows how much work it would need. My estimation is that we essentially would be rewriting ld, including bugs and undocumented stuff.

Link to comment
Share on other sites

  • 5 months later...
  • 4 weeks later...
On 11/28/2018 at 6:29 PM, ggn said:

Also I totally forgot I have packaged up gcc 8.2 for macs (built on El Capitan) here: http://d-bug.mooo.com/various/brownart.tar.bz2. So worst case you could give this a shot!

IIRC I've this version installed with a very strip down version of the C libraries, and if I've a float in the sources I get a lot of linker errors (undefined references to ___addsf3, ___muldf3, etc), where can I find the source of the floating point library?

 

I know that floating point it's very slow but it's better to have project running and then make changes to remove the floating point part.

 

Link to comment
Share on other sites

Oh, floats. Well, in the past I've used https://github.com/ggnkua/pml-bigbrownbuild which is still not built using the build script. I think this repo is kind of patched up to work with newer gas format.

 

If memory serves correct, just get this repo, cd to 'pmlsrc', edit 'Makefile.16' and 'Makefile.32' to the right paths. Then type 'make -f Makefile.16', copy the .a file somewhere, then 'make -f Makefile.32'. I cannot remember which of the two I used in the past but at least one should work.

  • Like 1
Link to comment
Share on other sites

Compiled but I still have the same errors, I've tried both libraries, I've seen that the library defines functions like cadd and cmult but I got undefined references to ___addsf3, ___multdf3, etc At least the cos, sin, round, errors are fixed.

 

 

Edited by swapd0
Link to comment
Share on other sites

  • 1 year later...

I'm trying to compile some cpp code but I got liker errors, it works fine with C code.

 

This is the code, if I don't alloc X into the heap it works, but fails with the new operator.

class X
{
public:
    int a;
    int b;
};

int main(int argc, char **argv)
{
    X *x = new X;
    x->a = 100;
    return 0;
}

And here the weird link error. Where is _Znwm defined?

 

m68k-ataribrownart-elf-g++ -c -m68000 -Ofast -fomit-frame-pointer -fstrict-aliasing -fno-zero-initialized-in-bss -fcaller-saves -flto -ffunction-sections -fdata-sections -fleading-underscore -D__JAGUAR__ -D__M68000__ -Wall -o obj/main.o main.cpp
m68k-ataribrownart-elf-g++ -L/opt/local/bin/gcc68k/m68k-ataribrownart-elf/lib/m68000 -L/Users/Shared/apps/Jaguar/projects/lib -o out.elf  /opt/local/bin/gcc68k/lib/libcxx-jaguar/boot.o /opt/local/bin/gcc68k/lib/libcxx-jaguar/brownboot.o /opt/local/bin/gcc68k/lib/libcxx-jaguar/browncrti.o /opt/local/bin/gcc68k/lib/libcxx-jaguar/browncrt++.o /opt/local/bin/gcc68k/lib/libcxx-jaguar/zerolibc.o /opt/local/bin/gcc68k/lib/libcxx-jaguar/zerocrtfini.o /opt/local/bin/gcc68k/lib/libcxx-jaguar/vsnprint.o /opt/local/bin/gcc68k/lib/libcxx-jaguar/tinyalloc.o /opt/local/bin/gcc68k/lib/libcxx-jaguar/skunk.o \
	obj/main.o obj/gpu.o -lkatu -nostartfiles -nostdlib -Wl,-T,jag.ld,-Map,out.map -m68000 -Ofast -fomit-frame-pointer -fstrict-aliasing -fno-zero-initialized-in-bss -fcaller-saves -flto -ffunction-sections -fdata-sections -fleading-underscore  /opt/local/bin/gcc68k/lib/libcxx-jaguar/browncrtn.o
/var/folders/2g/phns652128s1650l3ck_1xbc0000gn/T//ccsrY2mK.ltrans0.ltrans.o: In function `_main':
<artificial>:(.text.startup.main+0x6): undefined reference to `__Znwm'
collect2: error: ld returned 1 exit status
make: *** [out.elf] Error 1

 

I used a modified version of the files found here.

https://github.com/ggnkua/bigbrownbuild-git/tree/master/barebones

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...