Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b6e28b59
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b6e28b59
编写于
6月 24, 2022
作者:
T
topjohnwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow dynamically linking against libLLVM on macOS
Create symlinks to workaround file missing error in llvm-config
上级
fdca237d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
16 deletion
+41
-16
src/bootstrap/lib.rs
src/bootstrap/lib.rs
+10
-6
src/bootstrap/native.rs
src/bootstrap/native.rs
+31
-10
未找到文件。
src/bootstrap/lib.rs
浏览文件 @
b6e28b59
...
...
@@ -107,15 +107,11 @@
use
std
::
collections
::{
HashMap
,
HashSet
};
use
std
::
env
;
use
std
::
fs
::{
self
,
File
};
use
std
::
io
;
use
std
::
path
::{
Path
,
PathBuf
};
use
std
::
process
::{
self
,
Command
};
use
std
::
str
;
#[cfg(unix)]
use
std
::
os
::
unix
::
fs
::
symlink
as
symlink_file
;
#[cfg(windows)]
use
std
::
os
::
windows
::
fs
::
symlink_file
;
use
filetime
::
FileTime
;
use
once_cell
::
sync
::
OnceCell
;
...
...
@@ -1446,7 +1442,7 @@ fn copy_internal(&self, src: &Path, dst: &Path, dereference_symlinks: bool) {
src
=
t!
(
fs
::
canonicalize
(
src
));
}
else
{
let
link
=
t!
(
fs
::
read_link
(
src
));
t!
(
symlink_file
(
link
,
dst
));
t!
(
s
elf
.s
ymlink_file
(
link
,
dst
));
return
;
}
}
...
...
@@ -1571,6 +1567,14 @@ fn read_dir(&self, dir: &Path) -> impl Iterator<Item = fs::DirEntry> {
iter
.map
(|
e
|
t!
(
e
))
.collect
::
<
Vec
<
_
>>
()
.into_iter
()
}
fn
symlink_file
<
P
:
AsRef
<
Path
>
,
Q
:
AsRef
<
Path
>>
(
&
self
,
src
:
P
,
link
:
Q
)
->
io
::
Result
<
()
>
{
#[cfg(unix)]
use
std
::
os
::
unix
::
fs
::
symlink
as
symlink_file
;
#[cfg(windows)]
use
std
::
os
::
windows
::
fs
::
symlink_file
;
if
!
self
.config.dry_run
{
symlink_file
(
src
.as_ref
(),
link
.as_ref
())
}
else
{
Ok
(())
}
}
fn
remove
(
&
self
,
f
:
&
Path
)
{
if
self
.config.dry_run
{
return
;
...
...
src/bootstrap/native.rs
浏览文件 @
b6e28b59
...
...
@@ -238,9 +238,7 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
};
builder
.update_submodule
(
&
Path
::
new
(
"src"
)
.join
(
"llvm-project"
));
if
builder
.llvm_link_shared
()
&&
(
target
.contains
(
"windows"
)
||
target
.contains
(
"apple-darwin"
))
{
if
builder
.llvm_link_shared
()
&&
target
.contains
(
"windows"
)
{
panic!
(
"shared linking to LLVM is not currently supported on {}"
,
target
.triple
);
}
...
...
@@ -346,7 +344,9 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
//
// If we're not linking rustc to a dynamic LLVM, though, then don't link
// tools to it.
if
builder
.llvm_link_tools_dynamically
(
target
)
&&
builder
.llvm_link_shared
()
{
let
llvm_link_shared
=
builder
.llvm_link_tools_dynamically
(
target
)
&&
builder
.llvm_link_shared
();
if
llvm_link_shared
{
cfg
.define
(
"LLVM_LINK_LLVM_DYLIB"
,
"ON"
);
}
...
...
@@ -425,18 +425,18 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
);
}
if
let
Some
(
ref
suffix
)
=
builder
.config.llvm_version_suffix
{
let
llvm_version_suffix
=
if
let
Some
(
ref
suffix
)
=
builder
.config.llvm_version_suffix
{
// Allow version-suffix="" to not define a version suffix at all.
if
!
suffix
.is_empty
()
{
cfg
.define
(
"LLVM_VERSION_SUFFIX"
,
suffix
);
}
if
!
suffix
.is_empty
()
{
Some
(
suffix
.to_string
())
}
else
{
None
}
}
else
if
builder
.config.channel
==
"dev"
{
// Changes to a version suffix require a complete rebuild of the LLVM.
// To avoid rebuilds during a time of version bump, don't include rustc
// release number on the dev channel.
cfg
.define
(
"LLVM_VERSION_SUFFIX"
,
"-rust-dev"
);
Some
(
"-rust-dev"
.to_string
())
}
else
{
let
suffix
=
format!
(
"-rust-{}-{}"
,
builder
.version
,
builder
.config.channel
);
Some
(
format!
(
"-rust-{}-{}"
,
builder
.version
,
builder
.config.channel
))
};
if
let
Some
(
ref
suffix
)
=
llvm_version_suffix
{
cfg
.define
(
"LLVM_VERSION_SUFFIX"
,
suffix
);
}
...
...
@@ -465,6 +465,27 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
cfg
.build
();
// When building LLVM with LLVM_LINK_LLVM_DYLIB for macOS, an unversioned
// libLLVM.dylib will be built. However, llvm-config will still look
// for a versioned path like libLLVM-14.dylib. Manually create a symbolic
// link to make llvm-config happy.
if
llvm_link_shared
&&
target
.contains
(
"apple-darwin"
)
{
let
mut
cmd
=
Command
::
new
(
&
build_llvm_config
);
let
version
=
output
(
cmd
.arg
(
"--version"
));
let
major
=
version
.split
(
'.'
)
.next
()
.unwrap
();
let
lib_name
=
match
llvm_version_suffix
{
Some
(
s
)
=>
format!
(
"lib/libLLVM-{}{}.dylib"
,
major
,
s
),
None
=>
format!
(
"lib/libLLVM-{}.dylib"
,
major
),
};
// The reason why we build the library path from llvm-config is because
// the output of llvm-config depends on its location in the file system.
// Make sure we create the symlink exactly where it's needed.
let
llvm_base
=
build_llvm_config
.parent
()
.unwrap
()
.parent
()
.unwrap
();
let
lib_llvm
=
llvm_base
.join
(
lib_name
);
t!
(
builder
.symlink_file
(
"libLLVM.dylib"
,
&
lib_llvm
));
}
t!
(
stamp
.write
());
build_llvm_config
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录