GHC does not care __RENAME macro
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.[[BR]] 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
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.8.2 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (FFI) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | Unknown |