Command line has become too large
Command line has become too large
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?
Re:Command line has become too large
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
INPUT(file1.o file2.o)
Voil?
Candamir
PS: I hope this was your problem ;D
- Combuster
- 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
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
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
- Pype.Clicker
- 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
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...
Re:Command line has become too large
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
How do you do it in the linker script? Can you give an example?
Thanks,
-Stephen
Re:Command line has become too large
Oh good call, I swear when I tried that earlier it refused it. Oh well it's all working nicely now. ThankyPype.Clicker wrote: another option would be simply to use something like "build/*.o" in the command line, no?
Re:Command line has become too large
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):
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).
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).
- Pype.Clicker
- 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
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.Schol-R-LEA wrote: Actually, I would say that using a makefile would be a more general solution that a linker script
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?
Re:Command line has become too large
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.