Skip to content

3.18 Regression: -framework flags shouldn't be deduplicated #12555

Open

Description

@kztk-m

Describe the bug

Building with cabal 3.18.2.0 fails when compiling an .hsc file when more than one framework is specified in frameworks, which has no issue with cabal 3.16.1.0. The actual package causing the issue is bindings-GLFW-3.3.9.3, which is required, for example, by brillo and gloss (when GLFW flag is on). Here is an extract of the error message.

linking dist/build/Bindings/GLFW_hsc_make.o failed (exit code 1)
rsp file was: "dist/build/Bindings/hsc2hscall87248-2.rsp"
command was: /usr/bin/gcc dist/build/Bindings/GLFW_hsc_make.o dist/build/Bindings/GLFW_hsc_utils.o -o dist/build/Bindings/GLFW_hsc_make --target=arm64-apple-darwin -Wl,-no_fixup_chains -Wl,-no_warn_duplicate_libraries --target=arm64-apple-darwin -Wl,-no_fixup_chains -Wl,-no_warn_duplicate_libraries -framework Cocoa OpenGL IOKit CoreFoundation CoreVideo -L/Users/kztk/.cabal/store/ghc-9.6.7/bndngs-DSL-1.0.25-6a74f003/lib -L/Users/kztk/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/aarch64-osx-ghc-9.6.7/base-4.18.3.0 -liconv -L/Users/kztk/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/aarch64-osx-ghc-9.6.7/ghc-bignum-1.3 -L/Users/kztk/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/aarch64-osx-ghc-9.6.7/ghc-prim-0.10.0 -L/Users/kztk/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/aarch64-osx-ghc-9.6.7/rts-1.0.2 -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lm -ldl -lffi
error: clang: error: no such file or directory: 'OpenGL'
clang: error: no such file or directory: 'IOKit'
clang: error: no such file or directory: 'CoreFoundation'
clang: error: no such file or directory: 'CoreVideo'

A suspicious part is -framework Cocoa OpenGL IOKit CoreFoundation CoreVideo.

To Reproduce

As mentioned above, one can reproduce the issue by building bindings-GLFW-3.3.9.3 with cabal-3.18.2.0 on macOS.

The following is a minimal working example to reproduce the issue more easily. Suppose that we have the following files Foo.hsc and hsc-frameworks-mwe.cabal in a certain directory.

module Foo (bar) where

bar = ()
cabal-version: 2.2
name:          hsc-frameworks-mwe
version:       0.1.0.0
build-type:    Simple

library
  exposed-modules:  Foo
  hs-source-dirs:   .
  build-depends:    base
  default-language: Haskell2010
  frameworks:       Foundation CoreFoundation 

Then, building the package will fail with cabal-3.18.2.0.

$ cabal build 
Resolving dependencies...
Build profile: -w ghc-9.6.7 -O1
In order, the following will be built (use -v for more details):
 - hsc-frameworks-mwe-0.1.0.0 (lib) (first run)
Configuring library for hsc-frameworks-mwe-0.1.0.0...
Preprocessing library for hsc-frameworks-mwe-0.1.0.0...
linking dist-newstyle/build/aarch64-osx/ghc-9.6.7/hsc-frameworks-mwe-0.1.0.0/build/Foo_hsc_make.o failed (exit code 1)
rsp file was: "dist-newstyle/build/aarch64-osx/ghc-9.6.7/hsc-frameworks-mwe-0.1.0.0/build/hsc2hscall83144-2.rsp"
command was: /usr/bin/gcc dist-newstyle/build/aarch64-osx/ghc-9.6.7/hsc-frameworks-mwe-0.1.0.0/build/Foo_hsc_make.o dist-newstyle/build/aarch64-osx/ghc-9.6.7/hsc-frameworks-mwe-0.1.0.0/build/Foo_hsc_utils.o -o dist-newstyle/build/aarch64-osx/ghc-9.6.7/hsc-frameworks-mwe-0.1.0.0/build/Foo_hsc_make --target=arm64-apple-darwin -Wl,-no_fixup_chains -Wl,-no_warn_duplicate_libraries --target=arm64-apple-darwin -Wl,-no_fixup_chains -Wl,-no_warn_duplicate_libraries -framework Foundation CoreFoundation -L/Users/kztk/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/aarch64-osx-ghc-9.6.7/base-4.18.3.0 -liconv -L/Users/kztk/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/aarch64-osx-ghc-9.6.7/ghc-bignum-1.3 -L/Users/kztk/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/aarch64-osx-ghc-9.6.7/ghc-prim-0.10.0 -L/Users/kztk/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/aarch64-osx-ghc-9.6.7/rts-1.0.2 -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lm -ldl -lffi
error: clang: error: no such file or directory: 'CoreFoundation'

Error: [Cabal-7125]
Failed to build hsc-frameworks-mwe-0.1.0.0.

Expected behavior

cabal build succeeds as it does with cabal-3.16.1.0. For example, when we run

$ ghcup set cabal 3.16.1.0
$ cabal clean
$ cabal build

the build succeeds.

System information

  • Operating system: macOS 27
  • cabal, ghc versions: cabal-3.18.2.0 and ghc-9.6.7.

Additional context

Since I am not familiar with Haskell FFI, I used Claude to make the minimal working example. However, all the reported behavior in this issue has been confirmed by me.

I am not fully confident, but this behavior may be related to #11005.

Activity

  1. changed the title [-]3.18 Regression: frameworks shouldn't be deduplicated[/-] [+]3.18 Regression: `-framework` flags shouldn't be deduplicated[/+] on Nov 9, 2026
  2. kztk-m commented on Nov 9, 2026

    @kztk-m
    Author

    I have edited the title and body; I accidentally submitted the issue before proofreading it. Sorry for any confusion.

  3. ffaf1 commented on Nov 9, 2026

    @ffaf1
    Collaborator

    Thanks for the report, do you happen to know whether 3.18.1.0 is affected too?

  4. kztk-m commented on Nov 9, 2026

    @kztk-m
    Author

    Yes, I have now confirmed that the same issue happens with 3.18.1.0.

  5. ffaf1 commented on Nov 9, 2026

    @ffaf1
    Collaborator

    Works on linux and indeed #11005 contains some framework/OSX specific stuff.

    https://github.com/haskell/cabal/pull/11005/changes#diff-7bf52f59066d048286852f159107d4da28d30bb997310f2480bed80a5e9150b8R613-R618

    I could not bisect as I run Linux.

    @sergv can you shed some light?

  6. sergv commented on Nov 14, 2026

    @sergv
    Collaborator

    Yes, this is the effect of my PR, the -framework arguments gets deduplicated. The command line should be -framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo instead of -framework Cocoa OpenGL IOKit CoreFoundation CoreVideo.

  7. sergv commented on Nov 15, 2026

    @sergv
    Collaborator

    Should be fixed in #12598, please give it a test if you will. I've tested on bindings-GLFW and it works now with master cabal.

  8. ffaf1 commented on Nov 15, 2026

    @ffaf1
    Collaborator

    Thanks for the work. Does anyone happen to know whether there is a workaround for this?

    If there is not, this seems quite an important regression.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions