Skip to content

PackageInfo functionality is not guarded behind cabal-version. #9331

Closed
@phadej

Description

@phadej

Given a package with just foo.cabal:

cabal-version: 2.4
name: foo
version: 0
license: BSD-3-Clause
license-file: LICENSE
maintainer: Someone
category: Example
synopsis: Foo
description: FooBar
build-type: Simple

library
  default-language: Haskell2010
  build-depends: base <5
  autogen-modules: PackageInfo_foo
  exposed-modules: PackageInfo_foo

cabal-install-3.10.1.0 check doesn't complaint, and cabal build succeeds:

% ~/.ghcup/bin/cabal-3.10.1.0 check
No errors or warnings could be found in the package.

% ~/.ghcup/bin/cabal-3.10.1.0 build
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - foo-0 (lib) (configuration changed)
Configuring library for foo-0..
Preprocessing library for foo-0..
Building library for foo-0..
[1 of 1] Compiling PackageInfo_foo  ( ... )

However older cabal-installs, or if I change to build-type: Custom (and use say GHC-9.2.7) fails.

Older cabal-install (note, you need to clear dist-newstyle in between so autogenerated left-overs are removed):

% ~/.ghcup/bin/cabal-3.6.2.0 check 
No errors or warnings could be found in the package.

[polinukli] /codetmp/foo % ~/.ghcup/bin/cabal-3.6.2.0 build
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - foo-0 (lib) (first run)
Preprocessing library for foo-0..
cabal-3.6.2.0: can't find source for PackageInfo_foo in .,
/codetmp/foo/dist-newstyle/build/x86_64-linux/ghc-8.6.5/foo-0/build/autogen,
/codetmp/foo/dist-newstyle/build/x86_64-linux/ghc-8.6.5/foo-0/build/global-autogen

or with build-type: Custom:

% grep -A 4 build-type foo.cabal                
build-type: Custom

custom-setup
  setup-depends: base, Cabal

[polinukli] /codetmp/foo % ~/.ghcup/bin/cabal-3.10.1.0 build -w ghc-9.2.7
Build profile: -w ghc-9.2.7 -O1
In order, the following will be built (use -v for more details):
 - foo-0 (lib:foo) (cannot read state cache)
Configuring foo-0...
Preprocessing library for foo-0..
setup: can't find source for PackageInfo_foo in .,
/codetmp/foo/dist-newstyle/build/x86_64-linux/ghc-9.2.7/foo-0/build/autogen,
/codetmp/foo/dist-newstyle/build/x86_64-linux/ghc-9.2.7/foo-0/build/global-autogen

Error: cabal-3.10.1.0: Failed to build foo-0.

Features changing cabal_macros.h, Paths_pkgname.hs etc SHOULD be guarded behind cabal-version.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions