Bug 27404 - Support building with Sun Studio
Summary: Support building with Sun Studio
Status: NEW
Alias: None
Product: liboil
Classification: Unclassified
Component: unknown (show other bugs)
Version: 0.3.5
Hardware: Other Solaris
: medium normal
Assignee: David Schleef
QA Contact: David Schleef
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-31 16:04 UTC by Brian Cameron
Modified: 2010-04-16 14:52 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
patch allowing liboil to be built with Sun Studio support taking advantage of its new GCC-style assembly support. (16.75 KB, patch)
2010-03-31 16:04 UTC, Brian Cameron
Details | Splinter Review
updated patch (18.01 KB, patch)
2010-04-05 21:43 UTC, Brian Cameron
Details | Splinter Review
updated patch (17.14 KB, patch)
2010-04-16 14:52 UTC, Brian Cameron
Details | Splinter Review

Description Brian Cameron 2010-03-31 16:04:26 UTC
Created attachment 34590 [details] [review]
patch allowing liboil to be built with Sun Studio support taking advantage of its new GCC-style assembly support.

The latest releases of Sun Studio 12 now support GCC-style assembly.  I was able to get liboil to compile with Sun Studio after making the changes in the attached patch.  I will summarize these changes:

- When building code for different architectures (mmx, sse, etc.), Solaris does
  not normally allow you to use libraries that are built with a different 
  instruction set.  So if you build a library with sse support, and try to run
  a program that uses it on a system without sse support, then it will fail
  with an error and not let the program run.  To override this, you need to 
  specify a mapfile with the line 

  hwcap_1 = V0x0 FPU OVERRIDE;

  This patch adds a file liboil/solaris-hwcap.mapfile and there are minor 
  changes to configure.ac and liboil/Makefile.am to add the needed linker magic 
  to use this file if using the Sun Studio compiler on Solaris.

- Minor changes to m4/as-gcc-inline-assembly.m4 so that it tries to compile
  and run tests when using Sun Studio and not just with GCC.

- Changes to as-intrinsics.m4 to set the right flags for building with various
  architectures.

- Sun Studio does not know #ifdef (__i386__) but instead uses "__i386" so there
  are some minor changes to allow either.

- Some changes to liboil/fb/fbmmx.c so that the code works with Sun Studio.
  This is handled a bit differently with the Sun Studio compiler.

- In two files I changed _mm_load_pd1 to _mm_load1_pd.  Without
  this change I was seeing this error:

  "math_sse.c", line 356: assignment type mismatch:
	struct __m128d_ {array[2] of double d_} "=" int
  cc: acomp failed for math_sse.c

If you feel that any of the above issues should be handled in a different way
or if you think that there are really bugs in the Sun Studio compiler's 
support for GCC-style assembly, then let me know and I can rework the patch
and/or work with the Sun Studio developers to figure out what should be done.

Can these changes go upstream?  Even if all the patch cannot go in, it would be 
good if we could allow as many changes are reasonable to go in.
Comment 1 Brian Cameron 2010-04-05 21:43:38 UTC
Created attachment 34701 [details] [review]
updated patch


Here is an updated patch.  A few minor changes.  With this patch "make check" works for both i386 and amd64 and I can run "oil-bugreport" without it failing.

+ The mapfile is applied for both i386 and amd64 in configure.ac
+ m4/as-host-defines.m4 now has a better check for Solaris I386 versus AMD64
  that works.
+ Reworked m4/as-intrinsics.m4 so that it is a little smarter and just sets
  the flags as is appropriate for the different intrinsics and does not bother
  calling getisax.  The flags are set more closely to what the Sun Studio cc
  manpage says they should be set to.
+ A new hunk for liboil/liboiltest.c.  Sun Studio requires that if you pass a 
  floating-point type to an integer hex printf specifier, it will not work 
  unless it is specifically cast.  Refer here:

  http://developers.sun.com/solaris/articles/about_amd64_abi.html#varargs

  This hunk avoids a crash when running one of the tests in "make check".
Comment 2 Brian Cameron 2010-04-05 21:48:41 UTC
Note that aside from that latest patch, I also make two other changes:

- When building in amd64 mode I modify liboil/Makefile.am so that it does not
  build the amd64 and i386_amd64 directories when building amd64.  When these are 
  built, there are problems with the code segfaulting when tests are run and 
  oil-bugreport is run.

- In liboil/i386/trans8x8_i386.c I comment out the functions trans8x8_u16_asm1
  and trans8x8_u16_asm2 since they crash when running oil-bugreport in a manner 
  that looks like a Sun Studio bug.

I will work with the Sun Studio team to address these problems.  I do not think we
should try to get these fixes upstream since they are workarounds for what seem to be Sun Studio bugs.  I only mention this so that if people try to build liboil with Sun Studio with the latest patch, they about these additional problems if they are using a compiler that does not yet have the fixes.
Comment 3 Brian Cameron 2010-04-16 14:52:46 UTC
Created attachment 35116 [details] [review]
updated patch

Here is a patch which applies against the latest 0.3.17 version of liboil


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.