Hi all,

I have a function

ft :: CMode -> FileType
ft i = toEnum (fromIntegral i)

which is used to marshal a function defined with c2hs, viz.

{# fun archive_entry_filetype as ^ { `ArchiveEntryPtr' } -> `FileType' ft #}

This all works fine under GHC 8.8.1-GHC-8.2.2. When I try to compile the test suite with GHC 8.0.2 I get

Linking /home/vanessa/programming/haskell/done/libarchive/dist-newstyle/build/x86_64-linux/ghc-8.0.2/libarchive-2.0.0.0/t/libarchive-test/build/libarchive-test/libarchive-test ...
/usr/bin/ld: /home/vanessa/programming/haskell/done/libarchive/dist-newstyle/build/x86_64-linux/ghc-8.0.2/libarchive-2.0.0.0/build/libHSlibarchive-2.0.0.0-inplace.a(ArchiveEntry.o): in function `rg6i_info':
(.text+0x9cd6): undefined reference to `archive_entry_acl_next_w'
/usr/bin/ld: /home/vanessa/programming/haskell/done/libarchive/dist-newstyle/build/x86_64-linux/ghc-8.0.2/libarchive-2.0.0.0/build/libHSlibarchive-2.0.0.0-inplace.a(ArchiveEntry.o): in function `cjVN_info':
(.text+0x128c6): undefined reference to `archive_entry_acl_next_w'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

When I define the marshaling function with

ft :: CMode -> FileType
ft 0 = error "here"
ft i = toEnum (fromIntegral i)

I can no longer compile the test suite; it fails with a linker error, even with GHC 8.8.1-GHC-8.2.2. I get

Linking /home/vanessa/programming/haskell/done/libarchive/dist-newstyle/build/x86_64-linux/ghc-8.8.1/libarchive-2.0.0.0/t/libarchive-test/build/libarchive-test/libarchive-test ...
/home/vanessa/programming/haskell/done/libarchive/dist-newstyle/build/x86_64-linux/ghc-8.8.1/libarchive-2.0.0.0/build/libHSlibarchive-2.0.0.0-inplace.a(ArchiveEntry.o)(.text+0x9d86): error: undefined reference to 'archive_entry_acl_next_w'
/home/vanessa/programming/haskell/done/libarchive/dist-newstyle/build/x86_64-linux/ghc-8.8.1/libarchive-2.0.0.0/build/libHSlibarchive-2.0.0.0-inplace.a(ArchiveEntry.o):function libarchivezm2zi0zi0zi0zminplace_CodecziArchiveziForeignziArchiveEntry_zdwarchiveEntryAclNextW_info: error: undefined reference to 'archive_entry_acl_next_w'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

You can have a look at some of some of the code in this branch here:

https://github.com/vmchale/libarchive/blob/ghc-potential-bug/src/Codec/Archive/Foreign/ArchiveEntry.chs#L27

and here:

https://github.com/vmchale/libarchive/blob/ghc-potential-bug/src/Codec/Archive/Foreign/ArchiveEntry.hs#L57

Cheers,
Vanessa McHale