Skip to content

Conversation

nathanchance
Copy link
Member

When building the LoongArch Linux kernel without CONFIG_DYNAMIC_FTRACE, the build fails to link because the mcount symbol is mcount, not _mcount like GCC generates and the kernel expects:

ld.lld: error: undefined symbol: mcount
>>> referenced by version.c
>>>               init/version.o:(early_hostname) in archive vmlinux.a
>>> referenced by do_mounts.c
>>>               init/do_mounts.o:(rootfs_init_fs_context) in archive vmlinux.a
>>> referenced by main.c
>>>               init/main.o:(__traceiter_initcall_level) in archive vmlinux.a
>>> referenced 97011 more times
>>> did you mean: _mcount
>>> defined in: vmlinux.a(arch/loongarch/kernel/mcount.o)

Set MCountName in LoongArchTargetInfo to _mcount, which resolves the build failure.

When building the LoongArch Linux kernel without CONFIG_DYNAMIC_FTRACE,
the build fails to link because the mcount symbol is "mcount", not
"_mcount" like GCC generates and the kernel expects:

  ld.lld: error: undefined symbol: mcount
  >>> referenced by version.c
  >>>               init/version.o:(early_hostname) in archive vmlinux.a
  >>> referenced by do_mounts.c
  >>>               init/do_mounts.o:(rootfs_init_fs_context) in archive vmlinux.a
  >>> referenced by main.c
  >>>               init/main.o:(__traceiter_initcall_level) in archive vmlinux.a
  >>> referenced 97011 more times
  >>> did you mean: _mcount
  >>> defined in: vmlinux.a(arch/loongarch/kernel/mcount.o)

Set MCountName in LoongArchTargetInfo to "_mcount", which resolves the build
failure.
@nathanchance nathanchance requested review from a team as code owners September 7, 2023 19:07
@github-actions github-actions bot added clang:frontend Language frontend issues, e.g. anything involving "Sema" backend:loongarch labels Sep 7, 2023
@nathanchance
Copy link
Member Author

cc @xen0n

@xen0n
Copy link
Contributor

xen0n commented Sep 7, 2023

also cc @SixWeining (BTW we want to have a GitHub team set up for notifications and assignments apparently)

It's 4 am here and I'd take a look after getting some sleep, to ensure review quality ;-)

@SixWeining
Copy link
Contributor

SixWeining commented Sep 8, 2023

also cc @SixWeining (BTW we want to have a GitHub team set up for notifications and assignments apparently)

There is one:
https://github.com/orgs/llvm/teams/pr-subscribers-loongarch

I will invite you to join this team and others interested in could also request to join.

EDIT: Seems that you should request to join the llvm organization firstly.

Copy link
Contributor

@SixWeining SixWeining left a comment

Choose a reason for hiding this comment

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

I have checked that glibc/sysdeps/loongarch/machine-gmon.h defines _mcount.

@nathanchance nathanchance merged commit cc2b09b into llvm:main Sep 8, 2023
@nathanchance nathanchance deleted the loongarch-mcount-rename branch September 8, 2023 17:56
leecheechen pushed a commit to leecheechen/llvm-project that referenced this pull request Jun 9, 2025
When building the LoongArch Linux kernel without
`CONFIG_DYNAMIC_FTRACE`, the build fails to link because the mcount
symbol is `mcount`, not `_mcount` like GCC generates and the kernel
expects:

```
ld.lld: error: undefined symbol: mcount
>>> referenced by version.c
>>>               init/version.o:(early_hostname) in archive vmlinux.a
>>> referenced by do_mounts.c
>>>               init/do_mounts.o:(rootfs_init_fs_context) in archive vmlinux.a
>>> referenced by main.c
>>>               init/main.o:(__traceiter_initcall_level) in archive vmlinux.a
>>> referenced 97011 more times
>>> did you mean: _mcount
>>> defined in: vmlinux.a(arch/loongarch/kernel/mcount.o)
```

Set `MCountName` in `LoongArchTargetInfo` to `_mcount`, which resolves
the build failure.

(cherry picked from commit cc2b09b)
Change-Id: I7d8b9b50c22471688b577ca434f8654cdfd0d1da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:loongarch clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants