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

Compilation on macOS broken? #3

Open
sternenseemann opened this issue Jun 14, 2021 · 4 comments
Open

Compilation on macOS broken? #3

sternenseemann opened this issue Jun 14, 2021 · 4 comments

Comments

@sternenseemann
Copy link

I've tried to get FractalArt to compile on darwin with nix using the following override:

  FractalArt = overrideCabal super.FractalArt (drv: {
    executableSystemDepends = [
      darwin.libobjc
    ] ++ (drv.librarySystemDepends or []);
    executableFrameworkDepends = [
      darwin.apple_sdk.frameworks.AppKit
    ] ++ (drv.executableFrameworkDepends or []);
  });

Which results in the following build log:

setupCompilerEnvironmentPhase
Build with /nix/store/66sk6q7j0gd3v83ixraisd25mzhi3l0c-ghc-8.10.4.
unpacking sources
unpacking source archive /nix/store/hhvy3bx21bgiymw44c7jaxgmwqd7sw8p-FractalArt-0.2.0.3.tar.gz
source root is FractalArt-0.2.0.3
setting SOURCE_DATE_EPOCH to timestamp 1462540030 of file FractalArt-0.2.0.3/FractalArt.cabal
patching sources
compileBuildDriverPhase
setupCompileFlags: -package-db=/private/tmp/nix-build-FractalArt-0.2.0.3.drv-0/setup-package.conf.d -j1 -threaded -rtsopts
[1 of 1] Compiling Main             ( Setup.hs, /private/tmp/nix-build-FractalArt-0.2.0.3.drv-0/Main.o )
Linking Setup ...
configuring
configureFlags: --verbose --prefix=/nix/store/wxxxrv18ygsh821ml2kb5ym8vzkxny8g-FractalArt-0.2.0.3 --libdir=$prefix/lib/$compiler --libsubdir=$abi/$libname --docdir=/nix/store/88i0j3l35cqc7970lvp8kynsbsbqbpim-FractalArt-0.2.0.3-doc/share/doc/FractalArt-0.2.0.3 --with-gcc=clang --package-db=/private/tmp/nix-build-FractalArt-0.2.0.3.drv-0/package.conf.d --ghc-options=-j1 --disable-split-objs --enable-library-profiling --profiling-detail=exported-functions --disable-profiling --enable-shared --disable-coverage --enable-static --disable-executable-dynamic --enable-tests --disable-benchmarks --enable-library-vanilla --disable-library-for-ghci --extra-include-dirs=/nix/store/mw8cdz4nbq523xa33zyamsylci73cd63-libcxx-7.1.0-dev/include --extra-lib-dirs=/nix/store/64d69jqbz4s8ziqbpam41sd70w338ars-libcxx-7.1.0/lib --extra-include-dirs=/nix/store/i8mm0yixkl8c10a4kmwz68zp99cb3nrs-libcxxabi-7.1.0-dev/include --extra-lib-dirs=/nix/store/6q1rhqvyzxb3j5pb1h4qxsa0hh1i45wv-libcxxabi-7.1.0/lib --extra-include-dirs=/nix/store/xcix5ygyy05z2q9v6901xlm4ljw2yvs8-compiler-rt-libc-7.1.0-dev/include --extra-lib-dirs=/nix/store/pdd276ydvg3zvky684wp78q8zfjkc6d4-compiler-rt-libc-7.1.0/lib --extra-lib-dirs=/nix/store/kdydav4gqzd91qlpprnjascbs5hs8qmg-ncurses-6.2/lib --extra-lib-dirs=/nix/store/680v3dy36ghk5szlz07r2s54b8r119pi-libffi-3.3/lib --extra-lib-dirs=/nix/store/ka12q1srbmcrc5fm7kn5slgwnajppppc-gmp-6.2.1/lib --extra-include-dirs=/nix/store/pgnb12anscja205zycd2l994028vas2b-libiconv-50/include --extra-lib-dirs=/nix/store/pgnb12anscja205zycd2l994028vas2b-libiconv-50/lib --extra-include-dirs=/nix/store/08iavk27gxjf5kwpzisj9fqhbfqxg0r1-objc4-709.1/include --extra-lib-dirs=/nix/store/08iavk27gxjf5kwpzisj9fqhbfqxg0r1-objc4-709.1/lib --extra-framework-dirs=/nix/store/39y8lss2p8dlhqq0il46z2dpgmag17h4-apple-framework-AppKit/Library/Frameworks --extra-framework-dirs=/nix/store/w7nyyfn0n0nxn5pbr65sakcrckl1jv8k-apple-framework-ApplicationServices/Library/Frameworks --extra-framework-dirs=/nix/store/r2f98pgsb6vk53ha9cipq5yl64qcg5i2-apple-framework-CoreGraphics/Library/Frameworks --extra-framework-dirs=/nix/store/5a8mq3rrryr8c3zii078qg7p7rp41xdg-apple-framework-Accelerate/Library/Frameworks --extra-framework-dirs=/nix/store/cghxll8lpzg7x0x7nhzyrqdk4q8xhiwz-apple-framework-CoreWLAN/Library/Frameworks --extra-framework-dirs=/nix/store/dn63dxzz06k8g39lnvankk5schq8b97v-apple-framework-SecurityFoundation/Library/Frameworks --extra-framework-dirs=/nix/store/dvs74mhgp5kgk5v2is05sizgwr9p3bb7-apple-framework-IOBluetooth/Library/Frameworks --extra-framework-dirs=/nix/store/8pwz6jq4zpqlzsz0q0xwz69hlsypyyvq-apple-framework-CoreBluetooth/Library/Frameworks --extra-framework-dirs=/nix/store/yy952p18g4hvkgwd3hh8c4rql8ic5bwk-apple-framework-IOKit/Library/Frameworks --extra-framework-dirs=/nix/store/yy952p18g4hvkgwd3hh8c4rql8ic5bwk-apple-framework-IOKit/Library/Frameworks --extra-framework-dirs=/nix/store/hjx5rb2n7l730b2qxwbh3bn875qqj1x7-apple-framework-IOSurface/Library/Frameworks --extra-include-dirs=/nix/store/q7awcbl6bkn34glqalr02gkid537ky0f-apple-lib-xpc/include --extra-framework-dirs=/nix/store/1cl9r959bj5pz9y4d6dzszch5yadq3vg-apple-framework-SystemConfiguration/Library/Frameworks --extra-framework-dirs=/nix/store/293i28pj9jswm0bgx7qdnbpkckz72kwb-apple-framework-Security/Library/Frameworks --extra-framework-dirs=/nix/store/9sfxgkvasbzsl6ny0i9m12ipq0qccxl9-apple-framework-CoreServices/Library/Frameworks --extra-framework-dirs=/nix/store/svnhbzykd9wfglyc8jzkc7683pyhx8ka-apple-framework-CFNetwork/Library/Frameworks --extra-framework-dirs=/nix/store/m17pjjxfq8gx9anyqbyw3v72zzaajqqr-apple-framework-CoreAudio/Library/Frameworks --extra-framework-dirs=/nix/store/hbk6lpggwx5v1am7r0nwj14w8rr6xki0-apple-framework-CoreData/Library/Frameworks --extra-framework-dirs=/nix/store/f9cchxc5hkk9p4n6y45cw4f3nf3w3va1-apple-framework-CoreFoundation/Library/Frameworks --extra-framework-dirs=/nix/store/s7166g2g4ay8zij3ih08xw25hwmhw13f-apple-framework-DiskArbitration/Library/Frameworks --extra-framework-dirs=/nix/store/wkxjczcm6h9gppa6mc097jm1rza4a0fz-apple-framework-NetFS/Library/Frameworks --extra-framework-dirs=/nix/store/nr0zr4wdd1a5w4rqy2908kgn9j1vlcm8-apple-framework-OpenDirectory/Library/Frameworks --extra-framework-dirs=/nix/store/6wjm2ml2sq0fwsw954mj8q5h7yrhhxb6-apple-framework-ServiceManagement/Library/Frameworks --extra-framework-dirs=/nix/store/57hx4c6dv3vd0g2gjf9gqzld1fr4ncm2-apple-framework-CoreText/Library/Frameworks --extra-framework-dirs=/nix/store/bgq90w547d89zy496kyisckyx3y42cly-apple-framework-ImageIO/Library/Frameworks --extra-framework-dirs=/nix/store/pfj4xw40bgfjxr014ab4sj50615n2jw1-apple-framework-AudioToolbox/Library/Frameworks --extra-framework-dirs=/nix/store/zwha875pf1mah7lb52qxly4nf5d1gpmk-apple-framework-CoreMIDI/Library/Frameworks --extra-framework-dirs=/nix/store/xpzbd9lkkl3152xs8pgp72w07nvsjaa1-apple-framework-AudioUnit/Library/Frameworks --extra-framework-dirs=/nix/store/4k7hfca13xys2gckrsf96y8v4ln5w04c-apple-framework-Carbon/Library/Frameworks --extra-framework-dirs=/nix/store/b73xlnighh544ah15qgpn2id95ibskfc-apple-framework-Foundation/Library/Frameworks --extra-include-dirs=/nix/store/08iavk27gxjf5kwpzisj9fqhbfqxg0r1-objc4-709.1/include --extra-lib-dirs=/nix/store/08iavk27gxjf5kwpzisj9fqhbfqxg0r1-objc4-709.1/lib --extra-framework-dirs=/nix/store/fpga8if76brxvgn30z06c8haa60rnmlb-apple-framework-QuartzCore/Library/Frameworks --extra-framework-dirs=/nix/store/y7bmnccssmbxqz559rqqnb9ippd4p5rw-apple-framework-CoreImage/Library/Frameworks --extra-framework-dirs=/nix/store/sfvln72zl1wk9d8lz9l29addvzdgi4a7-apple-framework-CoreVideo/Library/Frameworks --extra-framework-dirs=/nix/store/48b91qzw4wwm851il6b0mqvc6c04xp65-apple-framework-OpenGL/Library/Frameworks --extra-framework-dirs=/nix/store/7fq6iy6xzygy0m94krccdgi29iz3dpv1-apple-framework-Metal/Library/Frameworks --extra-framework-dirs=/nix/store/pa4zkrwmswyiz71q9a8mhf6i9kpwawdi-apple-framework-OpenCL/Library/Frameworks --extra-framework-dirs=/nix/store/mlj2ij9gqrk1h7y9ixsfn4b1b5dqvlap-apple-framework-UIFoundation/Library/Frameworks --extra-include-dirs=/nix/store/3qzl4kq8yi6vwcrsff2s27v67j8ysnp6-libX11-1.7.0-dev/include --extra-lib-dirs=/nix/store/3qzl4kq8yi6vwcrsff2s27v67j8ysnp6-libX11-1.7.0-dev/lib --extra-include-dirs=/nix/store/gyz5pnynjsh1gj13ib6qrfwvjii3prw1-xorgproto-2021.3/include --extra-include-dirs=/nix/store/spb7wn7kd6j3a5mnv6b8b02xzf10cim2-libxcb-1.14-dev/include --extra-lib-dirs=/nix/store/spb7wn7kd6j3a5mnv6b8b02xzf10cim2-libxcb-1.14-dev/lib --extra-lib-dirs=/nix/store/mb6xzkbwamq51lbc9swxwbv7zdgnvzp8-libxcb-1.14/lib --extra-lib-dirs=/nix/store/77dwv9vvxxy2nksb3gy6wb0kq6z3v97x-libX11-1.7.0/lib --extra-framework-dirs=/nix/store/f7f3gz636cqxkav7cy1nlldkwv2b22n1-swift-corefoundation/Library/Frameworks
Using Parsec parser
Configuring FractalArt-0.2.0.3...
Dependency JuicyPixels -any: using JuicyPixels-3.3.5
Dependency base >4 && <5: using base-4.14.1.0
Dependency directory -any: using directory-1.3.6.0
Dependency filepath -any: using filepath-1.4.2.1
Dependency mwc-random -any: using mwc-random-0.14.0.0
Dependency primitive -any: using primitive-0.7.1.0
Dependency random -any: using random-1.2.0
Dependency vector -any: using vector-0.12.3.0
Source component graph: component exe:FractalArt
Configured component graph:
    component FractalArt-0.2.0.3-5FQHmKvRZTs9LKdFPKk9aZ-FractalArt
        include JuicyPixels-3.3.5-LgFab8Qpa6TC01PG99Wtwj
        include base-4.14.1.0
        include directory-1.3.6.0
        include filepath-1.4.2.1
        include mwc-random-0.14.0.0-9StmDrCPrGJExSaB8A4gFD
        include primitive-0.7.1.0-Jxsyd70oUttYiCXCa0HqV
        include random-1.2.0-6zIdUIrmHInBiqbyqpDYsu
        include vector-0.12.3.0-GzQsO3hyEsQ1m59KXdGHEQ
Linked component graph:
    unit FractalArt-0.2.0.3-5FQHmKvRZTs9LKdFPKk9aZ-FractalArt
        include JuicyPixels-3.3.5-LgFab8Qpa6TC01PG99Wtwj
        include base-4.14.1.0
        include directory-1.3.6.0
        include filepath-1.4.2.1
        include mwc-random-0.14.0.0-9StmDrCPrGJExSaB8A4gFD
        include primitive-0.7.1.0-Jxsyd70oUttYiCXCa0HqV
        include random-1.2.0-6zIdUIrmHInBiqbyqpDYsu
        include vector-0.12.3.0-GzQsO3hyEsQ1m59KXdGHEQ
Ready component graph:
    definite FractalArt-0.2.0.3-5FQHmKvRZTs9LKdFPKk9aZ-FractalArt
        depends JuicyPixels-3.3.5-LgFab8Qpa6TC01PG99Wtwj
        depends base-4.14.1.0
        depends directory-1.3.6.0
        depends filepath-1.4.2.1
        depends mwc-random-0.14.0.0-9StmDrCPrGJExSaB8A4gFD
        depends primitive-0.7.1.0-Jxsyd70oUttYiCXCa0HqV
        depends random-1.2.0-6zIdUIrmHInBiqbyqpDYsu
        depends vector-0.12.3.0-GzQsO3hyEsQ1m59KXdGHEQ
Using Cabal-3.2.1.0 compiled by ghc-8.10
Using compiler: ghc-8.10.4
Using install prefix:
/nix/store/wxxxrv18ygsh821ml2kb5ym8vzkxny8g-FractalArt-0.2.0.3
Executables installed in:
/nix/store/wxxxrv18ygsh821ml2kb5ym8vzkxny8g-FractalArt-0.2.0.3/bin
Libraries installed in:
/nix/store/wxxxrv18ygsh821ml2kb5ym8vzkxny8g-FractalArt-0.2.0.3/lib/ghc-8.10.4/x86_64-osx-ghc-8.10.4/FractalArt-0.2.0.3
Dynamic Libraries installed in:
/nix/store/wxxxrv18ygsh821ml2kb5ym8vzkxny8g-FractalArt-0.2.0.3/lib/ghc-8.10.4/x86_64-osx-ghc-8.10.4
Private executables installed in:
/nix/store/wxxxrv18ygsh821ml2kb5ym8vzkxny8g-FractalArt-0.2.0.3/libexec/x86_64-osx-ghc-8.10.4/FractalArt-0.2.0.3
Data files installed in:
/nix/store/wxxxrv18ygsh821ml2kb5ym8vzkxny8g-FractalArt-0.2.0.3/share/x86_64-osx-ghc-8.10.4/FractalArt-0.2.0.3
Documentation installed in:
/nix/store/88i0j3l35cqc7970lvp8kynsbsbqbpim-FractalArt-0.2.0.3-doc/share/doc/FractalArt-0.2.0.3
Configuration files installed in:
/nix/store/wxxxrv18ygsh821ml2kb5ym8vzkxny8g-FractalArt-0.2.0.3/etc
No alex found
Using ar found on system at:
/nix/store/9xawf09c90761xkxv8r1b55ja46x4wr3-cctools-binutils-darwin-949.0.1/bin/ar
No c2hs found
No cpphs found
No doctest found
Using gcc version 4.2.1 given by user at:
/nix/store/d4p8v32sivk3zj3jklx3irswbwwigxcd-clang-wrapper-7.1.0/bin/clang
Using ghc version 8.10.4 found on system at:
/nix/store/66sk6q7j0gd3v83ixraisd25mzhi3l0c-ghc-8.10.4/bin/ghc
Using ghc-pkg version 8.10.4 found on system at:
/nix/store/66sk6q7j0gd3v83ixraisd25mzhi3l0c-ghc-8.10.4/bin/ghc-pkg
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.24.0 found on system at:
/nix/store/66sk6q7j0gd3v83ixraisd25mzhi3l0c-ghc-8.10.4/bin/haddock
No happy found
Using haskell-suite found on system at: haskell-suite-dummy-location
Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location
No hmake found
Using hpc version 0.68 found on system at:
/nix/store/66sk6q7j0gd3v83ixraisd25mzhi3l0c-ghc-8.10.4/bin/hpc
Using hsc2hs version 0.68.7 found on system at:
/nix/store/66sk6q7j0gd3v83ixraisd25mzhi3l0c-ghc-8.10.4/bin/hsc2hs
No hscolour found
No jhc found
Using ld found on system at:
/nix/store/7qk9mqi411ip2jh10d1bbj7x7mgrfksg-cctools-binutils-darwin-wrapper-949.0.1/bin/ld
No pkg-config found
Using runghc version 8.10.4 found on system at:
/nix/store/66sk6q7j0gd3v83ixraisd25mzhi3l0c-ghc-8.10.4/bin/runghc
Using strip found on system at:
/nix/store/9xawf09c90761xkxv8r1b55ja46x4wr3-cctools-binutils-darwin-949.0.1/bin/strip
Using tar found on system at:
/nix/store/y215y67kv3z408mdja2fy3xkk0maqhx3-gnutar-1.34/bin/tar
No uhc found
building
Preprocessing executable 'FractalArt' for FractalArt-0.2.0.3..
Building executable 'FractalArt' for FractalArt-0.2.0.3..
[1 of 3] Compiling FractalArt.ForeignFunctions ( src/FractalArt/ForeignFunctions.hs, dist/build/FractalArt/FractalArt-tmp/FractalArt/ForeignFunctions.o )
ld: warning: /nix/store/pgnb12anscja205zycd2l994028vas2b-libiconv-50/lib/libiconv.dylib, ignoring unexpected dylib file
ld: warning: /nix/store/f9cchxc5hkk9p4n6y45cw4f3nf3w3va1-apple-framework-CoreFoundation/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd, ignoring unexpected dylib text stub file
[2 of 3] Compiling FractalArt.SimpleCommandParser ( src/FractalArt/SimpleCommandParser.hs, dist/build/FractalArt/FractalArt-tmp/FractalArt/SimpleCommandParser.o )
[3 of 3] Compiling Main             ( src/Main.hs, dist/build/FractalArt/FractalArt-tmp/Main.o )

cbits/wallpaper.m:3:9: error:
     fatal error: module 'AppKit' not found
  |
3 | @import AppKit;
  |         ^
@import AppKit;
 ~~~~~~~^~~~~~
1 error generated.
`cc' failed in phase `C Compiler'. (Exit code: 1)
builder for '/nix/store/mm01r7j2hx1pr085jwjnxn1dqz5w0q40-FractalArt-0.2.0.3.drv' failed with exit code 1
@TomSmeets
Copy link
Owner

Hi,
I have to admit that I don't know much about Mac OS and Objective C.

Ill look around the documentation and see if I can figure out the issue.
Is it somehow possible for me to reproduce this issue without owning a MacOS machine?

The code for Mac OS was contributed by @codebje in #1.
@codebje if you have some free time, maybe you could take a quick look?

Tom

@codebje
Copy link
Contributor

codebje commented Jun 19, 2021

I'm not able to help with nix issues to any substantial degree - it needs more disk space than I have available to install and use, and more head space than I have available to understand and debug.

You can still build FractalArt on OS X using stack --no-nix build though, if that's useful as a work-around.

@TomSmeets
Copy link
Owner

Thanks for the feedback codebje. Good to hear that it does compile normally without nix.

It seems that the code has problems finding the AppKit module. After looking a bit into Objective-C if found that the @import is a newer version of #import. It could be that this causes issues for some reason. I also found one instance of this inside nixpkgs. The commit did not state the reason for why the sed was used, but they might have had the same issue.

I would suggest @sternenseemann that you try the following commit 5170bad which is available in the nix-macos-fix branch.

diff --git a/cbits/wallpaper.m b/cbits/wallpaper.m
index ee744f9..d580f36 100644
--- a/cbits/wallpaper.m
+++ b/cbits/wallpaper.m
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 
-@import AppKit;
+#import <AppKit/AppKit.h>
 
 NSSize getRootWindowSize() {
   @autoreleasepool {

If that doesn't work, then try adding the following to the nix override:

NIX_LDFLAGS = "-framework AppKit";

@sternenseemann
Copy link
Author

sternenseemann commented Jun 29, 2021

That does work, but now we have a new linker error:

Linking dist/build/FractalArt/FractalArt ...
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_NSString", referenced from:
      objc-class-ref in wallpaper.o
  "_OBJC_CLASS_$_NSWorkspace", referenced from:
      objc-class-ref in wallpaper.o
  "_OBJC_CLASS_$_NSScreen", referenced from:
      objc-class-ref in wallpaper.o
ld: symbol(s) not found for architecture x86_64
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)

darwin.libobjc is in librarySystemDepends already (removing it doesn't change the error though), so not sure what we should do here. Maybe ghc is not passing a flag or something.

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

No branches or pull requests

3 participants