D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14296 - RDMD fails at building a lib when the source is in a subdir
Summary: RDMD fails at building a lib when the source is in a subdir
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: tools (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on: 14305
Blocks:
  Show dependency treegraph
 
Reported: 2015-03-16 20:54 UTC by Nick Sabalausky
Modified: 2017-01-16 23:24 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nick Sabalausky 2015-03-16 20:54:06 UTC
$ mkdir src
$ touch src/test.d
$ rdmd --build-only -lib src/test.d
std.file.FileException@std/file.d(409): src/test.a: No such file or directory
$ ls src/
src  test.d
$ ls src/src/
test.a.tmp

This used to work with the RDMD packaged in DMD v2.064.2, but fails starting with RDMD 2.065.0.
Comment 1 Vladimir Panteleev 2015-03-18 14:47:09 UTC
(In reply to Nick Sabalausky from comment #0)
> This used to work with the RDMD packaged in DMD v2.064.2, but fails starting
> with RDMD 2.065.0.

It didn't exactly work as one would expect in 2.064.2 either, did it? It still repeated the leading path component, it just didn't crash.

The real bug is in DMD: it interprets -of / -od differently depending on whether -lib is supplied.

There isn't much that can be done on rdmd's side, other than adding detection for .lib and explicitly working around the DMD bug, so it should be fixed in DMD instead.

https://issues.dlang.org/show_bug.cgi?id=14305
Comment 2 Nick Sabalausky 2015-06-19 03:53:43 UTC
https://github.com/D-Programming-Language/dmd/pull/4753
Comment 3 Nick Sabalausky 2015-06-21 05:27:20 UTC
This can be worked around by giving -of an absolute path:

$ rdmd --build-only -lib src/test.d
Fails

$ rdmd --build-only -lib -oflib/hi.a src/test.d
Fails

$ rdmd --build-only -lib -of`pwd`/lib/hi.a src/test.d/
OK
Comment 4 Nick Sabalausky 2015-06-21 05:28:29 UTC
(In reply to Nick Sabalausky from comment #3)
> 
> $ rdmd --build-only -lib -of`pwd`/lib/hi.a src/test.d/
> OK

That should've been:

$ rdmd --build-only -lib -of`pwd`/lib/hi.a src/test.d
OK
Comment 5 Walter Bright 2015-07-11 23:33:43 UTC
A better solution for now is to have rdmd not use both -od and -of.
Comment 6 Vladimir Panteleev 2015-07-21 12:09:15 UTC
(In reply to Walter Bright from comment #5)
> A better solution for now is to have rdmd not use both -od and -of.

That would mean to either put the intermediary object files in the current directory or to put the .lib file in a temporary directory. Again it would mean special logic in rdmd depending on whether -lib is supplied to work around the DMD bug.
Comment 7 Walter Bright 2015-07-23 10:15:46 UTC
(In reply to Vladimir Panteleev from comment #6)
> (In reply to Walter Bright from comment #5)
> > A better solution for now is to have rdmd not use both -od and -of.
> 
> That would mean to either put the intermediary object files in the current
> directory or to put the .lib file in a temporary directory. Again it would
> mean special logic in rdmd depending on whether -lib is supplied to work
> around the DMD bug.

dmd is not going to change the behavior of -od or -of. Their behavior is confusing enough - breaking peoples' makefiles will make things even worse. Best case is adding a new switch with the desired behavior.

rdmd can work by using fully qualified output file names.
Comment 8 Walter Bright 2015-07-23 10:20:33 UTC
BTW, every file name generation algorithm in DMD is different from every other one. It is extremely bad design. Frankly, we should design a new set of flags and do it consistently, and then undocument the existing ones.

Meanwhile, rdmd should simply use fully qualified names and avoid the issue entirely.
Comment 9 Vladimir Panteleev 2016-12-17 16:02:33 UTC
https://github.com/dlang/tools/pull/207
Comment 10 github-bugzilla 2016-12-24 11:03:23 UTC
Commits pushed to stable at https://github.com/dlang/tools

https://github.com/dlang/tools/commit/e245e29d8bebe4d3965dbee40216135df513bccf
Fix Issue 14296 - RDMD fails at building a lib when the source is in a subdir

https://github.com/dlang/tools/commit/bfbcd086bad634066ba142964823f1689e879aaf
Merge pull request #207 from CyberShadow/issue-16962

rdmd fixes (issues 14296, 16962 and 16978)
merged-on-behalf-of: Martin Nowak <code@dawg.eu>
Comment 11 github-bugzilla 2017-01-07 02:56:14 UTC
Commits pushed to master at https://github.com/dlang/tools

https://github.com/dlang/tools/commit/e245e29d8bebe4d3965dbee40216135df513bccf
Fix Issue 14296 - RDMD fails at building a lib when the source is in a subdir

https://github.com/dlang/tools/commit/bfbcd086bad634066ba142964823f1689e879aaf
Merge pull request #207 from CyberShadow/issue-16962
Comment 12 github-bugzilla 2017-01-16 23:24:20 UTC
Commits pushed to newCTFE at https://github.com/dlang/tools

https://github.com/dlang/tools/commit/e245e29d8bebe4d3965dbee40216135df513bccf
Fix Issue 14296 - RDMD fails at building a lib when the source is in a subdir

https://github.com/dlang/tools/commit/bfbcd086bad634066ba142964823f1689e879aaf
Merge pull request #207 from CyberShadow/issue-16962