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

ld.gold crashes or produces broken executables #101490

Open
utsl42 opened this issue Oct 23, 2020 · 7 comments · May be fixed by #101666
Open

ld.gold crashes or produces broken executables #101490

utsl42 opened this issue Oct 23, 2020 · 7 comments · May be fixed by #101666
Labels
0.kind: bug 6.topic: musl Running or building packages with musl libc 9.needs: upstream fix

Comments

@utsl42
Copy link
Contributor

utsl42 commented Oct 23, 2020

gold fails with pkgsMusl
As described in #49071, but the -pie workaround seems to no longer work.

To Reproduce
Steps to reproduce the behavior:

  1. nix-build -E 'let pkgs = (import {}).pkgsMusl; in pkgs.hello.overrideDerivation(_: {CFLAGS="-fuse-ld=gold";})'
  2. nix-build -E 'let pkgs = (import {}).pkgsMusl; in pkgs.llvm_9'
    All versions of llvm I tested failed tests, due to gold breaking.
  3. nix-build -E 'let pkgs = (import {}).pkgsMusl; in pkgs.hello.overrideDerivation(_: {CFLAGS="-fuse-ld=gold -fPIE -pie";})'
    Suggested in ld.gold crashes or produces invalid executables when Musl is used as a libc #49071 also fails.

Expected behavior
gold should neither crash nor produce broken executables

Additional context
See also issues #49071, #94228, #96890, #84670

Notify maintainers

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

  • system: "x86_64-linux"
  • host os: Linux 5.4.39, NixOS, 20.09beta992.7badbf18c45 (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.7
  • channels(root): "nixos-20.09beta992.7badbf18c45"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@utsl42
Copy link
Contributor Author

utsl42 commented Oct 23, 2020

llvmPackages_9 and llvmPackages_10 build and work with pkgsMusl if gold is disabled

@utsl42
Copy link
Contributor Author

utsl42 commented Oct 24, 2020

I've reproduced the behavior described in #49071 (comment)

The -fPIE -pie fix works in a VM, but not on bare metal on the same machine.

I have also had it work with no issues on a Docker VM on a Macbook. (nix/nixos image)

I have tested with nixpkgs pinned to the same version across multiple machines. That's not causing it.

@utsl42
Copy link
Contributor Author

utsl42 commented Oct 25, 2020

Breaking this down further, I found that gold will link with musl with the exact arguments if I run the glibc build of gold. The musl linked version of gold fails with fatal error: hello: No error information.

@utsl42
Copy link
Contributor Author

utsl42 commented Oct 25, 2020

The reason for the difference between VM's and bare metal is that the bare metal machines are on ZFS, which doesn't support fallocate.

It appears that the fix in https://sourceware.org/bugzilla/show_bug.cgi?id=22540 is not working for some reason on Musl.

@utsl42
Copy link
Contributor Author

utsl42 commented Oct 25, 2020

fallocate returns -1 and sets errno, but the error handling code in output.cc added in that binutils bug doesn't check errno. This keeps it from ever getting to the ftruncate. Probably not helped by posix_fallocate and fallocate having different error return conventions. Worse, glibc appears to be handling this differently.

@utsl42
Copy link
Contributor Author

utsl42 commented Oct 25, 2020

https://www.openwall.com/lists/musl/2018/04/26/4 indicates that glibc has a hacky workaround in posix_fallocate. That's why this shows up on musl and not glibc.

@utsl42 utsl42 linked a pull request Oct 25, 2020 that will close this issue
10 tasks
@stale
Copy link

stale bot commented Apr 26, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 26, 2021
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 4, 2023
@Artturin Artturin added the 6.topic: musl Running or building packages with musl libc label Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: musl Running or building packages with musl libc 9.needs: upstream fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants