Skip to content

Conversation

@alexfmpe
Copy link
Member

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)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Relase notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.


# Required for "undefined reference to __memset_chk" error
# see https://github.com/msys2/MINGW-packages-dev/pull/6
NIX_LDFLAGS = lib.optionalString stdenv.targetPlatform.isWindows "-lssp";
Copy link
Member Author

@alexfmpe alexfmpe Jul 31, 2021

Choose a reason for hiding this comment

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

CPPFLAGS=-fstack-protector also gets through the __memset_chk error, but later hits undefined reference to `__stack_chk_fail'`

@alexfmpe
Copy link
Member Author

Not sure if this should be backported to 4.3.2.nix / 5.1.x.nix

@veprbl veprbl added the 6.topic: windows Running, or buiding, packages on Windows label Jul 31, 2021
@ofborg ofborg bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. labels Jul 31, 2021
@ofborg ofborg bot requested review from peti and vrthra July 31, 2021 05:34
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Jul 31, 2021
@Mindavi Mindavi added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Jul 31, 2021
@Mindavi
Copy link
Contributor

Mindavi commented Jul 31, 2021

Diff LGTM

@alexfmpe
Copy link
Member Author

I just ran into the same issue when trying to build pkgsCross.mingw32.hello on master. Same fix. Maybe this should go somewhere more general?
This seems to be a somewhat recent issue, I do not run into it on nixpkgs-20.09.
cc @Ericson2314

@alyssais
Copy link
Member

This one also needs to target staging, due to the number of rebuilds.

@alexfmpe alexfmpe changed the base branch from master to staging July 31, 2021 10:42
@alexfmpe
Copy link
Member Author

This one also needs to target staging, due to the number of rebuilds.

Actually, I'm confused.
I see @NixOS/ofborg tagged this as linux/darwin rebuilds, but I'd expect lib.optionalString stdenv.targetPlatform.isWindows to prevent those from being affected? And AFAICT the mingw build was broken, so maybe no actual rebuild is triggered?

@FRidh
Copy link
Member

FRidh commented Jul 31, 2021

I see @NixOS/ofborg tagged this as linux/darwin rebuilds, but I'd expect lib.optionalString stdenv.targetPlatform.isWindows to prevent those from being affected? And AFAICT the mingw build was broken, so maybe no actual rebuild is triggered?

That's because optionalString still needs to return something, so NIX_LDFLAGS is still set. Don't worry about it.

@symphorien
Copy link
Member

I just ran into the same issue when trying to build pkgsCross.mingw32.hello on master. Same fix. Maybe this should go somewhere more general?

adding -lssp could probably go in pkgs/build-support/cc-wrapper/add-hardening.sh maybe?

@alexfmpe
Copy link
Member Author

alexfmpe commented Aug 1, 2021

Turns out this isn't quite right.
While it fixes the build issue, and makes pkgsCross.mingwW64.hello run fine (via wine) on top of master, that's not the case for staging - there it still builds but we get a runtime crash from not finding dlls.

adding -lssp could probably go in pkgs/build-support/cc-wrapper/add-hardening.sh maybe?

This ended up breaking other things, including a dependency of gmp: mcfgthreads-x86_64-w64-mingw32-git, because it can't find libssp

configure:2726: $? = 1
configure:2746: checking whether the C compiler works
configure:2768: x86_64-w64-mingw32-gcc    conftest.c  >&5
/nix/store/d8j3pwvdgqpm06qsg37d0w8j0w8vcsza-x86_64-w64-mingw32-binutils-2.35.1/bin/x86_64-w64-mingw32-ld: cannot find -lssp
collect2: error: ld returned 1 exit status

It seems actually fixing this requires #38632, which in turn requires #132340, so I'm marking this as a draft for the time being.

@alexfmpe alexfmpe marked this pull request as draft August 1, 2021 18:33
sternenseemann added a commit to sternenseemann/nixpkgs that referenced this pull request Aug 7, 2021
* The __memcpy_chk fix is similar to what is proposed here
  NixOS#132188

* We also need pthreads

Didn't test running, but compiles fine.
@alexfmpe
Copy link
Member Author

It seems actually fixing this requires #38632, which in turn requires #132340, so I'm marking this as a draft for the time being.

pkgsCross.mingwW64.gmp builds again on staging (likely since #133479).
I don't think this PR per-se is useful anymore, as the next improvement will come from the above linked PRs.

@alexfmpe alexfmpe closed this Aug 21, 2021
@alexfmpe alexfmpe deleted the cross-mingw-gmp branch June 28, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: windows Running, or buiding, packages on Windows 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants