Scroll to navigation

CLANG-EXTRACT(1) User Commands CLANG-EXTRACT(1)

NAME

clang-extract - Tool to extract code content from source files using clang and LLVM infrastructure

DESCRIPTION

OVERVIEW: Tool to extract code from C projects using the LLVM infrastructure.

It should be invoked as a C compiler.

USAGE: clang-extract [options] file...

CLANG-EXTRACT OPTIONS:

<clang-switch>
A clang switch, as specified by calling clang --help.
Indicate that we are processing a Linux sourcefile.
Extract the functions specified in the <args> list.
Force externalization of symbols specified in the <args> list
Output code to <arg> file. Default is <input>.CE.c.
Disable symbol externalization.
Dump the results of each transformation pass into files.
Keep all possible #include<file> directives.
Keep all possible #include<file> directives, but using the specified include expansion <policy>. Valid values are nothing, everything, kernel, system and compiler.
Force expansion of the headers provided in <args>.
Force the following headers to NOT be expanded.
Allow renaming of extracted symbols.
Path to the compiled (ELF) object of the desired program to extract. This is used to decide if externalization is necessary or not for given symbol.
Path to .ipa-clones files generated by gcc. Used to decide if desired function to extract was inlined into other functions.
Path to kernel Modules.symvers file. Only used when -D__KERNEL__ is specified.
Libpulp .dsc file output, used for userspace livepatching.
Outputs a header file with a forward declaration of all functions. This header is not self-compilable.
Enable late externalization (declare externalized variables later than the original). May reduce code output when -DCE_KEEP_INCLUDES is enabled
generated even if it won't compile.

The following arguments are ignored by clang-extract:

-mpreferred-stack-boundary=

-mindirect-branch=thunk-extern

-mindirect-branch-register

-mrecord-mcount

-falign-jumps=

-fasan-shadow-offset=

-fconserve-stack

-fdump-ipa-clones

-flive-patching=inline-clone

-fmin-function-alignment=16

-fno-allow-store-data-races

-fno-var-tracking-assignments

-Wno-alloc-size-larger-than

-Wno-dangling-pointer

-Wno-format-truncation

-Wno-format-overflow

-Wmaybe-uninitialized

-Wno-maybe-uninitialized

-Wpacked-not-aligned

-Wno-packed-not-aligned

-Wno-restrict

-Wno-stringop-overflow

-Wstringop-truncation

-Wno-stringop-truncation

-Werror=designated-init

-Wimplicit-fallthrough=

-Wendif-labels

-Wmissing-selector-name

-Wfree-labels

-Wmissing-parameter-name

For a list of switches accepted by clang, run:

$ clang --help

This manpage was developed by Aryan Karamtoth for the Debian GNU/Linux System but can be used by other distributions.

May 2026 clang-extract 1.0