Skip to content

Hack to include cabal_macros.h causes build failure with stack / GHC 9.10 #92

@andreasabel

Description

@andreasabel

/* A dirty hack to work around for broken versions of Cabal:
* https://github.com/phonohawk/HsOpenSSL/issues/8
*
* The trick is to abuse the fact that -Icbits is (almost) always
* passed to hsc2hs so we can reach the cabal_macros.h from cbits, but
* see #23, #24 and #25...
*/
#if !defined(MIN_VERSION_base) && \
!defined(HSOPENSSL_NEED_NOT_INCLUDE_CABAL_MACROS_H)
# include "../dist/build/autogen/cabal_macros.h"
#endif

HsOpenSSL                        > Building library for HsOpenSSL-0.11.7.7...
HsOpenSSL                        > [ 1 of 33] Compiling OpenSSL
HsOpenSSL                        > /private/var/folders/lg/qcd3v89j59l3m6520kr42bdm0000gn/T/stack-88a7366d6a42ff03/HsOpenSSL-0.11.7.7/In file included from /var/folders/lg/qcd3v89j59l3m6520kr42bdm0000gn/T/ghc51255_0/ghc_22.c:7:0: error:
HsOpenSSL                        > [ 2 of 33] Compiling OpenSSL.DH.Internal
HsOpenSSL                        >                 
HsOpenSSL                        >                 
HsOpenSSL                        > /private/var/folders/lg/qcd3v89j59l3m6520kr42bdm0000gn/T/stack-88a7366d6a42ff03/HsOpenSSL-0.11.7.7/cbits/HsOpenSSL.h:32:12: error:
HsOpenSSL                        >      fatal error: '../dist/build/autogen/cabal_macros.h' file not found
HsOpenSSL                        >    |            
HsOpenSSL                        > 32 | #  include "../dist/build/autogen/cabal_macros.h"
HsOpenSSL                        >    |            ^
HsOpenSSL                        >                 
HsOpenSSL                        > #  include "../dist/build/autogen/cabal_macros.h"
HsOpenSSL                        >            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HsOpenSSL                        > 1 error generated.
HsOpenSSL                        > <no location info>: error:
HsOpenSSL                        >     `gcc' failed in phase `C Compiler'. (Exit code: 1)
HsOpenSSL                        >               

This happens when I build a project with stack that uses HsOpenSSL (does not happen when I do stack build in the HsOpenSSL project).
I am on macOS (Monterey).
The problem is not limited to macOS, though https://github.com/hackage-trustees/hackage-cli/actions/runs/9759798062/job/26937247345:

Not sure what the reason is that the hack no longer works with GHC 9.10. Maybe a change in the Cabal library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions