wilzbach / tools-test

1 stars 0 forks source link

rdmd file-descriptor issues with snap packages #173

Open wilzbach opened 6 years ago

wilzbach commented 6 years ago

Note: the issue was created automatically migrated from https://issues.dlang.org

Original bug ID: BZ#17838 From: Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> Reported version: D2

wilzbach commented 6 years ago

Comment author: Joseph Rushton Wakeling <joseph.wakeling@webdrake.net>

rdmd uses spawnProcess to launch the D compiler of choice, and passes a custom File instance to the stdout parameter.

This means that the D compiler has to inherit a file-descriptor from rdmd. For traditional Linux packages, this is not a problem. However, where snap packages are concerned, this creates an issue: when the D compiler is itself a snap package, its confinement rules prevent it from inheriting the file descriptor, and rdmd will exit with an error message:

$ rdmd --compiler=ldc2 hello.d 
Failed to flush stdout: Permission denied
Failed: ["ldc2", "-v", "-o-", "hello.d", "-I."]

Some extended discussion of this issue can be found in this thread on the snapcraft forums: https://forum.snapcraft.io/t/failed-to-flush-stdout-permission-denied/485

This is considered at least partly a bug in snapd, hence I've held off on reporting it as an rdmd issue, but it looks like this is going to be long-lived enough for me to think it might be worth addressing in rdmd itself if possible.

A recent patch to rdmd (https://github.com/dlang/tools/commit/f7e6f4ed925f6a8f97b4c0f02cfce2620489357a) partially addresses this issue, as it ensures that when rdmd is invoking a D compiler within the same snap package as itself, the confinement rules do not come into play (because the compiler executable is launched directly, instead of indirectly via the wrapper script that the snap package exposes to the host system).

However, this still leaves unaddressed the broader issue of rdmd invoking a compiler provided by a separate snap package (e.g. the ldc2 snap package).

So: can rdmd be either patched or invoked in order to avoid the D compiler it invokes needing to inherit a file descriptor from it? :-)