[GHC] #9351: add ability to version symbols .c for packages with C code
GHC
ghc-devs at haskell.org
Wed Jul 23 16:06:46 UTC 2014
#9351: add ability to version symbols .c for packages with C code
-------------------------------------+-------------------------------------
Reporter: slyfox | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.3
Keywords: backpack | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Unknown | Type of failure:
Blocked By: | None/Unknown
Related Tickets: | Test Case:
| Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Let's consider an example:
We have a haskell package with some C code imported in
haskell:
{{{
// a.h file
int get_something(void);
// a.c file
#include "a.h"
int get_something(void) { return 42; }
// M.hs file
module M where
foreign import ccall "a.h get_something" :: IO Int
}}}
The problem here is we can't mix that package with other
packages having global 'get_something' symbol.
Sometimes it happens when a package copies part of
implementation from another package with .c bits under different
haskell namespace. Haskell parts would coexist freely, but
not C symbols.
Would be great if ghc would export some unique
package identifier in a way C code could attach
it to all exported symbols making linking possible.
Something like that:
{{{
// a.h file
#include "HsFFI.h" /* #define FOR_HASKELL(__sym) package_id_##__sym */
int FOR_HASKELL(get_something)(void);
// a.c file
#include "a.h"
int FOR_HASKELL(get_something)(void) { return 42; }
// M.hs file
module M where
foreign import ccall-for-haskell "a.h get_something" :: IO Int
}}}
That way we explicitly mark symbol as inaccessible to
external plain C code.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9351>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list