Static ExecutablesΒΆ

You can produce cross-compiled static executable with dk Exe YourModule.Name where YourModule.Name is the name of your module.

Linking goes through each layer of object files, top to bottom. Any unresolved symbols must be resolved in a layer below it. Only symbols that are needed by the main() function are included in your final executable.

LayerAssetDescriptionGenerating Project
Bytecode objects ocamlc generated .bc file, converted to multiple object files.Your project
Bytecode runtime dksdk-foundations/<TARGET>-{d,r}/{lib}foundation-databases-<TARGET>-{debug,release}.{a,lib}The OCaml runtime and DkSDK-specific replacements and extensions of the OCaml runtimedksdk-foundations
C packages dksdk-c-packages/<TARGET>/runtime_static.zipThird-party C librariesdksdk-c-packages
dksdk_os dksdk-os/<TARGET>/os.zipDkSDK Memory Allocation and Loggingdksdk-ffi-c
sysroot dksdk-os/<TARGET>/sysroot[-api<ANDROID_API_LEVEL>].zipSystem Libraries like the C runtime librarydksdk-ffi-c

LayersΒΆ

sysroot layerΒΆ

Operating SystemSysroot ProvenanceLicenses RequiredPackagesLibraries
LinuxDebian dpkg-cross
  • libc, libm, libdl - GNU libc
  • libgcc - GCC Runtime
Android./dk dksdk.android.ndk.downloadAndroid Software Development Kit License Agreement Android NDK r23b API 21 libc - Android Bionic C library.
macOSmust be macOS machineXcode and Apple SDKs Agreement
Windowsxwin MICROSOFT VISUAL C++ 2015 - 2022 RUNTIME Crypt32, Normaliz

dksdk_os layerΒΆ

The libraries in the dksdk_os layer provide the implementation of the C headers:

  • dksdk_os/mem.h
  • dksdk_os/align.h
  • dksdk_os/err.h
  • dksdk_os/logger.h
  • dksdk_os/loggerconf.h

C packages layerΒΆ

The following C package static libraries are created with vcpkg or cmake:

  • ssl - Linux only. OpenSSL for curl.
  • crypto - Linux only. OpenSSL for curl.
  • nghttp2 - HTTP/2.
  • z - zlib. Compression for curl.
  • zstd - Compression for curl.
  • brotlidec - Compression for curl.
  • brotlicommon - Compression for curl.
  • cares - c-ares. Asynchronous DNS resolver.

Bytecode runtime layerΒΆ

This layer is the set of object files for:

  1. The conventional "INRIA" OCaml bytecode runtime, minus any objects in the DkSDK runtime below. The INRIA bytecode libraries are:
    • libcamlrun
    • libunix
    • libthreads
    • libcamlstr
  2. The DkSDK runtime which includes:
    • static libraries for curl, sqlite3 and ev
    • static libraries for stubs between OCaml packages and C:
      • xdg
      • ctypes
      • sqlite3
      • curl
      • integers
      • spawn
      • shexp
      • base
      • posixat
      • tiny_httpd
      • mtime
      • cstruct
      • ptime
      • bigstringaf
      • lwt
      • checkseum
      • stdint
      • digestif
      • mirage-crypto
      • MlFront_ZipFile
      • terminal
    • the DkSDK FFI OCaml static library
    • a static library "bytemain" containing:
      • the main() C function
      • DkSDK startup objects
      • DkSDK replacements for symbols that are incompatible with static executables:
        • sqlite3_enable_load_extension
      • DkSDK replacement for OCaml callbacks (source available alongside the asset)
      • DkSDK replacement for bytecode interpreter (source available alongside the asset)

Bytecode objects layerΒΆ

The object files are a product of the following steps:

  1. The traditional OCaml .bc bytecode file is compiled with ocamlc from the source code of your project.
  2. dk uses the LLVM Machine Code project to create several object files from the .bc bytecode file.