|
21 | 21 | // Tracking Issue: https://github.com/rust-lang/rust/issues/129080
|
22 | 22 |
|
23 | 23 | use run_make_support::{
|
24 |
| - bin_name, cwd, diff, is_darwin, is_windows, rfs, run_in_tmpdir, rust_lib_name, rustc, |
| 24 | + bin_name, cwd, diff, is_darwin, is_windows, regex, rfs, run_in_tmpdir, rust_lib_name, rustc, |
25 | 25 | };
|
26 | 26 |
|
27 | 27 | fn main() {
|
@@ -117,7 +117,34 @@ fn smoke_test(flag: Option<SmokeFlag>) {
|
117 | 117 | .input("reproducible-build.rs")
|
118 | 118 | .linker(&cwd().join(bin_name("linker")).display().to_string())
|
119 | 119 | .run();
|
120 |
| - diff().actual_file("linker-arguments1").expected_file("linker-arguments2").run(); |
| 120 | + |
| 121 | + #[cfg(not(target_os = "aix"))] |
| 122 | + { |
| 123 | + diff().actual_file("linker-arguments1").expected_file("linker-arguments2").run(); |
| 124 | + } |
| 125 | + #[cfg(target_os = "aix")] |
| 126 | + { |
| 127 | + // The AIX link command includes an additional argument |
| 128 | + // that specifies the file containing exported symbols, e.g., |
| 129 | + // -bE:/tmp/rustcO6hxkY/list.exp. In this example, the part of the |
| 130 | + // directory name "rustcO6hxkY" is randomly generated to ensure that |
| 131 | + // different linking processes do not collide. For the purpose |
| 132 | + // of comparing link arguments, the randomly generated part is |
| 133 | + // replaced with a placeholder. |
| 134 | + let content1 = |
| 135 | + std::fs::read_to_string("linker-arguments1").expect("Failed to read file"); |
| 136 | + let content2 = |
| 137 | + std::fs::read_to_string("linker-arguments2").expect("Failed to read file"); |
| 138 | + |
| 139 | + // Define the regex for the directory name containing the random substring. |
| 140 | + let re = regex::Regex::new(r"rustc[a-zA-Z0-9]{6}/list\.exp").expect("Invalid regex"); |
| 141 | + |
| 142 | + // Compare link commands with random strings replaced by placeholders. |
| 143 | + assert!( |
| 144 | + re.replace_all(&content1, "rustcXXXXXX/list.exp").to_string() |
| 145 | + == re.replace_all(&content2, "rustcXXXXXX/list.exp").to_string() |
| 146 | + ); |
| 147 | + } |
121 | 148 | });
|
122 | 149 | }
|
123 | 150 |
|
@@ -207,7 +234,21 @@ fn diff_dir_test(crate_type: CrateType, remap_type: RemapType) {
|
207 | 234 | std::env::set_current_dir(&base_dir).unwrap();
|
208 | 235 | match crate_type {
|
209 | 236 | CrateType::Bin => {
|
210 |
| - assert!(rfs::read(bin_name("reproducible-build")) == rfs::read(bin_name("foo"))); |
| 237 | + #[cfg(not(target_os = "aix"))] |
| 238 | + { |
| 239 | + assert!( |
| 240 | + rfs::read(bin_name("reproducible-build")) == rfs::read(bin_name("foo")) |
| 241 | + ); |
| 242 | + } |
| 243 | + #[cfg(target_os = "aix")] |
| 244 | + { |
| 245 | + // At the 4th-byte offset, the AIX XCOFF file header defines a |
| 246 | + // 4-byte timestamp. Nullify the timestamp before performing a |
| 247 | + // binary comparison. |
| 248 | + let mut file1 = rfs::read(bin_name("reproducible-build")); |
| 249 | + let mut file2 = rfs::read(bin_name("foo")); |
| 250 | + assert!(file1[4..8].fill(0x00) == file2[4..8].fill(0x00)); |
| 251 | + }; |
211 | 252 | }
|
212 | 253 | CrateType::Rlib => {
|
213 | 254 | assert!(
|
|
0 commit comments