[Mesa-dev] [PATCH v2] replace file specific compileroptimization withinline attibute

Marc Dietrich marvin24 at gmx.de
Tue Sep 30 05:56:15 PDT 2014


Hi Matt,

Am Donnerstag, 25. September 2014, 09:56:42 schrieb Marc Dietrich:
> Am Mittwoch, 24. September 2014, 18:35:24 schrieb Matt Turner:
> > On Wed, Sep 24, 2014 at 6:25 AM, Marc Dietrich <marvin24 at gmx.de> wrote:
> > > Am Montag, 22. September 2014, 11:48:29 schrieb Matt Turner:
> > >> We need a configure check for support for __attribute__((target)). I'm
> > >> going to send a series that adds support for this (and does the check
> > >> for existing attribute uses, so once that goes in you can rebase this
> > >> patch on that).
> > > 
> > > nice, but won't work with the workaround above. Pragma and attribute
> > > does
> > > the same so, we could check for the attribute and use the pragma
> > > instead.
> > 
> > I wonder if the best thing to do is to add target("sse4.1") in
> > addition to using -msse4.1. That way, we'll retain compatibility with
> 
> The idea of this patch was to remove per file optimization flags because
> this breaks LTO. LTO will recompile all files during the final link and
> apply any "high-level" compiler flags from a single file (e.g. -msse4.1) to
> all files used in the linking process.

I tried to find some hints how gcc handles this. Unfortunately, the gcc docs 
aren't very helpful [1] and I failed to construct a test case :-( I tend to 
say that gcc does not apply the target options in the final link to *all* 
files, so this problem does seems not to exist at all (I'm running lto 
compiled mesa on amdfam10h with no sse4.1 support and see no crashes so far). 
As a side note, using "-msse4.1 -fno-lto" would prevent it in any case and 
also be compatible with clang.

Marc


[1]: info gcc on -flto:
     When producing the final binary with `-flto', GCC only applies
     link-time optimizations to those files that contain bytecode.
     Therefore, you can mix and match object files and libraries with
     GIMPLE bytecodes and final object code.  GCC automatically selects
     which files to optimize in LTO mode and which files to link without
     further processing.

     There are some code generation flags preserved by GCC when
     generating bytecodes, as they need to be used during the final link
     stage.  Currently, the following options are saved into the GIMPLE
     bytecode files: `-fPIC', `-fcommon' and all the `-m' target flags.

     At link time, these options are read in and reapplied.  Note that
     the current implementation makes no attempt to recognize
     conflicting values for these options.  If different files have
     conflicting option values (e.g., one file is compiled with `-fPIC'
     and another isn't), the compiler simply uses the last value read
     from the bytecode files.  It is recommended, then, that you
     compile all the files participating in the same link with the same
     options.



More information about the mesa-dev mailing list