[Issue 12116] dmd -op -od broken

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jan 7 20:05:11 PST 2017


https://issues.dlang.org/show_bug.cgi?id=12116

--- Comment #5 from Timothee Cour <timothee.cour2 at gmail.com> ---
Expected behavior:

* dmd -h | grep '\-od' should be accurate (currently: "write object & library
files to directory" is not true when source path is absolute or contains ..;
but would be under my proposed points below)

* `rdmd -c ` should place .o/.a files in same place as `dmd -c` (not the case
currently)

* dmd -op (path with ..)/fun.d should be an error: it's dangerous and
unexpected to have something writing BELOW dir when user gives '-od=mydir'. But
this won't restrict any use case, see below.

* `dmd` should be equivalent to `dmd -od=.`

* dmd -od=mydir -op /absolute_path/fun.d should write to:
mydir/absolute_path/fun.o (eg: -od=/tmp/ => /tmp/absolute_path/fun.o)

this behavior is useful when users don't want to pollute a source repository
with .o files, or when they want to keep multiple cached versions of object
files (eg for different compilation options): the current behavior
(/absolute_path/fun.o) won't allow that.

* Also introduce an optional value for -op=dir (multiple are possible, eg:
-op=mydir1 -op=mydir2) to make paths be relative to the first (if any)
directory where the absolute path is found:

dmd -c -od=/tmp/ -op=/absolute_path/ -op=import/ /absolute_path/std/fun.d
import/core/bar.d source/core/bar.d
/tmp/std/fun.o (thanks to -op=/absolute_path/)
/tmp/core/bar.o (thanks to -op=import/)
/tmp/source/core/bar.o (no match inside -op=)

There is a value to both -oq and -op (with the above fixes):
-op: allows compiling multiple source files with same module name (eg:
core.bar), which can be useful
-oq: should be used most of the time (when we don't expect such module name
clashes), because all builds are simply under 1 directory, simpler to reason
about.

--


More information about the Digitalmars-d-bugs mailing list