[llvm-commits] new linux/llvm patches

Benjamin Kramer benny.kra at googlemail.com
Sat May 12 04:48:05 PDT 2012


On 12.05.2012, at 03:15, PaX Team wrote:

> hi all,
> 
> after more than a year i finally found some time to work on the linux compilation
> project, the results of which are summarized below.
> 
> 1. one important development is that linux can now be compiled with linux-side
>   patches only (on x86 at least) as long as you don't want to use integrated-as.
> 
>   pax-linux-3.3.5-test11-clang-only.patch was created on top of PaX but i think
>   it'll mostly apply to vanilla as well.
> 
>   note that i enabled integrated-as (more in this later) so you'll want the
>   llvm patches as well if you want to try the linux patch as is.
> 
>   i also enabled -fcatch-undefined-behavior for W=1, this will produce a kernel
>   that triggers a runtime check in ext4 for me (that i didn't have time to fix
>   yet), so be careful.

It looks like there are a lot of undocumented hacks in there. It would be nice to have some descriptions of the behavior where gcc and clang diverge so we can rule out missing features/bugs in clang. Since the goal is to eventually get this into the vanilla kernel we better have a good explanation for every single character changed ;)

> 2. the rest of the patches are for llvm (with the hope that they'll be accepted
>   in one form or another eventually ;).
> 
>   - elf-emit-R_X86_64_32S.patch: this is a fix for a link-time problem (wrong
>     relocation type gets emitted for some insns on amd64), i'm sure there's a
>     better way to identify all the affected insns but for now i just used a 
>     simple grep you can find in the patch to produce the full list.

Ugly, this information should be tablegen'd somehow.

>   - handle-empty-archive.patch: this is a small fix for LTO to be able to accept
>     empty .a archives.

Looks ok, it could probably pushed down into the archive logic. I'll see if I can whip up a test case and commit this.

>   - kernel-riprel.patch: this patch enables rip-relative addressing on amd64
>     even for -mcmodel=kernel (something gcc also does already). this is useful
>     for linux when creating a relocatable kernel since it reduces the number of
>     relocations and speeds up booting.

Looks reasonable, Anton?

>   - integrated-as-single-quoted-string.patch: this makes integrated-as accept
>     strings enclosed in single quotes (something the GNU as accepts as well).

I'm pretty sure this is incorrect. I did a simple test with my local gas and it didn't accept any single quoted strings. Maybe there is a special flag or it accepts them only in some contexts?

>   - integrated-as-code16gcc.patch

OK, committed as r156708.

>     integrated-as-extern.patch

Committed with a test case as r156707.

>     integrated-as-ifb.patch

Committed with a testcase and additional support for .ifnb (the inverse) in r156705.

>     integrated-as-ifc.patch

Committed with a testcase and additional support for .ifnc (the inverse) in r156706.

>     integrated-as-octa.patch

Not entirely sure about this one, I'll poke at it later.

>     integrated-as-purgem.patch

Committed with a memory leak fix and a testcase in r156709.

> : these simple patches add support for some new
>     directives needed for linux. the only interesting and perhaps controversial
>     one is .octa support where i chose to support a very specific use case only
>     instead of making MCExpr be fully 128 bit aware (my guess was that it's not
>     desirable/worth the effort just for this one directive).
> 
>   - integrated-as-macro.patch: this is by far the biggest and most complex patch
>     in the series, so let me elaborate on it a bit more. first, the goals i wanted
>     to accomplish:
> 
>     - support for new macro-like directives: .rept .irp .irpc .endr
>     - support for nesting the above directives and .macro as well
>     - support for default .macro arguments (in GNU as mode), note that there's
>       still no support for keyword arguments and qualifiers such as :req and :vararg
>     - support for whitespace separated .macro parameters and arguments (in GNU as mode)
>     - a fix when substituting quoted string arguments (quotes weren't omitted)
>     - code reuse among all these directives as much as possible
> 
>     some problems that i ran into with the implementation:
> 
>     - it seems that .macro behaviour mostly models darwin's assembler, not the GNU
>       one, and i had to reuse the same hack that PlatformParser has to differentiate
>       some behaviour. it'd be nice to have a way to know the target assembler flavour
>       in AsmParser. moving code into ELFAsmParser and DarwinAsmParser could be another
>       way but that requires more changes to be able to share code due to the way this
>       class hierarchy is designed.
> 
>     - i took the liberty to introduce a few typedefs to reduce eyestrain on various
>       support data structures, i hope that std::vector and std::pair use is acceptable
>       here (i'll note though that supporting qualifiers will need std::map or something
>       similar, ideas are welcome).
> 
>     - more tests are needed for all this (but llvm can at least digest most linux code
>       now, maybe that counts for something ;).
> 
>   - integrated-as-all.patch: this is a merge of all the above patches plus some whitespace
>     fixes that i couldn't be bothered to separate out.

This is a big patch and really needs better tests. Any volunteers? ;)

- Ben

> so that's all for now, let me know what you think. note that i won't have much more time
> to spend on the llvm side of patches, so i'd also appreciate if someone could take over
> in case the review process drags out.
> 
> cheers,
>  PaX Team
> 
> PS: the missing piece to fully enable integrated-as for linux is .code16 and .code16gcc
>    support, in case anyone's looking out for a challenge ;).
> 
> The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  pax-linux-3.3.5-test11-clang-only.patch
>     Date:  12 May 2012, 1:31
>     Size:  68258 bytes.
>     Type:  Unknown
> <pax-linux-3.3.5-test11-clang-only.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  elf-emit-R_X86_64_32S.patch
>     Date:  11 May 2012, 0:51
>     Size:  2609 bytes.
>     Type:  Unknown
> <elf-emit-R_X86_64_32S.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  handle-empty-archive.patch
>     Date:  11 May 2012, 0:51
>     Size:  668 bytes.
>     Type:  Unknown
> <handle-empty-archive.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  kernel-riprel.patch
>     Date:  11 May 2012, 0:45
>     Size:  6791 bytes.
>     Type:  Unknown
> <kernel-riprel.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  integrated-as-single-quoted-string.patch
>     Date:  11 May 2012, 0:41
>     Size:  795 bytes.
>     Type:  Unknown
> <integrated-as-single-quoted-string.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  integrated-as-code16gcc.patch
>     Date:  11 May 2012, 0:06
>     Size:  520 bytes.
>     Type:  Unknown
> <integrated-as-code16gcc.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  integrated-as-extern.patch
>     Date:  11 May 2012, 0:08
>     Size:  531 bytes.
>     Type:  Unknown
> <integrated-as-extern.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  integrated-as-ifb.patch
>     Date:  12 May 2012, 0:39
>     Size:  1636 bytes.
>     Type:  Unknown
> <integrated-as-ifb.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  integrated-as-ifc.patch
>     Date:  11 May 2012, 0:13
>     Size:  1862 bytes.
>     Type:  Unknown
> <integrated-as-ifc.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  integrated-as-octa.patch
>     Date:  11 May 2012, 0:01
>     Size:  3542 bytes.
>     Type:  Unknown
> <integrated-as-octa.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  integrated-as-purgem.patch
>     Date:  11 May 2012, 0:07
>     Size:  1872 bytes.
>     Type:  Unknown
> <integrated-as-purgem.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  integrated-as-macro.patch
>     Date:  12 May 2012, 0:43
>     Size:  22237 bytes.
>     Type:  Unknown
> <integrated-as-macro.patch>The following section of this message contains a file attachment
> prepared for transmission using the Internet MIME message format.
> If you are using Pegasus Mail, or any other MIME-compliant system,
> you should be able to save it or view it from within your mailer.
> If you cannot, please ask your system administrator for assistance.
> 
>   ---- File information -----------
>     File:  integrated-as-all.patch
>     Date:  11 May 2012, 23:29
>     Size:  43524 bytes.
>     Type:  Unknown
> <integrated-as-all.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list