Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
swift-ci opened this issue Jan 30, 2017 · 17 comments
Closed

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

swift-ci opened this issue Jan 30, 2017 · 17 comments
Labels

Comments

@swift-ci
Copy link

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>

@belkadan
Copy link

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

@belkadan
Copy link

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

@swift-ci
Copy link
Author

Comment by Peter (JIRA)

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

@swift-ci
Copy link
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<~~~~----------------

@belkadan
Copy link

Okay, retagging as LLDB.

@gottesmm
Copy link
Member

@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?

@belkadan
Copy link

belkadan commented Feb 7, 2017

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

@swift-ci
Copy link
Author

Comment by Hugh Bellamy (JIRA)

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

@ahti
Copy link

ahti commented Mar 16, 2017

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.

@swift-ci
Copy link
Author

Comment by Peter (JIRA)

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

@swift-ci
Copy link
Author

swift-ci commented Apr 3, 2017

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'

@swift-ci
Copy link
Author

swift-ci commented Apr 3, 2017

Comment by Hugh Bellamy (JIRA)

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

@swift-ci
Copy link
Author

swift-ci commented Apr 4, 2017

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?

@swift-ci
Copy link
Author

swift-ci commented Apr 5, 2017

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

@swift-ci
Copy link
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
^

@swift-ci
Copy link
Author

Comment by Matthias M. Schneider (JIRA)

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

@dcci
Copy link
Mannequin

dcci mannequin commented Oct 29, 2019

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!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants