Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,248
    • Issues 4,248
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 391
    • Merge Requests 391
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9351

Closed
Open
Opened Jul 23, 2014 by Sergei Trofimovich@trofiReporter

add ability to version symbols .c for packages with C code

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.

Trac metadata
Trac field Value
Version 7.8.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#9351