Skip to content

[Clang][LoongArch] Generate _mcount instead of mcount #65657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2023

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
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