|
9 | 9 | // the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all |
10 | 10 | // code runs in the same environment, no process separation is supported. |
11 | 11 |
|
12 | | -use crate::spec::{base, LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions}; |
| 12 | +use crate::spec::{ |
| 13 | + base, LinkerFlavor, Lld, MaybeLazy, PanicStrategy, StackProbeType, TargetOptions, |
| 14 | +}; |
13 | 15 |
|
14 | 16 | pub fn opts() -> TargetOptions { |
15 | 17 | let mut base = base::msvc::opts(); |
16 | 18 |
|
17 | | - base.add_pre_link_args( |
18 | | - LinkerFlavor::Msvc(Lld::No), |
19 | | - &[ |
20 | | - // Non-standard subsystems have no default entry-point in PE+ files. We have to define |
21 | | - // one. "efi_main" seems to be a common choice amongst other implementations and the |
22 | | - // spec. |
23 | | - "/entry:efi_main", |
24 | | - // COFF images have a "Subsystem" field in their header, which defines what kind of |
25 | | - // program it is. UEFI has 3 fields reserved, which are EFI_APPLICATION, |
26 | | - // EFI_BOOT_SERVICE_DRIVER, and EFI_RUNTIME_DRIVER. We default to EFI_APPLICATION, |
27 | | - // which is very likely the most common option. Individual projects can override this |
28 | | - // with custom linker flags. |
29 | | - // The subsystem-type only has minor effects on the application. It defines the memory |
30 | | - // regions the application is loaded into (runtime-drivers need to be put into |
31 | | - // reserved areas), as well as whether a return from the entry-point is treated as |
32 | | - // exit (default for applications). |
33 | | - "/subsystem:efi_application", |
34 | | - ], |
35 | | - ); |
| 19 | + base.pre_link_args = MaybeLazy::lazy(|| { |
| 20 | + TargetOptions::link_args( |
| 21 | + LinkerFlavor::Msvc(Lld::No), |
| 22 | + &[ |
| 23 | + // Non-standard subsystems have no default entry-point in PE+ files. We have to define |
| 24 | + // one. "efi_main" seems to be a common choice amongst other implementations and the |
| 25 | + // spec. |
| 26 | + "/entry:efi_main", |
| 27 | + // COFF images have a "Subsystem" field in their header, which defines what kind of |
| 28 | + // program it is. UEFI has 3 fields reserved, which are EFI_APPLICATION, |
| 29 | + // EFI_BOOT_SERVICE_DRIVER, and EFI_RUNTIME_DRIVER. We default to EFI_APPLICATION, |
| 30 | + // which is very likely the most common option. Individual projects can override this |
| 31 | + // with custom linker flags. |
| 32 | + // The subsystem-type only has minor effects on the application. It defines the memory |
| 33 | + // regions the application is loaded into (runtime-drivers need to be put into |
| 34 | + // reserved areas), as well as whether a return from the entry-point is treated as |
| 35 | + // exit (default for applications). |
| 36 | + "/subsystem:efi_application", |
| 37 | + ], |
| 38 | + ) |
| 39 | + }); |
36 | 40 |
|
37 | 41 | TargetOptions { |
38 | 42 | os: "uefi".into(), |
|
0 commit comments