Skip to content

Commit ddfa546

Browse files
saibulususaibulusu
andauthored
Compiler Installation fixes (#368)
* Adding success codes for compiler installation, to avoid throwin an unnecessary error. * Changing formula for MemorySizeMB in LMBench profile to only use integers. * Increment VERSION. --------- Co-authored-by: saibulusu <saibulusu@microsoft.com>
1 parent 66afca9 commit ddfa546

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/VirtualClient/VirtualClient.Dependencies/CompilerInstallation.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace VirtualClient.Dependencies
2727
public class CompilerInstallation : VirtualClientComponent
2828
{
2929
private ISystemManagement systemManager;
30+
private int[] successCodes = { 0, 2 };
3031

3132
/// <summary>
3233
/// Initializes a new instance of the <see cref="CompilerInstallation"/> class.
@@ -238,21 +239,22 @@ private async Task InstallGccAsync(string gccVersion, EventContext telemetryCont
238239

239240
private async Task RemoveAlternativesAsync(EventContext telemetryContext, CancellationToken cancellationToken)
240241
{
241-
string[] compilers =
242+
string[] packages =
242243
{
243244
"gcc",
244-
"gfortran"
245+
"gfortran",
246+
"cpp"
245247
};
246248

247249
// due to the following error:
248250
// update-alternatives: error: alternative g++ can't be slave of gcc: it is a master alternative
249251
// must remove alternatives from the VM to avoid errors, then set all of them together
250252

251-
foreach (string compiler in compilers)
253+
foreach (string package in packages)
252254
{
253255
try
254256
{
255-
await this.ExecuteCommandAsync("update-alternatives", $"--remove-all {compiler}", Environment.CurrentDirectory, telemetryContext, cancellationToken);
257+
await this.ExecuteCommandAsync("update-alternatives", $"--remove-all {package}", Environment.CurrentDirectory, telemetryContext, cancellationToken, this.successCodes);
256258
}
257259
catch
258260
{
@@ -274,9 +276,6 @@ private async Task SetGccPriorityAsync(string gccVersion, EventContext telemetry
274276

275277
await this.ExecuteCommandAsync("update-alternatives", updateAlternativeArgument, Environment.CurrentDirectory, telemetryContext, cancellationToken);
276278

277-
// Remove all existing alternatives for cpp before the subsequent "update-alternatives" of cpp
278-
await this.ExecuteCommandAsync("update-alternatives", "--remove-all cpp", Environment.CurrentDirectory, telemetryContext, cancellationToken);
279-
280279
// For some update path, the cpp can't be update-alternative by a gcc, so needs a separate call.
281280
string updateAlternativeArgumentCpp = $"--install /usr/bin/cpp cpp /usr/bin/cpp-{gccVersion} {gccVersion}0";
282281

@@ -312,7 +311,7 @@ private async Task InstallCharmplusplusAsync(string charmplusplusVersion, EventC
312311
}
313312
}
314313

315-
private Task ExecuteCommandAsync(string pathToExe, string commandLineArguments, string workingDirectory, EventContext telemetryContext, CancellationToken cancellationToken)
314+
private Task ExecuteCommandAsync(string pathToExe, string commandLineArguments, string workingDirectory, EventContext telemetryContext, CancellationToken cancellationToken, int[] successCodes = null)
316315
{
317316
return this.RetryPolicy.ExecuteAsync(async () =>
318317
{
@@ -328,7 +327,7 @@ private Task ExecuteCommandAsync(string pathToExe, string commandLineArguments,
328327
{
329328
await this.LogProcessDetailsAsync(process, telemetryContext);
330329

331-
process.ThrowIfErrored<DependencyException>(errorReason: ErrorReason.DependencyInstallationFailed);
330+
process.ThrowIfErrored<DependencyException>(successCodes: this.successCodes, errorReason: ErrorReason.DependencyInstallationFailed);
332331
}
333332
}
334333
});

src/VirtualClient/VirtualClient.Main/profiles/PERF-MEM-LMBENCH.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"CompilerName": "gcc",
1212
"CompilerVersion": "10",
1313
"CompilerFlags": "CPPFLAGS=\"-I /usr/include/tirpc\"",
14-
"MemorySizeMB": "{calculate({SystemMemoryMegabytes} * 0.25})}"
14+
"MemorySizeMB": "{calculate({SystemMemoryMegabytes} / 4)}"
1515
},
1616
"Actions": [
1717
{

0 commit comments

Comments
 (0)