Thread overview
How to get DMD to stop littering my source dir with .o files?
Oct 26, 2015
Shriramana Sharma
Oct 26, 2015
Andrea Fontana
Oct 26, 2015
Cauterite
October 26, 2015
The subject line says it all. Every time I compile a D file to an executable I get an unwanted .o file and have to manually clean up things. I'm using DMD 2.0.68.2.

-of doesn't help, and my God, it doesn't even allow a space or equal sign between itself and the desired name of the output file making the commandline all the more horrible to read.

-o- is totally misleadingly labeled "Suppress generation of object file" – when all it suppresses is the generation of the executable file but it still produces the .o file.

With GCC or Clang I'm able to do clang -o exec exec.c and there's no exec.o littering my directly. I am not expert enough to submit a PR for the compiler while I have attempted some for Phobos. Is there already some way to avoid the .o files or shall I submit a bug request for it?

In the meanwhile, can someone please give the CLI syntax some love? Comparing to standard compilers like GCC and Clang, the totally strange syntax puts one off... Again, I'm not expert enough to do a PR for DMD.

-- 
Shriramana Sharma, Penguin #395953
October 26, 2015
On Monday, 26 October 2015 at 11:55:48 UTC, Shriramana Sharma wrote:
> The subject line says it all. Every time I compile a D file to an executable I get an unwanted .o file and have to manually clean up things. I'm using DMD 2.0.68.2.

Do you mean:
 -odobjdir      write object & library files to directory objdir

?
October 26, 2015
The problem is that the compiler and linker are separate programs; the compiler has to generate input for the linker in the form of a file.

RDMD automatically cleans up all the .obj garbage, so one solution is to run
	rdmd --build-only asdf.d

Also, the -of flag is a little more readable if you use quotes
	dmd -of"asdf.exe" asdf.d
Yeah, it's totally inconsistent with other flag syntax like -deps=filename

On Monday, 26 October 2015 at 11:55:48 UTC, Shriramana Sharma wrote:
> The subject line says it all. Every time I compile a D file to an executable I get an unwanted .o file and have to manually clean up things.