ocramz / petsc-hs

Haskell bindings for PETSc and SLEPc
GNU General Public License v3.0
20 stars 4 forks source link

cabalize build #2

Closed ocramz closed 8 years ago

ocramz commented 9 years ago

The low-level bindings of petsc-hs are based on inline-c, therefore three compiler passes are needed:

It's not pretty, but it works. So far I had no time to turn this process into a single cabal install step.

ocramz commented 8 years ago
ocramz commented 8 years ago

As of a7bb4f2 (Nov 26, 105) :

$ stack build
inline-c-0.5.5.1: configure
inline-c-0.5.5.1: build
inline-c-0.5.5.1: install
petsc-hs-0.1.0.0: configure
Configuring petsc-hs-0.1.0.0...
setup-Simple-Cabal-1.22.4.0-x86_64-osx-ghc-7.10.2: The pkg-config package
'PETSc' is required but it could not be found.

There also seems to be a problem with cabal not properly handling relative paths : https://github.com/haskell/cabal/issues/2641 (fixed for now by hardcoding library paths in .cabal)

ocramz commented 8 years ago

Cabal file seems to work (visible of course both with stack build and cabal sandbox init && cabal install), but

Linker error in 23151a7 :

$ stack build inline-c-0.5.5.1: configure inline-c-0.5.5.1: build inline-c-0.5.5.1: install petsc-hs-0.1.0.0: configure Configuring petsc-hs-0.1.0.0... petsc-hs-0.1.0.0: build Preprocessing library petsc-hs-0.1.0.0... [ 1 of 19] Compiling Numerical.PETSc.Internal.Storable.Common ( src/Numerical/PETSc/Internal/Storable/Common.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Numerical/PETSc/Internal/Storable/Common.o ) [ 2 of 19] Compiling Numerical.PETSc.Internal.Exception ( src/Numerical/PETSc/Internal/Exception.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Numerical/PETSc/Internal/Exception.o ) ... [19 of 19] Compiling Numerical.PETSc ( src/Numerical/PETSc.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Numerical/PETSc.o ) In-place registering petsc-hs-0.1.0.0... Preprocessing executable 'petsc-example' for petsc-hs-0.1.0.0... [1 of 1] Compiling Main ( test/Main.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/petsc-example/petsc-example-tmp/Main.o ) Linking .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/petsc-example/petsc-example ...

Undefined symbols for architecture x86_64:

"_inline_c_Numerical_PETSc_Internal_InlineC_0_958eca3a12b1f5647efa0dbbd0c9ae0747e8978a", referenced from: _r1kiI_info in libHSpetsc-hs-0.1.0.0-GYdWeqSgYsHKX8EtM5oOb4.a(InlineC.o) _petsczuGYdWeqSgYsHKX8EtM5oOb4_NumericalziPETScziInternalziInlineC_zdwa10_info in libHSpetsc-hs-0.1.0.0-GYdWeqSgYsHKX8EtM5oOb4.a(InlineC.o) _c1BQI_info in libHSpetsc-hs-0.1.0.0-GYdWeqSgYsHKX8EtM5oOb4.a(InlineC.o) "_inline_c_Numerical_PETSc_Internal_InlineC_100_8d5695a2da88cedabdfb04533b6cf2aadcf2568b", referenced from: _r1kgy_info in libHSpetsc-hs-0.1.0.0-GYdWeqSgYsHKX8EtM5oOb4.a(InlineC.o) _c1v94_info in libHSpetsc-hs-0.1.0.0-GYdWeqSgYsHKX8EtM5oOb4.a(InlineC.o)

...

  _c23Mp_info in libHSpetsc-hs-0.1.0.0-GYdWeqSgYsHKX8EtM5oOb4.a(Vec.o)

ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status C
-- While building package petsc-hs-0.1.0.0 using: /Users/ocramz/.stack/setup-exe-cache/setup-Simple-Cabal-1.22.4.0-x86_64-osx-ghc-7.10.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/ build lib:petsc-hs exe:petsc-example --ghc-options -hpcdir .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/hpc/.hpc/ -ddump-hi -ddump-to-file Process exited with code: ExitFailure 1 ompleted all 2 actions.

ocramz commented 8 years ago

I had forgotten the c-sources: src/Numerical/PETSc/Internal/InlineC.c line. Duh.

This implicitly calls GCC (which I don't like because its name doesn't imply compilation), moreover it triggers a warning because the C file doesn't exist yet at the beginning of the compilation.