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 does not respect ghc-options for -pgmc, -pgml etc #4439

Closed
nh2 opened this issue Apr 7, 2017 · 8 comments
Closed

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

nh2 opened this issue Apr 7, 2017 · 8 comments

Comments

@nh2
Copy link
Member

nh2 commented Apr 7, 2017

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
@jberryman
Copy link

Linking back to the context/motivation: https://github.com/nh2/link-with-lld-example

@ezyang
Copy link
Contributor

ezyang commented May 7, 2017

@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.

@ezyang ezyang added this to the 2.2 milestone May 7, 2017
syntheorem added a commit to syntheorem/cabal that referenced this issue Jul 17, 2018
This fix allows users to override the C/C++ compiler, either by passing
--with-gcc to configure or adding -pgmc to ghc-options in their Cabal
file.

Tested manually with a project using C++ sources that require a more
recent version of clang than the default install (macOS). Inspected the
output of `Setup.hs build -v` to confirm that the correct arguments are
being passed to GHC when compiling the C++ sources.

Resolves: haskell#4439
syntheorem added a commit to syntheorem/cabal that referenced this issue Jul 17, 2018
This fix allows users to override the C/C++ compiler, either by passing
--with-gcc to configure or adding -pgmc to ghc-options in their Cabal
file.

Tested manually with a project using C++ sources that require a more
recent version of clang than the default install (macOS). Inspected the
output of `Setup.hs build -v` to confirm that the correct arguments are
being passed to GHC when compiling the C++ sources.

Resolves: haskell#4439
@23Skidoo 23Skidoo modified the milestones: 2.2, 2.4 Aug 29, 2018
@23Skidoo 23Skidoo modified the milestones: 2.4, 2.4.1 Sep 17, 2018
@23Skidoo 23Skidoo modified the milestones: 2.4.1.0, 2.4.2.0 Apr 26, 2019
@phadej phadej modified the milestones: 2.4.2.0, 3.4 Nov 27, 2019
@nh2
Copy link
Member Author

nh2 commented Feb 12, 2020

@nh2 If you want to attempt solving this ticket, I'd be happy to advise

@ezyang Would you mind taking a look at #5440? It's been sitting there for 1.5 years already.

jberryman pushed a commit to jberryman/cabal that referenced this issue Dec 21, 2021
This fix allows users to override the C/C++ compiler, either by passing
--with-gcc to configure or adding -pgmc to ghc-options in their Cabal
file.

Tested manually with a project using C++ sources that require a more
recent version of clang than the default install (macOS). Inspected the
output of `Setup.hs build -v` to confirm that the correct arguments are
being passed to GHC when compiling the C++ sources.

Resolves: haskell#4439
@Mikolaj
Copy link
Member

Mikolaj commented Dec 22, 2021

Hi! Heads up about #7874, which is a PR solving this ticket that @jberryman has kindly just rebased and we are desperate to merge before it bitrots.

We need to add a small test for that or at least test the branch on the examples you have. Help!

@Mikolaj
Copy link
Member

Mikolaj commented Jan 11, 2022

Please kindly also have a look (and review) at #7900, which provides a test and discusses its result. Last chance to provide feedback before we merge. Thank you!

@mergify mergify bot closed this as completed in 25aa866 Jan 12, 2022
@Mikolaj
Copy link
Member

Mikolaj commented Jan 12, 2022

@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.

@andreasabel
Copy link
Member

@gbaz
Copy link
Collaborator

gbaz commented Jun 8, 2023

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants