-
-
Notifications
You must be signed in to change notification settings - Fork 134
feat: Wire up LLD tests via wild-linker/lld-tests submodule #2399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deepakshirkem
wants to merge
1
commit into
wild-linker:main
Choose a base branch
from
deepakshirkem:feat/lld-vendor-batch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| [skipped_groups.lld_specific] | ||
| reason = "Test exercises an lld-specific flag or behavior not applicable to Wild" | ||
| tests = ["x86-64-branch-to-branch.s"] | ||
|
|
||
| [skipped_groups.requires_newer_lld] | ||
| reason = "Test requires a newer lld/relocation type than our local llvm-mc supports" | ||
| tests = [ | ||
| "x86-64-gotpc-no-relax-err.s", | ||
| "x86-64-gotpc-relax.s", | ||
| "x86-64-gotpc-relax-nopic.s", | ||
| "x86-64-plt-high-addr.s", | ||
| "x86-64-tlsdesc-gd.s", | ||
| "x86-64-tls-ie-err.s", | ||
| "x86-64-tls-ie-local.s", | ||
| ] | ||
|
|
||
| [skipped_groups.design_differences] | ||
| reason = "Wild intentionally differs from lld's PLT/GOT layout and relocation binding strategy (immediate binding vs lazy binding)" | ||
| tests = [ | ||
| "x86-64-tlsdesc-ld.s", | ||
| "x86-64-tlsdesc-gd-mixed.s", | ||
| "x86-64-reloc-gotoff64.s", | ||
| "x86-64-reloc-gotpc64.s", | ||
| "x86-64-reloc-pltoff64.s", | ||
| "x86-64-static-tls-model.s", | ||
| "x86-64-combined-dynrel.s", | ||
| "x86-64-got-plt-header.s", | ||
| "x86-64-plt.s", | ||
| "x86-64-rela.s", | ||
| "x86-64-tls-gd-local.s", | ||
| "x86-64-tls-ld-local.s", | ||
| "x86-64-zrel-zrela.s", | ||
| ] | ||
|
|
||
| [skipped_groups.error_message_wording] | ||
| reason = "Wild correctly errors but with different message wording than lld" | ||
| tests = [ | ||
| "x86-64-reloc-tpoff32-error.s", | ||
| "x86-64-pc32-overflow-large.s", | ||
| "x86-64-reloc-error2.s", | ||
| "x86-64-reloc-debug-overflow.s", | ||
| "x86-64-reloc-range-debug-loc.s", | ||
| "x86-64-tls-ie-opt-local.s", | ||
| ] | ||
|
|
||
| [skipped_groups.gc_sections_behavior] | ||
| reason = "Test relies on lld's default --gc-sections behavior differing from Wild's" | ||
| tests = ["x86-64-reloc-error.s"] | ||
|
|
||
| [skipped_groups.noinhibit_exec_unsupported] | ||
| reason = "Test relies on --noinhibit-exec, which Wild does not support" | ||
| tests = ["x86-64-reloc-range.s", "x86-64-tls-le-undef.s"] | ||
|
|
||
| [skipped_groups.unsupported_features] | ||
| reason = "Feature not yet implemented in Wild" | ||
| tests = [ | ||
| "x86-64-feature-cet.s", | ||
| "x86-64-dyn-rel-error.s", | ||
| "x86-64-dyn-rel-error3.s", | ||
| "x86-64-dyn-rel-error5.s", | ||
| "x86-64-relax-got-abs.s", | ||
| "x86-64-reloc-size.s", | ||
| "x86-64-retpoline.s", | ||
| "x86-64-retpoline-linkerscript.s", | ||
| "x86-64-retpoline-znow.s", | ||
| "x86-64-retpoline-znow-linkerscript.s", | ||
| "x86-64-retpoline-znow-static-iplt.s", | ||
| "x86-64-section-layout.s", | ||
| "x86-64-split-stack-prologue-adjust-fail.s", | ||
| "x86-64-split-stack-prologue-adjust-shared.s", | ||
| "x86-64-split-stack-prologue-adjust-silent.s", | ||
| "x86-64-tls-gd-got.s", | ||
| "x86-64-tls-opt-noplt.s", | ||
| "x86-64-tls-pie.s", | ||
| ] | ||
|
|
||
| [skipped_groups.missing_flag_support] | ||
| reason = "Wild does not yet recognize the --image-base flag used by this test" | ||
| tests = ["x86-64-reloc-32.s"] | ||
|
|
||
| [skipped_groups.previously_believed_working] | ||
| reason = "Manual testing previously suggested Wild handles this correctly, but it fails under this harness's exact FileCheck comparison. Needs investigation to reconcile: possible regression, an imprecise manual check, or a local tooling gap (e.g. objdump missing x86_64 target support)." | ||
| tests = [ | ||
| "x86-64-tls-le-align.s", | ||
| "x86-64-tls-ie.s", | ||
| "x86-64-tls-gdie.s", | ||
| "x86-64-reloc-8-16.s", | ||
| "x86-64-tls-ld-preemptable.s", | ||
| "x86-64-relax-offset.s", | ||
| "x86-64-gotpc-relax-too-far.s", | ||
| "x86-64-gotpc-relax-und-dso.s", | ||
| "x86-64-tls-dynamic.s", | ||
| "x86-64-reloc-pc32.s", | ||
| "x86-64-split-stack-prologue-adjust-success.s", | ||
| ] | ||
|
|
||
| [skipped_groups.untriaged] | ||
| reason = "Not yet manually triaged against Wild" | ||
| tests = [ | ||
| "x86-64-gotpc-offset.s", | ||
| "x86-64-gotpc-relax-too-far-relr.s", | ||
| "x86-64-relax-jump-tables.s", | ||
| "x86-64-reloc-size-shared.s", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,11 +7,37 @@ | |
| use crate::Result; | ||
| use libtest_mimic::Failed; | ||
| use libtest_mimic::Trial; | ||
| use serde::Deserialize; | ||
| use std::collections::HashMap; | ||
| use std::fs; | ||
| use std::path::Path; | ||
| use std::process::Command; | ||
| use std::sync::OnceLock; | ||
|
|
||
| #[derive(Deserialize)] | ||
| struct Config { | ||
| skipped_groups: HashMap<String, SkippedGroup>, | ||
| } | ||
|
|
||
| #[derive(Deserialize)] | ||
| struct SkippedGroup { | ||
| tests: Vec<String>, | ||
| } | ||
|
|
||
| static SKIP_TESTS_NAME: OnceLock<Option<Vec<String>>> = OnceLock::new(); | ||
|
|
||
| const PREFIX: &str = "external_test_suites/lld"; | ||
|
|
||
| /// Architecture prefixes used by LLD's test file naming convention | ||
| /// (e.g. `x86-64-pcrel.s`, `aarch64-abs16.s`). | ||
| const SUPPORTED_ARCH_PREFIXES: &[&str] = &["x86-64-"]; | ||
|
|
||
| fn is_supported_arch_test(file_name: &str) -> bool { | ||
| SUPPORTED_ARCH_PREFIXES | ||
| .iter() | ||
| .any(|prefix| file_name.starts_with(prefix)) | ||
| } | ||
|
|
||
| pub(crate) fn collect_tests(tests: &mut Vec<Trial>, filter: &crate::Filter) -> Result { | ||
| if filter.excludes(PREFIX) { | ||
| return Ok(()); | ||
|
|
@@ -21,23 +47,48 @@ pub(crate) fn collect_tests(tests: &mut Vec<Trial>, filter: &crate::Filter) -> R | |
| if !test_dir.exists() { | ||
| return Ok(()); | ||
| } | ||
|
|
||
| let dir = std::fs::read_dir(&test_dir)?; | ||
| for ent in dir { | ||
| let ent = ent?; | ||
| let path = ent.path(); | ||
| if path.extension().is_some_and(|ext| ext == "s") { | ||
| let file_name = | ||
| String::from_utf8_lossy(path.file_name().unwrap().as_encoded_bytes()).to_string(); | ||
|
|
||
| // Other architectures (aarch64, riscv64, ...) are left for a | ||
| // TODO. | ||
| if !is_supported_arch_test(&file_name) { | ||
| continue; | ||
| } | ||
|
|
||
| let name = format!("{PREFIX}/test/ELF/{file_name}"); | ||
| tests.push(Trial::test(name, move || { | ||
| run_lld_test(&path).map_err(|e| Failed::from(e.to_string())) | ||
| })); | ||
|
|
||
| if !should_skip_lld_test(&path) { | ||
| tests.push(Trial::test(name, move || { | ||
| run_lld_test(&path).map_err(|e| Failed::from(e.to_string())) | ||
| })); | ||
| } else { | ||
| tests.push(Trial::test(format!("{name}/expect_failure"), move || { | ||
| verify_skipped_lld_test_still_fails(&path) | ||
| .map_err(|e| Failed::from(e.to_string())) | ||
| })); | ||
| } | ||
| } | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn verify_skipped_lld_test_still_fails(test_file: &Path) -> Result { | ||
| if run_lld_test(test_file).is_ok() { | ||
| return Err(format!( | ||
| "Test `{}` is in the skip list but now passes. Should be removed from skip list.", | ||
| test_file.display() | ||
| ) | ||
| .into()); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn run_lld_test(test_file: &Path) -> Result { | ||
| let llvm_mc = find_tool("llvm-mc")?; | ||
| let filecheck = find_tool("FileCheck")?; | ||
|
|
@@ -97,9 +148,11 @@ fn extract_run_lines(content: &str) -> Vec<String> { | |
| } | ||
|
|
||
| fn substitute_vars(cmd: &str, test_file: &Path, tmpdir: &Path) -> String { | ||
| let dir = test_file.parent().unwrap().display().to_string(); | ||
| cmd.replace("%s", &test_file.display().to_string()) | ||
| .replace("%t", &tmpdir.join("test").display().to_string()) | ||
| .replace("%p", &test_file.parent().unwrap().display().to_string()) | ||
| .replace("%S", &dir) | ||
| .replace("%p", &dir) | ||
| } | ||
|
|
||
| fn substitute_tools(cmd: &str, llvm_mc: &str, filecheck: &str) -> String { | ||
|
|
@@ -128,3 +181,41 @@ fn execute_command(cmd: &str) -> Result { | |
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn load_skip_tests_config() -> &'static Option<Vec<String>> { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly here, it's a code that is not actually run. |
||
| SKIP_TESTS_NAME.get_or_init(|| { | ||
| let skip_tests_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| .join("tests") | ||
| .join("external_tests") | ||
| .join("lld_skip_tests.toml"); | ||
|
|
||
| fs::read_to_string(&skip_tests_path) | ||
| .map(|content| { | ||
| let config: Config = | ||
| toml::from_str(&content).expect("Failed to parse lld_skip_tests.toml"); | ||
|
|
||
| config | ||
| .skipped_groups | ||
| .into_values() | ||
| .flat_map(|group| group.tests) | ||
| .collect() | ||
| }) | ||
| .ok() | ||
| }) | ||
| } | ||
|
|
||
| fn should_skip_lld_test(path: &Path) -> bool { | ||
| let file_name = path | ||
| .file_name() | ||
| .expect("Must be a valid filename") | ||
| .to_str() | ||
| .expect("Expected valid string name"); | ||
|
|
||
| if crate::external_tests::should_not_ignore_tests("lld") { | ||
| return false; | ||
| } | ||
|
|
||
| load_skip_tests_config() | ||
| .as_ref() | ||
| .is_some_and(|skip_list| skip_list.contains(&file_name.to_string())) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a typo that I've been known to make myself, so it'd be good if we could avoid adding it here. I just did some experimentation, and it looks like we can skip typo checking specifically for the excluded test lists with something like this: