|
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,40 @@ 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() |
| 124 | + .actual_file("linker-arguments1") |
| 125 | + .expected_file("linker-arguments2") |
| 126 | + .run(); |
| 127 | + } |
| 128 | + #[cfg(target_os = "aix")] |
| 129 | + { |
| 130 | + // The AIX link command includes an additional argument |
| 131 | + // that specifies the file containing exported symbols, e.g., |
| 132 | + // -bE:/tmp/rustcO6hxkY/list.exp. In this example, the part of the |
| 133 | + // directory name "rustcO6hxkY" is randomly generated to ensure that |
| 134 | + // different linking processes do not collide. For the purpose |
| 135 | + // of comparing link arguments, the randomly generated part is |
| 136 | + // replaced with a placeholder. |
| 137 | + let content1 = |
| 138 | + std::fs::read_to_string("linker-arguments1").expect("Failed to read file"); |
| 139 | + let content2 = |
| 140 | + std::fs::read_to_string("linker-arguments2").expect("Failed to read file"); |
| 141 | + |
| 142 | + // Define the regex for the directory name containing the random substring. |
| 143 | + let re = regex::Regex::new(r"rustc[a-zA-Z0-9]{6}/list\.exp").expect("Invalid regex"); |
| 144 | + |
| 145 | + // Compare link commands with random strings replaced by placeholders. |
| 146 | + assert!( |
| 147 | + re.replace_all(&content1, "rustcXXXXXX/list.exp") |
| 148 | + .to_string() |
| 149 | + == re |
| 150 | + .replace_all(&content2, "rustcXXXXXX/list.exp") |
| 151 | + .to_string() |
| 152 | + ); |
| 153 | + } |
121 | 154 | }); |
122 | 155 | } |
123 | 156 |
|
@@ -207,7 +240,21 @@ fn diff_dir_test(crate_type: CrateType, remap_type: RemapType) { |
207 | 240 | std::env::set_current_dir(&base_dir).unwrap(); |
208 | 241 | match crate_type { |
209 | 242 | CrateType::Bin => { |
210 | | - assert!(rfs::read(bin_name("reproducible-build")) == rfs::read(bin_name("foo"))); |
| 243 | + #[cfg(not(target_os = "aix"))] |
| 244 | + { |
| 245 | + assert!( |
| 246 | + rfs::read(bin_name("reproducible-build")) == rfs::read(bin_name("foo")) |
| 247 | + ); |
| 248 | + } |
| 249 | + #[cfg(target_os = "aix")] |
| 250 | + { |
| 251 | + // At the 4th-byte offset, the AIX XCOFF file header defines a |
| 252 | + // 4-byte timestamp. Nullify the timestamp before performing a |
| 253 | + // binary comparison. |
| 254 | + let mut file1 = rfs::read(bin_name("reproducible-build")); |
| 255 | + let mut file2 = rfs::read(bin_name("foo")); |
| 256 | + assert!(file1[4..8].fill(0x00) == file2[4..8].fill(0x00)); |
| 257 | + }; |
211 | 258 | } |
212 | 259 | CrateType::Rlib => { |
213 | 260 | assert!( |
|
0 commit comments