Ticket #2305 (closed feature request: wontfix)
GHC does not care __RENAME macro
| Reported by: | iquiw | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.10.1 |
| Component: | Compiler (FFI) | Version: | 6.8.2 |
| Keywords: | Cc: | donn@… | |
| Operating System: | NetBSD | Architecture: | Unknown/Multiple |
| Type of failure: | Difficulty: | Unknown | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
Problem
GHC+FFI does not use correct symbol if __RENAME macro is used.
Background
NetBSD uses __RENAME macro to solve compatibility issue of different versioned shared library.
For example, the following line is in /usr/include/locale.h.
char *setlocale(int, const char *) __RENAME(__setlocale_mb_len_max_32);
If setlocale() is called from C source that includes "locale.h", then it is linked to symbol __setlocale_mb_len_max_32 after compiled.
GHC (-fasm) does not do this.
If GHC option -fvia-C is specified, then correct symbol is used
Example
__RENAME(foo) is actually expanded as __asm("foo"). So the following codes simulate the problem.
rename.h
int foo() __asm("bar");
rename.c
int foo() { return 1; }
int bar() { return 2; }
main.hs
foreign import ccall unsafe "rename.h" foo :: IO Int main = foo >>= print
(1) -fvia-C(OK)
$ ghc -fvia-C -ffi main.hs rename.c && ./a.out 2
(2) -fasm (OK)
$ ghc -fasm -ffi main.hs rename.c && ./a.out 1
Change History
Note: See
TracTickets for help on using
tickets.
