rust
rust copied to clipboard
Add test for Apple's `-weak_framework` linker argument
The -weak_framework
linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets.
So I made a test to ensure that it continues to work.
Discussed in https://github.com/rust-lang/rust/issues/99427.
r? @b-naber
(rustbot has picked a reviewer for you, use r? to override)
I guess a test that runs otool -L
and checks the output could also be useful, are those kinds of tests desired?
I guess a test that runs otool -L and checks the output could also be useful, are those kinds of tests desired?
Not your reviewer, but I added tests like that for deployment targets so I don't see why not.
I've added such tests now, thanks for the input
@bors r+ rollup
:pushpin: Commit d63d1a17a05c18fc9a47e12cf96fcb0cc7a20893 has been approved by b-naber
It is now in the queue for this repository.
I think it failed in https://github.com/rust-lang/rust/pull/119027.
:hourglass: Testing commit d63d1a17a05c18fc9a47e12cf96fcb0cc7a20893 with merge a7e25d7aed9c7aecdbd8c977bd378574176dd2fc...
The job aarch64-apple
failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
SCRIPT=./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin
SELECT_XCODE=/Applications/Xcode_13.4.1.app
SHELL=/bin/bash
SHLVL=3
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.Er2iAtQJug/Listeners
STATS_EXTP=https://provjobdsettingscdn.blob.core.windows.net/settings/provjobdsettings-0.5.154/provjobd.data
STATS_RDCL=true
STATS_TIS=mining
STATS_TRP=true
---
test [ui] tests/ui/linkage-attr/issue-10755.rs ... ok
test [ui] tests/ui/linkage-attr/issue-109144.rs ... ok
test [ui] tests/ui/link-section.rs ... ok
test [ui] tests/ui/linkage-attr/link-attr-validation-early.rs ... ok
test [ui] tests/ui/linkage-attr/framework.rs#link ... ok
test [ui] tests/ui/linkage-attr/framework.rs#both ... ok
test [ui] tests/ui/linkage-attr/link-attr-validation-late.rs ... ok
test [ui] tests/ui/linkage-attr/framework.rs#weak ... ok
test [ui] tests/ui/linkage-attr/link-self-contained-consistency.rs#many ... ok
test [ui] tests/ui/linkage-attr/linkage1.rs ... ignored, ignored when the operating system is macos
test [ui] tests/ui/linkage-attr/linkage2.rs ... ok
test [ui] tests/ui/linkage-attr/linkage3.rs ... ok
---
test [ui] tests/ui/lint-group-forbid-always-trumps-cli.rs ... ok
test [ui] tests/ui/lint/anonymous-reexport.rs ... ok
test [ui] tests/ui/lint/bad-lint-cap.rs ... ok
test [ui] tests/ui/lint/bad-lint-cap2.rs ... ok
test [ui] tests/ui/linkage-attr/framework.rs#omit ... FAILED
test [ui] tests/ui/lint-unknown-lints-at-crate-level.rs ... ok
test [ui] tests/ui/linkage-attr/linkage-import.rs ... ok
test [ui] tests/ui/lint/clashing-extern-fn-recursion.rs ... ok
test [ui] tests/ui/lint/clashing-extern-fn-wasm.rs ... ok
---
test [ui] tests/ui/wrong-hashset-issue-42918.rs ... ok
failures:
---- [ui] tests/ui/linkage-attr/framework.rs#omit stdout ----
1 error: linking with `cc` failed: exit status: 1
2 |
3 = note: [linker command]
3 = note: [linker command]
- = note: ld: warning: search path '$TEST_BUILD_DIR/linkage-attr/framework.omit/auxiliary' not found
- ld: Undefined symbols:
- _CFRunLoopGetTypeID, referenced from:
+ = note: ld: warning: directory not found for option '-L$TEST_BUILD_DIR/linkage-attr/framework.omit/auxiliary'
+ Undefined symbols for architecture arm64:
+ "_CFRunLoopGetTypeID", referenced from:
7 framework::main::HASH in framework.framework.HASH-cgu.0.rcgu.o
+ ld: symbol(s) not found for architecture arm64
8 clang: error: linker command failed with exit code 1 (use -v to see invocation)
10
The actual stderr differed from the expected stderr.
The actual stderr differed from the expected stderr.
Actual stderr saved to /Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/ui/linkage-attr/framework.omit/framework.omit.stderr
To only update this specific test, also pass `--test-args linkage-attr/framework.rs`
error in revision `omit`: 1 errors occurred comparing output.
status: exit status: 1
command: RUSTC_ICE="0" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" "/Users/runner/work/rust/rust/tests/ui/linkage-attr/framework.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/Users/runner/.cargo" "--sysroot" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2" "--target=aarch64-apple-darwin" "--cfg" "omit" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/ui/linkage-attr/framework.omit" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/Users/runner/work/rust/rust/build/aarch64-apple-darwin/native/rust-test-helpers" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/ui/linkage-attr/framework.omit/auxiliary"
--- stderr -------------------------------
error: linking with `cc` failed: exit status: 1
|
|
= note: env -u IPHONEOS_DEPLOYMENT_TARGET -u TVOS_DEPLOYMENT_TARGET LC_ALL="C" PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/bin:/opt/homebrew/lib/ruby/gems/3.0.0/bin:/opt/homebrew/opt/[email protected]/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/runner/.cargo/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/bin:/bin:/usr/sbin:/sbin:/Users/runner/.dotnet/tools" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "arm64" "/var/folders/pt/pcptgk8n1jgfqqk0263cpblm0000gn/T/rustct7H1DX/symbols.o" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/ui/linkage-attr/framework.omit/framework.framework.17ab4582b218217d-cgu.0.rcgu.o" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/native/rust-test-helpers" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/ui/linkage-attr/framework.omit/auxiliary" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/lib" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/lib" "-lstd-44e70665c9772f1d" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-550a14a24d201f87.rlib" "-lSystem" "-lc" "-lm" "-L" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/ui/linkage-attr/framework.omit/framework" "-Wl,-dead_strip" "-nodefaultlibs" "-Wl,-rpath,@loader_path/../../../../stage2/lib/rustlib/aarch64-apple-darwin/lib"
= note: ld: warning: directory not found for option '-L/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/ui/linkage-attr/framework.omit/auxiliary'
Undefined symbols for architecture arm64:
"_CFRunLoopGetTypeID", referenced from:
framework::main::h8acad2a093599f0d in framework.framework.17ab4582b218217d-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
------------------------------------------
failures:
[ui] tests/ui/linkage-attr/framework.rs#omit
test result: FAILED. 15746 passed; 1 failed; 217 ignored; 0 measured; 0 filtered out; finished in 224.56s
Build completed unsuccessfully in 0:18:33
Some tests failed in compiletest suite=ui mode=ui host=aarch64-apple-darwin target=aarch64-apple-darwin
:broken_heart: Test failed - checks-actions
The .stderr
test is kinda flaky, since the error output of the linker changes between Xcode versions. I've tried to make it a bit more robust now (tested with Xcode 13.4.1, Xcode 14.3.1 and Xcode 15.0.1), but let me know if you'd rather just have me exclude that part of the test altogether.
Sounds good enough, thanks.
@bors retry
Seems like bors didn't pick this up for some reason?
@bors retry
EDIT: Hmm, that didn't work, maybe someone else can retry?
@madsmtm: :key: Insufficient privileges: not in try users
The job x86_64-gnu-llvm-16
failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_3edac0d6-c7c5-4b6e-948d-43aa6d7641e1
GITHUB_EVENT_NAME=pull_request
GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=macos-weak-linking-test
GITHUB_JOB=pr
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_3edac0d6-c7c5-4b6e-948d-43aa6d7641e1
GITHUB_REF=refs/pull/118644/merge
GITHUB_REF_NAME=118644/merge
GITHUB_REF_PROTECTED=false
---
#12 writing image sha256:c580d5b14b1b36d1173be0499c6bc1969813603cfaff83584c2c5c2114b573dc done
#12 naming to docker.io/library/rust-ci done
#12 DONE 10.0s
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-16]
##[group]Clock drift check
local time: Sat Feb 17 01:37:33 UTC 2024
network time: Sat, 17 Feb 2024 01:37:33 GMT
network time: Sat, 17 Feb 2024 01:37:33 GMT
##[endgroup]
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-16', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'build.optimized-compiler-builtins', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-16/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id := 99999999
---
Compiling compiletest v0.0.0 (/checkout/src/tools/compiletest)
Finished release [optimized] target(s) in 13.67s
##[endgroup]
##[group]Testing stage2 compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu)
error: detected legacy-style directives in ui test: /checkout/tests/ui/linkage-attr/framework.rs:3, please use `ui_test`-style directives `//@` instead:Some(
None,
None,
"revisions: omit link weak both",
)
)
errors encountered during EarlyProps parsing: /checkout/tests/ui/linkage-attr/framework.rs
errors encountered during EarlyProps parsing
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:11:49
local time: Sat Feb 17 01:50:00 UTC 2024
Ping @b-naber, could you retry bors?
:umbrella: The latest upstream changes (presumably #121370) made this pull request unmergeable. Please resolve the merge conflicts.
@rustbot ready
#120690 r? compiler
@bors r+ rollup=iffy
:pushpin: Commit 98b0769555b9d4397de435756e81e3b5ae79baa5 has been approved by compiler-errors
It is now in the queue for this repository.
:hourglass: Testing commit 98b0769555b9d4397de435756e81e3b5ae79baa5 with merge 9af0410c24674516baef6a9e0acb818efb60acb3...
The job x86_64-gnu-llvm-18
failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
[TIMING] core::build_steps::tool::ToolBuild { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu }, target: x86_64-unknown-linux-gnu, tool: "compiletest", path: "src/tools/compiletest", mode: ToolStd, source_type: InTree, extra_features: [], allow_features: "test" } -- 18.677
[TIMING] core::build_steps::tool::Compiletest { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu }, target: x86_64-unknown-linux-gnu } -- 0.019
[TIMING] core::build_steps::test::RemoteCopyLibs { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu }, target: x86_64-unknown-linux-gnu } -- 0.000
##[group]Testing stage1 compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu)
error: detected unknown compiletest test directive `compare-output-lines-by-subset` in /checkout/tests/ui/linkage-attr/framework.rs:10
errors encountered during EarlyProps parsing: /checkout/tests/ui/linkage-attr/framework.rs
errors encountered during EarlyProps parsing
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:06:59
local time: Tue Mar 12 21:47:23 UTC 2024
:broken_heart: Test failed - checks-actions
The compare-output-lines-by-subset
directive is used rarely enough that it wasn't added to the known directive names, I've added it now.
@bors r+
:pushpin: Commit 47cab49fa70b1c1a6c95b12ed2f2beb632d80c7a has been approved by compiler-errors
It is now in the queue for this repository.
:hourglass: Testing commit 47cab49fa70b1c1a6c95b12ed2f2beb632d80c7a with merge 23fb07988ee6918cea84c74457c20df615e4278e...
The job x86_64-apple-2
failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
SCRIPT=./x.py --stage 2 test tests/ui tests/rustdoc tests/run-make-fulldeps
SELECT_XCODE=/Applications/Xcode_14.3.1.app
SHELL=/bin/bash
SHLVL=3
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.UYJQzDqPqO/Listeners
STATS_EXTP=https://provjobdsettingscdn.blob.core.windows.net/settings/provjobdsettings-0.5.154/provjobd.data
STATS_RDCL=true
STATS_TIS=mining
STATS_TRP=true
---
diff of stderr:
1 error: linking with `cc` 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)
The actual stderr differed from the expected stderr.
Actual stderr saved to /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/linkage-attr/framework.omit/framework.omit.stderr
Actual stderr saved to /Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/linkage-attr/framework.omit/framework.omit.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args linkage-attr/framework.rs`
error in revision `omit`: 1 errors occurred comparing output.
status: exit status: 1
command: RUSTC_ICE="0" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/bin/rustc" "/Users/runner/work/rust/rust/tests/ui/linkage-attr/framework.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/Users/runner/.cargo" "--sysroot" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2" "--target=x86_64-apple-darwin" "--cfg" "omit" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/linkage-attr/framework.omit" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/native/rust-test-helpers" "-L" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/linkage-attr/framework.omit/auxiliary"
--- stderr -------------------------------
error: linking with `cc` failed: exit status: 1
|
|
= note: env -u IPHONEOS_DEPLOYMENT_TARGET -u TVOS_DEPLOYMENT_TARGET LC_ALL="C" PATH="/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/bin:/usr/local/lib/ruby/gems/3.0.0/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/pipx_bin:/Users/runner/.cargo/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/bin:/bin:/usr/sbin:/sbin:/Users/runner/.dotnet/tools" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "x86_64" "-m64" "/var/folders/f8/xn9w26457_v2fc5qzhbrlyj00000gn/T/rustcrpSv5c/symbols.o" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/linkage-attr/framework.omit/framework.framework.17ab4582b218217d-cgu.0.rcgu.o" "-L" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/native/rust-test-helpers" "-L" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/linkage-attr/framework.omit/auxiliary" "-L" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib" "-lstd-75e6d868016a60bc" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-a06f8ab3c3faaa02.rlib" "-lSystem" "-lc" "-lm" "-L" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/linkage-attr/framework.omit/framework" "-Wl,-dead_strip" "-nodefaultlibs" "-Wl,-rpath,@loader_path/../../../../stage2/lib/rustlib/x86_64-apple-darwin/lib"
= note: ld: warning: directory not found for option '-L/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/linkage-attr/framework.omit/auxiliary'
Undefined symbols for architecture x86_64:
"_CFRunLoopGetTypeID", referenced from:
framework::main::hf2ec8ec5673c6fdc in framework.framework.17ab4582b218217d-cgu.0.rcgu.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to 1 previous error
------------------------------------------
:broken_heart: Test failed - checks-actions