Skip to content

Commit e4e1cdc

Browse files
committed
port tests/ui/linkage-attr/framework to run-make
this makes it much easier to understand test failures. before: ``` diff of stderr: 1 error: linking with `LINKER` failed: exit status: 1 2 | - ld: Undefined symbols: 4 _CFRunLoopGetTypeID, referenced from: 5 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` after: ``` === HAYSTACK === error: linking with `cc` failed: exit status: 1 | = note: use `--verbose` to show all linker arguments = note: Undefined symbols for architecture arm64: "_CFRunLoopGetTypeID", referenced from: main::main::hbb553f5dda62d3ea in main.main.d17f5fbe6225cf88-cgu.0.rcgu.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) error: aborting due to 1 previous error === NEEDLE === _CFRunLoopGetTypeID\.?, referenced from: thread 'main' panicked at /Users/jyn/git/rust-lang/rust/tests/run-make/linkage-attr-framework/rmake.rs:22:10: needle was not found in haystack ``` this also fixes a failure related to missing whitespace; we don't actually care about whitespace in this test.
1 parent 56064d5 commit e4e1cdc

File tree

4 files changed

+43
-40
lines changed

4 files changed

+43
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![cfg_attr(any(weak, both), feature(link_arg_attribute))]
2+
3+
#[cfg_attr(any(link, both), link(name = "CoreFoundation", kind = "framework"))]
4+
#[cfg_attr(
5+
any(weak, both),
6+
link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim"),
7+
link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim")
8+
)]
9+
extern "C" {
10+
fn CFRunLoopGetTypeID() -> core::ffi::c_ulong;
11+
}
12+
13+
fn main() {
14+
unsafe {
15+
CFRunLoopGetTypeID();
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//! Check that linking frameworks on Apple platforms works.
2+
3+
//@ only-apple
4+
5+
use run_make_support::{Rustc, run, rustc};
6+
7+
fn compile(cfg: &str) -> Rustc {
8+
let mut rustc = rustc();
9+
rustc.cfg(cfg).input("main.rs");
10+
rustc
11+
}
12+
13+
fn main() {
14+
for cfg in ["link", "weak", "both"] {
15+
compile(cfg).run();
16+
run("main");
17+
}
18+
19+
let errs = compile("omit").run_fail();
20+
// The linker's exact error output changes between Xcode versions, depends on
21+
// linker invocation details, and the linker sometimes outputs more warnings.
22+
errs.assert_stderr_contains_regex(r"error: linking with `.*` failed");
23+
errs.assert_stderr_contains_regex(r"(Undefined symbols|ld: symbol[^\s]* not found)");
24+
errs.assert_stderr_contains_regex(r".?_CFRunLoopGetTypeID.?, referenced from:");
25+
errs.assert_stderr_contains("clang: error: linker command failed with exit code 1");
26+
}

tests/ui/linkage-attr/framework.omit.stderr

-8
This file was deleted.

tests/ui/linkage-attr/framework.rs

-32
This file was deleted.

0 commit comments

Comments
 (0)