File tree Expand file tree Collapse file tree 4 files changed +27
-9
lines changed
Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ interface Compiler {
132132 string [] lflagsToDFlags (const string [] lflags) const ;
133133
134134 // / Determines compiler version
135- string determineVersion (string compiler_binary , string verboseOutput);
135+ string determineVersion (in BuildPlatform platform , string verboseOutput);
136136
137137 /* * Runs a tool and provides common boilerplate code.
138138
@@ -193,8 +193,8 @@ interface Compiler {
193193 format(" Failed to invoke the compiler %s to determine the build platform: %s" ,
194194 compiler_binary, result.output));
195195 BuildPlatform build_platform = readPlatformSDLProbe(result.output);
196- string ver = determineVersion(compiler_binary, result.output).strip;
197196 build_platform.compilerBinary = compiler_binary;
197+ string ver = determineVersion(build_platform, result.output).strip;
198198
199199 if (ver.empty) {
200200 logWarn(` Could not probe the compiler version for "%s". ` ~
Original file line number Diff line number Diff line change @@ -99,11 +99,29 @@ config /etc/dmd.conf
9999 assert (c && c.length > 1 && c[1 ] == " 2.084.0-beta.1" );
100100 }
101101
102- string determineVersion (string compiler_binary , string verboseOutput)
102+ string determineVersion (in BuildPlatform platform , string verboseOutput)
103103 {
104- import std.regex : matchFirst, regex;
105- auto ver = matchFirst(verboseOutput, regex(dmdVersionRe, " m" ));
106- return ver && ver.length > 1 ? ver[1 ] : null ;
104+ // Find the backend version of the compiler, not the dmd FE.
105+ // Specificically, for gdmd-14 this function should return
106+ // 14.X.Y not 2.108.Z
107+ switch (platform.compiler) {
108+ case " dmd" :
109+ case " ldc" :
110+ {
111+ import std.regex : matchFirst, regex;
112+ auto ver = matchFirst(verboseOutput, regex(dmdVersionRe, " m" ));
113+ return ver && ver.length > 1 ? ver[1 ] : null ;
114+ }
115+ case " gdc" :
116+ {
117+ import std.process ;
118+ const result = execute([platform.compilerBinary, " -q,-dumpfullversion" , " --version" ]);
119+ return result.status == 0 ? result.output : null ;
120+ }
121+ default :
122+ throw new UnknownCompilerException(platform.compiler);
123+ }
124+
107125 }
108126
109127 BuildPlatform determinePlatform (ref BuildSettings settings, string compiler_binary, string arch_override)
Original file line number Diff line number Diff line change @@ -54,10 +54,10 @@ class GDCCompiler : Compiler {
5454
5555 @property string name() const { return " gdc" ; }
5656
57- string determineVersion (string compiler_binary , string verboseOutput)
57+ string determineVersion (in BuildPlatform platform , string verboseOutput)
5858 {
5959 const result = execute([
60- compiler_binary ,
60+ platform.compilerBinary ,
6161 " -dumpfullversion" ,
6262 " -dumpversion"
6363 ]);
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ config /etc/ldc2.conf (x86_64-pc-linux-gnu)
6969 assert (c && c.length > 1 && c[1 ] == " 1.11.0" );
7070 }
7171
72- string determineVersion (string compiler_binary , string verboseOutput)
72+ string determineVersion (in BuildPlatform platform , string verboseOutput)
7373 {
7474 import std.regex : matchFirst, regex;
7575 auto ver = matchFirst(verboseOutput, regex(ldcVersionRe, " m" ));
You can’t perform that action at this time.
0 commit comments