@@ -13,39 +13,37 @@ use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOption
1313use std:: default:: Default ;
1414
1515pub fn opts ( ) -> TargetOptions {
16+ let pre_link_args_msvc = vec ! [
17+ // Suppress the verbose logo and authorship debugging output, which would needlessly
18+ // clog any log files.
19+ "/NOLOGO" . to_string( ) ,
20+ // UEFI is fully compatible to non-executable data pages. Tell the compiler that
21+ // non-code sections can be marked as non-executable, including stack pages. In fact,
22+ // firmware might enforce this, so we better let the linker know about this, so it
23+ // will fail if the compiler ever tries placing code on the stack (e.g., trampoline
24+ // constructs and alike).
25+ "/NXCOMPAT" . to_string( ) ,
26+ // There is no runtime for UEFI targets, prevent them from being linked. UEFI targets
27+ // must be freestanding.
28+ "/nodefaultlib" . to_string( ) ,
29+ // Non-standard subsystems have no default entry-point in PE+ files. We have to define
30+ // one. "efi_main" seems to be a common choice amongst other implementations and the
31+ // spec.
32+ "/entry:efi_main" . to_string( ) ,
33+ // COFF images have a "Subsystem" field in their header, which defines what kind of
34+ // program it is. UEFI has 3 fields reserved, which are EFI_APPLICATION,
35+ // EFI_BOOT_SERVICE_DRIVER, and EFI_RUNTIME_DRIVER. We default to EFI_APPLICATION,
36+ // which is very likely the most common option. Individual projects can override this
37+ // with custom linker flags.
38+ // The subsystem-type only has minor effects on the application. It defines the memory
39+ // regions the application is loaded into (runtime-drivers need to be put into
40+ // reserved areas), as well as whether a return from the entry-point is treated as
41+ // exit (default for applications).
42+ "/subsystem:efi_application" . to_string( ) ,
43+ ] ;
1644 let mut pre_link_args = LinkArgs :: new ( ) ;
17-
18- pre_link_args. insert (
19- LinkerFlavor :: Lld ( LldFlavor :: Link ) ,
20- vec ! [
21- // Suppress the verbose logo and authorship debugging output, which would needlessly
22- // clog any log files.
23- "/NOLOGO" . to_string( ) ,
24- // UEFI is fully compatible to non-executable data pages. Tell the compiler that
25- // non-code sections can be marked as non-executable, including stack pages. In fact,
26- // firmware might enforce this, so we better let the linker know about this, so it
27- // will fail if the compiler ever tries placing code on the stack (e.g., trampoline
28- // constructs and alike).
29- "/NXCOMPAT" . to_string( ) ,
30- // There is no runtime for UEFI targets, prevent them from being linked. UEFI targets
31- // must be freestanding.
32- "/nodefaultlib" . to_string( ) ,
33- // Non-standard subsystems have no default entry-point in PE+ files. We have to define
34- // one. "efi_main" seems to be a common choice amongst other implementations and the
35- // spec.
36- "/entry:efi_main" . to_string( ) ,
37- // COFF images have a "Subsystem" field in their header, which defines what kind of
38- // program it is. UEFI has 3 fields reserved, which are EFI_APPLICATION,
39- // EFI_BOOT_SERVICE_DRIVER, and EFI_RUNTIME_DRIVER. We default to EFI_APPLICATION,
40- // which is very likely the most common option. Individual projects can override this
41- // with custom linker flags.
42- // The subsystem-type only has minor effects on the application. It defines the memory
43- // regions the application is loaded into (runtime-drivers need to be put into
44- // reserved areas), as well as whether a return from the entry-point is treated as
45- // exit (default for applications).
46- "/subsystem:efi_application" . to_string( ) ,
47- ] ,
48- ) ;
45+ pre_link_args. insert ( LinkerFlavor :: Msvc , pre_link_args_msvc. clone ( ) ) ;
46+ pre_link_args. insert ( LinkerFlavor :: Lld ( LldFlavor :: Link ) , pre_link_args_msvc) ;
4947
5048 TargetOptions {
5149 dynamic_linking : false ,
0 commit comments