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

haskellPackages.apecs-physics: fix build on darwin #107395

Merged

Conversation

sternenseemann
Copy link
Member

Motivation for this change

apecs-physics was broken by glibc 2.32 which removed sys/sysctl.h. Since
sysctl is only used on macOS in the offending source file, we patch it
to only include the header on macOS, fixing the build on linux.

Resolves #107358.

Testing this fix on darwin may be a good idea.

apecs-stm is broken for an unrelated reason, it seems.

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/)
  • 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.

@sternenseemann
Copy link
Member Author

cc @siraben for testing

@siraben
Copy link
Member

siraben commented Dec 22, 2020

Result of nixpkgs-review pr 107395 run on x86_64-darwin 1

EDIT: seems like nixpkgs-review didn't produce any build outputs, I'll compile it manually.

@siraben
Copy link
Member

siraben commented Dec 22, 2020

Suggest removing broken label.

diff --git a/pkgs/development/haskell-modules/hackage-packages.nix b/pkgs/development/haskell-modules/hackage-packages.nix
index f172a3d4247..8eb07a0dfbe 100644
--- a/pkgs/development/haskell-modules/hackage-packages.nix
+++ b/pkgs/development/haskell-modules/hackage-packages.nix
@@ -30736,7 +30736,6 @@ self: {
        description = "Simple gloss renderer for apecs";
        license = stdenv.lib.licenses.bsd3;
        hydraPlatforms = stdenv.lib.platforms.none;
-       broken = true;
      }) {};
 
   "apecs-physics" = callPackage
@@ -30754,7 +30753,6 @@ self: {
        description = "2D physics for apecs";
        license = stdenv.lib.licenses.bsd3;
        hydraPlatforms = stdenv.lib.platforms.none;
-       broken = true;
      }) {};
 
   "apecs-physics-gloss" = callPackage
@@ -30767,7 +30765,6 @@ self: {
        description = "Gloss rendering for apecs-physics";
        license = stdenv.lib.licenses.bsd3;
        hydraPlatforms = stdenv.lib.platforms.none;
-       broken = true;
      }) {};
 
   "apecs-stm" = callPackage

@sternenseemann
Copy link
Member Author

No, this is done automatically during the next haskellPackage update. The process is described here. To test the change, you'll have to checkout the branch, build and set NIXPKGS_ALLOW_BROKEN=1 temporarily.

@siraben
Copy link
Member

siraben commented Dec 22, 2020

I see, I wasn't aware of that! Thanks!

@siraben
Copy link
Member

siraben commented Dec 22, 2020

Build fails on darwin

Preprocessing library for apecs-physics-0.4.4..
Building library for apecs-physics-0.4.4..
[1 of 9] Compiling Apecs.Physics.Types ( src/Apecs/Physics/Types.hs, dist/build/Apecs/Physics/Types.o, dist/build/Apecs/Physics/Types.dyn_o )

src/Apecs/Physics/Types.hs:24:1: warning: [-Wunused-imports]
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
   |
24 | import           Data.Monoid               ((<>))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2 of 9] Compiling Apecs.Physics.Space ( src/Apecs/Physics/Space.hs, dist/build/Apecs/Physics/Space.o, dist/build/Apecs/Physics/Space.dyn_o )

src/Apecs/Physics/Space.hs:19:1: warning: [-Wunused-imports]
    The import of ‘liftIO’
    from module ‘Control.Monad.IO.Class’ is redundant
   |
19 | import           Control.Monad.IO.Class (liftIO, MonadIO)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In file included from /private/tmp/nix-build-apecs-physics-0.4.4.drv-0/ghc65731_0/ghc_13.c:2:0: error:
    

In file included from Chipmunk2D/include/chipmunk/chipmunk.h:60:0: error:
    

Chipmunk2D/include/chipmunk/chipmunk_types.h:45:12: error:
     fatal error: 'ApplicationServices/ApplicationServices.h' file not found
                    #include <ApplicationServices/ApplicationServices.h>
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   |
45 |                 #include <ApplicationServices/ApplicationServices.h>
   |            ^
1 error generated.

<no location info>: error:
    `cc' failed in phase `C Compiler'. (Exit code: 1)
[5 of 9] Compiling Apecs.Physics.Geometry ( src/Apecs/Physics/Geometry.hs, dist/build/Apecs/Physics/Geometry.o, dist/build/Apecs/Physics/Geometry.dyn_o )
builder for '/nix/store/g9704wwzvl8iazs2wmim2r8wqb7xx3i5-apecs-physics-0.4.4.drv' failed with exit code 1
error: build of '/nix/store/g9704wwzvl8iazs2wmim2r8wqb7xx3i5-apecs-physics-0.4.4.drv', '/nix/store/knwc67mbs388ag01rdmqbjxz79ryhnfy-apecs-gloss-0.2.4.drv' failed

@sternenseemann
Copy link
Member Author

sternenseemann commented Dec 22, 2020

This build failure is at least unrelated to the change, seems like it is caused by this inclusion https://github.com/slembcke/Chipmunk2D/blob/edf83e5603c5a0a104996bd816fca6d3facedd6a/include/chipmunk/chipmunk_types.h#L44-L46.

I tried adding ApplicationServices in the latest commit, can you try again?

@siraben
Copy link
Member

siraben commented Dec 22, 2020

Builds succeed.

/nix/store/c1pg6nwma239hl3frmnps5xvraqs0490-apecs-physics-gloss-0.1.0.0/lib/ghc-8.10.2/x86_64-osx-ghc-8.10.2/libHSapecs-physics-gloss-0.1.0.0-3bBGdoAytgO4tSFqGMPwDX-ghc8.10.2.dylib: fixing dylib
/nix/store/c1pg6nwma239hl3frmnps5xvraqs0490-apecs-physics-gloss-0.1.0.0/lib/ghc-8.10.2/x86_64-osx-ghc-8.10.2/libHSapecs-physics-gloss-0.1.0.0-3bBGdoAytgO4tSFqGMPwDX-ghc8.10.2.dylib: fixing dylib
strip is /nix/store/i1mccwrczhhacpk0jn58wmixqiqh1vkb-cctools-binutils-darwin-949.0.1/bin/strip
patching script interpreter paths in /nix/store/d6wx7dvw47hr6ymhg5nwfvz9pasa9kc5-apecs-physics-gloss-0.1.0.0-doc
/nix/store/7v431007lprfk4m6hxh6lalikvdmm5ha-apecs-physics-0.4.4
/nix/store/98kvmwv6as2n0svrxwxi7mwslniclzql-apecs-gloss-0.2.4
/nix/store/c1pg6nwma239hl3frmnps5xvraqs0490-apecs-physics-gloss-0.1.0.0

Comment on lines 1544 to 1553
# Add ApplicationServices on darwin
# Patch can be removed if https://github.com/jonascarpay/apecs/pull/77 is resolved
apecs-physics =
let
sysDeps = pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.ApplicationServices;
in addPkgconfigDepends (appendPatch super.apecs-physics (pkgs.fetchpatch {
url = "https://github.com/jonascarpay/apecs/pull/77/commits/24975a4e689fb9920168bbbcb451d8fb8a16abdb.patch";
sha256 = "0w7ivv9wgrkba9psbc4920y0apg5cpyz9fwwzizfgqhy0gz6ss7y";
stripLen = 1;
})) sysDeps;
Copy link
Member

Choose a reason for hiding this comment

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

Ping @jonascarpay.

Does this change look okay to you, or does it make more sense just to wait for you to release a new version of apecs-physics to Hackage?

@jonascarpay
Copy link
Contributor

@cdepillabout Yeah, I think this is best fixed properly upstream. I'll push a new version today.

@sternenseemann
Copy link
Member Author

To fix the darwin build, 96376c6 should be cherry-picked or merged either way though.

@sternenseemann sternenseemann force-pushed the fix-apecs-physics branch 2 times, most recently from 901e618 to 54e44bf Compare December 23, 2020 09:32
@jonascarpay
Copy link
Contributor

@sternenseemann Why is that the case? The stock Chipmunk2D doesn't have that. Is there something I can do about that?

@sternenseemann
Copy link
Member Author

@jonascarpay Judging from this comment, seems like the normal Chipmunk hasn't been really tested on macOS:

platforms = platforms.unix; # supports Windows and MacOS as well, but those require more work

As far as I understand in apec-physics Chipmunk is vendored anyways right?

On darwin the build fails because ApplicationServices/ApplicationServices.h is missing on macOS (#107395 (comment)) which is fixed by the mentioned commit by adding that as a build dependency.

@jonascarpay
Copy link
Contributor

Judging from this comment, seems like the normal Chipmunk hasn't been really tested on macOS

ahh I see, thanks, I overlooked that line

As far as I understand in apec-physics Chipmunk is vendored anyways right?

Yeah, just asking for my own edification.

@jonascarpay
Copy link
Contributor

jonascarpay commented Dec 23, 2020

I just pushed 0.4.5 to hackage, which includes the sysctl.h guard. Thanks for letting me know.

@sternenseemann sternenseemann force-pushed the fix-apecs-physics branch 2 times, most recently from dea822a to 9679699 Compare December 23, 2020 12:14
@sternenseemann
Copy link
Member Author

@cdepillabout is it alright to just update the pin to 0.4.5 for the next haskell-update like in 96796994bf684689bcc6997d65d91d1368c17049?

@cdepillabout
Copy link
Member

@cdepillabout is it alright to just update the pin to 0.4.5 for the next haskell-update like in 9679699?

I think this should be okay, but let's confirm with @maralorn.

@maralorn, a short explanation is that apecs-physics just had a new version released which partially fixed it here in nixpkgs. I imagine this will be available next time the stackage-nightly version is bumped. @sternenseemann has directly bumped it in 9679699, and I just wanted to confirm that this won't cause any weird problems next time you and peti bump it during the weekly merge thing?

@siraben
Copy link
Member

siraben commented Dec 23, 2020

Build still succeeds on darwin

strip is /nix/store/i1mccwrczhhacpk0jn58wmixqiqh1vkb-cctools-binutils-darwin-949.0.1/bin/strip
patching script interpreter paths in /nix/store/qij59k6ccvv1liagvwwp1fb7d14vbdc3-apecs-physics-gloss-0.1.0.0-doc
/nix/store/yafv97h26d1iig2m6cqx4a96sijdxx6a-apecs-physics-0.4.4
/nix/store/lc80b4n4zlblganrplmpn1mrr17kwgv7-apecs-gloss-0.2.4
/nix/store/yhc0axljjmvwk5jcnprck1xvkhdzd2zg-apecs-physics-gloss-0.1.0.0

@sternenseemann
Copy link
Member Author

(Should be broken on linux until the update is actually performed though)

@maralorn
Copy link
Member

maralorn commented Dec 23, 2020

Huh, @cdepillabout, the problem is that those pins are automatically generated from stackage-nightly. So I am pretty sure this bump would just be reverted if it hasn‘t happened in stackage-nightly. The next time peti updates the stackage pin.

I think normally we do this by using a "apecs-physics = super.apecs-physics_0_4_5" override. I am not sure if there is a way to override the stackage version in the yaml file.

@sternenseemann
Copy link
Member Author

Maybe it's a better idea to merge the darwin fix only which can be done right now and I check after the next haskell-update if we have to override apecs-physics or can just mark the packages as unbroken?

@cdepillabout
Copy link
Member

@sternenseemann That sounds like an easy thing to do right away if you're willing to update this PR again.

@sternenseemann
Copy link
Member Author

@cdepillabout Yeah, no problem!

hackage2nix is run on fridays usually right?

@cdepillabout
Copy link
Member

hackage2nix is run on fridays usually right?

hackage2nix is usually run once a day, but haskell-updates is merged into master normally once a week on fridays. I think at the same time the stackage nightly version is updated. It is normally peti and maralorn doing this: https://www.twitch.tv/videos/841867369

@sternenseemann
Copy link
Member Author

@cdepillabout okay, then I'll wait till the new stackage-nightly is out.

Should I force push to drop the second commit then, so you can merge the darwin fix?

@sternenseemann sternenseemann changed the title haskellPackages.apecs-physics: unbreak haskellPackages.apecs-physics: fix build on darwin Dec 24, 2020
@cdepillabout
Copy link
Member

@sternenseemann This looks good, thanks.

Also, I checked the stackage nightly releases, and it looks like they completely stopped two weeks ago or so. Don't know what's up: https://www.stackage.org/snapshots

@cdepillabout cdepillabout merged commit 5c2517c into NixOS:haskell-updates Dec 25, 2020
@sternenseemann sternenseemann deleted the fix-apecs-physics branch December 25, 2020 09:30
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

5 participants