Skip to content

undefined reference to __divdi3 #186

@bulwahn

Description

@bulwahn

clang fails to properly link the kernel build with tinyconfig:

LD      vmlinux
ld: kernel/events/core.o: in function `perf_adjust_period':
core.c:(.text+0x5bb9): undefined reference to `__divdi3'
ld: mm/filemap.o: in function `filemap_fault':
filemap.c:(.text+0x1d25): undefined reference to `__divdi3'
ld: filemap.c:(.text+0x1f25): undefined reference to `__divdi3'
ld: mm/filemap.o: in function `filemap_map_pages':
filemap.c:(.text+0x213f): undefined reference to `__divdi3'
ld: mm/page-writeback.o: in function `balance_dirty_pages_ratelimited':
page-writeback.c:(.text+0xaf3): undefined reference to `__divdi3'
make: *** [Makefile:1037: vmlinux] Error 1

I tested it with clang-7 and the recent version of clang-8 (clang version 8.0.0-svn343562-1exp1+020181002091440.2051~1.gbp47b1b6 (trunk)).

To get to this point of compiling and linking the kernel (tag: next-20181002 from linux-next), I applied three hacky patches:

hack around to make it compile with clang
compiler.h: give up __compiletime_assert_fallback()
Make clang hate percpu.h less in 32-bit mode 

I provide the three patches in this repository here:

https://github.com/bulwahn/linux-kernel-analysis/tree/clang-patches/clang/next/next-20181002/patches

Metadata

Metadata

Assignees

No one assigned

    Labels

    [ARCH] x86This bug impacts ARCH=i386[BUG] linuxA bug that should be fixed in the mainline kernel.[FIXED][LINUX] 5.1This bug was fixed in Linux 5.1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions