Skip to content

Commit 2bd8ec2

Browse files
committed
Auto merge of #21944 - alexcrichton:lframework, r=eddyb
On OSX the linker has a separate framework lookup path which is specified via the `-F` flag. This adds a new kind of `-L` path recognized by the compiler for frameworks to be passed through to the linker. Closes #20259
2 parents fa28f02 + 6c62839 commit 2bd8ec2

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

man/rustc.1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ Display the help message
1818
\fB\-\-cfg\fR SPEC
1919
Configure the compilation environment
2020
.TP
21-
\fB\-L\fR PATH
22-
Add a directory to the library search path
23-
.TP
24-
\fB\-l\fR NAME[:KIND]
21+
\fB\-L\fR [KIND=]PATH
22+
Add a directory to the library search path. The optional KIND can be one of:
23+
dependency = only lookup transitive dependencies here
24+
crate = only lookup local `extern crate` directives here
25+
native = only lookup native libraries here
26+
framework = only look for OSX frameworks here
27+
all = look for anything here (the default)
28+
.TP
29+
\fB\-l\fR [KIND=]NAME
2530
Link the generated crate(s) to the specified native library NAME. The optional
2631
KIND can be one of, static, dylib, or framework. If omitted, dylib is assumed.
2732
.TP

src/librustc/session/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
738738
vec![
739739
opt::flag("h", "help", "Display this message"),
740740
opt::multi("", "cfg", "Configure the compilation environment", "SPEC"),
741-
opt::multi("L", "", "Add a directory to the library search path", "PATH"),
741+
opt::multi("L", "", "Add a directory to the library search path",
742+
"[KIND=]PATH"),
742743
opt::multi("l", "", "Link the generated crate(s) to the specified native
743744
library NAME. The optional KIND can be one of,
744745
static, dylib, or framework. If omitted, dylib is

src/librustc/session/search_paths.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub enum PathKind {
2525
Native,
2626
Crate,
2727
Dependency,
28+
Framework,
2829
ExternFlag,
2930
All,
3031
}
@@ -41,6 +42,8 @@ impl SearchPaths {
4142
(PathKind::Crate, &path["crate=".len()..])
4243
} else if path.starts_with("dependency=") {
4344
(PathKind::Dependency, &path["dependency=".len()..])
45+
} else if path.starts_with("framework=") {
46+
(PathKind::Framework, &path["framework=".len()..])
4447
} else if path.starts_with("all=") {
4548
(PathKind::All, &path["all=".len()..])
4649
} else {

src/librustc_trans/back/link.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,11 @@ fn link_args(cmd: &mut Command,
10441044
// in the current crate. Upstream crates with native library dependencies
10451045
// may have their native library pulled in above.
10461046
fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
1047-
sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path, _| {
1048-
cmd.arg("-L").arg(path);
1047+
sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path, k| {
1048+
match k {
1049+
PathKind::Framework => { cmd.arg("-F").arg(path); }
1050+
_ => { cmd.arg("-L").arg(path); }
1051+
}
10491052
FileDoesntMatch
10501053
});
10511054

0 commit comments

Comments
 (0)