Skip to content

cabal does not respect ghc-options for -pgmc, -pgml etc #4439

Closed

Description

@nh2

In this place

               hPutStrLn testchnd "int foo() { return 0; }"
               hClose testchnd; hClose testohnd
               runProgram verbosity ghcProg
                          [ "-hide-all-packages"
                          , "-c", testcfile
                          , "-o", testofile
                          ]

cabal calls ghc just like that, without respecting the C compiler and linker that the user has set in --ghc-options and --with-gcc/with-ld.

To reproduce, simply sudo mv /usr/bin/gcc /usr/bin/gcc.backup and try to run cabal configure --with-gcc=clang --with-ld=clang -v3. You will get:

("/home/niklas/bin/ghc",["-c","/tmp/1804289383846930886.c","-o","/tmp/16816927771714636915.o"])
ghc: could not execute: /usr/bin/gcc

In this instance, cabal ignored --with-gcc.

--

Next, make gcc available again (sudo mv /usr/bin/gcc.backup /usr/bin/gcc), complete the configure, then move gcc away again and try to compile a

library
  hs-source-dirs: src
  exposed-modules: Lib
  build-depends: base
  ghc-options: "-pgmP clang" "-pgmc clang" "-pgma clang" "-pgml clang"

You will get when Linking... the library:

("/home/niklas/bin/ghc",["-shared","-dynamic","-dynload deploy","-optl-Wl,-rpath,/raid/stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/base_HQfYBxpPvuw8OunzQu6JGM","-optl-Wl,-rpath,/raid/stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/rts","-optl-Wl,-rpath,/raid/stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/ghcpr_8TmvWUcS1U1IKHT0levwg3","-optl-Wl,-rpath,/raid/stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/integ_2aU3IZNMF9a7mQ0OzsZ0dS","-this-package-key","linkw_0jOmkDd3hz89pUUv8NIHkg","-no-auto-link-packages","-package-db","dist/package.conf.inplace","-package-id","base-4.8.2.0-0d6d1084fbc041e1cded9228e80e264d","dist/build/Lib.dyn_o","-o","dist/build/libHSlink-with-lld-example-1-0jOmkDd3hz89pUUv8NIHkg-ghc7.10.3.so"])
ghc: could not execute: /usr/bin/gcc

Activity

  1. ezyang commented on May 7, 2017

    @ezyang
    Contributor

    @nh2 If you want to attempt solving this ticket, I'd be happy to advise. I hope that this is as simple as going through the ProgramDb interface rather than doing it directly, but there may be other complications.

  2. added this to the 2.2 milestone on May 7, 2017
  3. added 2 commits that reference this issue on Jul 17, 2018
    afc623d
    1259167
  4. modified the milestones: 2.2, 2.4 on Aug 29, 2018
  5. modified the milestones: 2.4, 2.4.1 on Sep 17, 2018
  6. modified the milestones: 2.4.1.0, 2.4.2.0 on Apr 26, 2019
  7. 7 remaining items

  8. Mikolaj commented on Jan 12, 2022

    @Mikolaj
    Member

    @jberryman: thank you for #7900, which is now merged, which ends the saga! Please, everybody, test and reopen if anything doesn't work as expected.

  9. andreasabel commented on Mar 22, 2022

    @andreasabel
    Member
  10. gbaz commented on Jun 8, 2023

    @gbaz
    Collaborator

    reclosing. anything future with the upstream issue were are blocked in can be handled in the other ticket.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions