Skip to content
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

Fails to build with musl libc, undefined reference to `backtrace' #57193

Closed
0x6273 opened this issue Jan 25, 2022 · 5 comments · Fixed by #63983
Closed

Fails to build with musl libc, undefined reference to `backtrace' #57193

0x6273 opened this issue Jan 25, 2022 · 5 comments · Fixed by #63983

Comments

@0x6273
Copy link

0x6273 commented Jan 25, 2022

Godot version

4.0 alpha 1, commit 2b61d02

System information

Gentoo, with musl libc overlay

Issue description

When linking, it does not find backtrace or backtrace_symbols. Unlike glibc, the musl libc does not come with those symbols.

From SCons output:

[100%] Linking Static Library core/libcore.linuxbsd.tools.64.a ...
Ranlib Library core/libcore.linuxbsd.tools.64.a ...
[100%] Linking Program bin/godot.linuxbsd.tools.64 ...
/usr/lib/gcc/x86_64-gentoo-linux-musl/11.2.0/../../../../x86_64-gentoo-linux-musl/bin/ld: platform/linuxbsd/crash_handler_linuxbsd.linuxbsd.tools.64.o: in function `handle_crash(int)':
/home/user/Projects/godot/platform/linuxbsd/crash_handler_linuxbsd.cpp:56: undefined reference to `backtrace'
/usr/lib/gcc/x86_64-gentoo-linux-musl/11.2.0/../../../../x86_64-gentoo-linux-musl/bin/ld: /home/user/Projects/godot/platform/linuxbsd/crash_handler_linuxbsd.cpp:80: undefined reference to `backtrace_symbols'
collect2: error: ld returned 1 exit status
scons: *** [bin/godot.linuxbsd.tools.64] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:04:45.680]

Steps to reproduce

  1. Have musl libc, and libexecinfo installed
  2. Clone repo
  3. Run scons

Minimal reproduction project

No response

@akien-mga
Copy link
Member

Did you try build with execinfo=yes?

@0x6273
Copy link
Author

0x6273 commented Jan 25, 2022

Did you try build with execinfo=yes?

I have not tried that, but I got it to link by patching the SCsub file in platform/linuxbsd. I'm not very familiar with SCons, but would it be possible to set this automatically for systems that need execinfo?

@akien-mga
Copy link
Member

akien-mga commented Jan 25, 2022

That's already what the code does:

        BoolVariable("execinfo", "Use libexecinfo on systems where glibc is not available", False),

...

    if platform.system().find("BSD") >= 0:
        env["execinfo"] = True

    if env["execinfo"]:
        env.Append(LIBS=["execinfo"])

You just need to build with scons p=linuxbsd execinfo=yes.

I don't know if there's an easy way to detect the need for execinfo on GNU/Linux. If there's a reliable way to check from Python, this could be added to the same check that looks for *BSD.

@0x6273
Copy link
Author

0x6273 commented Jan 25, 2022

I'm not sure if there's a good way to test if libexecinfo is needed. Adding another special case for musl like we already have for BSD is probably the simplest fix.

There's a file /lib/ld-musl-$ARCH.so.1 on musl systems, so something like this would work:

if glob.glob("/lib/ld-musl-*.so*"):
    env["execinfo"] = True

@LinuxUserGD
Copy link
Contributor

LinuxUserGD commented Jan 25, 2022

I'm not sure if there's a good way to test if libexecinfo is needed. Adding another special case for musl like we already have for BSD is probably the simplest fix.

There's a file /lib/ld-musl-$ARCH.so.1 on musl systems, so something like this would work:

if glob.glob("/lib/ld-musl-*.so*"):
    env["execinfo"] = True

See godotengine/godot-proposals#2439 (comment)

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

Successfully merging a pull request may close this issue.

5 participants