From bad33144a806500eef42df01cc46deaa8cb83eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandar=20Pejovi=C4=87?= Date: Mon, 5 Feb 2024 11:29:51 +0100 Subject: [PATCH] Report error if building static executable without musl libc --- .../src/com/oracle/svm/core/SubstrateOptions.java | 4 ++++ .../svm/core/option/ValidateImageBuildOptionsFeature.java | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java index 46cf946a543d..63a3eee22172 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java @@ -108,6 +108,10 @@ public class SubstrateOptions { if (!Platform.includedIn(Platform.LINUX.class)) { throw UserError.invalidOptionValue(key, key.getValue(), "Building static executable images is currently only supported on Linux. Remove the '--static' option or build on a Linux machine"); } + if (!LibCBase.targetLibCIs(MuslLibC.class)) { + throw UserError.invalidOptionValue(key, key.getValue(), + "Building static executable images is only supported with musl libc. Remove the '--static' option or add the '--libc=musl' option."); + } }); @APIOption(name = "libc")// diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/ValidateImageBuildOptionsFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/ValidateImageBuildOptionsFeature.java index b7fea207a8ce..c20c7d1b8041 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/ValidateImageBuildOptionsFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/ValidateImageBuildOptionsFeature.java @@ -25,15 +25,16 @@ package com.oracle.svm.core.option; import org.graalvm.collections.UnmodifiableMapCursor; -import jdk.graal.compiler.options.OptionKey; -import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; + +import jdk.graal.compiler.options.OptionKey; @AutomaticallyRegisteredFeature public class ValidateImageBuildOptionsFeature implements InternalFeature { @Override - public void afterRegistration(AfterRegistrationAccess access) { + public void beforeAnalysis(BeforeAnalysisAccess access) { UnmodifiableMapCursor, Object> cursor = RuntimeOptionValues.singleton().getMap().getEntries(); while (cursor.advance()) { validate(cursor.getKey());