Command line has become too large

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
elaverick

Command line has become too large

Post by elaverick »

I'm using batch files at the moment to build my kernel however I've run into a slight problem in that my ld-elf statment has become too long to process... can you do the link in multiple steps to spread it over additional lines or is there a better solution?
Candamir

Re:Command line has become too large

Post by Candamir »

If you're using a linker script (I hope so), then just declare the input files inside the linker script:

INPUT(file1.o file2.o)

Voil?

Candamir

PS: I hope this was your problem ;D
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re:Command line has become too large

Post by Combuster »

You can also link in steps, using ld's -r option, sort of like this:

ld -r -o stage1.o file1.o
ld -r -o stage2.o file2.o stage1.o
ld -r -o stage3.o file3.o stage2.o
ld -o kernel.bin stage3.o
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Command line has become too large

Post by Pype.Clicker »

another option would be simply to use something like "build/*.o" in the command line, no? Depending on your shell environment variables, you might also need to tell the shell not to expand the patterns itself, but instead leave that to the app...
srg_13

Re:Command line has become too large

Post by srg_13 »

I had the same problem... I can't make any more C files at the moment until I fix this.

How do you do it in the linker script? Can you give an example?

Thanks,

-Stephen
elaverick

Re:Command line has become too large

Post by elaverick »

Pype.Clicker wrote: another option would be simply to use something like "build/*.o" in the command line, no?
Oh good call, I swear when I tried that earlier it refused it. Oh well it's all working nicely now. Thanky :)
Schol-R-LEA

Re:Command line has become too large

Post by Schol-R-LEA »

Actually, I would say that using a makefile would be a more general solution that a linker script, though there's no reason I know of why you couldn't do both (except simplicity). This would allow you to handle compiling, dependency checking, update checking, linking, and temporary file removal all at once.

For comparison, here's a makefile (for GBU make) which I used for building my test boot loader (file paths removed to protect the guilty):

Code: Select all

ASM = nasm -f bin
COPY = partcopy
RUN = bochs

boot.img: verbum.bin stagetwo.bin
   $(COPY) verbum.bin 0 200 boot.img 0
   $(COPY) stagetwo.bin 0 200  boot.img 200
   $(RUN)

verbum.bin:
   $(ASM) verbum.asm -o verbum.bin

stagetwo.bin:
   $(ASM) stagetwo.asm -o stagetwo.bin

Mind you, it doesn't necessarily have to be GNU make which you use, though that one is probably the simplest solution due to it's ubiquity; any other project management system should do as well, provided it supports at least the basic features mentioned above (and isn't language specific, like ANT is).
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Command line has become too large

Post by Pype.Clicker »

Schol-R-LEA wrote: Actually, I would say that using a makefile would be a more general solution that a linker script
Erhm, sorry, schol-r-lea, but i fail to see how the makefile could help when the shell starts thinking your "ld <options> aaa.o aab.o aac.o .... zzz.o" command line is getting too long ... even if there's some implicit/explicit rule to do the linking stage.

Oh, true, back in time with DJGPP, using the same command within MAKE could work while it didn't work in DOS prompt, because MAKE was using its own 32bit shell rather than reusing COMMAND.COM and that the internal(?) 32-bit shell was accepting a larger command (i think it's only 256 chars. with COMMAND.COM).

but still, that was almost 8 years ago. With everyone using cygwin now, do we still have cases where the cygwin shell cannot deal with a LD command line that make will chomp happily?
B.E

Re:Command line has become too large

Post by B.E »

You could just use an makefile in each directory that increasemental links everything in that directory to a single file and then in you make file link them files to an exe or bin file.
Post Reply