Docker Community Forums

Share and learn in the Docker community.

Missing setupterm Symbol


(Napperley) #1

During the Docker image build process compilation of a Kotlin Native program fails (missing setupterm symbol) with the following errors:

error: compilation failed: /opt/kotlin-native-linux-0.7.1/konan/nativelib/libllvmstubs.so: Error relocating /opt/kotlin-native-linux-0.7.1/konan/nativelib/libllvmstubs.so: setupterm: symbol not found

 * Source files: main.kt
 * Compiler version info: Konan: 0.7.1 / Kotlin: 1.2.60
 * Output kind: PROGRAM

exception: java.lang.UnsatisfiedLinkError: /opt/kotlin-native-linux-0.7.1/konan/nativelib/libllvmstubs.so: Error relocating /opt/kotlin-native-linux-0.7.1/konan/nativelib/libllvmstubs.so: setupterm: symbol not found
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
	at java.lang.System.loadLibrary(System.java:1122)
	at llvm.llvm.<clinit>(llvm.kt:4262)
	at org.jetbrains.kotlin.backend.konan.llvm.IrToBitcodeKt.emitLLVM(IrToBitcode.kt:63)
	at org.jetbrains.kotlin.backend.konan.KonanDriverKt$runTopLevelPhases$4$2.invoke(KonanDriver.kt:97)
	at org.jetbrains.kotlin.backend.konan.KonanDriverKt$runTopLevelPhases$4$2.invoke(KonanDriver.kt)
	at org.jetbrains.kotlin.backend.konan.PhaseManager$phase$$inlined$with$lambda$1.invoke(KonanPhases.kt:139)
	at org.jetbrains.kotlin.backend.konan.PhaseManager$phase$$inlined$with$lambda$1.invoke(KonanPhases.kt:118)
	at org.jetbrains.kotlin.konan.util.UtilKt.profileIf(Util.kt:34)
	at org.jetbrains.kotlin.backend.konan.PhaseManager.phase$backend_native_compiler(KonanPhases.kt:138)
	at org.jetbrains.kotlin.backend.konan.KonanDriverKt$runTopLevelPhases$4.invoke(KonanDriver.kt:96)
	at org.jetbrains.kotlin.backend.konan.KonanDriverKt$runTopLevelPhases$4.invoke(KonanDriver.kt)
	at org.jetbrains.kotlin.backend.konan.PhaseManager$phase$$inlined$with$lambda$1.invoke(KonanPhases.kt:139)
	at org.jetbrains.kotlin.backend.konan.PhaseManager$phase$$inlined$with$lambda$1.invoke(KonanPhases.kt:118)
	at org.jetbrains.kotlin.konan.util.UtilKt.profileIf(Util.kt:34)
	at org.jetbrains.kotlin.backend.konan.PhaseManager.phase$backend_native_compiler(KonanPhases.kt:138)
	at org.jetbrains.kotlin.backend.konan.KonanDriverKt.runTopLevelPhases(KonanDriver.kt:90)
	at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:75)
	at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:42)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:95)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:50)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:88)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:66)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:34)
	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:180)
	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:171)
	at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:197)
	at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:188)
	at org.jetbrains.kotlin.konan.util.UtilKt.profileIf(Util.kt:34)
	at org.jetbrains.kotlin.konan.util.UtilKt.profile(Util.kt:29)
	at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:190)
	at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:202)
	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:27)

The command '/bin/sh -c /opt/kotlin-native-linux-${KOTLIN_NATIVE_VER}/bin/konanc -opt -o handler main.kt' returned a non-zero code: 2

Below are the contents of the Dockerfile:

FROM openjdk:8u121-jdk-alpine
ENV KOTLIN_NATIVE_VER 0.7.1
ADD https://github.com/openfaas/faas/releases/download/0.8.2/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog
RUN mkdir -p /opt
RUN apk update
RUN apk add curl

RUN cd /opt && curl -L https://github.com/JetBrains/kotlin-native/releases/download/v${KOTLIN_NATIVE_VER}/kotlin-native-linux-${KOTLIN_NATIVE_VER}.tar.gz | tar -xz
RUN chmod +x /opt/kotlin-native-linux-${KOTLIN_NATIVE_VER}/bin/konanc
RUN mkdir -p /app

WORKDIR /app
COPY main.kt .
RUN echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories
RUN apk update
RUN apk add --no-cache bash
RUN apk add libc6-compat
RUN /opt/kotlin-native-linux-${KOTLIN_NATIVE_VER}/bin/konanc -opt -o handler main.kt

ENV fprocess="./handler.kexe"
HEALTHCHECK --interval=2s CMD [ -e /tmp/.lock ] || exit 1
CMD ["fwatchdog"]

Is there a way to install the full version of glibc in Alpine Linux?


(Napperley) #2

Found that replacing Alpine with a Debian image fixed the problem.