gentoo / dlang

[MIRROR] D programming language ebuild repository
https://gitweb.gentoo.org/repo/user/dlang.git
GNU General Public License v2.0
30 stars 25 forks source link

Add git as a build dependency for some dmd ebuilds #93

Closed the-horo closed 2 years ago

the-horo commented 2 years ago

Dmd ebuilds 2.084-2.087 throw an exception that git was not found when trying to build:

../../linux/bin64/dmd ../config.d -of../generated/linux/release/64/version_check
std.process.ProcessException@std/process.d(379): Executable file not found: git
----------------
??:? @trusted std.process.Pid std.process.spawnProcessImpl(scope const(char[])[], std.stdio.File, std.stdio.File, std.stdio.File, scope const(immutable(char)[][immutable(char)[]]), std.process.Config, const(char)[]) [0x699cdc2f]
??:? @trusted std.process.Pid std.process.spawnProcess(scope const(char[])[], std.stdio.File, std.stdio.File, std.stdio.File, const(immutable(char)[][immutable(char)[]]), std.process.Configconst , char[]) [0x699cd8eb]
??:? @trusted std.process.ProcessPipes std.process.pipeProcessImpl!(std.process.spawnProcess, const(char[])[]).pipeProcessImpl(const(char[])[], std.process.Redirect, const(immutable(char)[][immutable(char)[]]), std.process.Config, const(char)[]) [0x699ae0b7]
??:? @safe std.process.ProcessPipes std.process.pipeProcess(scope const(char[])[], std.process.Redirect, const(immutable(char)[][immutable(char)[]]), std.process.Config, const(char)[]) [0x699ad570]
??:? std.typecons.Tuple!(int, "status", immutable(char)[], "output").Tuple std.process.executeImpl!(std.process.pipeProcess, const(char[])[]).executeImpl(const(char[])[], const(immutable(char)[][immutable(char)[]]), std.process.Config, ulong, scope const(char)[]) [0x6997dc82]
??:? @trusted std.typecons.Tuple!(int, "status", immutable(char)[], "output").Tuple std.process.execute(scope const(char[])[],
const(immutable(char)[][immutable(char)[]]), std.process.Config, ulong, scope const(char)[]) [0x6997d47c]
??:? immutable(char)[] config.generateVersion(const(immutable(char)[])) [0x6995cbe3]
??:? _Dmain [0x6995ca8e]
make: *** [posix.mak:552: ../generated/linux/release/64/VERSION] Error 1
make: Leaving directory '/var/tmp/portage/dev-lang/dmd-2.084.1-r2/work/dmd2/dmd/src'
 * ERROR: dev-lang/dmd-2.084.1-r2::dlang failed (compile phase):
 *   emake failed

When dev-vcs/git is installed the build works fine.

mleise commented 2 years ago

I see. Ideally ebuilds don't network at all during compilation. The VERSION file or whatever is missing should be created by other means. This has happened in the past, maybe the file location changed. Compare e.g. the mv src/VERSION dmd/VERSION || die "Failed to move 'src/VERSION' to 'dmd/VERSION'" in dmd.eclass.

the-horo commented 2 years ago

I have been investigating this VERSION file issue and I think I've got an idea of what's happening.

First of all, in my initial comment, it was not the first line that, when executed, threw the exception, it was instead:

../generated/linux/release/64/version_check ../generated/linux/release/64 ../VERSION /etc

Looking at the make file we find the VERSION heading containing the following recipes:

$G/version_check: ../config.d $(HOST_DMD_PATH)
    @echo "  (HOST_DMD_RUN)  $<  $<"
    $(HOST_DMD_RUN) $< -of$@

$G/VERSION: $G/version_check ../VERSION FORCE
    @$< $G ../VERSION $(SYSCONFDIR)

FORCE: ;

Going next to the source code of ../config.d we see:

void main(const string[] args)
{
    // [...]
    const version_ = generateVersion(versionFile);
    // [...]
}

string generateVersion(const string versionFile)
{
    // [...]
    const result = execute(["git", "-C", workDir, "describe", "--dirty"]);
    // [...]
}

And, according to the standard, execute will throw on failure to start the process, i.e. when git is not available.

So, this problem doesn't look easy to fix.

We have some options though:

  1. add git as a dependency for these particular versions (what I did)
  2. patch the ../config.d file, similarly to what was done in dmd-2.088.0 (link)
  3. screw with the makefile/the build system
  4. remove the ebuilds from the overlay
mleise commented 2 years ago

Good job tracing the issue down. I always went with manually placing the VERSION file where the makefile tests for it, but if git -C <path> describe --dirty does not open any network connections, I see no problem running that in the sandbox and adding the dependency. We can go with option 1 then.