Ticket #4115 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

hsc2hs puts linker flags before object file, causes linker errors

Reported by: guest Owned by:
Priority: high Milestone: 7.0.1
Component: hsc2hs Version: 6.10.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Other Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I'm trying to write a Haskell wrapper for a C library (called unibilium) using hsc2hs. In one of my files I have custom macros that reference functions from the C library (and #include "unibilium.h").

When I run hsc2hs -I.. foo.hsc, I get linker errors for those functions, as expected. However:

% hsc2hs -I.. foo.hsc -L-L.. -L-lunibilium
foo_hsc_make.o: In function `main':
foo_hsc_make.c:(.text+0x1a0): undefined reference to `unibi_name_bool'
foo_hsc_make.c:(.text+0x23b): undefined reference to `unibi_name_bool'
collect2: ld returned 1 exit status
linking foo_hsc_make.o failed
command was: gcc -L.. -lunibilium foo_hsc_make.o -o foo_hsc_make

Same error. This is because hsc2hs calls gcc with the -l option before the filename, at which point there are no unresolved references, so the library is simply discarded.

hsc2hs should leave my linker options where I put them, at the end of the command line.

Attachments

linker-flag-order.dpatch Download (2.4 KB) - added by duncan 3 years ago.
patch to put the linker flags at the end of the command line

Change History

Changed 3 years ago by duncan

patch to put the linker flags at the end of the command line

Changed 3 years ago by duncan

Patch needs testing.

Changed 3 years ago by igloo

  • status changed from new to patch

Changed 3 years ago by igloo

  • priority changed from normal to high
  • milestone set to 6.14.1

Changed 3 years ago by igloo

  • status changed from patch to closed
  • resolution set to fixed

Applied, thanks

Note: See TracTickets for help on using tickets.