#20563: Cannot compile SnapPy for sage because sage's gcc is incompatible with
system's as
-------------------------------------+-------------------------------------
       Reporter:  mgoerner           |        Owner:
           Type:  defect             |       Status:  needs_info
       Priority:  major              |    Milestone:  sage-7.2
      Component:  porting            |   Resolution:
       Keywords:                     |    Merged in:
        Authors:                     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/mgoerner/binutils2.24            |  afbe56b320454d496e82bf62d1a8efda15aededc
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------
Changes (by leif):

 * status:  new => needs_info


Comment:

 Replying to [comment:7 mgoerner]:
 > Replying to [comment:6 dunfield]:
 > > My guess is that the trigger is that the code is such that gcc decides
 to optimize by issuing certain SSE instructions/operands.  Which SSE
 instructions/operands it generates depends on what version of "as" was
 present when gcc was compiled, not what version is present at run time.
 The version of "as" on 10.11 knows more SSE stuff than the one on (say)
 10.9, hence the issue.
 >
 > Nathan and I actually verified it by looking at the results of "gcc
 SnapPy.c -S" when run under "sage -sh" which produces the intermittent
 assembly code.
 >
 > My guess is that the configure script of gcc follows a certain pattern
 to search for "as" and, if it finds it, probes it for its capabilities. If
 gcc is then compiled, the assembly produced by that gcc depends on the
 "as" found during configure time.

 Yep (from `gcc/configure.ac`):
 {{{
 #!sh
     gcc_GAS_CHECK_FEATURE([interunit movq mnemonic],
       gcc_cv_as_ix86_interunit_movq,,,
       [.code64
        movq %mm0, %rax
        movq %rax, %xmm0])
     AC_DEFINE_UNQUOTED(HAVE_AS_IX86_INTERUNIT_MOVQ,
       [`if test $gcc_cv_as_ix86_interunit_movq = yes; then echo 1; else
 echo 0; fi`],
       [Define if your assembler supports interunit movq mnemonic.])

 }}}

 \\

 > <SNIP>
 >
 > In detail:
 > The "offending instruction" is a movq instruction where an operand is an
 SSE register xmm0, ...
 > When using the sage binary distribution, the result of the above gcc
 command contains the offending instruction.

 Because the assembler (used when building GCC) on the buildbot is less
 broken, namely clang's / LLVM's instead of Apple's ancient GAS 1.38 fork.

 \\

 > When Nathan compiled sage (and thus its gcc) himself on Mac OS 10.9, the
 result of the same command does not contain the offending instruction
 (though it still contained other instructions with SSE registers).
 > "as" on 10.11 accepts the "offending instruction" but on 10.9 it does
 not (supporting of the "offending instruction" starting binutils version
 2.17 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43215#c7).

 Up to version 4.8 GCC still emitted the traditional, wrong instruction
 (`movd`; cf. the problem report above), while it was changed to the
 correct one (`movq`) in 4.9.

 To stay compatible with "broken" (very old) assemblers, this has again
 been changed (also in 4.9) to depend on the assembler found/used ''during
 the build of GCC'' (i.e., in its `configure` run, which in the case of
 Sage binary dists happens on the buildbot).

 The relevant PR is [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56656],
 [https://gcc.gnu.org/ml/gcc-patches/2013-03/msg00789.html corresponding
 patch].

 Note that in fact the brokenness of bdists on older MacOS X versions
 wasn't even triggered by upgrading Sage's GCC, but by upgrading the
 buildbot (to a more recent OS version and hence a newer version of
 XCode)... XD

 ----

 So it's not really clear (from the current ticket ''description'') whether
 this ticket is supposed to deal (only) with the specific `movd`/`movq`
 issue which may pop up ''when compiling !SnapPy'' (as the title says), or
 the more general problem with old Apple assemblers.

 The latter will presumably be solved on #20779, thereby also fixing the
 more specific problem here (which could easily be solved in even more ways
 though).

--
Ticket URL: <https://trac.sagemath.org/ticket/20563#comment:16>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to