@@ -103,12 +103,39 @@ fn compile_with_driver( |
| 103 | 103 | output: &Path, |
| 104 | 104 | extra_envs: &[(&str, &Path)], |
| 105 | 105 | context: &str, |
| 106 | +) -> Output { |
| 107 | + compile_with_driver_args(driver, source, output, extra_envs, &[], context) |
| 108 | +} |
| 109 | + |
| 110 | +fn compile_with_driver_args( |
| 111 | + driver: &Path, |
| 112 | + source: &Path, |
| 113 | + output: &Path, |
| 114 | + extra_envs: &[(&str, &Path)], |
| 115 | + extra_args: &[&str], |
| 116 | + context: &str, |
| 117 | +) -> Output { |
| 118 | + compile_with_driver_args_and_vars(driver, source, output, extra_envs, &[], extra_args, context) |
| 119 | +} |
| 120 | + |
| 121 | +fn compile_with_driver_args_and_vars( |
| 122 | + driver: &Path, |
| 123 | + source: &Path, |
| 124 | + output: &Path, |
| 125 | + extra_envs: &[(&str, &Path)], |
| 126 | + extra_vars: &[(&str, &str)], |
| 127 | + extra_args: &[&str], |
| 128 | + context: &str, |
| 106 | 129 | ) -> Output { |
| 107 | 130 | let mut cmd = Command::new(driver); |
| 108 | 131 | for (name, value) in extra_envs { |
| 109 | 132 | cmd.env(name, value); |
| 110 | 133 | } |
| 111 | | - run_command(cmd.arg(source).arg("-o").arg(output), context) |
| 134 | + for (name, value) in extra_vars { |
| 135 | + cmd.env(name, value); |
| 136 | + } |
| 137 | + cmd.arg(source).arg("-o").arg(output).args(extra_args); |
| 138 | + run_command(&mut cmd, context) |
| 112 | 139 | } |
| 113 | 140 | |
| 114 | 141 | #[test] |
@@ -278,6 +305,54 @@ fn hello_world_runs_through_driver_with_standalone_tool_overrides() { |
| 278 | 305 | assert_eq!(standalone_stdout, " Hello, World!\n"); |
| 279 | 306 | } |
| 280 | 307 | |
| 308 | +#[test] |
| 309 | +fn hello_world_runs_through_driver_with_afs_ld_enable_flag() { |
| 310 | + let Some(armfortas) = binary("armfortas") else { |
| 311 | + eprintln!("skipping: armfortas binary not built"); |
| 312 | + return; |
| 313 | + }; |
| 314 | + let Some(afs_as) = binary("afs-as") else { |
| 315 | + eprintln!("skipping: afs-as binary not built"); |
| 316 | + return; |
| 317 | + }; |
| 318 | + let Some(_afs_ld) = binary("afs-ld") else { |
| 319 | + eprintln!("skipping: afs-ld binary not built"); |
| 320 | + return; |
| 321 | + }; |
| 322 | + let Some(runtime) = runtime_archive() else { |
| 323 | + eprintln!("skipping: libarmfortas_rt.a not built"); |
| 324 | + return; |
| 325 | + }; |
| 326 | + let Some(libsystem) = libsystem_tbd() else { |
| 327 | + eprintln!("skipping: libSystem.tbd not found"); |
| 328 | + return; |
| 329 | + }; |
| 330 | + |
| 331 | + let source = workspace_root().join("test_programs/hello.f90"); |
| 332 | + assert!(source.exists(), "hello.f90 missing at {}", source.display()); |
| 333 | + |
| 334 | + let dir = unique_dir("driver_afs_ld_flag_hello"); |
| 335 | + let standalone_bin = dir.join("hello-driver-afs-ld-flag"); |
| 336 | + |
| 337 | + let standalone_compile = compile_with_driver_args_and_vars( |
| 338 | + &armfortas, |
| 339 | + &source, |
| 340 | + &standalone_bin, |
| 341 | + &[ |
| 342 | + ("AFS_AS_PATH", &afs_as), |
| 343 | + ("AFS_RUNTIME_PATH", &runtime), |
| 344 | + ("AFS_LIBSYSTEM_TBD", &libsystem), |
| 345 | + ], |
| 346 | + &[("AFS_LD", "1")], |
| 347 | + &["-L", "/tmp", "-rpath", "/tmp"], |
| 348 | + "AFS_LD=1 armfortas compile", |
| 349 | + ); |
| 350 | + assert_success(&standalone_compile, "AFS_LD=1 armfortas compile"); |
| 351 | + let standalone_run = run_binary(&standalone_bin, "AFS_LD=1 armfortas run"); |
| 352 | + let standalone_stdout = String::from_utf8_lossy(&standalone_run.stdout); |
| 353 | + assert_eq!(standalone_stdout, " Hello, World!\n"); |
| 354 | +} |
| 355 | + |
| 281 | 356 | #[test] |
| 282 | 357 | fn hello_world_compiles_to_object_with_standalone_assembler_override() { |
| 283 | 358 | let Some(armfortas) = binary("armfortas") else { |