Uploaded image for project: 'Swift'
  1. Swift
  2. SR-5524

Importing a modulemapped C library in REPL throws an error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: LLDB for Swift
    • Labels:
    • Environment:

      Ubuntu Linux 16.04 LTS, Swift 3.1.1, Swift 4.0.0-dev

      Description

      A Swift package of type system-module throws an error when trying to import in REPL.

      Swift 3.1.1

      swift -I ./Clibssh -L /usr/lib/x86_64-linux-gnu
      Welcome to Swift version 3.1.1 (swift-3.1.1-RELEASE). Type :help for assistance.
        1> import Clibssh 
      error: repl.swift:1:8: error: could not build Objective-C module 'Clibssh'
      import Clibssh
             ^
      

      Swift 4.0.0-dev

      swift -I ./Clibssh -L /usr/lib/x86_64-linux-gnu
      Welcome to Swift version 4.0-dev (LLVM a15decabe3, Clang ae62debbb4, Swift 823d7e27bf). Type :help for assistance.
        1> import Clibssh 
      error: repl.swift:1:8: error: could not build C module 'Clibssh'
      import Clibssh
             ^
      

      Module definition for Clibssh

      The following sources were used to produce the system module for using libssh.so in Swift.

      Package definition for the module
      Package.swift
      import PackageDescription
      
      let package = Package(
          name: "Clibssh",
          pkgConfig: "libssh"
      )
      
      Module map definition
      module.modulemap
      module Clibssh [system] {
        header "/usr/include/libssh/libssh.h"
        link "ssh"
        export *
      }
      

      Note 1: Importing the module in Swift 3.0.1 REPL works fine.
      Note 2: Building an executable file with this module definition works flawlessly in Swift 3.1.1 and Swift 4.0.0

      I'm linking this issue to SR-3794, SR-3648 and SR-2783 as it seems there are some similarities.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              MatiMax Matthias M. Schneider
              Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated: