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

WIP: Cross compilation to musl32 support #89471

Closed
wants to merge 7 commits into from
Closed

WIP: Cross compilation to musl32 support #89471

wants to merge 7 commits into from

Conversation

wfranzini
Copy link
Contributor

This is the continuation of PR #62817
The original PR was based on master instead of the staging branch. I find easier to start a new PR.

I still need to review some commits.

Motivation for this change

Crosscompiling packages to musl32 lead to compilation errors due to the missing __stack_chk_fail_local symbol. Even building nix fails. This PR disable stackprotector for musl32.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)

  • Built on platform(s)

    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)

  • Successful compilation of the following packages:

    • nix
    • openssl
    • python2
    • python3
    • perl
  • The following packages, among many others, does not build:

    • nixFlakes
    • audit
    • openssh
    • gnupg
  • Tested execution of all binary files (usually in ./result/bin/)

  • Determined the impact on package closure size (by running nix path-info -S before and after)

  • Ensured that relevant documentation is up to date

  • Fits CONTRIBUTING.md.

The makefile patch pulled from alpinelinux used to enable
stackprotector unconditionally.  This change use the nixpkgs flag
hardeningEnable.

This is required to support platform where stackprotector has
problems.
The patches from alpinelinux failed to apply to v2.8.5, on the other
hand upstream has added support for musl based system in the master
branch on github [1].

The patch has been added to the nixpkgs repo since it needs to be
modified slightly, a copyright notice has been removed, to apply
cleanly.

1. linux-audit/audit-userspace@d579a08
Disable the pipe rewind related feature since musl has no support for it.
In order to support stackprotector on musl32, this change import a
couple of patches from alpinelinux:
1. libssp_nonshared.a is built alongside musl's libc
2. the above library is automatically linked when compiling with gcc6
   or gcc7
@@ -65,6 +65,10 @@ let majorVersion = "7";
})
++ optional langFortran ../gfortran-driving.patch
++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch
++ optional (targetPlatform.libc == "musl" && targetPlatform.isx86_32) (fetchpatch {
Copy link
Member

Choose a reason for hiding this comment

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

is this still an issue with gcc 8+?

@symphorien symphorien mentioned this pull request Jul 1, 2020
10 tasks
@@ -48,7 +47,7 @@ stdenv.mkDerivation rec {
cp ${patch} $out
substituteInPlace $out --replace \
'-* Copyright (c) 2007-09,2011-16,2018 Red Hat Inc., Durham, North Carolina.' \
'-* Copyright (c) 2007-09,2011-16 Red Hat Inc., Durham, North Carolina.'
'-* Copyright (c) 2007-09,2012-19 Red Hat Inc., Durham, North Carolina.'
Copy link
Member

Choose a reason for hiding this comment

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

The patch does not apply.

$  nix-build . -A pkgsStatic.audit
these derivations will be built:
  /nix/store/7si79l161j4vn7pkgbxis9n548q565jl-audit-2.8.5-x86_64-unknown-linux-musl.drv
building '/nix/store/7si79l161j4vn7pkgbxis9n548q565jl-audit-2.8.5-x86_64-unknown-linux-musl.drv'...
unpacking sources
unpacking source archive /nix/store/nbzjp4q72pb3rn4w03s6pwh2cqfyjvv1-audit-2.8.5.tar.gz
source root is audit-2.8.5
setting SOURCE_DATE_EPOCH to timestamp 1551474932 of file audit-2.8.5/bindings/swig/python3/audit.py
patching sources
applying patch /nix/store/38c3kkylsxv4bg1ya4gzlx1sdqcib733-Add-substitue-functions-for-strndupa-rawmemchr.patch-fix-copyright-merge-conflict
patching file ChangeLog
Hunk #1 succeeded at 32 with fuzz 2 (offset -30 lines).
patching file auparse/auparse.c
Hunk #2 succeeded at 1118 (offset -1 lines).
patching file auparse/interpret.c
Hunk #1 FAILED at 1.
Hunk #2 succeeded at 853 (offset -2 lines).
Hunk #3 succeeded at 870 (offset -2 lines).
1 out of 3 hunks FAILED -- saving rejects to file auparse/interpret.c.rej
patching file configure.ac
patching file src/ausearch-lol.c
builder for '/nix/store/7si79l161j4vn7pkgbxis9n548q565jl-audit-2.8.5-x86_64-unknown-linux-musl.drv' failed with exit code 1
error: build of '/nix/store/7si79l161j4vn7pkgbxis9n548q565jl-audit-2.8.5-x86_64-unknown-linux-musl.drv' failed

@stale
Copy link

stale bot commented Jul 21, 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 Jul 21, 2021
@symphorien
Copy link
Member

was included in #112939

@symphorien symphorien closed this Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants