Build Instructions

Build instructions, supported environments, and feature selection.

Overview

AsmJit is designed to be easy embeddable in any project. However, it depends on some compile-time definitions that can be used to enable or disable features to decrease the resulting binary size. A typical way of building AsmJit is to use cmake, but it's also possible to just include AsmJit source code in your project and to just build it. The easiest way to include AsmJit in your project is to just include src directory in your project and to define ASMJIT_STATIC. AsmJit can be just updated from time to time without any changes to this integration process. Do not embed AsmJit's test files in such case as these are used exclusively for testing.

Supported C++ Compilers

  • Requirements:
    • AsmJit won't build without C++11 enabled. If you use older GCC or Clang you would have to enable at least C++11 standard through compiler flags.
  • Tested:
    • Clang - Tested by Travis-CI - Clang 3.9+ (with C++11 enabled) is officially supported (older Clang versions having C++11 support are probably fine, but are not regularly tested).
    • GNU - Tested by Travis-CI - GCC 4.8+ (with C++11 enabled) is officially supported.
    • MINGW - Tested by Travis-CI - Use the latest version, if possible.
    • MSVC - Tested by Travis-CI - VS2017+ is officially supported, VS2015 is reported to work.
  • Untested:
    • Intel - No maintainers and no CI environment to regularly test this compiler.
    • Other C++ compilers would require basic support in core/api-config.h.

Supported Operating Systems and Platforms

  • Tested:
    • Linux - Tested by Travis-CI (any distribution is generally supported).
    • OSX - Tested by Travis-CI (any version is supported).
    • Windows - Tested by Travis-CI - (Windows 7+ is officially supported).
    • Emscripten - Works if compiled with ASMJIT_NO_JIT. AsmJit cannot generate WASM code, but can be used to generate X86/X64 code within a browser, for example.
  • Untested:
    • BSDs - No maintainers, no CI environment to regularly test BSDs, but they should work out of box.
    • Haiku - Not regularly tested, but reported to work.
    • Other operating systems would require some testing and support in the following files:

Supported Backends / Architectures

  • X86 - Both 32-bit and 64-bit backends tested by Travis-CI.
  • ARM - Work-in-progress (not public at the moment).

Static Builds and Embedding

These definitions can be used to enable static library build. Embed is used when AsmJit's source code is embedded directly in another project, implies static build as well.

Note
Projects that use AsmJit statically must define ASMJIT_STATIC in all compilation units that use AsmJit, otherwise AsmJit would use dynamic library imports in ASMJIT_API decorator. The recommendation is to define this macro across the whole project that uses AsmJit this way.

Build Configuration

These definitions control whether asserts are active or not. By default AsmJit would autodetect build configuration from existing pre-processor definitions, but this behavior can be overridden, for example to enable debug asserts in release configuration.

  • ASMJIT_BUILD_DEBUG - Overrides build configuration to debug, asserts will be enabled in this case.
  • ASMJIT_BUILD_RELEASE - Overrides build configuration to release, asserts will be disabled in this case.
Note
There is usually no need to override the build configuration. AsmJit detects the build configuration by checking whether NDEBUG is defined and automatically defines ASMJIT_BUILD_RELEASE if configuration overrides were not used. We only recommend using build configuration overrides in special situations, like using AsmJit in release configuration with asserts enabled for whatever reason.

AsmJit Backends

AsmJit currently supports only X86/X64 backend, but the plan is to add more backends in the future. By default AsmJit builds only the host backend, which is autodetected at compile-time, but this can be overridden.

  • ASMJIT_BUILD_X86 - Always build X86 backend (X86 and X86_64).
  • ASMJIT_BUILD_ARM - Always build ARM backend (ARM and AArch64).
  • ASMJIT_BUILD_HOST - Always build the host backend.

Features Selection

AsmJit builds by defaults all supported features, which includes all emitters, logging, instruction validation and introspection, and JIT memory allocation. Features can be disabled at compile time by using ASMJIT_NO_... definitions.

Note
It's not recommended to disable features if you plan to build AsmJit as a shared library that will be used by multiple projects that you don't control how AsmJit was built (for example AsmJit in a Linux distribution). The possibility to disable certain features exists mainly for customized AsmJit builds.

Macros

Macro Definition Documentation

#define ASMJIT_EMBED

Asmjit is embedded, implies ASMJIT_STATIC.

#define ASMJIT_STATIC

Enables static-library build.

#define ASMJIT_BUILD_DEBUG

Defined when AsmJit's build configuration is 'Debug'.

Note
Can be defined explicitly to bypass autodetection.

#define ASMJIT_BUILD_RELEASE

Defined when AsmJit's build configuration is 'Release'.

Note
Can be defined explicitly to bypass autodetection.

#define ASMJIT_BUILD_X86

Defined to build X86/X64 backend.

#define ASMJIT_BUILD_HOST

Defined to build host backend autodetected at compile-time.

#define ASMJIT_NO_DEPRECATED

Disables deprecated API at compile time.

#define ASMJIT_NO_FOREIGN

Disable non-host architectures entirely.

#define ASMJIT_NO_BUILDER

Disables Builder functionality completely.

#define ASMJIT_NO_COMPILER

Disables Compiler functionality completely.

#define ASMJIT_NO_JIT

Disables JIT memory management and JitRuntime.

#define ASMJIT_NO_LOGGING

Disables Logger and Formatter.

#define ASMJIT_NO_TEXT

Disables everything that contains text.

#define ASMJIT_NO_VALIDATION

Disables instruction validation API.

#define ASMJIT_NO_INTROSPECTION

Disables instruction introspection API.