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

cabal install ignores --enable-executable-dynamic flag #8909

Closed
FedericoStra opened this issue Apr 19, 2023 · 5 comments
Closed

cabal install ignores --enable-executable-dynamic flag #8909

FedericoStra opened this issue Apr 19, 2023 · 5 comments

Comments

@FedericoStra
Copy link

The bug

There is no (obvious) way to have cabal install a dynamically linked executable.

To Reproduce

With the following configuration

-- cabal.project
packages: .
executable-dynamic: True
-- cabal.project.local
ignore-project: False
executable-dynamic: True

if I run cabal install --enable-executable-dynamic, then a statically linked version of the executable gets installed:

$ ldd ~/.cabal/bin/<progname>
	linux-vdso.so.1 (0x00007ffc2934b000)
	libgmp.so.10 => /lib64/libgmp.so.10 (0x00007f1d49003000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f1d48e26000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f1d48d46000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f1d490cd000)

Expected behavior

$ ldd ~/.cabal/bin/<progname>
	linux-vdso.so.1 (0x00007ffe02fde000)
	libHSbase-4.16.4.0-ghc9.2.7.so => ~/.ghcup/ghc/9.2.7/lib/ghc-9.2.7/base-4.16.4.0/libHSbase-4.16.4.0-ghc9.2.7.so (0x00007f440b000000)
	libHSghc-bignum-1.2-ghc9.2.7.so => ~/.ghcup/ghc/9.2.7/lib/ghc-9.2.7/ghc-bignum-1.2/libHSghc-bignum-1.2-ghc9.2.7.so (0x00007f440baa4000)
	libHSghc-prim-0.8.0-ghc9.2.7.so => ~/.ghcup/ghc/9.2.7/lib/ghc-9.2.7/ghc-prim-0.8.0/libHSghc-prim-0.8.0-ghc9.2.7.so (0x00007f440aa00000)
	libHSrts-ghc9.2.7.so => ~/.ghcup/ghc/9.2.7/lib/ghc-9.2.7/rts/libHSrts-ghc9.2.7.so (0x00007f440af6e000)
	libffi.so.7 => ~/.ghcup/ghc/9.2.7/lib/ghc-9.2.7/rts/libffi.so.7 (0x00007f440a600000)
	libgmp.so.10 => /lib64/libgmp.so.10 (0x00007f440a95b000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f440a423000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f440a87b000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f440ba7a000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f440ba75000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f440ba6e000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f440baf9000)

System information

  • Operating system: Fedora Linux 37 (Workstation Edition) 6.2.10-200.fc37.x86_64
  • $ cabal --version
    cabal-install version 3.6.2.0
    compiled using version 3.6.2.0 of the Cabal library
    
    $ ghc --version
    The Glorious Glasgow Haskell Compilation System, version 9.2.7
    

Additional information

I can get around the problem by putting ghc-options: -dynamic in the package.cabal file, but I don't think it's the appropriate solution.

@Mikolaj
Copy link
Member

Mikolaj commented Apr 19, 2023

I remember diagnosing this or a similar issue in the past. There should be a ticket with cabal install in it. This looked not implemented and not that hard to implement, so volunteers are kindly welcome.

@ulysses4ever
Copy link
Collaborator

The closest I'm able to find are:

But they're not exactly the same: they talk about static rather than dynamic... (and in one instance about build rather than install).

@alt-romes alt-romes self-assigned this Jan 8, 2024
@alt-romes
Copy link
Collaborator

This is another instance of #7297. The --enable-executable-dynamic is simply not considered when building the sdist.
cabal build --enable-executable-dynamic works as expected.

alt-romes added a commit to alt-romes/cabal that referenced this issue Jan 8, 2024
Currently, there are three kinds of cabal configurations considered when
determining an option of an `ElaboratedConfiguredPackage`:

* Global configuration, in `.cabal/config`

* Local configuration, in
    - Options passed in the cabal invocation, e.g. `cabal build --enable-executable-dynamic`
    - Fields in the top level `cabal.project`, or `cabal.project.local`, e.g. `extra-include-dirs: /opt/homebrew/include`

    Note thus that top-level cabal.project flags and cli flags are
    treated all together at the same level (`local`).

* Per package configuration, as in

    package HsOpenSSL
      extra-include-dirs: /opt/homebrew/Cellar/openssl@3/3.2.0_1/include
      extra-lib-dirs: /opt/homebrew/Cellar/openssl@3/3.2.0_1/lib

Then, we have a definition for whether a package is local to the
project. The local packages are the packages listed in the project which
have a specific source package, rather than just being listed by name in
a `source-repository-stanza`, or in a `package <package-name>` stanza
that configures installed packages.

In this patch, we try fix the mistmatch between the `local` flags and the
packages which are deemed `local`, and define a specification for what
exactly should happen..... TODO

Fixes haskell#7297, haskell#8909, haskell#2997
alt-romes added a commit to alt-romes/cabal that referenced this issue Feb 1, 2024
Currently, there are three kinds of cabal configurations considered when
determining an option of an `ElaboratedConfiguredPackage`:

* Global configuration, in `.cabal/config`

* Local configuration, in
    - Options passed in the cabal invocation, e.g. `cabal build --enable-executable-dynamic`
    - Fields in the top level `cabal.project`, or `cabal.project.local`, e.g. `extra-include-dirs: /opt/homebrew/include`

    Note thus that top-level cabal.project flags and cli flags are
    treated all together at the same level (`local`).

* Per package configuration, as in

    package HsOpenSSL
      extra-include-dirs: /opt/homebrew/Cellar/openssl@3/3.2.0_1/include
      extra-lib-dirs: /opt/homebrew/Cellar/openssl@3/3.2.0_1/lib

Then, we have a definition for whether a package is local to the
project. The local packages are the packages listed in the project which
have a specific source package, rather than just being listed by name in
a `source-repository-stanza`, or in a `package <package-name>` stanza
that configures installed packages.

The reason why local packages being installed are treated as non-local
is that TODO

In this patch, we try fix the mistmatch between the `local` flags and the
packages which are deemed `local`, and define a specification for what
exactly should happen..... TODO

Fixes haskell#7297, haskell#8909, haskell#2997
@alt-romes
Copy link
Collaborator

Fix in #9697.

alt-romes added a commit to alt-romes/cabal that referenced this issue Feb 5, 2024
The target of `cabal install` is not considered to be a local package,
which means local configuration (e.g. in cabal.project, or flags like
--enable-profiling) does not apply to it.

In 76670eb, we changed the behaviour to
applying the local flags to cabal install targets, but it used the
literal target string as a package name to which the flags were
additionally applied.

However, `cabal install` targets are NOT necessarily package names, so,
e.g., if we did `cabal install exe:mycomp`, the local flags would not
apply since "exe:mycomp" is not a recognized /package/.

The solution is to parse the target selectors first, and apply the local
flags to the package of the resolved targets.

Fixes haskell#7297 haskell#8909 and the install part of haskell#7236
alt-romes added a commit to alt-romes/cabal that referenced this issue Feb 6, 2024
The target of `cabal install` is not considered to be a local package,
which means local configuration (e.g. in cabal.project, or flags like
--enable-profiling) does not apply to it.

In 76670eb, we changed the behaviour to
applying the local flags to cabal install targets, but it used the
literal target string as a package name to which the flags were
additionally applied.

However, `cabal install` targets are NOT necessarily package names, so,
e.g., if we did `cabal install exe:mycomp`, the local flags would not
apply since "exe:mycomp" is not a recognized /package/.

The solution is to parse the target selectors first, and apply the local
flags to the package of the resolved targets.

Fixes haskell#7297 haskell#8909 and the install part of haskell#7236
alt-romes added a commit to alt-romes/cabal that referenced this issue Feb 6, 2024
The target of `cabal install` is not considered to be a local package,
which means local configuration (e.g. in cabal.project, or flags like
--enable-profiling) does not apply to it.

In 76670eb, we changed the behaviour to
applying the local flags to cabal install targets, but it used the
literal target string as a package name to which the flags were
additionally applied.

However, `cabal install` targets are NOT necessarily package names, so,
e.g., if we did `cabal install exe:mycomp`, the local flags would not
apply since "exe:mycomp" is not a recognized /package/.

The solution is to parse the target selectors first, and apply the local
flags to the package of the resolved targets.

Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
alt-romes added a commit to alt-romes/cabal that referenced this issue Feb 6, 2024
The target of `cabal install` is not considered to be a local package,
which means local configuration (e.g. in cabal.project, or flags like
--enable-profiling) does not apply to it.

In 76670eb, we changed the behaviour to
applying the local flags to cabal install targets, but it used the
literal target string as a package name to which the flags were
additionally applied.

However, `cabal install` targets are NOT necessarily package names, so,
e.g., if we did `cabal install exe:mycomp`, the local flags would not
apply since "exe:mycomp" is not a recognized /package/.

The solution is to parse the target selectors first, and apply the local
flags to the package of the resolved targets.

Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
mpickering pushed a commit to alt-romes/cabal that referenced this issue Feb 6, 2024
The target of `cabal install` is not considered to be a local package,
which means local configuration (e.g. in cabal.project, or flags like
--enable-profiling) does not apply to it.

In 76670eb, we changed the behaviour to
applying the local flags to cabal install targets, but it used the
literal target string as a package name to which the flags were
additionally applied.

However, `cabal install` targets are NOT necessarily package names, so,
e.g., if we did `cabal install exe:mycomp`, the local flags would not
apply since "exe:mycomp" is not a recognized /package/.

The solution is to parse the target selectors first, and apply the local
flags to the package of the resolved targets.

Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
Mikolaj pushed a commit to alt-romes/cabal that referenced this issue Feb 9, 2024
The target of `cabal install` is not considered to be a local package,
which means local configuration (e.g. in cabal.project, or flags like
--enable-profiling) does not apply to it.

In 76670eb, we changed the behaviour to
applying the local flags to cabal install targets, but it used the
literal target string as a package name to which the flags were
additionally applied.

However, `cabal install` targets are NOT necessarily package names, so,
e.g., if we did `cabal install exe:mycomp`, the local flags would not
apply since "exe:mycomp" is not a recognized /package/.

The solution is to parse the target selectors first, and apply the local
flags to the package of the resolved targets.

Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
alt-romes added a commit to alt-romes/cabal that referenced this issue Feb 9, 2024
The target of `cabal install` is not considered to be a local package,
which means local configuration (e.g. in cabal.project, or flags like
--enable-profiling) does not apply to it.

In 76670eb, we changed the behaviour to
applying the local flags to cabal install targets, but it used the
literal target string as a package name to which the flags were
additionally applied.

However, `cabal install` targets are NOT necessarily package names, so,
e.g., if we did `cabal install exe:mycomp`, the local flags would not
apply since "exe:mycomp" is not a recognized /package/.

The solution is to parse the target selectors first, and apply the local
flags to the package of the resolved targets.

Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
alt-romes added a commit to alt-romes/cabal that referenced this issue Feb 9, 2024
The target of `cabal install` is not considered to be a local package,
which means local configuration (e.g. in cabal.project, or flags like
--enable-profiling) does not apply to it.

In 76670eb, we changed the behaviour to
applying the local flags to cabal install targets, but it used the
literal target string as a package name to which the flags were
additionally applied.

However, `cabal install` targets are NOT necessarily package names, so,
e.g., if we did `cabal install exe:mycomp`, the local flags would not
apply since "exe:mycomp" is not a recognized /package/.

The solution is to parse the target selectors first, and apply the local
flags to the package of the resolved targets.

Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
@alt-romes
Copy link
Collaborator

Fixed by #9697

erikd pushed a commit to erikd/cabal that referenced this issue Apr 22, 2024
The target of `cabal install` is not considered to be a local package,
which means local configuration (e.g. in cabal.project, or flags like
--enable-profiling) does not apply to it.

In 76670eb, we changed the behaviour to
applying the local flags to cabal install targets, but it used the
literal target string as a package name to which the flags were
additionally applied.

However, `cabal install` targets are NOT necessarily package names, so,
e.g., if we did `cabal install exe:mycomp`, the local flags would not
apply since "exe:mycomp" is not a recognized /package/.

The solution is to parse the target selectors first, and apply the local
flags to the package of the resolved targets.

Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
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