Skip to content

GetUnixCompilerInfo fails on LANG=de_DE.UTF8 #1856

@matthiasbeyer

Description

@matthiasbeyer

private void GetUnixCompilerInfo(string headersPath, out string compiler,
out string longVersion, out string shortVersion)
{
if (!Platform.IsLinux)
{
compiler = "gcc";
// Search for the available GCC versions on the provided headers.
var versions = Directory.EnumerateDirectories(Path.Combine(headersPath,
"usr", "include", "c++"));
if (!versions.Any())
throw new Exception("No valid GCC version found on system include paths");
var gccVersionPath = versions.First();
longVersion = shortVersion = gccVersionPath.Substring(
gccVersionPath.LastIndexOf(Path.DirectorySeparatorChar) + 1);
return;
}
var info = new ProcessStartInfo(Environment.GetEnvironmentVariable("CXX") ?? "gcc", "-v")
{
RedirectStandardError = true,
CreateNoWindow = true,
UseShellExecute = false
};
var process = Process.Start(info);
if (process == null)
throw new SystemException("GCC compiler was not found.");
process.WaitForExit();
var output = process.StandardError.ReadToEnd();
var match = Regex.Match(output, "(gcc|clang) version (([0-9]+\\.[0-9]+)\\.[0-9]+)");
if (!match.Success)
throw new SystemException("GCC compiler was not found.");
compiler = match.Groups[1].ToString();
longVersion = match.Groups[2].ToString();
shortVersion = match.Groups[3].ToString();
}

This function fails to find the GCC compiler on my system with my normal LANG=de_DE.UTF8, but succeeds if I export LANG=C before running the relevant code.

Unfortunately the Code running this is proprietary, so I cannot share more about it, but it is literally:

$ ./myCode # fails
$ export LANG=C
$ ./myCode # succeeds

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions