Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
安装Swift 3&x2B;Linux上的libdispatch和Ansible_Linux_Ansible_Swift3_Libdispatch - Fatal编程技术网

安装Swift 3&x2B;Linux上的libdispatch和Ansible

安装Swift 3&x2B;Linux上的libdispatch和Ansible,linux,ansible,swift3,libdispatch,Linux,Ansible,Swift3,Libdispatch,我很难在Ubuntu 16.04上安装Swift 3.0和GCD。这在今天应该是可能的,对吗 下面是一个从Swift.org下载Swift 3、从GitHub克隆、构建和安装Swift corelibs libdispatch的任务 即使libdispatch的安装没有错误地完成,它也无法工作。当我尝试在Swift repl中导入分派时,它会抱怨缺少功能“块”。检查Makefiles可确认至少向编译器提供了标志-fblocks 以下是Swift repl的示例输出: vagrant@swift3

我很难在Ubuntu 16.04上安装Swift 3.0和GCD。这在今天应该是可能的,对吗

下面是一个从Swift.org下载Swift 3、从GitHub克隆、构建和安装Swift corelibs libdispatch的任务

即使libdispatch的安装没有错误地完成,它也无法工作。当我尝试在Swift repl中导入分派时,它会抱怨缺少功能“块”。检查Makefiles可确认至少向编译器提供了标志
-fblocks

以下是Swift repl的示例输出:

vagrant@swift3:/tmp/swift-3.0-PREVIEW-3-ubuntu15.10/usr/bin$ ./swift
Welcome to Swift version 3.0 (swift-3.0-PREVIEW-3). Type :help for assistance.
  1> 6 * 7
$R0: Int = 42
  2> import Dispatch
error: module 'CDispatch' requires feature 'blocks'
error: could not build Objective-C module 'CDispatch'

  2>  
用于设置框的文件:

# -*- mode: ruby -*-
# vi: set ft=ruby :


Vagrant.configure(2) do |config|
    config.ssh.forward_agent = true
    config.vm.box = "bento/ubuntu-16.04"

    config.vm.define "swift3" do |dev|
        dev.vm.hostname = "swift3.dev"
    end

    config.vm.network :private_network, ip: "10.0.0.10"

    config.vm.provider "virtualbox" do |vb|
        vb.memory = "2048"
    end

    config.vm.provision "ansible" do |ansible|
        ansible.playbook = "ansible/main.yml"
    end
end
负责安装Swift 3的任务:

---

- name: Install Swift 3 requirements
  apt: name={{ item }} state=installed
  with_items:
  - autoconf
  - clang
  - git
  - libblocksruntime-dev
  - libbsd-dev
  - libcurl4-openssl-dev
  - libdispatch-dev
  - libkqueue-dev
  - libpython2.7-dev
  - libtool
  - pkg-config


- name: download Swift 3
  get_url: url=https://swift.org/builds/swift-3.0-preview-3/ubuntu1510/swift-3.0-PREVIEW-3/swift-3.0-PREVIEW-3-ubuntu15.10.tar.gz
           dest=/tmp/swift.tgz mode=0440

- name: unarchive Swift 3
  unarchive: dest=/tmp src=/tmp/swift.tgz copy=no creates=/tmp/swift-3.0-PREVIEW-3-ubuntu15.10

- name: clone Swift 3 libdispatch core library
  git: repo=https://github.com/apple/swift-corelibs-libdispatch dest=/tmp/swift-corelibs-libdispatch
       version=swift-3.0-preview-3-branch force=true

- name: generate Swift 3 libdispatch build files
  command: "sh ./autogen.sh"
  args:
    chdir: /tmp/swift-corelibs-libdispatch

- name: configure Swift 3 libdispatch
  command: "sh ./configure --with-blocks-runtime=/usr/lib/x86_64-linux-gnu --with-swift-toolchain=/tmp/swift-3.0-PREVIEW-3-ubuntu15.10/usr --prefix=/tmp/swift-3.0-PREVIEW-3-ubuntu15.10/usr"
  args:
    chdir: /tmp/swift-corelibs-libdispatch

- name: make Swift 3 libdispatch
  command: "make"
  args:
    chdir: /tmp/swift-corelibs-libdispatch

- name: install Swift 3 libdispatch
  command: "make install"
  args:
    chdir: /tmp/swift-corelibs-libdispatch

- name: grant permissions to use Swift 3
  file: dest=/tmp/swift-3.0-PREVIEW-3-ubuntu15.10 mode=a+rX recurse=true

正如您所注意到的,
-fblocks
链接器标志在编译libdispatch时被适当地设置。这很好,因为现在您有了libdispatch的工作版本

不幸的是,您制作的任何包含
Dispatch
的东西也需要
-fblocks
链接器标志

tl;dr解决方案的解决方法是,只要在编译时将
-Xcc-fblock
提供给
swiftc

正如我所说,这是一种变通方法。提出了较长期的解决方案。在这之前,尽管上面的工作是从你所在的地方到你想去的地方的最短距离


我将自己补充,我只是使用上面拉请求中的补丁来修补我的本地构建。YMMV.

虽然我对Swift 3一无所知,但我可以建议您跳过ansible Provisionier(通过使用
--无供应
标志),手动运行安装步骤以隔离问题区域。如果可行,那么问题很可能就在剧本中。如果仍然不起作用,问题可能是方框图像中缺少一些依赖项。