reflex-frp / reflex-platform

A curated package set and set of tools that let you build Haskell packages so they can run on a variety of platforms. reflex-platform is built on top of the nix package manager.
https://reflex-frp.org
BSD 3-Clause "New" or "Revised" License
720 stars 164 forks source link

Darwin ghc build is broken #133

Closed imalsogreg closed 6 years ago

imalsogreg commented 7 years ago

Following instructions on README.md (try-reflex, make hello.hs, ghc hello.hs, linking fails with this error:

ld: framework not found Foundation
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)

Reproduced on El Capitan and Sierra.

The ghc builds of reflex-todomvc that occur while entering the sandbox do work.

imalsogreg commented 7 years ago

After some investigation:

On the develop branch, ./try-reflex only brings me into a nix shell for commits equal to or later than c6c60935b52d68320358f9736e3fd2207943d86e (Merge branch 'jsaddle' into develop - May 6 2017).

For commits that succeed with ./try-reflex, compiling a hello-world module with ghc produces this error:

[nix-shell:~/code/reflex-platform]$ ghc hello.hs
[1 of 1] Compiling Main             ( hello.hs, hello.o )
Linking hello ...

In file included from /var/folders/1s/m81mfsps417c5ygs6vglqbd40000gn/T/ghc94146_0/ghc_4.c:1:0: error:

In file included from /nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/Rts.h:217:0: error:

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:505:5: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF || ZERO_SLOP_FOR_SANITY_CHECK
    ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:502:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF     (defined(PROFILING))
                                    ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:505:31: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF || ZERO_SLOP_FOR_SANITY_CHECK
                              ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                    ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:505:31: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:56: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                                       ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:523:5: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
    ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:502:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF     (defined(PROFILING))
                                    ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:523:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
                               ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                    ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:523:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:56: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                                       ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:552:5: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
    ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:502:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF     (defined(PROFILING))
                                    ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:552:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
                               ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                    ^

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:552:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

/nix/store/qjsa967fh6ys9makxfm3qxsbq71hqih3-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:56: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                                       ^
9 warnings generated.
ld: framework not found Foundation
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)

For earlier commits, ./try-reflex fails with this message:

Command:  ./try-reflex
If you have any trouble with this script, please submit an issue at https://github.com/reflex-frp/reflex-platform/issues
Entering the reflex sandbox...
building path(s) ‘/nix/store/gk0g43mi0v729nhj19vjha9pdnxwxdci-stage2.nix’
builder for ‘/nix/store/7k1m1vlgrn0w3imyw9sd99x9i0wpcklg-stage2.nix.drv’ failed due to signal 4 (Illegal instruction: 4)
error: build of ‘/nix/store/7k1m1vlgrn0w3imyw9sd99x9i0wpcklg-stage2.nix.drv’ failed
(use ‘--show-trace’ to show detailed location information)
building path(s) ‘/nix/store/gk0g43mi0v729nhj19vjha9pdnxwxdci-stage2.nix’
builder for ‘/nix/store/7k1m1vlgrn0w3imyw9sd99x9i0wpcklg-stage2.nix.drv’ failed due to signal 4 (Illegal instruction: 4)
error: build of ‘/nix/store/7k1m1vlgrn0w3imyw9sd99x9i0wpcklg-stage2.nix.drv’ failed
(use ‘--show-trace’ to show detailed location information)
It looks like a problem occurred.  Please submit an issue at https://github.com/reflex-frp/reflex-platform/issues - include ./try-reflex.log to provide more information
sanketr commented 7 years ago

The same issue happens for me on Sierra. A fix resolution will be very helpful since this prevents us from building native binary.

imalsogreg commented 7 years ago

@sanketr Can you try adding ghc-options: -dynamic -threaded to your .cabal file, in any executable sections? That's working in some of my projects, at least the ones that rely on reflex-platform.

sanketr commented 7 years ago

@imalsogreg , tried your suggestion to add ghc-options. Still fails with linking error for Foundation:

In file included from /var/folders/hw/40drc6410ydcwscl7_p186500000gn/T/ghc63232_0/ghc_1.c:1:0: error:

In file included from /nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/Rts.h:217:0: error:

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:505:5: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF || ZERO_SLOP_FOR_SANITY_CHECK
    ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:502:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF     (defined(PROFILING))
                                    ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:505:31: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF || ZERO_SLOP_FOR_SANITY_CHECK
                              ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                    ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:505:31: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:56: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                                       ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:523:5: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
    ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:502:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF     (defined(PROFILING))
                                    ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:523:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
                               ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                    ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:523:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:56: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                                       ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:552:5: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
    ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:502:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_LDV_PROF'
#define ZERO_SLOP_FOR_LDV_PROF     (defined(PROFILING))
                                    ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:552:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
                               ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:37: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                    ^

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:552:32: error:
     warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

/nix/store/aywrg07n9wmfsr3vx58ljb8vjlf6yfai-ghc-8.0.2/lib/ghc-8.0.2/include/rts/storage/ClosureMacros.h:503:56: error:
     note: expanded from macro 'ZERO_SLOP_FOR_SANITY_CHECK'
#define ZERO_SLOP_FOR_SANITY_CHECK (defined(DEBUG) && !defined(THREADED_RTS))
                                                       ^
9 warnings generated.
ld: framework not found Foundation
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)
imalsogreg commented 7 years ago

@sanketr Ok. Maybe the difference is that I was trying with the most recent mobile2 commit?

michaelmesser commented 7 years ago

On OS X Sierra:


[nix-shell:~/Sources/reflex-platform]$  cat >hello.hs <<EOF
> {-# LANGUAGE OverloadedStrings #-}
> import Reflex.Dom
> main = mainWidget $ text "Hello, world!"
> EOF

[nix-shell:~/Sources/reflex-platform]$ ghc hello.hs
[1 of 1] Compiling Main             ( hello.hs, hello.o )
Linking hello ...
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_NSURL", referenced from:
      objc-class-ref in libHSjsaddle-wkwebview-0.9.0.0-8r8IaBDFmdeLQZ28oulvRZ.a(WKWebView.o)
ld: symbol(s) not found for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)```
3noch commented 7 years ago

Is this related to https://github.com/NixOS/nixpkgs/issues/22810?

ryantrinkle commented 6 years ago

I think this is fixed, although nix is known to have issues on High Sierra: https://github.com/NixOS/nix/issues/1583

Other versions of OS X should work!