google-research / dex-lang

Research language for array processing in the Haskell/ML family
BSD 3-Clause "New" or "Revised" License
1.58k stars 107 forks source link

Can't build dev branch on Mac #756

Closed duvenaud closed 2 years ago

duvenaud commented 2 years ago

I updated to LLVM 12, Clang 12, and updated all my paths, as far as I can tell. But when I run make on a freshly-downloaded safer-names-dev branch, I get this error:

make
clang++ -fPIC -I/usr/local/include -std=c++11 -fno-exceptions -fno-rtti -DDEX_LIVE -c -emit-llvm src/lib/dexrt.cpp -o src/lib/dexrt.bc
stack --stack-yaml=stack-macos.yaml build 
Building all executables for `dex' once. After a successful build of all of them, only specified executables will be rebuilt.
dex> configure (lib + internal-lib + exe)
Configuring dex-0.1.0.0...
dex> build (lib + internal-lib + exe)
Preprocessing library 'dex-resources' for dex-0.1.0.0..
Building library 'dex-resources' for dex-0.1.0.0..
[1 of 1] Compiling Resources
Preprocessing library for dex-0.1.0.0..
Building library for dex-0.1.0.0..
[ 1 of 36] Compiling CUDA
[ 2 of 36] Compiling Err
[ 3 of 36] Compiling Cat
[ 4 of 36] Compiling LLVM.HEAD.JIT

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:37:27: error:
    Not in scope:
      type constructor or class ‘OrcJIT.RTDyldObjectLinkingLayer’
    Perhaps you meant ‘OrcJIT.ObjectLinkingLayer’ (imported from LLVM.OrcJIT)
    Module ‘LLVM.OrcJIT’ does not export ‘RTDyldObjectLinkingLayer’.
   |
37 |         , objectLayer  :: OrcJIT.RTDyldObjectLinkingLayer
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:46:19: error:
    Not in scope: ‘OrcJIT.createRTDyldObjectLinkingLayer’
    Module ‘LLVM.OrcJIT’ does not export ‘createRTDyldObjectLinkingLayer’.
   |
46 |   objectLayer  <- OrcJIT.createRTDyldObjectLinkingLayer session
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:47:19: error:
    Not in scope: ‘OrcJIT.createIRCompileLayer’
    Perhaps you meant one of these:
      ‘OrcJIT.newIRCompileLayer’ (imported from LLVM.OrcJIT),
      ‘OrcJIT.withIRCompileLayer’ (imported from LLVM.OrcJIT)
    Module ‘LLVM.OrcJIT’ does not export ‘createIRCompileLayer’.
   |
47 |   compileLayer <- OrcJIT.createIRCompileLayer session objectLayer tm
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:60:36: error:
    Not in scope: type constructor or class ‘OrcJIT.JITDylib’
    Module ‘LLVM.OrcJIT’ does not export ‘JITDylib’.
   |
60 |                , moduleDylib    :: OrcJIT.JITDylib
   |                                    ^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:74:7: error:
    Not in scope: ‘OrcJIT.cloneAsThreadSafeModule’
    Module ‘LLVM.OrcJIT’ does not export ‘cloneAsThreadSafeModule’.
   |
74 |       OrcJIT.cloneAsThreadSafeModule m
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:77:3: error:
    Not in scope:
      ‘OrcJIT.addDynamicLibrarySearchGeneratorForCurrentProcess’
    Module ‘LLVM.OrcJIT’ does not export ‘addDynamicLibrarySearchGeneratorForCurrentProcess’.
   |
77 |   OrcJIT.addDynamicLibrarySearchGeneratorForCurrentProcess compileLayer moduleDylib
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:82:7: error:
    Not in scope: ‘OrcJIT.lookupSymbol’
    Module ‘LLVM.OrcJIT’ does not export ‘lookupSymbol’.
   |
82 |       OrcJIT.lookupSymbol session compileLayer moduleDylib $ fromString dtorName
   |       ^^^^^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:116:5: error:
    Not in scope: ‘OrcJIT.lookupSymbol’
    Module ‘LLVM.OrcJIT’ does not export ‘lookupSymbol’.
    |
116 |     OrcJIT.lookupSymbol session compileLayer moduleDylib (fromString funcName)
    |     ^^^^^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:119:23: error:
    Not in scope: type constructor or class ‘OrcJIT.JITDylib’
    Module ‘LLVM.OrcJIT’ does not export ‘JITDylib’.
    |
119 | newDylib :: JIT -> IO OrcJIT.JITDylib
    |                       ^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:124:3: error:
    Not in scope: ‘OrcJIT.createJITDylib’
    Module ‘LLVM.OrcJIT’ does not export ‘createJITDylib’.
    |
124 |   OrcJIT.createJITDylib (session jit) name
    |   ^^^^^^^^^^^^^^^^^^^^^

/Users/bmo/code/dex/src/lib/LLVM/HEAD/JIT.hs:126:26: error:
    Not in scope: type constructor or class ‘OrcJIT.JITDylib’
    Module ‘LLVM.OrcJIT’ does not export ‘JITDylib’.
    |
126 | loadObjectFile :: JIT -> OrcJIT.JITDylib -> ObjectFileContents -> IO ()
    |                          ^^^^^^^^^^^^^^^

--  While building package dex-0.1.0.0 (scroll up to its section to see the error) using:
      /Users/bmo/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-3.0.1.0 build lib:dex lib:dex-resources exe:dex --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
make: *** [build] Error 1
dougalm commented 2 years ago

Hmmm, macOS CI was giving those same messages. I assumed it was some stale cache problem and disabled it. It looks like it's still trying to use the old version of llvm-hs. Have you tried nuking the system-wide stack cache at ~/.stack ? I can try debugging on Melis's mac this evening.

duvenaud commented 2 years ago

I nuked the stack cache, and now make fails at building the Haskell LLVM library version 9.0.1:

make
clang++ -fPIC -I/usr/local/include -std=c++11 -fno-exceptions -fno-rtti -DDEX_LIVE -c -emit-llvm src/lib/dexrt.cpp -o src/lib/dexrt.bc
stack --stack-yaml=stack-macos.yaml build 
llvm-hs> configure
llvm-hs> [1 of 2] Compiling Main             ( /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-ede3e916140be721/llvm-hs-9.0.1/Setup.hs, /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-ede3e916140be721/llvm-hs-9.0.1/.stack-work/dist/x86_64-osx/Cabal-3.0.1.0/setup/Main.o )
llvm-hs> [2 of 2] Compiling StackSetupShim   ( /Users/bmo/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-ede3e916140be721/llvm-hs-9.0.1/.stack-work/dist/x86_64-osx/Cabal-3.0.1.0/setup/StackSetupShim.o )
llvm-hs> Linking /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-ede3e916140be721/llvm-hs-9.0.1/.stack-work/dist/x86_64-osx/Cabal-3.0.1.0/setup/setup ...
llvm-hs> setup: The program 'llvm-config' version ==9.0.* is required but the version
llvm-hs> found at /usr/local/opt/llvm@12/bin/llvm-config is version 12.0.1
llvm-hs>    
Progress 1/2

--  While building package llvm-hs-9.0.1 (scroll up to its section to see the error) using:
      /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-ede3e916140be721/llvm-hs-9.0.1/.stack-work/dist/x86_64-osx/Cabal-3.0.1.0/setup/setup --builddir=.stack-work/dist/x86_64-osx/Cabal-3.0.1.0 configure --user --package-db=clear --package-db=global --package-db=/Users/bmo/.stack/snapshots/x86_64-osx/3d315b4f96ed92d039edbdffbe5c917b8d118542bb335e176474c01c9c849f1b/8.8.4/pkgdb --libdir=/Users/bmo/.stack/snapshots/x86_64-osx/3d315b4f96ed92d039edbdffbe5c917b8d118542bb335e176474c01c9c849f1b/8.8.4/lib --bindir=/Users/bmo/.stack/snapshots/x86_64-osx/3d315b4f96ed92d039edbdffbe5c917b8d118542bb335e176474c01c9c849f1b/8.8.4/bin --datadir=/Users/bmo/.stack/snapshots/x86_64-osx/3d315b4f96ed92d039edbdffbe5c917b8d118542bb335e176474c01c9c849f1b/8.8.4/share --libexecdir=/Users/bmo/.stack/snapshots/x86_64-osx/3d315b4f96ed92d039edbdffbe5c917b8d118542bb335e176474c01c9c849f1b/8.8.4/libexec --sysconfdir=/Users/bmo/.stack/snapshots/x86_64-osx/3d315b4f96ed92d039edbdffbe5c917b8d118542bb335e176474c01c9c849f1b/8.8.4/etc --docdir=/Users/bmo/.stack/snapshots/x86_64-osx/3d315b4f96ed92d039edbdffbe5c917b8d118542bb335e176474c01c9c849f1b/8.8.4/doc/llvm-hs-9.0.1 --htmldir=/Users/bmo/.stack/snapshots/x86_64-osx/3d315b4f96ed92d039edbdffbe5c917b8d118542bb335e176474c01c9c849f1b/8.8.4/doc/llvm-hs-9.0.1 --haddockdir=/Users/bmo/.stack/snapshots/x86_64-osx/3d315b4f96ed92d039edbdffbe5c917b8d118542bb335e176474c01c9c849f1b/8.8.4/doc/llvm-hs-9.0.1 --dependency=Cabal=Cabal-3.0.1.0 --dependency=array=array-0.5.4.0 --dependency=attoparsec=attoparsec-0.13.2.4-AHmlmm44dvnKaiPmUJc2M1 --dependency=base=base-4.13.0.0 --dependency=bytestring=bytestring-0.10.10.1 --dependency=containers=containers-0.6.2.1 --dependency=exceptions=exceptions-0.10.4-6ENJVzINLe28VlhOUrvEZK --dependency=llvm-hs-pure=llvm-hs-pure-9.0.0-1zpu9iorlHyBu5P9Rr9VX1 --dependency=mtl=mtl-2.2.2 --dependency=template-haskell=template-haskell-2.15.0.0 --dependency=transformers=transformers-0.5.6.2 --dependency=utf8-string=utf8-string-1.0.1.1-K3Cc2i5eeGM49mkpXdBKoc -f-debug -f-shared-llvm --exact-configuration --ghc-option=-fhide-source-paths
    Process exited with code: ExitFailure 1
make: *** [build] Error 1
dougalm commented 2 years ago

--stack-yaml=stack-macos.yaml

Oops! I didn't know there was a stack-macos.yaml. That'll do it!

Does it work if you copy the llvm lines from stack.yaml to stack-macos.yaml?

duvenaud commented 2 years ago

Haha, yes just noticed the hardcoded reference to apaszke/llvm-hs. Rebuilding now. Not sure whether to keep the last lines of the old stack-macos.yaml:

flags:
  llvm-hs:
    shared-llvm: false

but I'm leaving them in for now, I'll try both ways if it doesn't work.

dougalm commented 2 years ago

Probably also need to update the resolver, resolver: lts-18.23

duvenaud commented 2 years ago

Yes, I copied the updated resolver over, too.

duvenaud commented 2 years ago

Hmmm, that helps, it's actually building llvm-hs 12.0.0 now, but it seems to choke on compiling one of the cpp files:

.
.
.
[ 99 of 102] Compiling LLVM.Transforms
llvm-hs              > [100 of 102] Compiling LLVM.Internal.FFI.PassManager
llvm-hs              > [101 of 102] Compiling LLVM.Internal.PassManager
llvm-hs              > [102 of 102] Compiling LLVM.PassManager
llvm-hs              >   
llvm-hs              > /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-626bff90a687736e/llvm-hs-12.0.0/In file included from src/LLVM/Internal/FFI/AssemblyC.cpp:2:0: error:
llvm-hs              >     
llvm-hs              >   
llvm-hs              > /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-626bff90a687736e/llvm-hs-12.0.0/In file included from /usr/local/Cellar/llvm@12/12.0.1_1/include/llvm/AsmParser/Parser.h:16:0: error:
llvm-hs              >     
llvm-hs              >   
llvm-hs              > /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-626bff90a687736e/llvm-hs-12.0.0/In file included from /usr/local/Cellar/llvm@12/12.0.1_1/include/llvm/ADT/STLExtras.h:19:0: error:
llvm-hs              >     
llvm-hs              >   
llvm-hs              > /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-626bff90a687736e/llvm-hs-12.0.0/In file included from /usr/local/Cellar/llvm@12/12.0.1_1/include/llvm/ADT/Optional.h:18:0: error:
llvm-hs              >     
llvm-hs              >   
llvm-hs              > /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-626bff90a687736e/llvm-hs-12.0.0/In file included from /usr/local/Cellar/llvm@12/12.0.1_1/include/llvm/ADT/Hashing.h:49:0: error:
llvm-hs              >     
llvm-hs              >   
llvm-hs              > /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-626bff90a687736e/llvm-hs-12.0.0//usr/local/Cellar/llvm@12/12.0.1_1/include/llvm/Support/SwapByteOrder.h:98:1: error:
llvm-hs              >      error: unknown type name 'constexpr'
llvm-hs              >    |
llvm-hs              > 98 | constexpr bool IsBigEndianHost = false;
llvm-hs              >    | ^
llvm-hs              > constexpr bool IsBigEndianHost = false;
.
.
.
fatal error: too many errors emitted, stopping now [-ferror-limit=]
llvm-hs              > 4 warnings and 20 errors generated.
llvm-hs              > `gcc' failed in phase `C Compiler'. (Exit code: 1)
Progress 121/122         

--  While building package llvm-hs-12.0.0 (scroll up to its section to see the error) using:
      /private/var/folders/xg/c4_dcmvd2fb8q18hfqy3dgn00000gn/T/stack-626bff90a687736e/llvm-hs-12.0.0/.stack-work/dist/x86_64-osx/Cabal-3.2.1.0/setup/setup --builddir=.stack-work/dist/x86_64-osx/Cabal-3.2.1.0 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
make: *** [build] Error 1

Every line of this file throws an error. It's surprising to me that gcc is being called instead of clang.

dougalm commented 2 years ago

Getting closer at least...

I just made #757 to see if we can get the CI build working with the fixed stack-macos.yaml

dougalm commented 2 years ago

CI failed with the same error you're now getting: https://github.com/google-research/dex-lang/runs/5045648459?check_suite_focus=true

Maybe it's an llvm-hs bug at this point? @apaszke , any ideas?

apaszke commented 2 years ago

Yeah that looks like an llvm-hs bug, where it doesn't specify -std=c++11 to the C++ files it compiles. Should be easy to fix

EDIT: Seems like it is doing that

dougalm commented 2 years ago

Adam's fix seems to work! Just merged #757. @duvenaud , does it work for you now?

duvenaud commented 2 years ago

Yep, builds fine for me now! Thanks a ton guys.