Skip to main content
7-Zip can be compiled on Linux using GCC or Clang compilers, with optional assembler optimizations for better performance.

Requirements

Compiler

GCC 4.8 or later (GCC 9+ recommended)
Install on Debian/Ubuntu:

Build Tools

Assembler (Optional, for Performance)

For x86/x64 optimizations, install one of:
JWasm is not recommended - It doesn’t support AES instructions used in 7-Zip. The build will fall back to C versions of AES code, reducing performance.

Quick Start

Navigate to a bundle directory and build:
1

Navigate to Bundle

2

Build with make

The -j flag enables parallel compilation for faster builds.
3

Run the binary

Build Configurations

7-Zip provides specialized makefiles for optimized builds:

Basic Builds (No Assembler)

Optimized Builds (With Assembler)

Makefile Variables

You can customize builds using variables with makefile.gcc:

Platform Control

boolean
default:"0"
Build for x86-64 architecture
boolean
default:"0"
Enable assembler optimizations
string
default:"asmc"
Specify assembler program

RAR Support Control

boolean
default:"0"
Remove all RAR-related code
boolean
default:"0"
Remove RAR decompression codecs (keeps archive listing support)

Assembler Selection

boolean
default:"0"
Use JWasm instead of Asmc (not recommended)
When using USE_JWASM=1, AES code from AesOpt.c will be used instead of assembler AesOpt.asm because JWasm doesn’t support AES instructions.

Build Examples

Standard x64 Build Without Assembler

Output: b/g/7zz

Optimized x64 Build With Assembler

Output: b/g_x64/7zz

Build Without RAR Support

Build With Custom UASM Assembler

Build Targets

Different bundle directories produce different binaries:

Compiler Flags

The build system uses the following optimization flags (from 7zip_gcc.mak):
Additional optimization options:
  • -flto - Link-time optimization (enabled in some configs)
  • -ffunction-sections - Separate functions for linker optimization

Output Directory Structure

Builds create output in subdirectories:
  • b/g/ - GCC builds (general)
  • b/g_x64/ - GCC x64 builds
  • b/g_arm64/ - GCC ARM64 builds
  • _o/ - Default output directory for makefile.gcc

Troubleshooting

If building with USE_ASM=1 but assembler is missing:
Install pthread development libraries:
Use the -j flag to enable parallel compilation:

Performance Comparison

Builds with assembler optimizations provide significant performance improvements:
With Assembler (cmpl_gcc_x64.mak):
  • Optimized CRC32 calculation
  • Hardware AES encryption (if CPU supports)
  • Faster LZMA compression/decompression
  • Optimized SHA-256 hashing
Without Assembler (cmpl_gcc.mak):
  • Uses C implementations for all codecs
  • Portable to any architecture
  • Slower but still functional

Cross-Compilation

To cross-compile for a different architecture:
The var_gcc.mak file supports the CROSS_COMPILE variable for setting the compiler prefix.

Next Steps

  • Test your build: ./b/g/7zz --help
  • Benchmark performance: ./b/g/7zz b
  • Review build options

See Also