Hi Cran, You know to support X64 Microsoft variable argument (VA) ABI, we need two parts work together in edk2:
First is to the define "DEFIAPI=__attribute__((ms_abi)) in CC_FLAGS. Second is to use below __builtin_ms_va_* builtins as the VA macro. __builtin_ms_va_list ap; __builtin_ms_va_start (ap, n); __builtin_ms_va_end (ap); Only set -mabi=ms cannot really work. See the GCC example in below link. As Andrew mentioned, we wish GCC or LLVM can natively support EFI/Windows ABIs, and then we don't need use special builtins and macro any longer. This request has been raised to GCC for ~5 years, see below link, but we has not convince GCC guys to implement it yet... https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50818 Steven Shi Intel\SSG\STO\UEFI Firmware Tel: +86 021-61166522 iNet: 821-6522 > -----Original Message----- > From: af...@apple.com [mailto:af...@apple.com] > Sent: Wednesday, June 29, 2016 10:22 AM > To: Gao, Liming <liming....@intel.com> > Cc: Bruce Cran <br...@cran.org.uk>; Shi, Steven <steven....@intel.com>; > edk2-devel@lists.01.org; Kinney, Michael D <michael.d.kin...@intel.com> > Subject: Re: [edk2] [PATCH 0/7] Introduce three new toolchains in edk2 > > > > On Jun 28, 2016, at 7:09 PM, Gao, Liming > > <liming....@intel.com<mailto:liming....@intel.com>> wrote: > > > > Bruce: > > Yes. We add EFIAPI in such function, and define "- > DEFIAPI=__attribute__((ms_abi))" in GCC CC_FLAGS. > > > > I don't know how the version of clang used was constructed, but clang is > inherently a cross compiler and it can easily support multiple ABIs (System V > and X64). It comes down to how it was constructed. > > Basically a flag like -arch x86_64 will be the system default ABI, but you can > build other stuff for the architecture via -target x86_64-pc-win32-macho. So > for example you might be able to enable -target x86_64-pc-win32-efl. So > have the native EFI/Windows ABI, but make an ELF with dwarf for the > debugger. > > If you don't want to use the __attribute__((ms_abi)) then you might be able > to get that support in upstream. There might already be some support for > cross building Windows Apps on Linux that could be leveraged. You just need > the correctly ABI, and a source level debugging scheme that works on your > build target. > > Thanks, > > Andrew Fish > > > Thanks > > Liming > >> -----Original Message----- > >> From: Bruce Cran [mailto:br...@cran.org.uk] > >> Sent: Wednesday, June 29, 2016 6:45 AM > >> To: Shi, Steven <steven....@intel.com<mailto:steven....@intel.com>>; > >> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>; Gao, > >> Liming <liming....@intel.com<mailto:liming....@intel.com>> > >> Cc: Kinney, Michael D > >> <michael.d.kin...@intel.com<mailto:michael.d.kin...@intel.com>>; > >> af...@apple.com<mailto:af...@apple.com> > >> Subject: Re: [edk2] [PATCH 0/7] Introduce three new toolchains in edk2 > >> > >> On 6/28/16 9:18 AM, Shi, Steven wrote: > >>> Introduce three new toolchains in edk2. The first two ones support Link > >> Time Optimization (LTO) for aggressive code size improvement and the > third > >> one is for static analysis. > >>> > >>> CLANG38 : Enable LLVM Link Time Optimization (LTO) and code size > >> optimization flag (-Os) by default for aggressive code size improvement. > >>> X64 code is small code model + position independent code (PIE). > >> > >> One problem I've run into trying to build with clang is that we have a > >> set of files which are the same across platforms, and they use varargs. > >> > >> With gcc, we can just set -mabi=ms and be done with it, but it appears > >> clang doesn't have that option. Do you know of a way to set the default > >> ABI with clang, or would we need to add an __attribute__((ms_abi)) > >> anywhere we need to use varargs? > >> > >> -- > >> Bruce Cran > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org> > > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel