Skip to content

Conversation

Copy link

Copilot AI commented Oct 16, 2025

Overview

This PR fixes all compilation errors in the MT6765 kernel source (Linux 4.9.190) to enable successful compilation with modern toolchains, including Python 3 and GCC 10+.

Problem

The kernel source code failed to compile due to:

  1. Python 2 to 3 incompatibility - Build scripts (DrvGen.py and related tools) used deprecated Python 2 syntax
  2. Device Tree Compiler linker errors - Multiple definition of yylloc symbol
  3. Strict GCC warnings - Modern GCC versions treat more warnings as errors
  4. Incorrect header include paths - Local headers using system include syntax

Changes Made

Python 3 Compatibility Fixes

Fixed all Python 2 syntax in tools/dct/ to work with Python 3:

  • Updated print statements to use function syntax: print(...) instead of print ...
  • Fixed exception syntax: except Exception as e: instead of except Exception, e:
  • Replaced deprecated string.atoi() with int()
  • Replaced removed cmp() function with direct comparison operators
  • Updated ConfigParser imports for Python 3 compatibility
  • Fixed relative imports to absolute imports in all dct Python modules
  • Added strict=False to ConfigParser instances to handle duplicate config keys

Device Tree Compiler Fix

  • Changed yylloc declaration from regular variable to extern in scripts/dtc/dtc-lexer.l and scripts/dtc/dtc-lexer.lex.c_shipped to prevent multiple definition linker errors

GCC Compiler Warning Fixes

Addressed various strict compiler warnings now treated as errors:

Array Comparison Warnings:

  • Added explicit type casts in mm/page_alloc.c to fix array symbol comparison warnings

Function Name Conflicts:

  • Renamed free() to xts_free() in crypto/xts.c to avoid conflict with stdlib function

Uninitialized Variable Warnings:

  • Initialized buffers in: sound/soc/soc-core.c, net/compat.c, net/wireless/wext-core.c, lib/kstrtox.c, drivers/base/regmap/regcache-rbtree.c

False Positive Warnings:

  • Added pragmas to suppress false-positive warnings in:
    • arch/arm64/include/asm/cmpxchg.h (array-bounds in atomic operations)
    • arch/arm64/include/asm/syscall.h (array-bounds in syscall handling)
    • lib/reed_solomon/decode_rs.c (stringop-overflow and restrict)

Header Include Path Fixes

Fixed all local header includes in drivers/devfreq/ to use quotes instead of angle brackets:

  • Changed #include <helio-dvfsrc*.h> to #include "helio-dvfsrc*.h"
  • Changed #include <mtk_dvfsrc*.h> to #include "mtk_dvfsrc*.h"

This ensures the compiler searches in the local directory first rather than system include paths.

Testing

  • Successfully compiled kernel with k65v1_64_bsp_defconfig configuration
  • Used aarch64-linux-gnu-gcc cross-compilation toolchain
  • All compilation errors resolved, kernel builds without errors

Impact

This PR makes the kernel source compatible with:

  • Python 3.x (tested with 3.12)
  • Modern GCC versions (tested with GCC 11+)
  • Current build environments and CI/CD systems

No functional changes to the kernel code - all fixes are build-system and compatibility related.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Compile This Kernel Source And Fix Errors.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 11 commits October 16, 2025 04:05
Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
…cripts

Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
…strictness

Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
…ame conflict

Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
…omic ops

Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
…mon overflow warning

Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
…elio-dvfsrc-sysfs includes

Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
…rray-bounds warning

Co-authored-by: techdiwas <209884248+techdiwas@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix errors while compiling kernel source Fix kernel compilation errors for modern toolchains (Python 3, GCC 10+) Oct 16, 2025
Copilot AI requested a review from techdiwas October 16, 2025 04:41
Copy link
Contributor

@techdiwas techdiwas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants