Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Interpretml Interpret Build Script

From Leeroopedia


Knowledge Sources
Domains Build_System, Native_Compilation, Cross_Platform
Last Updated 2026-02-07 12:00 GMT

Overview

Cross-platform POSIX shell build script that compiles the native libebm shared library for Linux (x64, x86, ARM) and macOS (x64, ARM) in both release and debug configurations, with optional assembly output, SIMD instruction set support, and conda environment compatibility.

Description

This is the primary build script for the InterpretML native C++ library. It handles the full compilation pipeline:

Helper functions:

  • sanitize() -- Escapes single quotes in shell arguments for safe eval usage.
  • get_file_body() -- Extracts the filename body (without extension or directory) using sed.
  • check_install() -- Installs system packages via apt-get or dnf if not already installed, with checkpoint files to avoid reinstallation.
  • make_paths() -- Creates object and binary output directories.
  • compile_file() -- Compiles a single .cpp file to a .o object file, with optional assembly (.s) generation using -fverbose-asm -S.
  • compile_directory() -- Compiles all .cpp files in a directory.
  • link_file() -- Links all accumulated object files into the final shared library.
  • copy_bin_files() / copy_asm_files() -- Copy build artifacts to staging and assembly output directories.

Build configurations:

  • Platforms: Linux (g++), macOS (clang++)
  • Architectures: x64, x86 (Linux only), ARM
  • Modes: Release (-O3, -DNDEBUG) and Debug (-O1)
  • SIMD: AVX2 and AVX512F support for x64 builds, compiled as separate translation units
  • Conda mode: Alternative build path that uses environment-specified compiler ($CXX), flags ($CXXFLAGS, $LDFLAGS), and explicit file listing

Compiler flags:

  • C++11 standard with comprehensive warnings (-Wall, -Wextra, -Wdouble-promotion, -Wold-style-cast, -Wshadow)
  • Strict floating-point behavior (-fno-math-errno, -fno-trapping-math, -fno-fast-math, -ffp-contract=off)
  • Hidden symbol visibility by default (-fvisibility=hidden)
  • Position-independent code (-fpic) and pthread support
  • Optional AddressSanitizer/UndefinedBehaviorSanitizer support via -asan flag
  • Linux uses version script and static libgcc/libstdc++ linking for portability
  • macOS uses install_name with @rpath for dynamic library loading

Command-line flags: -conda, -release_64, -debug_64, -release_32, -debug_32, -release_arm, -debug_arm, -asm, -extra_debugging, -asan

Usage

This script is invoked by the CI workflow for Linux and macOS builds, and can be run locally for development builds. Use the appropriate flags to select the target platform and configuration.

Code Reference

Source Location

Signature

#!/bin/sh

# Helper functions
sanitize()           # Escape single quotes for safe eval
get_file_body()      # Extract filename body from path
check_install()      # Install system package if missing
make_paths()         # Create obj and bin directories
compile_file()       # Compile single .cpp to .o (and optionally .s)
compile_directory()  # Compile all .cpp files in a directory
link_file()          # Link all object files into shared library
copy_bin_files()     # Copy binary to staging directory
copy_asm_files()     # Copy assembly output and generate objdump disassembly

# Usage:
#   ./build.sh [-conda] [-release_64] [-debug_64] [-release_32] [-debug_32]
#              [-release_arm] [-debug_arm] [-asm] [-extra_debugging] [-asan]

Import

N/A -- This is a shell script, not an importable module.

I/O Contract

Inputs

Name Type Required Description
-conda flag No Use conda environment compiler and flags
-release_64 flag No Build release configuration for x64
-debug_64 flag No Build debug configuration for x64
-release_32 flag No Build release configuration for x86 (Linux only)
-debug_32 flag No Build debug configuration for x86 (Linux only)
-release_arm flag No Build release configuration for ARM
-debug_arm flag No Build debug configuration for ARM
-asm flag No Generate assembly output alongside compilation
-extra_debugging flag No Add -g debug symbols flag
-asan flag No Enable AddressSanitizer and UndefinedBehaviorSanitizer

Outputs

Name Type Description
bld/lib/libebm*.so Shared library Linux shared library (platform/config-specific naming)
bld/lib/libebm*.dylib Shared library macOS shared library (platform/config-specific naming)
bld/asm/{tag}/*.s Assembly Annotated assembly output per source file (with -asm flag)
bld/asm/{tag}/libebm*.s Assembly objdump disassembly of final library (with -asm flag)

Usage Examples

# Build release x64 with assembly output
./build.sh -release_64 -asm

# Build debug ARM with AddressSanitizer
./build.sh -debug_arm -asan

# Build for conda environment
./build.sh -conda

# Build both release and debug x64
./build.sh -release_64 -debug_64

# Default build (release for current platform)
./build.sh

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment