Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azlinux3 dnf packages for compiler installation #423

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace VirtualClient.Actions
using global::VirtualClient.Contracts;
using Microsoft.Extensions.DependencyInjection;
using VirtualClient.Contracts.Metadata;
using VirtualClient.Metadata;

/// <summary>
/// The SpecCpu workload executor.
Expand Down Expand Up @@ -432,11 +433,30 @@ private async Task WriteSpecCpuConfigAsync(CancellationToken cancellationToken)
true);
}

string gccVersion;
if (string.IsNullOrEmpty(this.CompilerVersion))
{
IDictionary<string, object> compilerMetadata = await this.systemManager.GetInstalledCompilerMetadataAsync();
object compilerVersion;
if (compilerMetadata.TryGetValue("compilerVersion_gcc", out compilerVersion))
{
gccVersion = compilerVersion.ToString().Split(".")[0];
}
else
{
throw new WorkloadException("gcc version not found.");
}
}
else
{
gccVersion = this.CompilerVersion;
}

templateText = templateText.Replace(SpecCpuConfigPlaceHolder.BaseOptimizingFlags, this.BaseOptimizingFlags, StringComparison.OrdinalIgnoreCase);
templateText = templateText.Replace(SpecCpuConfigPlaceHolder.PeakOptimizingFlags, this.PeakOptimizingFlags, StringComparison.OrdinalIgnoreCase);
templateText = templateText.Replace(
SpecCpuConfigPlaceHolder.Gcc10Workaround,
Convert.ToInt32(this.CompilerVersion) >= 10 ? SpecCpuConfigPlaceHolder.Gcc10WorkaroundContent : string.Empty,
Convert.ToInt32(gccVersion) >= 10 ? SpecCpuConfigPlaceHolder.Gcc10WorkaroundContent : string.Empty,
StringComparison.OrdinalIgnoreCase);

await this.fileSystem.File.WriteAllTextAsync(this.Combine(this.PackageDirectory, "config", configurationFile), templateText, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public async Task CompilerInstallationRunsTheExpectedWorkloadCommandInWindowsFor
}

[Test]
public async Task CompilerInstallationInLinuxDefaultsToGcc10()
public async Task CompilerInstallationInLinuxDefaultsToEmpty()
{
this.mockFixture.Parameters = new Dictionary<string, IConvertible>();

Expand All @@ -246,15 +246,7 @@ public async Task CompilerInstallationInLinuxDefaultsToGcc10()
"sudo update-alternatives --remove-all gfortran",
"sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y",
"sudo apt update",
"sudo apt install build-essential gcc-10 g++-10 gfortran-10 -y --quiet",
"sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 " +
$"--slave /usr/bin/g++ g++ /usr/bin/g++-10 " +
$"--slave /usr/bin/gcov gcov /usr/bin/gcov-10 " +
$"--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-10 " +
$"--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-10 " +
$"--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-10",
"sudo update-alternatives --remove-all cpp",
"sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-10 100",
"sudo apt install build-essential gcc g++ gfortran -y --quiet"
};

int commandExecuted = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace VirtualClient.Dependencies
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
Expand Down Expand Up @@ -110,7 +110,7 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
{
await this.InstallGccAsync(this.CompilerVersion, telemetryContext, cancellationToken);

if (!await this.ConfirmGccVersionInstalledAsync(cancellationToken))
if (!string.IsNullOrEmpty(this.CompilerVersion) && !await this.ConfirmGccVersionInstalledAsync(cancellationToken))
{
throw new DependencyException($"'{this.CompilerName.ToLowerInvariant()}' compiler version '{this.CompilerVersion}' not confirmed.", ErrorReason.DependencyInstallationFailed);
}
Expand Down Expand Up @@ -209,26 +209,63 @@ private Task InstallCygwinAsync(DependencyPath cygwinInstallationPath, EventCont
private async Task InstallGccAsync(string gccVersion, EventContext telemetryContext, CancellationToken cancellationToken)
{
LinuxDistributionInfo distro = await this.systemManager.GetLinuxDistributionAsync(cancellationToken);
gccVersion = (string.IsNullOrEmpty(gccVersion)) ? string.Empty : gccVersion;

switch (distro.LinuxDistribution)
{
case LinuxDistribution.Ubuntu:
case LinuxDistribution.Debian:
// default to 10
await this.ExecuteCommandAsync("apt-get", "remove gcc -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.RemoveAlternativesAsync(telemetryContext, cancellationToken);
gccVersion = (string.IsNullOrEmpty(gccVersion)) ? "10" : gccVersion;
await this.ExecuteCommandAsync("add-apt-repository", $"ppa:ubuntu-toolchain-r/test -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("apt", $"update", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("apt", @$"install build-essential gcc-{gccVersion} g++-{gccVersion} gfortran-{gccVersion} -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.SetGccPriorityAsync(gccVersion, telemetryContext, cancellationToken);
if (string.IsNullOrEmpty(gccVersion))
{
await this.ExecuteCommandAsync("apt", "install build-essential gcc g++ gfortran -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("apt", "install make gcc g++ gfortran -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
}
else
{
await this.ExecuteCommandAsync("apt", @$"install build-essential gcc-{gccVersion} g++-{gccVersion} gfortran-{gccVersion} -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.SetGccPriorityAsync(gccVersion, telemetryContext, cancellationToken);
}

break;

case LinuxDistribution.CentOS8:
case LinuxDistribution.RHEL8:
await this.ExecuteCommandAsync("dnf", "remove gcc -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.RemoveAlternativesAsync(telemetryContext, cancellationToken);
if (string.IsNullOrEmpty(gccVersion))
saibulusu marked this conversation as resolved.
Show resolved Hide resolved
{
await this.ExecuteCommandAsync("dnf", "install kernel-headers kernel-devel -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install binutils -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install glibc-headers glibc-devel -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install git -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install libnsl -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install make gcc -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
}
else
{
await this.ExecuteCommandAsync("dnf", @$"install make gcc-toolset-{gccVersion} gcc-toolset-{gccVersion}-gcc-gfortran -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.SetGccPriorityAsync(gccVersion, telemetryContext, cancellationToken);
}

break;

case LinuxDistribution.AzLinux:
if (!string.IsNullOrEmpty(gccVersion))
{
throw new Exception($"gcc version must not be supplied for {distro.LinuxDistribution}");
}

await this.ExecuteCommandAsync("dnf", "remove gcc -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.RemoveAlternativesAsync(telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", @$"install make gcc-toolset-{gccVersion} gcc-toolset-{gccVersion}-gcc-gfortran -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.SetGccPriorityAsync(gccVersion, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install kernel-headers kernel-devel -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install binutils -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install glibc-headers glibc-devel -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install git -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install gcc gfortran -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);

break;

Expand Down Expand Up @@ -263,7 +300,7 @@ private async Task RemoveAlternativesAsync(EventContext telemetryContext, Cancel
}
}
}

private async Task SetGccPriorityAsync(string gccVersion, EventContext telemetryContext, CancellationToken cancellationToken)
{
string updateAlternativeArgument = $"--install /usr/bin/gcc gcc /usr/bin/gcc-{gccVersion} {gccVersion}0 " +
Expand Down
20 changes: 0 additions & 20 deletions website/docs/workloads/speccpu/speccpu-profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ for evaluating the performance of the CPU for processing calculations.
* **Supports Disconnected Scenarios**
* No. Internet connection required.

* **Supported Compilers**
The following compilers are supported with the workload for this profile. See profile parameters and usage examples below.

* GCC Compiler Versions = 8, 9, 10

* **Dependencies**
The dependencies defined in the 'Dependencies' section of the profile itself are required in order to run the workload operations effectively.
* Internet connection.
Expand Down Expand Up @@ -81,11 +76,6 @@ for evaluating the performance of the CPU for processing calculations.
* **Supports Disconnected Scenarios**
* No. Internet connection required.

* **Supported Compilers**
The following compilers are supported with the workload for this profile. See profile parameters and usage examples below.

* GCC Compiler Versions = 8, 9, 10

* **Dependencies**
The dependencies defined in the 'Dependencies' section of the profile itself are required in order to run the workload operations effectively.
* Internet connection.
Expand Down Expand Up @@ -135,11 +125,6 @@ for evaluating the performance of the CPU for processing calculations.
* **Supports Disconnected Scenarios**
* No. Internet connection required.

* **Supported Compilers**
The following compilers are supported with the workload for this profile. See profile parameters and usage examples below.

* GCC Compiler Versions = 8, 9, 10

* **Dependencies**
The dependencies defined in the 'Dependencies' section of the profile itself are required in order to run the workload operations effectively.
* Internet connection.
Expand Down Expand Up @@ -188,11 +173,6 @@ for evaluating the performance of the CPU for processing calculations.
* **Supports Disconnected Scenarios**
* No. Internet connection required.

* **Supported Compilers**
The following compilers are supported with the workload for this profile. See profile parameters and usage examples below.

* GCC Compiler Versions = 8, 9, 10

* **Dependencies**
The dependencies defined in the 'Dependencies' section of the profile itself are required in order to run the workload operations effectively.
* Internet connection.
Expand Down
Loading