• Recent
    • Docs
    • Github
    • 百度网盘
    • Google
    • Official
    • Shop
    • Register
    • Login

    用Clang构建内核

    Scheduled Pinned Locked Moved PI CM5 Laptop
    1 Posts 1 Posters 15 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jask
      last edited by

      截屏2026-01-13 21.54.26.png
      起因是用gen_compile_commands.py生成的compilation database对于clangd不太友好,便想着用clang构建内核试试,还是遇到了一些问题,也学习到很多东西。

      1. scripts/Makefile.extrawarn。clang构建内核需要关掉一些flag,否则会编译失败,这个是最容易修改的。
      2. cannot jump from this indirect goto statement to one of its possible targets。在此之前我并不知道gcc还有这样的拓展,这个问题出现在drm相关的代码里面,我用比较丑陋的代码暂时处理了,以后再看看mainline kernel是怎么处理的。
        64d06ff8-2c0f-4aee-a44a-a5eff0bc54e7-afe7b1040455aeedf0e6d426b95c9893.png a4a8a050-9b43-4eea-9822-52cc8a5000e6-3fba723c00a7809097282462a3cc1186.png
      3. 数组大小问题。eda8b240-93b8-48d7-ae1d-373e948aaa1b-6293296cb735f5889097a827b4504e1f.png

      对我而言这是一次有趣的体验,从lkml的patch里面提取有效信息、看llvm issue、看GCC手册,所以写下来当作消遣。

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post