Skip to content

Cabal v2.2 c-sources fails to link when .c file happens to have the same base name as a .hs file #5960

Open

Description

@moll

Hey,

I stumbled upon a weird issue. The capitalization of a .c file specified in c-sources affects whether its symbols get linked to the resulting executable. Has anyone seen anything like this?

Here's a test-case that reproduces this at least on my Arch Linux setup with GHC 8.4.3 and Cabal v2.2: https://github.com/moll/examples-haskell-csource/

Linking dist/build/csource/csource ...
/usr/bin/ld.gold: error: cannot find -lHScsource-0.1.337-7OQ5RPKzFZVCSEfeTtlOSq
dist/build/csource/csource-tmp/Main.o:Main_main2_info: error: undefined reference to 'foo'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

Rename the Csource.c file to csource.c and it links and runs fine.

Cheers

Activity

  1. moll commented on Mar 24, 2019

    @moll
    Author

    Jumped the gun a little. I think this is caused by the C file having the same name as a .hs file instead. Breaking at linking like this can't be a good failure mode...

  2. changed the title [-]Cabal v2.2 c-sources undefined symbol when .c file capitalized [/-] [+]Cabal v2.2 c-sources fails to link when .c file happens to have the same base name as a .hs file[/+] on Mar 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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