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

hookedPrograms are not configurable from cabal configure #9144

Closed
lyokha opened this issue Jul 24, 2023 · 14 comments
Closed

hookedPrograms are not configurable from cabal configure #9144

lyokha opened this issue Jul 24, 2023 · 14 comments

Comments

@lyokha
Copy link
Collaborator

lyokha commented Jul 24, 2023

What is your question?
Essentially, why? Is it by design or just a hard-to-implement thing?
Related question. Is therunhaskell Setup.hs interface going to be fully replaced by the cabal-install interface? Is it regarded obsolete or a bad manner?

System information
Applied to any OS and Cabal versions.

Additional context
I implemented a custom UserHooks which declares a hookedPrograms with a small shell script hslibdeps patching runpath in the target library with patchelf and, additionally, collecting all dependent libraries.

ngxExportHooks :: Verbosity                         -- ^ Verbosity level
               -> UserHooks
ngxExportHooks verbosity =
    simpleUserHooks { hookedPrograms = [hslibdeps]
                    , confHook = \desc flags -> do
                        let pdb = configPrograms flags
                        _ <- requireProgram verbosity hslibdeps pdb >>=
                                 requireProgram verbosity patchelf . snd
                        confHook simpleUserHooks desc flags
                    , buildHook = \desc lbi _ flags ->
                        buildSharedLib verbosity desc lbi flags >>= \lib ->
                            patchAndCollectDependentLibs verbosity lib desc lbi
                    }

(The code and some docs can be found at https://hackage.haskell.org/package/ngx-export-distribution.)

The script accepts some options that I can pass via Setup.hs, say

$ runhaskell Setup.hs configure --user --hslibdeps-options="-t/var/lib/nginx/deps -ddeps -adeps"

But I cannot pass them in cabal configure , both v1 and v2.

$ cabal v1-configure --user --hslibdeps-options="-t/var/lib/nginx/deps -ddeps -adeps"
Error: cabal: unrecognized 'v1-configure' option
`--hslibdeps-options=-t/var/lib/nginx/deps -ddeps -adeps'

Note that

$ runhaskell Setup.hs configure --help
  ...
The flags --with-PROG and --PROG-option(s) can be used with the following programs:
  alex ar c2hs cpphs doctest gcc ghc ghc-pkg ghcjs ghcjs-pkg greencard haddock
  happy haskell-suite haskell-suite-pkg hmake hpc hsc2hs hscolour hslibdeps
  jhc ld pkg-config runghc strip tar uhc

lists hslibdeps, while

$ cabal v1-configure --help
  ...
The flags --with-PROG and --PROG-option(s) can be used with the following programs:
  alex ar c2hs cpphs doctest gcc ghc ghc-pkg ghcjs ghcjs-pkg greencard haddock
  happy haskell-suite haskell-suite-pkg hmake hpc hsc2hs hscolour jhc ld
  pkg-config runghc strip tar uhc
  ...

doesn't.

After digging into the Cabal's source code

In defaultMainHelper, configureCommand gets fed with hookedPrograms:

    progs = addKnownPrograms (hookedPrograms hooks) defaultProgramDb
    commands =
      [ configureCommand progs
          `commandAddAction` \fs as -> configureAction hooks fs as >> return ()
      , buildCommand progs `commandAddAction` buildAction hooks

and that is why Setup.hs knows about hslibdeps.

In the cabal-install, configureCommand ignores userHooks. Probably, because the Cabal's configureCommand cannot be called ahead (or not called at all?). Therefore, lack of ability to configure hooked programs may appear a hard-to-implement thing. Am I right?

On the other hand, the question could be of no importance if runhaskell Setup.hs were regarded as indispensable and not fully covered by cabal-install command interface.

@gbaz
Copy link
Collaborator

gbaz commented Jul 24, 2023

There's no intention of replacing the Setup.hs interface -- all of cabal-install's commands (and much else besides) are built on top of it.

That said, the v1 interface is deprecated and nothing except urgent bugfixes is getting merged to it. On the other hand the v2 interface probably should be able to handle this.

But finally, we also want to encourage users, over the long-term, to attempt to avoid custom Setup.hs scripts wherever possible in favor of improving the expressiveness of cabal files themselves, so it is worth considering the minimal extension to existing cabal file syntax that might allow avoiding a custom Setup. In this case, it looks like despite the hook being simple, its doing something pretty nontrivial, and there may not be a nice alternative -- but its always good to ponder.

@lyokha
Copy link
Collaborator Author

lyokha commented Jul 24, 2023

@gbaz, thank you for the clarification!

There's no intention of replacing the Setup.hs interface -- all of cabal-install's commands (and much else besides) are built on top of it.

Good!

That said, the v1 interface is deprecated and nothing except urgent bugfixes is getting merged to it.

Yes, I know. I'm still using the v1 as a matter of habit.

In this case, it looks like despite the hook being simple, its doing something pretty nontrivial, and there may not be a nice alternative -- but its always good to ponder.

I wouldn't mind using ghc interface directly, but it's not feasible (at least, non-trivial) when dependencies were built by cabal v2-build.

My scenario is very simple:

  1. Build shared library with some FFI functions that could be called from C code,
  2. collect all libHS libraries from dependent packages scattered by cabal v2-build inside the Cabal store directory,
  3. put a target directory (where all those dependent libraries will reside) at the beginning of the runpath record of the library using patchelf,
  4. put the patched library and all dependent libHS libraries into a tarball for a future deployment.

That's it. Not sure if this can be achieved in Cabal without using a custom Setup.hs.

@andreabedini
Copy link
Collaborator

@lyokha Let me say I am very interested in your usecase!

cabal-install supports building foreign-libraries. You can do

cabal-version:              3.8
name:                       ngx-distribution-test
version:                    0.1.0.0

foreign-library ngx-distribution-test
  type:                     native-shared
  other-modules:            NgxDistributionTest
  build-depends:            base >= 4.8 && < 5
                          , ngx-export
                          , bytestring
                          , aeson
  default-language:         Haskell2010

and cabal build will create libngx-distribution-test.so (dynamically linked to both system and haskell libraries).

There is also some support to build standalone libraries:

A standalone dynamic library is one that does not have any dependencies on other (Haskell) shared libraries; without the standalone option the generated library would have dependencies on the Haskell runtime library (libHSrts), the base library (libHSbase), etc. Currently, standalone must be used on Windows and must not be used on any other platform.

I am not sure what is preventing it from working on linux but I guess one can try.

@andreabedini
Copy link
Collaborator

More discussion in #4827.

@lyokha
Copy link
Collaborator Author

lyokha commented Jul 25, 2023

@andreabedini This is a good point! I somehow missed availability of the foreign-library stanza in Cabal when was making ngx-distribution. I will think to move to this. Still, steps 2, 3, 4 of my scenario are not covered by the foreign-library.

As to building shared libraries in ngx-distribution, the implementation is simple: buildHook invokes ghc with the corresponding arguments such as -dynamic, -shared, -fPIC. However, when dependencies have been built with cabal v2-built, this is not sufficient because ghc is not aware of the Cabal store. This requires additional boilerplate around the build command, particularly, I must always start building by cabal v2-install --lib --only-dependencies --package-env . to properly bootstrap the GHC environment in the current directory. Additionally, I must keep an eye to provide the minimal set of packages listed in the GHC environment file to prevent linkage of the target library against excessive number of unneeded libraries. Hopefully, moving to the foreign-library would help me get rid of this kind of ceremony.

@andreabedini
Copy link
Collaborator

And down the rabbit hole I went!

I turns out the only thing that is stopping us from using standalone libraries on Linux is that the boot packages shipped with GHC bindists are not compiled with -fPIC.

So this happens:

ld.lld: error: relocation R_X86_64_32S cannot be used against symbol 'base_GHCziMaybe_Just_con_info'; recompile with -fPIC
>>> defined in /home/andrea/.ghcup/ghc/9.4.5/lib64/ghc-9.4.5/lib/../lib/x86_64-linux-ghc-9.4.5/base-4.17.1.0/libHSbase-4.17.1.0.a(Maybe.o)
>>> referenced by Base.o:(base_ControlziExceptionziBase_zdfExceptionRecSelErrorzuzdcfromException_info) in archive /home/andrea/.ghcup/ghc/9.4.5/lib64/ghc-9.4.5/lib/../lib/x86_64-linux-ghc-9.4.5/base-4.17.1.0/libHSbase-4.17.1.0.a

BUT

With modern tooling like ghcup, it's (relatively) easy to get a GHC with suitable boot packages. Putting together various examples I found online, I tried this:

$ cat build.mk
GhcLibHcOpts += -fPIC
GhcRtsHcOpts += -fPIC
GhcRtsCcOpts += -fPIC
BuildFlavour = quick

$ ghcup compile ghc -v 9.4.5 -b 9.0 -o 9.4-fpic --config build.mk

And a couple of hours later, I could try again

$ ghcup run --ghc 9.4-fpic cabal build
Resolving dependencies...
Build profile: -w ghc-9.4.5 -O1
In order, the following will be built (use -v for more details):
 - FLibSimple-0.1.0.0 (flib:FLibSimple) (configuration changed)
Warning: FLibSimple.cabal:16:5: Unknown field: import. Common stanza imports
should be at the top of the enclosing section
Configuring foreign library 'FLibSimple' for FLibSimple-0.1.0.0..
Preprocessing foreign library 'FLibSimple' for FLibSimple-0.1.0.0..
Building foreign library 'FLibSimple' for FLibSimple-0.1.0.0..
[1 of 1] Compiling Main             ( src/Main.hs, /home/andrea/Scratchpad/FLibSimple/dist-newstyle/build/x86_64-linux/ghc-9.4.5/FLibSimple-0.1.0.0/f/FLibSimple/build/FLibSimple/FLibSimple-tmp/Main.o ) [Flags changed]
[1 of 2] Compiling Main             ( src/Main.hs, /home/andrea/Scratchpad/FLibSimple/dist-newstyle/build/x86_64-linux/ghc-9.4.5/FLibSimple-0.1.0.0/f/FLibSimple/build/FLibSimple/FLibSimple-tmp/Main.o ) [Flags changed]
[2 of 2] Linking /home/andrea/Scratchpad/FLibSimple/dist-newstyle/build/x86_64-linux/ghc-9.4.5/FLibSimple-0.1.0.0/f/FLibSimple/build/FLibSimple/libFLibSimple.so [Objects changed]

$ ldd dist-newstyle/build/x86_64-linux/ghc-9.4.5/FLibSimple-0.1.0.0/f/FLibSimple/build/FLibSimple/libFLibSimple.so
	linux-vdso.so.1 (0x00007fff68508000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f299510a000)
	libffi.so.8 => /home/andrea/.ghcup/ghc/9.4-fpic/lib64/ghc-9.4.5/rts/libffi.so.8 (0x00007f29950f9000)
	libgmp.so.10 => /lib64/libgmp.so.10 (0x00007f2995053000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f2994203000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2995213000)

Which is quite the improvement! FLibSimple has lens as a direct dependency, so RTS and all Haskell libraries got compiled in. See ghcup guide for the details about compiling GHC. Note: I am not sure this is a reasonable GHC build, I invite you to do your own research.

This requires additional boilerplate around the build command, particularly, I must always start building by cabal v2-install --lib --only-dependencies --package-env . to properly bootstrap the GHC environment in the current directory.

There are few ways to get a GHC environment from a cabal project. Beside the one you mention you can do cabal build --write-ghc-environment-files=always to get a .ghc.environment file in your project root folder. Or you can use cabal exec which will pass the environment through the GHC_ENVIRONMENT environment variable. E.g. you could do

$ cabal exec -- ghc --make src/Main.hs
Loaded package environment from /home/andrea/Scratchpad/FLibSimple/dist-newstyle/tmp/environment.-11901/.ghc.environment.x86_64-linux-9.4.5
[2 of 2] Linking src/Main

where cabal-install has sorted out the dependencies but you compile your code yourself.

Additionally, I must keep an eye to provide the minimal set of packages listed in the GHC environment file to prevent linkage of the target library against excessive number of unneeded libraries

I am not sure I understand this. The environment that cabal spits out is minimal (sort of, since it includes the dependencies of any exe component in any package in the build plan). But if you follow what libraries the dynamic linker is loading, you won't need a minimal environment.

@lyokha
Copy link
Collaborator Author

lyokha commented Jul 27, 2023

And a couple of hours later...

Yes, I know :) Some long time ago, at the dawn of the Ghc 8.x era, I even wrote a tutorial of how to build standalone shared libraries for Linux which also implied rebuild of the base libraries. Here it is: https://github.com/lyokha/nginx-haskell-module/tree/master/docs/static-linkage#readme.

I am not sure I understand this. The environment that cabal spits out is minimal (sort of, since it includes the dependencies of any exe component in any package in the build plan). But if you follow what libraries the dynamic linker is loading, you won't need a minimal environment.

Yes, but I built dependent libraries together with dependent libraries of the build tool (ngx-export-distribution, which depends on Cabal) in the same Ghc environment. Obviously, the target library won't likely need Cabal and its dependencies, but it got linked against them as Cabat etc. was listed in the Ghc environment file.

@andreabedini
Copy link
Collaborator

Yes, I know :) Some long time ago, at the dawn of the Ghc 8.x era, I even wrote a tutorial of how to build standalone shared libraries for Linux which also implied rebuild of the base libraries. Here it is: https://github.com/lyokha/nginx-haskell-module/tree/master/docs/static-linkage#readme.

And I somehow missed your tutorial, damn! This seems to be haskell folkore that should be properly documented.

Yes, but I built dependent libraries together with dependent libraries of the build tool (ngx-export-distribution, which depends on Cabal) in the same Ghc environment.

I don't think setup dependencies end up in the environment but I will dobule check (following the example here).

@lyokha
Copy link
Collaborator Author

lyokha commented Jul 27, 2023

In the example, I did two preliminary steps:

$ cabal v2-install --lib --only-dependencies --package-env .
$ cabal v2-install --lib ngx-export-distribution --package-env .

Hmm, it looks that the 2nd command can be replaced with

$ cabal v2-build ngx-export-distribution

and, as soon as ngx-export-distribution gets built by the 1st command, this step is not needed at all.

Trying to reproduce excessive linkage in a fresh Cabal store

Indeed, in a fresh Cabal store, after

$ cabal --store-dir=$HOME/tmp/cabal v2-install --lib --only-dependencies --package-env .

I get the following .ghc.environment.x86_64-linux-9.6.2:

clear-package-db
global-package-db
package-db /home/lyokha/tmp/cabal/ghc-9.6.2/package.db
package-id ngx-distribution-test-0.1.0.0-c485dd0e274da10ef940cc2f882582edc5dddfe78b0fd60950b7adff131ac004

After the 2nd command

$ cabal --store-dir=$HOME/tmp/cabal v2-install --lib ngx-export-distribution --package-env .

the evironment gets

clear-package-db
global-package-db
package-db /home/lyokha/tmp/cabal/ghc-9.6.2/package.db
package-id ngx-export-distribution-0.3.2.3-02f1a35750566346c765d8b11e5710bfc5967e7918682c304722f9264151b9b6

Now, to build this, I should inject direct dependencies found by cabal-plan:

$ . ../cabal-plan-direct-deps.sh >> .ghc.environment.x86_64-linux-9.6.2

The Ghc environment gets:

clear-package-db
global-package-db
package-db /home/lyokha/tmp/cabal/ghc-9.6.2/package.db
package-id ngx-export-distribution-0.3.2.3-02f1a35750566346c765d8b11e5710bfc5967e7918682c304722f9264151b9b6
package-id aeson-2.2.0.0-b6ca5d0d574fab93a9f93c7ff97154fd6ffc4aef7a57e49453e9030b909a737c
package-id base-4.18.0.0
package-id bytestring-0.11.4.0
package-id ngx-export-1.7.5-1806001a3e60abca3232c3c98788aa840f65e1217f47524073eb21a4cfd4b82b

Now, if I configure this without deleting package-id ngx-export-distribution... and then build as

$ runhaskell --ghc-arg=-package=base --ghc-arg=-package=ngx-export-distribution Setup.hs build --ghc-options="ngx_distribution_test.hs -o ngx_distribution_test.so -threaded"

my target library gets linked against libHSCabal-3.10.1.0-ghc9.6.2.so and some other unneeded libraries.

Trying to skip v2-install --lib ngx-export-distribution

Refresh the temporary Cabal store:

$ rm -rf ~/tmp/cabal/ghc-9.6.2/

With v2-install --lib ngx-export-distribution skipped, I get .ghc.environment.x86_64-linux-9.6.2:

clear-package-db
global-package-db
package-db /home/lyokha/tmp/cabal/ghc-9.6.2/package.db
package-id ngx-distribution-test-0.1.0.0-c485dd0e274da10ef940cc2f882582edc5dddfe78b0fd60950b7adff131ac004

Looks good. Try to configure

$ ADD_CABAL_STORE=$(sed -n 's/^\(package-db\)\s\+/--\1=/p' .ghc.environment.x86_64-linux-$(ghc --numeric-version))
$ runhaskell --ghc-arg=-package=base --ghc-arg=-package=ngx-export-distribution Setup.hs configure --package-db=clear --package-db=global $ADD_CABAL_STORE --prefix=/var/lib/nginx
<command line>: cannot satisfy -package-id ngx-distribution-test-0.1.0.0-c485dd0e274da10ef940cc2f882582edc5dddfe78b0fd60950b7adff131ac004
    (use -v for more information)

I still have to comment the current package-id records in the Ghc environment and inject direct dependencies found by cabal-plan. After the injection, build creates a library without excessive linkage.


Now I'm using cabal-install version 3.10.1.0, and, unfortunately, I'm not sure if behavior of 3.6 and 3.8 (which I used when was making the example) regarding Ghc environments was exactly the same. So, I cannot say why I was talking in the example about multiple packages listed in the Ghc environment while now Cabal puts there only one: ngx-export-distribution or ngx-distribution-test, depending on if I skip the 2nd command or not.

@gbaz
Copy link
Collaborator

gbaz commented Jul 27, 2023

So, I cannot say why I was talking in the example about multiple packages listed in the Ghc environment while now Cabal puts there only one: ngx-export-distribution or ngx-distribution-test, depending on if I skip the 2nd command or not.

That's indeed a behavior change in cabal-install, to put far fewer packages in the env file when install --lib is run. There's one further change going forward, which is that base itself will always go in the env file. cf #8903

@lyokha
Copy link
Collaborator Author

lyokha commented Jul 29, 2023

@andreabedini Finally, I implemented a simple build approach by collecting commands from here in a Makefile. Projects affected:

The latter 2 involves linking against C libraries, in which case the libraries call graph is

Nginx C code -> dlopen a Haskell library -> C code from a C library

A typical cabal.project is

-- note that ngx-export-tools-extra will be taken from Hackage;
-- to build ngx-export-tools-extra locally, add
-- ../../ngx-export-tools-extra.cabal to packages
packages: test-tools-extra-subrequest.cabal

A typical Makefile is

NAME := test_tools_extra_subrequest
PKGNAME := $(subst _,-,$(NAME))
PKGVER := 0.1.0.0

PREFIX := /var/lib/nginx
MACHINE := $(shell uname -m)
KERNEL := $(shell uname -s | tr A-Z a-z)

PKGDISTR := ngx-export-distribution

SRC := $(NAME).hs
LIB := $(NAME).so
STUB := $(NAME)_stub.h
DISTR := $(PKGNAME)-$(PKGVER).tar.gz

GHCVER := $(shell ghc --numeric-version)
GHCENV := .ghc.environment.$(MACHINE)-$(KERNEL)-$(GHCVER)
DEPLIBS := $(MACHINE)-$(KERNEL)-ghc-$(GHCVER)
DISTDIR := dist
DISTV2DIR := dist-newstyle

INPLACE := $(shell grep '^packages:.*\.\./\.\./ngx-export-tools-extra' \
                       cabal.project &>/dev/null && echo 1 || echo 0)

all: $(DISTR)

$(DISTR): $(SRC)
	cabal install --lib --only-dependencies --package-env .
	cabal build $(PKGDISTR)
ifeq ($(INPLACE),1)
	cabal build ngx-export-tools-extra
	echo "package-db $$(pwd)/$(DISTV2DIR)/packagedb/ghc-$(GHCVER)" >> \
	 $(GHCENV)
endif
	sed -i 's/\(^package-id \)/--\1/' $(GHCENV)
	runhaskell --ghc-arg=-package=base \
	 --ghc-arg=-package=$(PKGDISTR) Setup.hs configure \
	 --package-db=clear --package-db=global \
	 $$(sed -n 's/^\(package-db\)\s\+/--\1=/p' $(GHCENV)) \
	 --prefix=$(PREFIX)
	. ../cabal-plan-direct-deps.sh | grep -v '.-e-ede-' >> $(GHCENV)
	runhaskell --ghc-arg=-package=base \
	 --ghc-arg=-package=$(PKGDISTR) Setup.hs build \
	 --ghc-options="$(SRC) -o $(LIB) $(LINKRTS)"

install: $(DISTR)
	install -d $(PREFIX)
	tar xf $(DISTR) -C $(PREFIX) --no-same-owner

.PHONY: clean

clean:
	rm -rf $(DISTDIR) $(DISTV2DIR) $(DEPLIBS)
	rm -f $(GHCENV) $(STUB) $(NAME).hi $(NAME).o
	rm -f $(LIB)

clean-all: clean
	rm -f $(DISTR)

With this, after typing only 2 commands

$ make
$ sudo make install

the libraries are ready to use.

There were no problems with building and testing this so far, including builds of the host modules inplace (i.e. when I build the test code together with the basic module). Except the following: when I built ngx-export-tools-extra inplace, I got the error

runhaskell --ghc-arg=-package=base \
  --ghc-arg=-package=ngx-export-distribution Setup.hs build \
  --ghc-options="test_tools_extra_subrequest.hs -o test_tools_extra_subrequest.so "
<command line>: cannot satisfy -package-id ede-0.3.3.0-e-ede-087231545cc80ecfefe6ed914609123982fd69780ec55708bd7a4e96b7463ea7
    (use -v for more information)

Module ngx-export-tools-extra depends on package ede which includes an executable ede. Looks like -e-ede- in the package-id should read as executable ede. The Ghc environment at this step looked as

clear-package-db
global-package-db
package-db /home/lyokha/.cabal/store/ghc-9.6.2/package.db
--package-id test-tools-extra-subrequest-0.1.0.0-f5e07fc47472dc8712d8a73a3cf993e1bca74bbfc48c3393a3dafb27318aa982
package-db /home/lyokha/devel/ngx-export-tools-extra/test/Subrequest/dist-newstyle/packagedb/ghc-9.6.2
package-id aeson-2.2.0.0-b6ca5d0d574fab93a9f93c7ff97154fd6ffc4aef7a57e49453e9030b909a737c
package-id array-0.5.5.0
package-id async-2.2.4-8477778d2ce48b5b4ada83ef9dc179b633f4d58d347fdd306c6e0be66249625d
package-id base-4.18.0.0
package-id base64-0.4.2.4-1fa75b09aa939dd4f502f1e3b2525247254fddbfa229e42158c4481b65eef807
package-id binary-0.8.9.1
package-id bytestring-0.11.4.0
package-id case-insensitive-1.2.1.0-e9cd3c669bf9b4aea9eb73f0778718f4d320d44ed069fdffa1f44dae7d9bc52c
package-id containers-0.6.7
package-id ede-0.3.3.0-f752268f2800a5ae38cbbc00c0dc10e58cde8c7a4ebe2b3897bd3f900275b48c
package-id ede-0.3.3.0-e-ede-087231545cc80ecfefe6ed914609123982fd69780ec55708bd7a4e96b7463ea7
package-id enclosed-exceptions-1.0.3-7b7d9e4d9761c0abacc47421a793fd7a6a513c9338524acb05f322912d11fe7c
package-id http-client-0.7.13.1-ef07e7a1645b36b6d58b4644cb89f0aba02fd4dd22ca7ebdaeaeba0b0217fc71
package-id http-client-brread-timeout-0.1.1.0-edf280dc915eeb52ea2c6e94eb3f9bdfe57dc298ec1ae84137ad913b3069af0c
package-id http-types-0.12.3-c8f6441bf8309a5165114edd28af85c5b754bc8571988a946271bd8eac222bed
package-id network-3.1.4.0-13bde0763bc9f6dbc4ac9d573449d21d0c35c10bd2d1e2c00c8e2823e14be965
package-id ngx-export-1.7.5-1806001a3e60abca3232c3c98788aa840f65e1217f47524073eb21a4cfd4b82b
package-id ngx-export-tools-1.0-081683033269fea6fe2d68ba0b32397c40aecfcb856d1fa788fdf20c2a8b7719
package-id pcre-heavy-1.0.0.3-ff7e0ec69832d882859f2e7259f5fa84487e7aa4351e66cd14fc0e0ab233dc36
package-id pcre-light-0.4.1.0-73bef387118599cdb4c3870371657e979d34d1c46aeeb460aecf0a7aac43bb6d
package-id prettyprinter-1.7.1-67c005d2da5fd09846dcf55e721bab88febded6f91b80d03e76049f72c01f607
package-id resolv-0.2.0.2-791e5f12d4b86e67624045f317b83d34f8d766e42966686c84f69b840a541fc8
package-id safe-0.3.19-b86ac065310488d7ae0382f27dc382907eb9c7de82da460ee5a9328d019614ec
package-id safe-exceptions-0.1.7.4-1086a27b2f01ccf61413e3b75fa73179671df9763c75fd91dfaf629be0aa59e5
package-id snap-core-1.0.5.1-2cbba33a50b80f2222e9d8ca2f9a41078f2f5b11e2251e606eb7068d1d69cf35
package-id snap-server-1.1.2.1-8199afc37396809bc1d64db0ddd5ab3c3042920762a2de3ed26f5946f891f47c
package-id template-haskell-2.20.0.0
package-id text-2.0.2
package-id time-1.12.2
package-id trifecta-2.1.2-b0ba56418ec98881495a1af069f072f22049080d0a8fc20c043bc64268fa13dd
package-id unordered-containers-0.2.19.1-daea9969f67e48ae90ae99568c946e41dadb4903dce86e6595887449ddae8428
package-id ngx-export-tools-extra-1.2.3-inplace

Not sure if this a bug in Cabal. Supposedly, executables should either not be configured at all when building dependencies for a library or, otherwise, not fail. Fortunately, I control the contents of the Ghc environment, and filter out the package with the -e-ede- in the Makefile.

. ../cabal-plan-direct-deps.sh | grep -v '.-e-ede-' >> $(GHCENV)

After this, build succeeds.

@andreabedini
Copy link
Collaborator

@lyokha Thanks for the detailed instructions. I had little time in the last few days so I couldn't compare my test with your instructions :-/ I uploaded it to https://gist.github.com/andreabedini/a3b012345124854c2fe58380dfe3d4ae so perhaps you can let me know if I misunderstood the problem you are trying to solve.

Also, feel free to contact me in private. I'd be happy to help you with this.

@lyokha
Copy link
Collaborator Author

lyokha commented Jul 31, 2023

@andreabedini Great! foreign-library + linuxdeploy look like a good alternative to my approach. Thank you for the example!

@lyokha
Copy link
Collaborator Author

lyokha commented Aug 29, 2023

Though hookedPrograms are not configurable from cabal executable, the problem is relaxed by ability to use runhaskell Setup.hs for this, which is ok to me. So, I'm closing this.

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

No branches or pull requests

4 participants