en Kernel Build FAQ - JackA1ltman/NonGKI_Kernel_Build_2nd GitHub Wiki
Kernel Build — FAQ
This page covers common errors and troubleshooting tips encountered during the build process. When something goes wrong, always read the full build log first — the real cause of a failure almost always appears above the Error 2 line.
Before the Build
Q1: Why do I get No such file or directory?
Cause: The compiler cannot find a required header file (.h) or source file (.c) at the specified path.
Fix:
- Double-check that all file paths are correct
- If a system header is missing, install the corresponding dependency library, for example:
sudo apt install libssl-dev zlib1g-dev
Q2: I see cannot open involving a .gz file?
Cause: The required kernel configuration file was never generated, or was wiped by a previous make mrproper.
Fix: Re-run the defconfig command to regenerate it:
make ARCH=arm64 O=out <your_defconfig>
Build Errors (Error 2)
Compiler & Toolchain Compatibility
Q3: I see unrecognized command line option?
Cause: The current toolchain version does not match what the kernel source expects — either too old or too new — so a compiler flag is not recognized.
Fix: Check the relevant compiler flags in the Makefile and consider upgrading or downgrading your GCC / Clang version accordingly.
Q4: I see target emulation unknown?
Cause: The linker (ld) does not recognize the specified emulation mode. This is typically caused by mixing LLVM and GNU toolchain components.
Fix: Make sure the LD variable points to the correct linker for your toolchain. When using LLVM, set:
LD=ld.lld
Q5: I see assembler command failed with exit code 1?
Cause: The assembler reported an error, usually an internal Clang issue or a version incompatibility.
Fix: Try switching to a different version of Clang.
KernelSU-Specific
Q6: I see MODULE_IMPORT_NS(...) VFS_internal...?
Cause: The official KernelSU is incompatible with Non-GKI kernels, or the wrong fork branch is being used.
Fix:
- Official KernelSU: Try rolling back to an older release such as
v0.9.5 - Fork: Switch to the correct branch. For example, with SukiSU-Ultra, Non-GKI kernels require the
builtinbranch, notmain
Clang Issues
Q7: I see not found (required by clang)?
Cause: The host system is too old to run the version of Clang you are using.
Fix: Upgrade your OS. Ubuntu 22.04 or later is recommended.
Q8: I see Error: junk at end of line...?
Cause: The assembler cannot parse the debug information produced by a newer Clang — a DWARF format version mismatch.
Fix (choose one):
- Downgrade Clang to a lower version (e.g. from Clang 20 to Clang 12)
- Add the following flag to
KBUILD_CFLAGSin yourMakefileto force a compatible DWARF format:
KBUILD_CFLAGS += -gdwarf-4
Code & Syntax Errors
Q9: I see undefined reference to ...?
Cause: A linker error — a function is declared but its implementation cannot be found (missing library or object file).
Fix:
- Check whether a required library is missing from the link step (e.g.
-lssl) - Confirm the library path is included in
LDFLAGS - Check for typos in function names
Q10: I see a misleading-indentation warning or error?
Cause: Code indentation does not match the logical control block structure (if / for / while), creating a potential logic trap.
Fix: Add explicit curly braces {} to the affected statements to make the scope unambiguous.
Q11: I see type specifier missing or makes pointer from integer...?
Cause: A C variable declaration is missing a type keyword, or there is a type mismatch (e.g. an integer being used where a pointer is expected).
Fix:
- Check whether type keywords like
intare missing from variable declarations - Verify whether the kernel API being used has changed between versions
Other Build Issues
Q12: I see multiple definition of 'yylloc'?
Cause: This is a well-known conflict between older kernel source code and newer versions of GCC.
Fix: Edit scripts/dtc/dtc-lexer.lex.c_shipped and change:
YYLTYPE yylloc;
to:
extern YYLTYPE yylloc;
Q13: I see make[N]: *** [Error X] — what does that mean?
Cause: This is a generic Makefile build failure marker. It contains no useful diagnostic information on its own.
Fix: This line is just the result — the actual error is above it. Scroll up in the log and look for the specific error message emitted by gcc, ld, or sh.