public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Andrew Fish" <afish@apple.com>
To: devel@edk2.groups.io, Liming Gao <liming.gao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [edk2-devel] [Patch 0/7] Add new CLANG8ELF tool chain for new LLVM/CLANG8
Date: Mon, 20 May 2019 20:36:46 -0700	[thread overview]
Message-ID: <ADDE9727-0E88-4B7F-BCDB-B933028A6018@apple.com> (raw)
In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E44E26D@SHSMSX104.ccr.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 7531 bytes --]



> On May 20, 2019, at 7:18 PM, Liming Gao <liming.gao@intel.com> wrote:
> 
> Andrew:
>   Thanks for your sharing. I would like the official LLVM tool chain instead of the customized version.
>  

Liming,

Hopefully all the bits are in place so you can cross compile for Linux on Windows, and Windows on Linux so you will not need a customer binary. If not that seems like something reasonable to ask for, bur remember some one is going to ask for tests. 

On thing to try is to get the default triple on Linux and try it Window, and get the default triple on Windows and try it on Linux. if you `clang -v` that should print out the default triple. From this writeup [1] some of the 4 fields in the triple can get skipped. You can then try to build the Windows triple on Linux etc. One of the good things about the edk2 is there is not a dependency on the include files or runtime so you just need to make the compiler/linker do the right thing. 

[1] https://clang.llvm.org/docs/CrossCompilation.html

Thanks,

Andrew Fish

>   I will investigate it more and go back. Now, I push this patch set into staging https://github.com/tianocore/edk2-staging/tree/llvm8 <https://github.com/tianocore/edk2-staging/tree/llvm8> for the evaluation.
>  
> Thanks
> Liming <>
>  <>From: afish@apple.com <mailto:afish@apple.com> [mailto:afish@apple.com <mailto:afish@apple.com>] 
> Sent: Tuesday, May 21, 2019 6:53 AM
> To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>; Gao, Liming <liming.gao@intel.com <mailto:liming.gao@intel.com>>
> Cc: Justen, Jordan L <jordan.l.justen@intel.com <mailto:jordan.l.justen@intel.com>>; Ard Biesheuvel <ard.biesheuvel@linaro.org <mailto:ard.biesheuvel@linaro.org>>
> Subject: Re: [edk2-devel] [Patch 0/7] Add new CLANG8ELF tool chain for new LLVM/CLANG8
>  
>  
> 
> 
> On May 20, 2019, at 6:47 AM, Liming Gao <liming.gao@intel.com <mailto:liming.gao@intel.com>> wrote:
>  
> Jordan:
> 
> 
> -----Original Message-----
> From: Justen, Jordan L
> Sent: Monday, May 20, 2019 4:15 AM
> To: Ard Biesheuvel <ard.biesheuvel@linaro.org <mailto:ard.biesheuvel@linaro.org>>; Gao, Liming <liming.gao@intel.com <mailto:liming.gao@intel.com>>; edk2-devel-groups-io <devel@edk2.groups.io <mailto:devel@edk2.groups.io>>
> Subject: Re: [edk2-devel] [Patch 0/7] Add new CLANG8ELF tool chain for new LLVM/CLANG8
> 
> On 2019-04-27 17:55:02, Liming Gao wrote:
> 
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org <mailto:ard.biesheuvel@linaro.org>]
> Sent: Saturday, April 27, 2019 12:33 AM
> 
> 
> This series confuses me. The existing CLANGxx toolchains already use
> GenFw and ELF to PE/COFF conversion, so the name CLANG8ELF is
> misleading.
> 
> LLVM/CLANG8.0 compiler supports to generate PE image or ELF image.
> This tool chain is to generate ELF image and be converted to PE
> image. I am investigating another tool chain with CLANG8.0 to
> directly generate PE image. To differentiate them, I use the tool
> chain name CLANG8ELF and CLANG8PE for them.
> 
> Assuming CLANG8ELF and CLANG8PE were functional, would both be needed?
> It kind of sounds like this a half-finished investigation.
> 
> One point is that they will generate the different debug format symbols (WinDBG or GDB).
> I have not done the full investigation to generate the different debug format symbols in single tool chain.
> 
>  
>  
> Liming,
>  
> I don't know the current answer but we moved over to using clang a while back on Mac so here are some general thoughts incase they help your investigation. 
>  
> We had to take a different approach for i386 vs x86_64.:
> 1) i386
> For i386 we used -arch i386 and compiler flags to produce the correct ABI. The thing about using -arch is the target triple defaults to your current machine, thus -arch i386 on a Mac is going to make a Mach-O object. if you use it one Linux it is going to make an ELF, on Windows a PE/COFF. To make this work we add mtoc to CCTOOLS this is a tool that converts Mach-O to PE/COFF. The PE/COFF contains a UUID for the Mach-O and the Mach-O dSYM (kind of like the PDB file) and that is what is used for debugging. You can even load the Mach-O directly into the debugger and do offline investigation of the image at its linked address. 
>  
> 2) x86_64
> Since the Mac uses the System V ABI we needed a cross compiler. Clang implements cross compilers via the Triple (this is the -target argument you pass to clang). We actually end up open sourcing a triple that did what we needed. 
>  
> For building on a Mac the triple is: -target x86_64-pc-win32-macho
>  
>  <arch><sub>-<vendor>-<sys>-<abi>
>  < x86_64 ><>-< pc     >-< win32 >-< macho >
>  
> Examples:
> arch = x86_64, i386, arm, thumb, mips, etc.
> sub = for ex. on ARM: v5, v6m, v7a, v7m, etc.
> vendor = pc, apple, nvidia, ibm, etc.
> sys = none, linux, win32, darwin, cuda, etc.
> abi = eabi, gnu, android, macho, elf, etc.
>  
> OK so they expanded the Triple to have 4 fields, so that is kind of naming fail, but they still seem to call it a triple. When we did the port "-DEFIAPI=__attribute__((ms_abi))" was not an option and that is why we ended up having to male our own triple. As far as I can tell __attribute__((ms_abi)) works correctly in the Xcode compiler. 
>  
> To make the debugging work we ended up defining a new CodeView signature [1] to the PE/COFF Debug Directory Entry. At this point the native lldb (llvm debugger) does not know how to load Mach-O DWARF from PE/COFF. We could teach it, but we have not really found a need as we ended up writing debugger scripts to load symbols and lldb can load the Mach-O image (our build system leaves them around) for offline debugging.
>  
> In terms of PDB vs DWARF generally the compiler emits the DWARF (or PDB) data at compile time and the linker just aggregates it together. I see a blog from last April [2] talking about LLVM PDB support and it ends with "Do I hear cross-compilation?". So you might have to compile from the start for PDB or DWARF. This seems to imply you are going to need a triple to invoke a cross compiler? Also you are going to need that triple present in the clang binary, so you might be able to make a custom version of clang that supports the triples you need, but that may not be in the official binary for clang. 
>  
> Converting ELF to PE/COFF is much more straight forward than converting the debugging information so that makes sense that it could just be the backend of the linker. 
>  
> I look forward to getting the results of your investigation.
>  
> [1] https://github.com/tianocore/edk2/blob/master/MdePkg/Include/IndustryStandard/PeImage.h#L647 <https://github.com/tianocore/edk2/blob/master/MdePkg/Include/IndustryStandard/PeImage.h#L647>
> [2] http://blog.llvm.org/2017/08/llvm-on-windows-now-supports-pdb-debug.html <http://blog.llvm.org/2017/08/llvm-on-windows-now-supports-pdb-debug.html>
>  
> Thanks,
>  
> Andrew Fish
>  
> I'm guessing that if CLANG8PE produces equal or better code, then it
> would be preferred.
> 
> Therefore, shouldn't we just finish the investigation, and add a
> single CLANG8 toolchain at the end? Or, maybe to reflect that it
> mostly uses the LLVM tool stack we could name it LLVM8.
> I also prefer single CLANG8 tool chain. I will collect more information and see whether it is possible. 
> Now, I would like to add this tool chain for the developer evaluation. Because I can't address all 
> comments now, I will remove this feature from Q2 stable tag. I will add it into edk2-staging first. 
> 
> 
> -Jordan
> 
>  
> 


[-- Attachment #2: Type: text/html, Size: 27142 bytes --]

  reply	other threads:[~2019-05-21  3:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-26 14:42 [Patch 0/7] Add new CLANG8ELF tool chain for new LLVM/CLANG8 Liming Gao
2019-04-26 14:42 ` [Patch 1/7] BaseTools: Add ClangBase.lds for CLANG8 tool chain with max-page-size Liming Gao
2019-04-26 14:42 ` [Patch 2/7] BaseTools GenFw: Support CLANG8ELF with conversion ELF to PE/COFF image Liming Gao
2019-04-26 14:42 ` [Patch 3/7] BaseTools: Update build_rule.template for ASLC rule with full C flags Liming Gao
2019-04-26 14:42 ` [Patch 4/7] BaseTools: Update build_rule to skip CLANG resource section generation Liming Gao
2019-04-26 14:42 ` [Patch 5/7] BaseTools: Update tools_def.template to directly refer to AutoGen.h Liming Gao
2019-04-26 14:42 ` [Patch 6/7] BaseTools: Add new CLANG8ELF tool chain for new LLVM/CLANG8 Liming Gao
2019-05-17  1:16   ` [edk2-devel] " Bob Feng
2019-04-26 14:42 ` [Patch 7/7] OvmfPkg: Update DSC/FDF to support CLANG8ELF tool chain Liming Gao
2019-05-19 13:24   ` [edk2-devel] " Ard Biesheuvel
2019-05-19 13:45     ` Liming Gao
2019-05-20 14:33   ` Laszlo Ersek
2019-04-26 16:33 ` [edk2-devel] [Patch 0/7] Add new CLANG8ELF tool chain for new LLVM/CLANG8 Ard Biesheuvel
2019-04-28  0:55   ` Liming Gao
2019-04-29 16:51     ` Leif Lindholm
2019-04-30  4:21       ` Liming Gao
2019-04-30 11:01         ` Leif Lindholm
2019-04-30 13:11           ` Steven Shi
2019-05-05  6:18           ` Liming Gao
     [not found]           ` <159BB5054AE8ABA6.12625@groups.io>
2019-05-16 13:29             ` Liming Gao
2019-05-19 20:14     ` Jordan Justen
2019-05-20 13:47       ` Liming Gao
2019-05-20 22:52         ` Andrew Fish
2019-05-21  2:18           ` Liming Gao
2019-05-21  3:36             ` Andrew Fish [this message]
     [not found] ` <15990D503F545BBC.4588@groups.io>
2019-05-19 11:59   ` [edk2-devel] [Patch 7/7] OvmfPkg: Update DSC/FDF to support CLANG8ELF tool chain Liming Gao
2019-05-21 21:13 ` [edk2-devel] [Patch 0/7] Add new CLANG8ELF tool chain for new LLVM/CLANG8 Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ADDE9727-0E88-4B7F-BCDB-B933028A6018@apple.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox