Bug 18762 – DMD should use a unique path/filename for __stdin.o

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-04-14T21:54:00Z
Last change time
2018-04-16T14:54:18Z
Keywords
pull
Assigned to
No Owner
Creator
Seb

Comments

Comment #0 by greensunny12 — 2018-04-14T21:54:00Z
``` Test the D Language specification ../dmd/generated/linux/release/64/dmd -run tools/dspec_tester.d --compiler=../dmd/generated/linux/release/64/dmd --- void main() { import std.stdio; import std.algorithm; int[] s = [1, 2, 3, 4]; copy(s[1..3], s[0..2]); assert(s == [2, 3, 3, 4]); } --- gcc: error: __stdin.o: No such file or directory Error: linker exited with status 1 ``` Happened on a few PRs (e.g. https://github.com/dlang/phobos/pull/6443, https://github.com/dlang/phobos/pull/6453 or https://github.com/dlang/dmd/pull/8168) See also: https://github.com/dlang/dlang.org/pull/2345
Comment #1 by dlang-bugzilla — 2018-04-15T20:06:09Z
The problem seems to be that the same object file name is used when reading from stdin: $ echo 'void main() {}' | dmd -v -run - | grep ^cc cc __stdin.o -o /tmp/dmd_runIAGsLe -m64 -Xlinker --export-dynamic -L/home/vladimir/opt/dmd/bin/../lib64 -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt -ldl This cannot work reliably in multiple threads, as several concurrent DMD instances will write __stdin.o, and several concurrent linkers will attempt to read it.
Comment #2 by dlang-bugzilla — 2018-04-16T13:40:30Z
Comment #3 by github-bugzilla — 2018-04-16T14:54:17Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/fdc6353140f059c25218a4d057eb7ebe20d69ef2 Fix Issue 18762 - DMD should use a unique path/filename for __stdin.o https://github.com/dlang/dmd/commit/bfb89f5099f4607d2b56a0508b3bbc6cec800de3 Merge pull request #8174 from CyberShadow/pull-20180416-133742 Fix Issue 18762 - DMD should use a unique path/filename for __stdin.o merged-on-behalf-of: Andrei Alexandrescu <[email protected]>