Compile Swift 4.0-dev on CentOS7.2
来源:互联网 发布:网警网络监控软件v2.0 编辑:程序博客网 时间:2024/06/14 17:34
环境:
CentOS7.2 x64, Python 3.6, GCC 4.8.5
一. 先按 swift官网的linux安装方法来,出了问题,再参考这里:
https://github.com/apple/swift
二. 我在CentOS 7.2上遇到的问题及解决方案:
1. sudo yum install clang gcc-c++ uuid-devel libicu-devel icu libedit-devel
libxml2-devel sqlite-devel swig python-devel ncurses-libs ncurses-devel
pkgconfig libuuid-devel epel-release libbsd-devel ninja-build libatomic
libblocksruntime-devel libcurl4-openssl-devel autoconf libtool systemtap-sdt-devel tzdata
2. clang(++) reserves the word __block when you enable -fblocks support. Alas,
unistd.h has (for a VERY long time) used this as the name of a variable, which
causes clang to throw a fit:
/usr/include/unistd.h:1147:35: error: __block attribute not allowed, only
allowed on local variables
extern void encrypt (char *__block, int __edflag) __THROW __nonnull ((1));
You can fix the file by:
sed -i -e 's/\*__block/\*__libc_block/g' /usr/include/unistd.h
(做个backup,后面记得改回来)
3. cd swift/utils/gyb_syntax_support
change the package import mechanism for all *.py files (if you use python3)
这几个都是local import方式,python3 要这种格式: from .Nodes import xxxx
不然提示找不到package,因为没有前面的".",python3就去sites-package里去找了。
这个目录下所有py文件都要改。
4. change branch
./swift/utils/update-checkout --scheme swift-3.1-branch
这个我没有用,直接就是最新的swift-4.0-dev
5. runtime block
git clone https://github.com/mackyle/blocksruntime.git
CFLAGS=' -fPIC ' ./buildlib
./installlib
找一个blocksruntime库先装上,Ubuntu上有现成的libblocksruntime-dev,CentOS要自己编译
6. vi /home/media/code/swift_src/swift/stdlib/public/core/Tuple.swift.gyb
line 108: range(1, arity - 1) + [arity])) --> list(range(1, arity - 1)) + [arity])))
这个默认是 range + list,会有类型操作不支持的错误,将range转换为list再相加
7. vi /home/media/code/swift_src/swift/stdlib/public/core/Integers.swift.gyb
comment the import code:
#from string import maketrans, capitalize
and change the maketrans to str.maketrans, capitalize to str.capitalize
Python3将这2个函数内置了,所以导入string会报错
我的环境上基本就遇到这些错误,到此可以编译成功。
Update:
如果遇到CoreFoundation/URL.subproj中缺少定义的错误, 例如:
CoreFundation/URL.subproj/CFURLSessionInterface.c:228:76 error: use of undeclared identifier 'CURLE_NO_CONNECTION_AVAILABLE'
请确认libcurl 的版本, 有些是 curl 7.30后加入的, 在 https://curl.haxx.se/docs/install.html 下载最新稳定版编译安装就可以解决。
我的build-script参数:
--libdisptach --install-swiftpm --release --llbuild --swiftpm --foundation --swift-enable-ast-verifier=0 --build-swift-static-stdlib=1 --skip-test-lldb=1
--xctest --lldb --build-args=-j8 --reconfigure
- Compile Swift 4.0-dev on CentOS7.2
- OpenOCD compile on Windows
- Compile C++ on AIX
- compile emule on vs2005
- Compile MaNGOS On Windows
- Compile Clang on Fedora15
- Compile FFmpeg on Ubuntu
- Compile openssl on windows
- libmad compile on ubuntu
- Compile FFmpeg on Ubuntu
- openssl compile on linux
- compile nginx on linux
- Compile FFmpeg on Ubuntu
- Compile FFmpeg on CentOS
- php Compile on Mac
- [DEV]How to compile TWRP touch recovery
- Windows Dev Intro - Direct2D Compile Error
- x265 Dev Intro - Compile and Install
- 最长回文子串--轻松理解Manacher算法
- PCB布局时去耦电容摆放经验分享
- bzoj5037: [Jsoi2014]电信网络
- sql
- 出现 Request Entity Too Large问题的解决方法
- Compile Swift 4.0-dev on CentOS7.2
- 详解Python中的多线程编程
- A Painless Q-learning Tutorial (一个 Q-learning 算法的简明教程)
- 使用pgAdmin3 调试存储过程
- 营销型企业网站建设内链优化怎么做?
- 【Leetcode】旋转数组最小值
- 机器学习基础知识-神经网络与深度学习学习笔记(二)
- iOS NSData与long long的互转
- CSS选择器总结