-
Notifications
You must be signed in to change notification settings - Fork 372
Description
Which component impacted?
Build
Is it regression? Good in old configuration?
No, this issue exist a long time
What happened?
PROBLEM
The CMake build configuration adds 600+ include directories (-I flags) to
individual source files. This is excessive - typical C++ projects use 20-100
include directories.
IMPACT
- Build failures in Yocto/OpenEmbedded (ARG_MAX limit exceeded)
- Fails with typical workspace path lengths (80-120 characters)
- Breaks in Docker, CI/CD, and automated build environments
- Slower compilation (compiler searches 600+ directories per file)
ERROR
fatal error: cannot execute 'cc1plus': posix_spawn: Argument list too long
CAUSE
600+ include paths × ~100 chars average = 60KB+ of path data
Combined with other compiler arguments, this exceeds Linux ARG_MAX limits.
Note: Response files don't solve this - GCC expands them before spawning
cc1plus, so the limit still applies.
SOLUTION
Reduce include directories using CMake best practices:
- Replace include_directories() with target_include_directories()
- Use PRIVATE visibility for internal headers
- Use INTERFACE/PUBLIC only for headers exposed to consumers
- Remove duplicate/redundant paths
- Use relative paths for headers
BENEFITS
- Fixes build failures across multiple environments
- Faster compilation (20-30% improvement typical)
- Better maintainability and clearer dependencies
- Modern CMake best practices
VERIFICATION
Check compile_commands.json - most files should have 20-100 include
directories, not 600+.
What's the usage scenario when you are seeing the problem?
Others
What impacted?
Compilation of media_driver source files, specifically:
- media_driver COMMON target compilation units
- Files including: cm_def.cpp, cm_buffer_rt.cpp, cm_event_rt.cpp, cm_hal.cpp
- Affects all builds where workspace path + include directories exceed ARG_MAX
- Build environments: Yocto/OpenEmbedded, Docker, CI/CD systems
Debug Information
Build System: CMake with Ninja generator
Compiler: GCC (g++)
System: Linux (ARG_MAX: 2097152 bytes / 2MB)
Include directory count from response file:
$ grep -c "^-I" media_driver/CMakeFiles/iHD_drv_video_COMMON.dir/file.rsp
600+
Example compilation command (from build.ninja):
/path/to/g++ --sysroot=/path/to/sysroot @response_file.rsp -MD -MT
Do you want to contribute a patch to fix the issue?
No.