FFI: exporting the same thing multiple times fails: error: redefinition of ‘stginit_export_ShouldCompile_zdfdiv’
If we foreign export the same thing multiple times, e.g.:
foreign export ccall "addByte" (+) :: Int8 -> Int8 -> Int8
foreign export ccall "addInt" (+) :: Int16 -> Int16 -> Int16
foreign export ccall "addLong" (+) :: Int32 -> Int32 -> Int32
then compilation fails due to redefinition of stginit_export_ShouldCompile_zdfzp. In the _stub.c we generate
static void stginit_export_ShouldCompile_zdfzp() __attribute__((constructor));
static void stginit_export_ShouldCompile_zdfzp()
{getStablePtr((StgPtr) &ShouldCompile_zdfzp_closure);}
n times.
It looks like the fix is simply to only generate it once; we just need to rejig the code so that that happens.
Test is cc013.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.6.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Compiler (FFI) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |