Page 1 of 2

[SGDK] limit on the number of files?

Posted: Wed Jun 20, 2012 1:40 am
by djcouchycouch
Hi,

I think I'm hitting some kind of file-related limit when trying to build with SGDK. Compiling about 80 files (.c and .h) is fine but adding any more pops up a dialog to debug a sh.exe crash. I don't know if it's the number of files the problem or simply the length of the command line.

It's happening during this line in makefile.gen:

Code: Select all

out/rom.out: out/sega.o $(OBJS) $(LIB)/libmd.a
	$(MKDIR) -p out
	$(CC) -T $(GDK)/md.ld -nostdlib out/sega.o $(OBJS) $(LIB)/libmd.a $(LIB)/libgcc.a -o out/rom.out
And I'm running this command line. Yes, it's long:

Code: Select all

C:/Dropbox/SegaGenesisDevelopment/sgdk091/bin/gcc -T C:/Dropbox/SegaGenesisDevelopment/sgdk091/md.ld -nostdlib out/sega.o out/resource.o out/AfterburnerChargeUp.o out/BreakableRock4x4.o out/Bullet.o out/Coin.o out/CoinSparkle.o out/Collisions.o out/Debug.o out/Door.o out/EnemyBullet.o out/EnemyPlane.o out/Explosion.o out/Fireball.o out/FireballPickup.o out/FunctionStubs.o out/Game.o out/GameFont.o out/GrassTileSetData.o out/HUD.o out/LargeExplosion.o out/Level.o out/Level001Section001.o out/Level001Section002.o out/Level001Section002Spawns.o out/Level001Section003.o out/LevelDefinitions.o out/MathUtils.o out/Objects.o out/Physics.o out/Player.o out/PlayerPhysics.o out/Poof.o out/SimpleEffect.o out/SpritesAndMaps.o out/VDP_Extra.o out/long128x64map.o out/main.o out/smallmap2.o out/smallmap_background.o out/smallmap_objects.o C:/Dropbox/SegaGenesisDevelopment/sgdk091/lib/libmd.a C:/Dropbox/SegaGenesisDevelopment/sgdk091/lib/libgcc.a -o out/rom.out
However, running the above command line manually outside of makefile.gen works. So could it be the makefile system?

I imagine if I consolidated the code into fewer files it'll work but it'll offend my one-file-per-object sensibilities :) And I might hit the limit again anyway.

Any idea how I can make this work?

Thanks!
DJCC

Posted: Wed Jun 20, 2012 1:47 am
by sega16
To me it sounds like you are running out of ram I have had issues similar to this closing all programs except the ide fixed it in my case try building your program and watch the ram usage in task manager.

Posted: Wed Jun 20, 2012 1:59 am
by Chilly Willy
Try putting the sdk in the drive root instead of a dozen directories deep and see if it's a line length problem.

Posted: Wed Jun 20, 2012 8:39 am
by Stef
Maybe this is related to the sh.exe shell which has strictly limited command line... Unfortunately i think the bundled version of sh.exe is not that outdated and a more recent version won't necessary fix the problem.

Posted: Wed Jun 20, 2012 2:02 pm
by djcouchycouch
Chilly Willy wrote:Try putting the sdk in the drive root instead of a dozen directories deep and see if it's a line length problem.
I'll test that tonight. And it's only a half dozen directories deep :) It'll mitigate the problem but I might hit it again later.
sega16 wrote:To me it sounds like you are running out of ram I have had issues similar to this closing all programs except the ide fixed it in my case try building your program and watch the ram usage in task manager.
I checked and there wasn't anything out of the ordinary for ram usage.
Stef wrote:Maybe this is related to the sh.exe shell which has strictly limited command line... Unfortunately i think the bundled version of sh.exe is not that outdated and a more recent version won't necessary fix the problem.
I forget the name for it but I seem to remember gcc having a feature where instead of passing a list of files in the command line, you could put that list in a text file and have gcc load that instead, shortening the command line length. Did I imagine that?

Posted: Wed Jun 20, 2012 5:32 pm
by Stef
djcouchycouch wrote: I forget the name for it but I seem to remember gcc having a feature where instead of passing a list of files in the command line, you could put that list in a text file and have gcc load that instead, shortening the command line length. Did I imagine that?
Hmm that might help indeed but i can't find any reference to that option... i'm afraid you just dream it :-/
You could try different version of sh.exe file, with luck you may find a better than current one.

Posted: Wed Jun 20, 2012 5:43 pm
by djcouchycouch
Found it. They're called response files.

http://gcc.gnu.org/wiki/Response_Files

Posted: Wed Jun 20, 2012 8:04 pm
by TmEE co.(TM)
Most of my tools work off such files :P

Posted: Wed Jun 20, 2012 8:09 pm
by Stef
djcouchycouch wrote:Found it. They're called response files.

http://gcc.gnu.org/wiki/Response_Files
Never heard about that but i just added it in SGDK and it works perfectly ! Thanks =)

Posted: Wed Jun 20, 2012 9:02 pm
by djcouchycouch
Stef wrote:
djcouchycouch wrote:Found it. They're called response files.

http://gcc.gnu.org/wiki/Response_Files
Never heard about that but i just added it in SGDK and it works perfectly ! Thanks =)
Great! You're going to have to share your fix :)

Posted: Thu Jun 21, 2012 7:58 am
by Stef
djcouchycouch wrote:
Stef wrote:
djcouchycouch wrote:Found it. They're called response files.

http://gcc.gnu.org/wiki/Response_Files
Never heard about that but i just added it in SGDK and it works perfectly ! Thanks =)
Great! You're going to have to share your fix :)
Very simple, i use an intermediate build step to build the command file with "echo" command :) I will put the listening when I will be back to home (currently at job).

Posted: Sat Jun 23, 2012 1:56 pm
by djcouchycouch
Stef wrote:Very simple, i use an intermediate build step to build the command file with "echo" command :) I will put the listening when I will be back to home (currently at job).
Will you be posting it soon? Between your fix and something I'd come up with on my own, I'd prefer yours as it'll be the one released in the SGDK.

EDIT:

I convinced my lazy butt to actually look at the potential solution, and yeah, it was pretty simple. I switched the original code (as shown in my original post) to this:

Code: Select all

out/rom.out: out/sega.o $(OBJS) $(LIB)/libmd.a
	$(MKDIR) -p out
	@echo "$(OBJS)" > out/objects.txt
	$(CC) -T $(GDK)/md.ld -nostdlib out/sega.o @out/objects.txt $(LIB)/libmd.a $(LIB)/libgcc.a -o out/rom.out
Works like a charm.

Posted: Sat Jun 23, 2012 2:42 pm
by Stef
djcouchycouch wrote:
Stef wrote:Very simple, i use an intermediate build step to build the command file with "echo" command :) I will put the listening when I will be back to home (currently at job).
Will you be posting it soon? Between your fix and something I'd come up with on my own, I'd prefer yours as it'll be the one released in the SGDK.

EDIT:

I convinced my lazy butt to actually look at the potential solution, and yeah, it was pretty simple. I switched the original code (as shown in my original post) to this:

Code: Select all

out/rom.out: out/sega.o $(OBJS) $(LIB)/libmd.a
	$(MKDIR) -p out
	@echo "$(OBJS)" > out/objects.txt
	$(CC) -T $(GDK)/md.ld -nostdlib out/sega.o @out/objects.txt $(LIB)/libmd.a $(LIB)/libgcc.a -o out/rom.out
Works like a charm.
Err sorry i did know i was forgetting something :p

Here's what i used but the solution is similar :

Code: Select all

out/rom.out: out/cmd_
	$(CC) @out/cmd_
	$(RM) out/cmd_

out/cmd_: out/sega.o $(OBJS) $(LIB)/libmd.a
	$(ECHO) -n -T $(GDK)/md.ld -nostdlib out/sega.o $(OBJS) $(LIB)/libmd.a $(LIB)/libgcc.a -o out/rom.out > out/cmd_

Posted: Sat Jun 23, 2012 2:43 pm
by Stef
i actually even prefer your version as only objs file take place ;)

Posted: Wed Oct 02, 2013 3:13 pm
by Moon-Watcher
I recently found this problem in my actual project in last SGDK</unuseful_reply> :P

- Edit:
Somebody move to the SGDK subforum, please