Skip to content

Commit

Permalink
[GR-17695] Enable all LLVM versions above 6.0.0.
Browse files Browse the repository at this point in the history
PullRequest: graal/4228
  • Loading branch information
loicottet committed Aug 21, 2019
2 parents 2920ceb + ab8254d commit bc91d24
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -106,7 +105,9 @@ public static HostedMethod getPersonalityStub() {

@Override
public void afterRegistration(AfterRegistrationAccess access) {
checkLLVMVersion();
if (!LLVMOptions.CustomLLC.hasBeenSet()) {
checkLLVMVersion();
}

ImageSingletons.add(SubstrateBackendFactory.class, new SubstrateBackendFactory() {
@Override
Expand Down Expand Up @@ -169,9 +170,23 @@ public void lower(LoadExceptionObjectNode node, LoweringTool tool) {
}
}

private static final int MIN_LLVM_MAJOR_VERSION = 6;
private static final int MIN_LLVM_MINOR_VERSION = 0;

private static void checkLLVMVersion() {
List<String> supportedVersions = Arrays.asList("6.0.0", "6.0.1");
String version = getLLVMVersion();

String[] splitVersion = version.split("\\.");
assert splitVersion.length == 3;
int majorVersion = Integer.parseInt(splitVersion[0]);
int minorVersion = Integer.parseInt(splitVersion[1]);

if (majorVersion < MIN_LLVM_MAJOR_VERSION || (majorVersion == MIN_LLVM_MAJOR_VERSION && minorVersion < MIN_LLVM_MINOR_VERSION)) {
throw UserError.abort("Unsupported LLVM version: " + version + ". Supported versions are LLVM " + MIN_LLVM_MAJOR_VERSION + "." + MIN_LLVM_MINOR_VERSION + ".0 and above");
}
}

private static String getLLVMVersion() {
int status;
String output = null;
try (OutputStream os = new ByteArrayOutputStream()) {
Expand All @@ -193,9 +208,8 @@ private static void checkLLVMVersion() {
if (status != 0) {
throw UserError.abort("Using the LLVM backend requires LLVM to be installed on your machine.");
}
if (!supportedVersions.contains(output)) {
throw UserError.abort("Unsupported LLVM version: " + output + ". Supported versions are: [" + String.join(", ", supportedVersions) + "]");
}

return output;
}
}

Expand Down

0 comments on commit bc91d24

Please sign in to comment.