Skip to content
Merged
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 @@ -816,14 +816,18 @@ public static final String getHeapDumpPath(String defaultFilename) {
public static final RuntimeOptionKey<String> FlightRecorderLogging = new RuntimeOptionKey<>("all=warning", Immutable);

public static String reportsPath() {
return Paths.get(Paths.get(Path.getValue()).toString(), ImageSingletons.lookup(ReportingSupport.class).reportsPath).toAbsolutePath().toString();
Path reportsPath = ImageSingletons.lookup(ReportingSupport.class).reportsPath;
if (reportsPath.isAbsolute()) {
return reportsPath.toString();
}
return Paths.get(Path.getValue()).resolve(reportsPath).toString();
}

public static class ReportingSupport {
String reportsPath;
Path reportsPath;

public ReportingSupport(Path reportingPath) {
this.reportsPath = reportingPath.toString();
this.reportsPath = reportingPath;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public boolean consume(ArgumentQueue args) {
return true;
case "--diagnostics-mode":
args.poll();
nativeImage.setDiagnostics(true);
nativeImage.enableDiagnostics();
nativeImage.addPlainImageBuilderArg("-H:+DiagnosticsMode");
nativeImage.addPlainImageBuilderArg("-H:DiagnosticsDir=" + nativeImage.diagnosticsDir);
System.out.println("# Diagnostics mode enabled: image-build reports are saved to " + nativeImage.diagnosticsDir);
Expand Down Expand Up @@ -217,7 +217,7 @@ public boolean consume(ArgumentQueue args) {
args.poll();
headArg = headArg.substring(1);
Path origArgFile = Paths.get(headArg);
Path argFile = nativeImage.bundleSupport != null ? nativeImage.bundleSupport.substituteAuxiliaryPath(origArgFile, BundleMember.Role.Input) : origArgFile;
Path argFile = nativeImage.useBundle() ? nativeImage.bundleSupport.substituteAuxiliaryPath(origArgFile, BundleMember.Role.Input) : origArgFile;
NativeImage.NativeImageArgsProcessor processor = nativeImage.new NativeImageArgsProcessor(OptionOrigin.argFilePrefix + argFile);
readArgFile(argFile).forEach(processor);
List<String> leftoverArgs = processor.apply(false);
Expand Down Expand Up @@ -458,7 +458,7 @@ private void handleJarFileArg(Path jarFilePath) {
String origin = "manifest from " + jarFilePath.toUri();
nativeImage.addPlainImageBuilderArg(NativeImage.injectHostedOptionOrigin(nativeImage.oHName + jarFileNameBase, origin));
}
Path finalFilePath = nativeImage.bundleSupport != null ? nativeImage.bundleSupport.substituteClassPath(jarFilePath) : jarFilePath;
Path finalFilePath = nativeImage.useBundle() ? nativeImage.bundleSupport.substituteClassPath(jarFilePath) : jarFilePath;
if (!NativeImage.processJarManifestMainAttributes(finalFilePath, nativeImage::handleMainClassAttribute)) {
NativeImage.showError("No manifest in " + finalFilePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private static <T> String oR(OptionKey<T> option) {

private int verbose = Boolean.valueOf(System.getenv("VERBOSE_GRAALVM_LAUNCHERS")) ? 1 : 0;
private boolean diagnostics = false;
String diagnosticsDir;
Path diagnosticsDir;
private boolean jarOptionMode = false;
private boolean moduleOptionMode = false;
private boolean dryRun = false;
Expand Down Expand Up @@ -776,7 +776,7 @@ protected NativeImage(BuildConfiguration config) {

void addMacroOptionRoot(Path configDir) {
Path origRootDir = canonicalize(configDir);
Path rootDir = bundleSupport != null ? bundleSupport.substituteClassPath(origRootDir) : origRootDir;
Path rootDir = useBundle() ? bundleSupport.substituteClassPath(origRootDir) : origRootDir;
optionRegistry.addMacroOptionRoot(rootDir);
}

Expand Down Expand Up @@ -1497,7 +1497,8 @@ protected int buildImage(List<String> javaArgs, LinkedHashSet<Path> cp, LinkedHa
final String commandLine = SubstrateUtil.getShellCommandString(completeCommandList, true);
if (isDiagnostics()) {
// write to the diagnostics dir
ReportUtils.report("command line arguments", diagnosticsDir, "command-line", "txt", printWriter -> printWriter.write(commandLine));
Path finalDiagnosticsDir = useBundle() ? bundleSupport.substituteAuxiliaryPath(diagnosticsDir, BundleMember.Role.Output) : diagnosticsDir.toAbsolutePath();
ReportUtils.report("command line arguments", finalDiagnosticsDir.toString(), "command-line", "txt", printWriter -> printWriter.write(commandLine));
} else {
showVerboseMessage(isVerbose(), "Executing [");
showVerboseMessage(isVerbose(), commandLine);
Expand Down Expand Up @@ -1670,22 +1671,22 @@ Path canonicalize(Path path) {
}

Path canonicalize(Path path, boolean strict) {
if (bundleSupport != null) {
if (useBundle()) {
Path prev = bundleSupport.restoreCanonicalization(path);
if (prev != null) {
return prev;
}
}
Path absolutePath = path.isAbsolute() ? path : config.getWorkingDirectory().resolve(path);
if (!strict) {
return bundleSupport != null ? bundleSupport.recordCanonicalization(path, absolutePath) : absolutePath;
return useBundle() ? bundleSupport.recordCanonicalization(path, absolutePath) : absolutePath;
}
try {
Path realPath = absolutePath.toRealPath();
if (!Files.isReadable(realPath)) {
showError("Path entry " + path + " is not readable");
}
return bundleSupport != null ? bundleSupport.recordCanonicalization(path, realPath) : realPath;
return useBundle() ? bundleSupport.recordCanonicalization(path, realPath) : realPath;
} catch (IOException e) {
throw showError("Invalid Path entry " + path, e);
}
Expand Down Expand Up @@ -1805,7 +1806,7 @@ void addImageModulePath(Path modulePathEntry, boolean strict) {
return;
}

Path mpEntryFinal = bundleSupport != null ? bundleSupport.substituteModulePath(mpEntry) : mpEntry;
Path mpEntryFinal = useBundle() ? bundleSupport.substituteModulePath(mpEntry) : mpEntry;
imageModulePath.add(mpEntryFinal);
processClasspathNativeImageMetaInf(mpEntryFinal);
}
Expand Down Expand Up @@ -1869,7 +1870,7 @@ private void addImageClasspathEntry(LinkedHashSet<Path> destination, Path classp
return;
}

Path classpathEntryFinal = bundleSupport != null ? bundleSupport.substituteClassPath(classpathEntry) : classpathEntry;
Path classpathEntryFinal = useBundle() ? bundleSupport.substituteClassPath(classpathEntry) : classpathEntry;
if (!imageClasspath.contains(classpathEntryFinal) && !customImageClasspath.contains(classpathEntryFinal)) {
destination.add(classpathEntryFinal);
if (ClasspathUtils.isJar(classpathEntryFinal)) {
Expand All @@ -1887,13 +1888,15 @@ void addVerbose() {
verbose += 1;
}

void setDiagnostics(boolean val) {
diagnostics = val;
diagnosticsDir = Paths.get("reports", ReportUtils.timeStampedFileName("diagnostics", "")).toString();
if (val) {
addVerbose();
addVerbose();
void enableDiagnostics() {
if (diagnostics) {
/* Already enabled */
return;
}
diagnostics = true;
diagnosticsDir = Paths.get("reports", ReportUtils.timeStampedFileName("diagnostics", ""));
addVerbose();
addVerbose();
}

void setJarOptionMode(boolean val) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import static com.oracle.svm.core.SubstrateOptions.TraceObjectInstantiation;

import java.nio.file.Paths;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -103,8 +102,7 @@ public void setConfigurationSealed(boolean sealed) {
if (configurationSealed && ClassInitializationOptions.PrintClassInitialization.getValue()) {
List<ClassOrPackageConfig> allConfigs = classInitializationConfiguration.allConfigs();
allConfigs.sort(Comparator.comparing(ClassOrPackageConfig::getName));
String path = Paths.get(Paths.get(SubstrateOptions.Path.getValue()).toString(), "reports").toAbsolutePath().toString();
ReportUtils.report("class initialization configuration", path, "class_initialization_configuration", "csv", writer -> {
ReportUtils.report("class initialization configuration", SubstrateOptions.reportsPath(), "class_initialization_configuration", "csv", writer -> {
writer.println("Class or Package Name, Initialization Kind, Reasons");
for (ClassOrPackageConfig config : allConfigs) {
writer.append(config.getName()).append(", ").append(config.getKind().toString()).append(", ")
Expand Down