Skip to content

[SR-3794] import Glibc does not work from the swift 3.1-dev REPL #4642

Closed

Description

@swift-ci
Previous ID SR-3794
Radar None
Original Reporter Ronnquist (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Ubuntu 16.10
swift -v
Swift version 3.1-dev (LLVM 3e67f314a4, Clang 0540ceb7ad, Swift ca7046e)
Target: x86_64-unknown-linux-gnu
/home/peter/Documents/programs/swift/swift-DEVELOPMENT-SNAPSHOT-2017-01-04-a-ubuntu16.10/usr/bin/lldb "--repl=-disable-objc-interop -color-diagnostics"
Welcome to Swift version 3.1-dev (LLVM 3e67f314a4, Clang 0540ceb7ad, Swift ca7046e).

Additional Detail from JIRA
Votes 10
Component/s LLDB for Swift
Labels Bug, Linux, REPL
Assignee None
Priority Medium

md5: 68542641f5966ad72f7a08689e36c7b3

is duplicated by:

  • SR-3868 Unable to import Glibc, Foundation or Dispatch in REPL (linux)

relates to:

  • SR-3648 Unable to Import Foundation
  • SR-5524 Importing a modulemapped C library in REPL throws an error

Issue Description:

I get the following error when I try to import Glibc in the swift 3.1-dev REPL

peter@peter-UX305CA:~/Documents/dev/swift/measurement$ swift -v
Swift version 3.1-dev (LLVM 3e67f314a4, Clang 0540ceb7ad, Swift ca7046e)
Target: x86_64-unknown-linux-gnu
/home/peter/Documents/programs/swift/swift-DEVELOPMENT-SNAPSHOT-2017-01-04-a-ubuntu16.10/usr/bin/lldb "--repl=-disable-objc-interop -color-diagnostics"
Welcome to Swift version 3.1-dev (LLVM 3e67f314a4, Clang 0540ceb7ad, Swift ca7046e). Type :help for assistance.
1> import Glibc
<module-includes>:3:10: note: in file included from <module-includes>:3:
#include "///usr/include/utmp.h"
^

///usr/include/utmp.h:23:10: note: in file included from ///usr/include/utmp.h:23:
#include <sys/types.h>
^

error: /usr/include/x86_64-linux-gnu/sys/types.h:146:10: error: 'stddef.h' file not found
#include <stddef.h>
^

error: could not build Objective-C module 'SwiftGlibc'

1>

Activity

  1. belkadan commented on Jan 30, 2017

    @belkadan

    Does this also fail when trying to compile a file, or is it just the REPL?

  2. belkadan commented on Jan 30, 2017

    @belkadan

    (This failure usually means the clang/ folder inside Swift's resource dir—usually lib/swift/—is missing.)

  3. swift-ci commented on Jan 30, 2017

    @swift-ci
    Author

    Comment by Peter (JIRA)

    For me it works when I compile a file, but fails in the REPL.

  4. swift-ci commented on Jan 30, 2017

    @swift-ci
    Author

    Comment by Peter (JIRA)

    This was actually reported by Chris Double in December 2016:

    https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20161219/004206.html

    He wrote:

    ---------------~~~~8<~~~~----------------

    If I explicitly pass include paths to 'swift' it works in the REPL:

    ---------------~~~~8<~~~~----------------
    $ swift -I/home/user/swift-install/usr/lib/swift/clang/include/
    -I/home/user/swift-install/usr/include/lldb/Symbol/
    Welcome to Swift version 3.1-dev (LLVM 7d4a331ed3, Clang d8c33dc710,
    Swift 2ea7951). Type :help for assistance.
    1> import Glibc
    2> random()
    $R0: Int = 1804289383
    ---------------~~~~8<~~~~----------------

  5. belkadan commented on Jan 30, 2017

    @belkadan

    Okay, retagging as LLDB.

  6. gottesmm commented on Jan 31, 2017

    @gottesmm

    @belkadan Whatever we should do, we should see why the integration tests did not catch this. The integration tests before we send out the package is supposed to run something in the repl. Maybe it is running it in the old repl?

  7. belkadan commented on Feb 7, 2017

    @belkadan

    jingham@apple.com (JIRA User), who should be looking at this?

  8. swift-ci commented on Feb 19, 2017

    @swift-ci
    Author

    Comment by Hugh Bellamy (JIRA)

    I'n getting a similar error here: swiftlang/swift#7490

  9. ahti commented on Mar 16, 2017

    @ahti

    I'm experiencing a similar error with current master on Arch Linux. Importing Foundation or Dispatch fails unless I pass -I /usr/lib/swift/clang/include/ to swift. However, I can successfully import Glibc, even though from what I can see in the headers, that too imports stddef.h, so I am unsure why importing Glibc does not fail as well.

  10. swift-ci commented on Mar 31, 2017

    @swift-ci
    Author

    Comment by Peter (JIRA)

    I tried the newly released swift 3.1 and the problem is still present.

  11. swift-ci commented on Apr 3, 2017

    @swift-ci
    Author

    Comment by Timothy S Hawkins (JIRA)

    I am getting the same issue on Fedora 25, however i can move on by adding the symlink

    cd /usr/include
    sudo ln -s linux x86_64-linux-gnu

    However when I do that I subsequently get the following, This worked fine on swift-3.0.2-RELEASE tag, it only fails on swift-3.1-RELEASE

    [thawkins@timdev05 bin]$ ./swift
    Welcome to Swift version 3.1 (swift-3.1-RELEASE). Type :help for assistance.
    1> import Glibc
    <module-includes>:2:10: note: in file included from <module-includes>:2:
    #include "///usr/include/pty.h"
    ^

    ///usr/include/pty.h:28:10: note: in file included from ///usr/include/pty.h:28:
    #include <sys/ioctl.h>
    ^

    /usr/include/sys/ioctl.h:29:10: note: in file included from /usr/include/sys/ioctl.h:29:
    #include <bits/ioctl-types.h>
    ^

    error: /usr/include/bits/ioctl-types.h:27:8: error: redefinition of 'winsize'
    struct winsize
    ^

    /usr/include/asm-generic/termios.h:14:8: note: previous definition is here
    struct winsize {
    ^

    <module-includes>:2:10: note: in file included from <module-includes>:2:
    #include "///usr/include/pty.h"
    ^

    ///usr/include/pty.h:28:10: note: in file included from ///usr/include/pty.h:28:
    #include <sys/ioctl.h>
    ^

    /usr/include/sys/ioctl.h:29:10: note: in file included from /usr/include/sys/ioctl.h:29:
    #include <bits/ioctl-types.h>
    ^

    error: /usr/include/bits/ioctl-types.h:36:8: error: redefinition of 'termio'
    struct termio
    ^

    /usr/include/asm-generic/termios.h:22:8: note: previous definition is here
    struct termio {
    ^

    <module-includes>:3:10: note: in file included from <module-includes>:3:
    #include "///usr/include/utmp.h"
    ^

    ///usr/include/utmp.h:23:10: note: in file included from ///usr/include/utmp.h:23:
    #include <sys/types.h>
    ^

    /usr/include/sys/types.h:219:11: note: in file included from /usr/include/sys/types.h:219:

    1. include <sys/select.h>
      ^

    /usr/include/sys/select.h:47:10: note: in file included from /usr/include/sys/select.h:47:
    #include <bits/time.h>
    ^

    error: /usr/include/bits/time.h:30:8: error: redefinition of 'timeval'
    struct timeval
    ^

    /usr/include/x86_64-linux-gnu/time.h:15:8: note: previous definition is here
    struct timeval {
    ^

    <module-includes>:3:10: note: in file included from <module-includes>:3:
    #include "///usr/include/utmp.h"
    ^

    ///usr/include/utmp.h:29:10: note: in file included from ///usr/include/utmp.h:29:
    #include <bits/utmp.h>
    ^

    /usr/include/bits/utmp.h:24:10: note: in file included from /usr/include/bits/utmp.h:24:
    #include <sys/time.h>
    ^

    error: /usr/include/sys/time.h:55:8: error: redefinition of 'timezone'
    struct timezone
    ^

    /usr/include/x86_64-linux-gnu/time.h:20:8: note: previous definition is here
    struct timezone {
    ^

    <module-includes>:3:10: note: in file included from <module-includes>:3:
    #include "///usr/include/utmp.h"
    ^

    ///usr/include/utmp.h:29:10: note: in file included from ///usr/include/utmp.h:29:
    #include <bits/utmp.h>
    ^

    /usr/include/bits/utmp.h:24:10: note: in file included from /usr/include/bits/utmp.h:24:
    #include <sys/time.h>
    ^

    error: /usr/include/sys/time.h:94:5: error: expected identifier
    ITIMER_REAL = 0,
    ^

    /usr/include/x86_64-linux-gnu/time.h:30:22: note: expanded from macro 'ITIMER_REAL'
    #define ITIMER_REAL 0
    ^

    <module-includes>:3:10: note: in file included from <module-includes>:3:
    #include "///usr/include/utmp.h"
    ^

    ///usr/include/utmp.h:29:10: note: in file included from ///usr/include/utmp.h:29:
    #include <bits/utmp.h>
    ^

    /usr/include/bits/utmp.h:24:10: note: in file included from /usr/include/bits/utmp.h:24:
    #include <sys/time.h>
    ^

    error: /usr/include/sys/time.h:97:5: error: expected identifier
    ITIMER_VIRTUAL = 1,
    ^

    /usr/include/x86_64-linux-gnu/time.h:31:25: note: expanded from macro 'ITIMER_VIRTUAL'
    #define ITIMER_VIRTUAL 1
    ^

    <module-includes>:3:10: note: in file included from <module-includes>:3:
    #include "///usr/include/utmp.h"
    ^

    ///usr/include/utmp.h:29:10: note: in file included from ///usr/include/utmp.h:29:
    #include <bits/utmp.h>
    ^

    /usr/include/bits/utmp.h:24:10: note: in file included from /usr/include/bits/utmp.h:24:
    #include <sys/time.h>
    ^

    error: /usr/include/sys/time.h:101:5: error: expected identifier
    ITIMER_PROF = 2
    ^

    /usr/include/x86_64-linux-gnu/time.h:32:22: note: expanded from macro 'ITIMER_PROF'
    #define ITIMER_PROF 2
    ^

    <module-includes>:3:10: note: in file included from <module-includes>:3:
    #include "///usr/include/utmp.h"
    ^

    ///usr/include/utmp.h:29:10: note: in file included from ///usr/include/utmp.h:29:
    #include <bits/utmp.h>
    ^

    /usr/include/bits/utmp.h:24:10: note: in file included from /usr/include/bits/utmp.h:24:
    #include <sys/time.h>
    ^

    error: /usr/include/sys/time.h:107:8: error: redefinition of 'itimerval'
    struct itimerval
    ^

    /usr/include/x86_64-linux-gnu/time.h:39:8: note: previous definition is here
    struct itimerval {
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:323:11: note: in file included from ///usr/include/signal.h:323:

    1. include <bits/sigstack.h>
      ^

    error: /usr/include/bits/sigstack.h:53:5: error: unknown type name 'size_t'; did you mean 'ssize_t'?
    size_t ss_size;
    ^

    /usr/include/sys/types.h:109:19: note: 'ssize_t' declared here
    typedef __ssize_t ssize_t;
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:4:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:4:
    #include <asm/signal.h>
    ^

    error: /usr/include/asm/signal.h:15:23: error: typedef redefinition with different types ('unsigned long' vs '__sigset_t')
    typedef unsigned long sigset_t;
    ^

    /usr/include/sys/select.h:37:20: note: previous definition is here
    typedef __sigset_t sigset_t;
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:4:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:4:
    #include <asm/signal.h>
    ^

    error: /usr/include/asm/signal.h:114:8: error: redefinition of 'sigaction'
    struct sigaction {
    ^

    /usr/include/bits/sigaction.h:24:8: note: previous definition is here
    struct sigaction
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:4:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:4:
    #include <asm/signal.h>
    ^

    error: /usr/include/asm/signal.h:115:17: error: expected ';' at end of declaration list
    __sighandler_t sa_handler;
    ^

    /usr/include/bits/sigaction.h:36:40: note: expanded from macro 'sa_handler'

    1. define sa_handler __sigaction_handler.sa_handler
      ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:4:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:4:
    #include <asm/signal.h>
    ^

    error: /usr/include/asm/signal.h:123:16: error: redefinition of 'sigaltstack'
    typedef struct sigaltstack {
    ^

    /usr/include/bits/sigstack.h:49:16: note: previous definition is here
    typedef struct sigaltstack
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:4:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:4:
    #include <asm/signal.h>
    ^

    error: /usr/include/asm/signal.h:126:2: error: unknown type name 'size_t'; did you mean 'ssize_t'?
    size_t ss_size;
    ^

    /usr/include/sys/types.h:109:19: note: 'ssize_t' declared here
    typedef __ssize_t ssize_t;
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:4:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:4:
    #include <asm/signal.h>
    ^

    error: /usr/include/asm/signal.h:127:3: error: typedef redefinition with different types ('struct (anonymous struct at /usr/include/asm/signal.h:123:16)' vs 'struct sigaltstack')
    } stack_t;
    ^

    /usr/include/bits/sigstack.h:54:5: note: previous definition is here
    } stack_t;
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:5:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:5:
    #include <asm/siginfo.h>
    ^

    /usr/include/asm/siginfo.h:14:10: note: in file included from /usr/include/asm/siginfo.h:14:
    #include <asm-generic/siginfo.h>
    ^

    error: /usr/include/asm-generic/siginfo.h:7:15: error: redefinition of 'sigval'
    typedef union sigval {
    ^

    /usr/include/bits/siginfo.h:32:15: note: previous definition is here
    typedef union sigval
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:5:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:5:
    #include <asm/siginfo.h>
    ^

    /usr/include/asm/siginfo.h:14:10: note: in file included from /usr/include/asm/siginfo.h:14:
    #include <asm-generic/siginfo.h>
    ^

    error: /usr/include/asm-generic/siginfo.h:10:3: error: typedef redefinition with different types ('union (anonymous union at /usr/include/asm-generic/siginfo.h:7:15)' vs 'union sigval')
    } sigval_t;
    ^

    /usr/include/bits/siginfo.h:36:5: note: previous definition is here
    } sigval_t;
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:5:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:5:
    #include <asm/siginfo.h>
    ^

    /usr/include/asm/siginfo.h:14:10: note: in file included from /usr/include/asm/siginfo.h:14:
    #include <asm-generic/siginfo.h>
    ^

    error: /usr/include/asm-generic/siginfo.h:118:24: error: typedef redefinition with different types ('struct siginfo' vs 'struct siginfo_t')
    } __ARCH_SI_ATTRIBUTES siginfo_t;
    ^

    /usr/include/bits/siginfo.h:133:5: note: previous definition is here
    } siginfo_t __SI_ALIGNMENT;
    ^

    <module-includes>:12:10: note: in file included from <module-includes>:12:
    #include "///usr/include/signal.h"
    ^

    ///usr/include/signal.h:326:12: note: in file included from ///usr/include/signal.h:326:

    1. include <sys/ucontext.h>
      ^

    /usr/include/sys/ucontext.h:22:10: note: in file included from /usr/include/sys/ucontext.h:22:
    #include <signal.h>
    ^

    /usr/include/x86_64-linux-gnu/signal.h:5:10: note: in file included from /usr/include/x86_64-linux-gnu/signal.h:5:
    #include <asm/siginfo.h>
    ^

    /usr/include/asm/siginfo.h:14:10: note: in file included from /usr/include/asm/siginfo.h:14:
    #include <asm-generic/siginfo.h>
    ^

    error: /usr/include/asm-generic/siginfo.h:290:16: error: redefinition of 'sigevent'
    typedef struct sigevent {
    ^

    /usr/include/bits/siginfo.h:320:16: note: previous definition is here
    typedef struct sigevent
    ^

    error: too many errors emitted, stopping now
    error: could not build Objective-C module 'SwiftGlibc'

  12. swift-ci commented on Apr 3, 2017

    @swift-ci
    Author

    Comment by Hugh Bellamy (JIRA)

    Feel like submitting a PR to add this to the CMake build?

  13. swift-ci commented on Apr 4, 2017

    @swift-ci
    Author

    Comment by Ryan Lovelett (JIRA)

    This is also effecting ldb. Is there an equivalent to send -I/path/to/usr/lib/swift/clang/include to lldb?

  14. swift-ci commented on Apr 5, 2017

    @swift-ci
    Author

    Comment by Rick M (JIRA)

    This was affecting me on Ubuntu 16.04, importing Glibc, in the swift repl. It does not seem to affect switfc

  15. swift-ci commented on Jun 15, 2017

    @swift-ci
    Author

    Comment by Vivian Kong (JIRA)

    I saw the same error in REPL on Linux on s390x (it used to work in 3.0.2). The workaround mentioned above allows me to import Glibc but I can't import Foundation/Dispatch etc. Any ideas on what might be the problem? Thanks.

    $ ./swift -I/home/tester/swift31/install/usr/lib/swift/clang/include
    Welcome to Swift version 3.1.1-dev (LLVM 9cb6a3ccee, Clang f38438fc01, Swift 8d233b16cb). Type :help for assistance.
    1> import Glibc
    2> import Foundation
    error: repl.swift:2:8: error: no such module 'Foundation'
    import Foundation
    ^

    2> import Dispatch
    error: repl.swift:2:8: error: no such module 'Dispatch'
    import Dispatch
    ^

  16. swift-ci commented on Jul 24, 2017

    @swift-ci
    Author

    Comment by Matthias M. Schneider (JIRA)

    Please see the comment on issue SR-5524 for a possible temporary fix.

  17. dcci commented on Oct 29, 2019

    dccimannequin
    Mannequin

    This seems to work with a recent lldb

    ./build/Ninja-ReleaseAssert/lldb-linux-x86_64/bin/lldb --repl
    Welcome to Swift version 5.1.1-dev (LLVM 7ade6a3e01, Swift cc60f2c351).
    Type :help for assistance.
      1> import Glibc
      2>

    Please try again and let us know!

  18. transferred this issue fromswiftlang/swifton May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions