[Issue 24293] ImportC: parallel compilation failure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 30 09:13:41 UTC 2023


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

--- Comment #4 from kdevel <kdevel at vogtner.de> ---
(In reply to Walter Bright from comment #3)
> I'm not understanding the need for dmd to generate the .i file rather than
> cpp?
dmd invokes cpp in order to generade the .i file:

$ strace -s128 -feexecve dmd cmysql.c
[...]
[pid 24506] execve("/usr/bin/cpp", ["cpp", "-m64", "-dD",
"-Wno-builtin-macro-redefined", "cmysql.c", "-include",
"[...]/dmd2/linux/bin64/../../src/druntime/import/importc.h", "cmysql.i"], [/*
96 vars */]) = 0
[...]

> I'm also not understanding the reentrancy problem - are multiple .i
> files being generated with the same base name, thus conflicting with each
> other?
There are two or more processes each writing to a file with the same file name
(cmysql.i):

$ strace -s128 -feexecve dmd xmysqltest1.d
[...]
[pid 24560] execve("/usr/bin/cpp", ["cpp", "-m64", "-dD",
"-Wno-builtin-macro-redefined", "cmysql.c", "-include",
"[...]/dmd2/linux/bin64/../../src/druntime/import/importc.h", "cmysql.i"], [/*
96 vars */]) = 0
[...]

$ strace -s128 -feexecve dmd xmysqltest2.d
[...]
[pid 24566] execve("/usr/bin/cpp", ["cpp", "-m64", "-dD",
"-Wno-builtin-macro-redefined", "cmysql.c", "-include",
"[...]/dmd2/linux/bin64/../../src/druntime/import/importc.h", "cmysql.i"], [/*
96 vars */]) = 0
[...]

If the processes run in parallel cmysql.i refers to the same file. Since
cmysql.i is opened with O_TRUNC the content already written is lost.

--


More information about the Digitalmars-d-bugs mailing list