Skip to content

Commit 3a9bc29

Browse files
committed
leverage LayerOptionVerification to enable layered image to get further on a non-supported platform before failing
1 parent 3b06b2d commit 3a9bc29

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ImageSingletonsSupportImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.graalvm.nativeimage.impl.AnnotationExtractor;
4545
import org.graalvm.nativeimage.impl.ImageSingletonsSupport;
4646

47+
import com.oracle.svm.core.SubstrateOptions;
4748
import com.oracle.svm.core.SubstrateUtil;
4849
import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport;
4950
import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingletonSupport;
@@ -430,7 +431,9 @@ private void addSingleton(Class<?> key, Object value) {
430431
traitMap.getTrait(SingletonTraitKind.LAYERED_INSTALLATION_KIND).ifPresent(trait -> {
431432
var kind = SingletonLayeredInstallationKind.getInstallationKind(trait);
432433
if (forbiddenInstallationKinds.contains(kind)) {
433-
throw VMError.shouldNotReachHere("Singleton with installation kind %s can no longer be added: %s", kind, value);
434+
if (SubstrateOptions.LayerOptionVerification.getValue()) {
435+
throw VMError.shouldNotReachHere("Singleton with installation kind %s can no longer be added: %s", kind, value);
436+
}
434437
}
435438
});
436439
}
@@ -633,10 +636,10 @@ public SingletonTraitMap getUninstalledSingletonTraitMap(Class<?> key) {
633636
var installationKindSupplierClass = annotation.layeredInstallationKind();
634637
/*
635638
* Initial Layer information should never be injected, as either
636-
*
639+
*
637640
* 1) We are building the initial layer, so it should be present in the
638641
* configObject which it exists.
639-
*
642+
*
640643
* 2) We are building an extension layer, so it is not relevant for this
641644
* layer.
642645
*/

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/imagelayer/HostedImageLayerBuildingSupport.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import com.oracle.svm.hosted.option.HostedOptionParser;
7070
import com.oracle.svm.shaded.org.capnproto.ReaderOptions;
7171
import com.oracle.svm.shaded.org.capnproto.Serialize;
72+
import com.oracle.svm.util.LogUtils;
7273
import com.oracle.svm.util.TypeResult;
7374

7475
import jdk.graal.compiler.core.common.SuppressFBWarnings;
@@ -324,8 +325,12 @@ public static HostedImageLayerBuildingSupport initialize(HostedOptionValues valu
324325
ValueWithOrigin<String> valueWithOrigin = getLayerCreateValueWithOrigin(values);
325326
String layerCreateValue = getLayerCreateValue(valueWithOrigin);
326327
String layerCreateArg = SubstrateOptionsParser.commandArgument(SubstrateOptions.LayerCreate, layerCreateValue);
327-
throw UserError.abort("Layer creation option '%s' from %s is not supported when building for platform %s/%s.",
328+
String message = String.format("Layer creation option '%s' from %s is not supported when building for platform %s/%s.",
328329
layerCreateArg, valueWithOrigin.origin(), platform.getOS(), platform.getArchitecture());
330+
if (SubstrateOptions.LayerOptionVerification.getValue(values)) {
331+
throw UserError.abort("%s", message);
332+
}
333+
LogUtils.warning(message);
329334
}
330335
}
331336

0 commit comments

Comments
 (0)