table of contents
- unstable 0.0~git20260224.ac30d66-1
| 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.
- -D__KERNEL__
- Indicate that we are processing a Linux sourcefile.
- -DCE_EXTRACT_FUNCTIONS=<args>
- Extract the functions specified in the <args> list.
- -DCE_EXPORT_SYMBOLS=<args>
- Force externalization of symbols specified in the <args> list
- -DCE_OUTPUT_FILE=<arg>
- Output code to <arg> file. Default is <input>.CE.c.
- -DCE_NO_EXTERNALIZATION
- Disable symbol externalization.
- -DCE_DUMP_PASSES
- Dump the results of each transformation pass into files.
- -DCE_KEEP_INCLUDES
- Keep all possible #include<file> directives.
- -DCE_KEEP_INCLUDES=<policy>
- Keep all possible #include<file> directives, but using the specified include expansion <policy>. Valid values are nothing, everything, kernel, system and compiler.
- -DCE_EXPAND_INCLUDES=<args>
- Force expansion of the headers provided in <args>.
- -DCE_NOT_EXPAND_INCLUDES=<args>
- Force the following headers to NOT be expanded.
- -DCE_RENAME_SYMBOLS
- Allow renaming of extracted symbols.
- -DCE_DEBUGINFO_PATH=<arg>
- 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.
- -DCE_IPACLONES_PATH=<arg>
- Path to .ipa-clones files generated by gcc. Used to decide if desired function to extract was inlined into other functions.
- -DCE_SYMVERS_PATH=<arg>
- Path to kernel Modules.symvers file. Only used when -D__KERNEL__ is specified.
- -DCE_DSC_OUTPUT=<arg>
- Libpulp .dsc file output, used for userspace livepatching.
- -DCE_OUTPUT_FUNCTION_PROTOTYPE_HEADER=<arg>
- Outputs a header file with a forward declaration of all functions. This header is not self-compilable.
- -DCE_LATE_EXTERNALIZE
- Enable late externalization (declare externalized variables later than the original). May reduce code output when -DCE_KEEP_INCLUDES is enabled
- -DCE_IGNORE_CLANG_ERRORS Ignore clang compilation errors in a hope that code is
- 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 |