Cannot Build Swift on FreeBSD - REPL error

1

I am attempting to install Swift 3 on FreeBSD 10.2 using the official build script but am unable to do so.

I am receiving the following error:

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

ninja: build stopped: subcommand failed.

utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

This is the text immediately preceding the error message:

/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:244:3: error: unknown type name 'HistoryW'; did you mean 'History'?
  HistoryW *h;
  ^~~~~~~~
  History
/usr/include/histedit.h:169:24: note: 'History' declared here
typedef struct history History;
                       ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:491:30: error: unknown type name 'LineInfoW'; did you mean 'LineInfo'?
  bool isAtStartOfLine(const LineInfoW *line) {
                             ^~~~~~~~~
                             LineInfo
/usr/include/histedit.h:64:3: note: 'LineInfo' declared here
} LineInfo;
  ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:501:33: error: unknown type name 'LineInfoW'; did you mean 'LineInfo'?
  bool lineLooksLikeLabel(const LineInfoW *line) {
                                ^~~~~~~~~
                                LineInfo
/usr/include/histedit.h:64:3: note: 'LineInfo' declared here
} LineInfo;
  ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:520:34: error: unknown type name 'LineInfoW'; did you mean 'LineInfo'?
  bool lineLooksLikeSetter(const LineInfoW *line) {
                                 ^~~~~~~~~
                                 LineInfo
/usr/include/histedit.h:64:3: note: 'LineInfo' declared here
} LineInfo;
  ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:548:32: error: unknown type name 'LineInfoW'; did you mean 'LineInfo'?
  bool lineLooksLikeCase(const LineInfoW *line) {
                               ^~~~~~~~~
                               LineInfo
/usr/include/histedit.h:64:3: note: 'LineInfo' declared here
} LineInfo;
  ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:277:9: error: use of undeclared identifier 'history_winit'; did you mean 'history_init'?
    h = history_winit();
        ^~~~~~~~~~~~~
        history_init
/usr/include/histedit.h:179:11: note: 'history_init' declared here
History *       history_init(void);
                ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:279:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_EDITOR, L"emacs");
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:280:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_PROMPT_ESC, PromptFn, LITERAL_MODE_CHAR);
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:281:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_CLIENTDATA, (void*)this);
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:282:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_HIST, history, h);
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:283:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_SIGNAL, 1);
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:284:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_GETCFN, GetCharFn);
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:287:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_ADDFN, L"swift-close-brace", L"Reduce {} indentation level",
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:289:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_BIND, L"}", L"swift-close-brace", nullptr);
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:291:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_ADDFN, L"swift-colon", L"Reduce label indentation level",
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:293:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_BIND, L":", L"swift-colon", nullptr);
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:296:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_ADDFN, L"swift-indent-or-complete",
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:299:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_BIND, L"\t", L"swift-indent-or-complete", nullptr);
    ^
/usr/local/swiftlang/swift/lib/Immediate/REPL.cpp:301:5: error: use of undeclared identifier 'el_wset'
    el_wset(e, EL_ADDFN, L"swift-complete",

I have checked for open tickets in Jinja, Github, and the Swift Users Mailing List, all to no avail. Does anyone have a solution?

Brandon Bradley

Posted 2016-10-27T03:08:54.747

Reputation: 113

Answers

2

You are building from a fork, not an Apple repo.

Look at the contents of REPL.cpp:

#if defined(__APPLE__)
// FIXME: Support REPL on non-Apple platforms. Ubuntu 14.10's editline does not
// include the wide character entry points needed by the REPL yet.
#include <histedit.h>
#endif // __APPLE__

FreeBSD's editline does have the wide character entry points. So you have to include it.

Change

#if defined(__APPLE__)

to

#if defined(__APPLE__) || defined(__FreeBSD__)

just like in the Apple repo. This should fix one compilation problem. But there might be a lot more.

You might want to try and build the official repo, although it doesn't list FreeBSD as a supported OS. The fork that you're using hasn't been modified in almost a year.

The FreeBSD ports collection contains swift 2.2.1. If you don't specifically need swift 3, I'd suggest you use that instead.

Roland Smith

Posted 2016-10-27T03:08:54.747

Reputation: 1 712