From fb1198459ccf53f0a1055ac6e202c6539379ce7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lazar=20Mitrovi=C4=87?= Date: Fri, 24 Apr 2020 17:40:10 +0200 Subject: [PATCH] Add initial support for Bionic LibC --- .../com/oracle/svm/core/SubstrateOptions.java | 3 + .../oracle/svm/core/c/libc/BionicLibc.java | 56 +++++++++++++++++++ .../svm/hosted/NativeImageGenerator.java | 3 + 3 files changed, 62 insertions(+) create mode 100644 substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/libc/BionicLibc.java 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 f75af1669338..fefd705f2e11 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 @@ -435,6 +435,9 @@ public static Predicate makeFilter(String[] definedFilters) { @Option(help = "file:doc-files/UseMuslCHelp.txt", type = OptionType.Expert)// public static final HostedOptionKey UseMuslC = new HostedOptionKey<>(null); + @Option(help = "When set to true builds a native image using Bionic as the libc implementation", type = OptionType.Expert)// + public static final HostedOptionKey UseBionicC = new HostedOptionKey<>(false); + @Option(help = "When set to true, the image generator verifies that the image heap does not contain a home directory as a substring", type = User)// public static final HostedOptionKey DetectUserDirectoriesInImageHeap = new HostedOptionKey<>(false); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/libc/BionicLibc.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/libc/BionicLibc.java new file mode 100644 index 000000000000..886a57f33812 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/libc/BionicLibc.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.c.libc; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; + +public class BionicLibc implements LibCBase { + + @Override + public String getJDKStaticLibsPath() { + return LibCBase.PATH_DEFAULT; + } + + @Override + public void prepare(Path directory) { + } + + @Override + public List getAdditionalQueryCodeCompilerOptions() { + return Collections.emptyList(); + } + + @Override + public List getCCompilerOptions() { + return Collections.emptyList(); + } + + @Override + public boolean hasIsolatedNamespaces() { + return false; + } +} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java index e7cc3351385d..03858b3eccc1 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java @@ -160,6 +160,7 @@ import com.oracle.svm.core.c.libc.GLibc; import com.oracle.svm.core.c.libc.LibCBase; import com.oracle.svm.core.c.libc.MuslLibc; +import com.oracle.svm.core.c.libc.BionicLibc; import com.oracle.svm.core.code.RuntimeCodeCache; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.graal.GraalConfiguration; @@ -875,6 +876,8 @@ private void prepareLibC() { LibCBase libc; if (SubstrateOptions.UseMuslC.hasBeenSet()) { libc = new MuslLibc(); + } else if (SubstrateOptions.UseBionicC.hasBeenSet()) { + libc = new BionicLibc(); } else { libc = new GLibc(); }