Skip to content

Commit 172783c

Browse files
committed
Ensure consistent use of SubstrateOptions.useDebugInfoGeneration()
1 parent bd5476e commit 172783c

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ public static int codeAlignment() {
631631

632632
@APIOption(name = "-g", fixedValue = "2", customHelp = "generate debugging information")//
633633
@Option(help = "Insert debug info into the generated native image or library")//
634-
public static final HostedOptionKey<Integer> GenerateDebugInfo = new HostedOptionKey<>(0, SubstrateOptions::validateGenerateDebugInfo) {
634+
static final HostedOptionKey<Integer> GenerateDebugInfo = new HostedOptionKey<>(0, SubstrateOptions::validateGenerateDebugInfo) {
635635
@Override
636636
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Integer oldValue, Integer newValue) {
637637
if (OS.WINDOWS.isCurrent()) {
@@ -651,11 +651,8 @@ public static boolean useDebugInfoGeneration() {
651651
return useLIRBackend() && GenerateDebugInfo.getValue() > 0;
652652
}
653653

654-
@Option(help = "Search path for source files for Application or GraalVM classes (list of comma-separated directories or jar files)")//
655-
public static final HostedOptionKey<LocatableMultiOptionValue.Paths> DebugInfoSourceSearchPath = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
656-
657654
@Option(help = "Directory under which to create source file cache for Application or GraalVM classes")//
658-
public static final HostedOptionKey<String> DebugInfoSourceCacheRoot = new HostedOptionKey<>("sources");
655+
static final HostedOptionKey<String> DebugInfoSourceCacheRoot = new HostedOptionKey<>("sources");
659656

660657
@Option(help = "Temporary option to disable checking of image builder module dependencies or increasing its verbosity", type = OptionType.Debug)//
661658
public static final HostedOptionKey<Integer> CheckBootModuleDependencies = new HostedOptionKey<>(ModuleSupport.modulePathBuild ? 1 : 0);

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/CCLinkerInvocation.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ public void addLinkedLibrary(int index, String libname) {
187187

188188
protected List<String> getCompilerCommand(List<String> options) {
189189
/* Relativize input files where applicable to avoid unintentional leaking of host paths. */
190-
Path[] inputPaths = inputFilenames.stream()
191-
.map(path -> path.startsWith(tempDirectory) ? tempDirectory.relativize(path) : path)
192-
.toArray(Path[]::new);
190+
Path[] inputPaths = inputFilenames.stream().map(path -> path.startsWith(tempDirectory) ? tempDirectory.relativize(path) : path).toArray(Path[]::new);
193191
return ImageSingletons.lookup(CCompilerInvoker.class).createCompilerCommand(options, outputFile, inputPaths);
194192
}
195193

@@ -241,8 +239,7 @@ public void addNativeLinkerOption(String option) {
241239
}
242240

243241
protected List<String> getNativeLinkerOptions() {
244-
return Stream.of(nativeLinkerOptions, Options.NativeLinkerOption.getValue().values())
245-
.flatMap(Collection::stream).collect(Collectors.toList());
242+
return Stream.of(nativeLinkerOptions, Options.NativeLinkerOption.getValue().values()).flatMap(Collection::stream).collect(Collectors.toList());
246243
}
247244

248245
private static class BinutilsCCLinkerInvocation extends CCLinkerInvocation {
@@ -270,8 +267,7 @@ private static class BinutilsCCLinkerInvocation extends CCLinkerInvocation {
270267
exportedSymbols.append("{\n");
271268
/* Only exported symbols are global ... */
272269
exportedSymbols.append("global:\n");
273-
Stream.concat(getImageSymbols(true).stream(), JNIRegistrationSupport.getShimLibrarySymbols())
274-
.forEach(symbol -> exportedSymbols.append('\"').append(symbol).append("\";\n"));
270+
Stream.concat(getImageSymbols(true).stream(), JNIRegistrationSupport.getShimLibrarySymbols()).forEach(symbol -> exportedSymbols.append('\"').append(symbol).append("\";\n"));
275271
/* ... everything else is local. */
276272
exportedSymbols.append("local: *;\n");
277273
exportedSymbols.append("};");
@@ -484,7 +480,7 @@ public List<String> getCommand() {
484480
/* Put .lib and .exp files in a temp dir as we don't usually need them. */
485481
cmd.add("/IMPLIB:" + getTempDirectory().resolve(imageName + ".lib"));
486482

487-
if (SubstrateOptions.GenerateDebugInfo.getValue() > 0) {
483+
if (SubstrateOptions.useDebugInfoGeneration()) {
488484
cmd.add("/DEBUG");
489485

490486
if (SubstrateOptions.DeleteLocalSymbols.getValue()) {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageViaCC.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private void runLinkerCommand(String imageName, LinkerInvocation inv, List<Strin
163163
BuildArtifacts.singleton().add(ArtifactType.IMPORT_LIBRARY, importLibCopy);
164164
}
165165

166-
if (SubstrateOptions.GenerateDebugInfo.getValue() > 0) {
166+
if (SubstrateOptions.useDebugInfoGeneration()) {
167167
BuildArtifacts.singleton().add(ArtifactType.DEBUG_INFO, SubstrateOptions.getDebugInfoSourceCacheRoot());
168168
if (Platform.includedIn(Platform.WINDOWS.class)) {
169169
BuildArtifacts.singleton().add(ArtifactType.DEBUG_INFO, imagePath.resolveSibling(imageName + ".pdb"));

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/sources/SourceCache.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@
3939
import java.util.HashMap;
4040
import java.util.List;
4141

42+
import org.graalvm.compiler.options.Option;
4243
import org.graalvm.nativeimage.ImageSingletons;
4344

4445
import com.oracle.svm.core.SubstrateOptions;
4546
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
4647
import com.oracle.svm.core.feature.InternalFeature;
48+
import com.oracle.svm.core.option.HostedOptionKey;
49+
import com.oracle.svm.core.option.LocatableMultiOptionValue;
4750
import com.oracle.svm.core.util.VMError;
4851
import com.oracle.svm.hosted.FeatureImpl;
4952
import com.oracle.svm.hosted.ImageClassLoader;
@@ -504,6 +507,12 @@ protected static void ensureTargetDirs(Path targetDir) {
504507
@AutomaticallyRegisteredFeature
505508
@SuppressWarnings("unused")
506509
class SourceCacheFeature implements InternalFeature {
510+
511+
public static class Options {
512+
@Option(help = "Search path for source files for Application or GraalVM classes (list of comma-separated directories or jar files)")//
513+
static final HostedOptionKey<LocatableMultiOptionValue.Paths> DebugInfoSourceSearchPath = new HostedOptionKey<>(LocatableMultiOptionValue.Paths.buildWithCommaDelimiter());
514+
}
515+
507516
ImageClassLoader imageClassLoader;
508517

509518
@Override
@@ -520,7 +529,7 @@ static List<Path> getModulePath() {
520529
}
521530

522531
static List<Path> getSourceSearchPath() {
523-
return SubstrateOptions.DebugInfoSourceSearchPath.getValue().values();
532+
return Options.DebugInfoSourceSearchPath.getValue().values();
524533
}
525534
}
526535

0 commit comments

Comments
 (0)