bugGNU Octave - Bugs: bug #44970, Build fails on ARM because qreal...

 
 

bug #44970: Build fails on ARM because qreal is a typedef for float

Submitter:  Orion Poplawski <opoplawski>
Submitted:  Thu 30 Apr 2015 08:08:27 PM UTC
   
 
Category:  Configuration and Build System Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Build Failure
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 02 Jun 2015 04:52:50 PM UTC, comment #9: 

Retagging release from 4.0.0-rc4 to 4.0.0.

John W. Eaton <jwe>
Group administrator
Sat 02 May 2015 04:41:30 AM UTC, comment #8: 

Oops.  Wrong report.

Rik <rik5>
Group administrator
Sat 02 May 2015 04:40:50 AM UTC, comment #7: 

I checked in a cset that at checks for a modern version of sndfile before setting HAVE_SNDFILE (http://hg.savannah.gnu.org/hgweb/octave/rev/3b3579ad7e46).  More could be done, but this is probably enough.

Rik <rik5>
Group administrator
Sat 02 May 2015 03:44:29 AM UTC, comment #6: 

I unrolled the for loop because it was so small and because I felt it was clearer about what was happening.  I checked in the change under your name here (http://hg.savannah.gnu.org/hgweb/octave/rev/6446649e42c1).  Closing report.

Rik <rik5>
Group administrator
Fri 01 May 2015 02:41:04 PM UTC, comment #5: 

I suspect (someone correct if I'm wrong) that the only functions that matter are the ones that pass a pointer or a reference to a qreal, not by value or return value.

There are only a handful of functions in the Qt header files that do so, a quick grep in the Qt directory shows functions like getRect, getCoords, getRgbF, getHsvF, etc.

And the only one of these I see in Octave is getRgbF, so this looks pretty safe and complete to me.

Mike Miller <mtmiller>
Group Member
Fri 01 May 2015 02:05:13 AM UTC, comment #4: 

This appears to be the only compile error on arm.  Final patch:


diff -r 3797df921988 libgui/graphics/QtHandlesUtils.cc
--- a/libgui/graphics/QtHandlesUtils.cc Wed Apr 29 17:09:24 2015 -0700
+++ b/libgui/graphics/QtHandlesUtils.cc Thu Apr 30 22:38:27 2015 +0200
@@ -152,7 +152,12 @@
   Matrix rgb (1, 3);
   double* rgbData = rgb.fortran_vec ();

-  c.getRgbF (rgbData, rgbData+1, rgbData+2);
+  // qreal is a typedef for double except for ARM CPU
+  // architectures where it is a typedef for float. (Bug #44970)
+  qreal tmp[3];
+  c.getRgbF (tmp, tmp+1, tmp+2);
+  for (int k=0; k<3; ++k)
+    rgbData[k] = tmp[k];

   return rgb;
 }


Orion Poplawski <opoplawski>
Thu 30 Apr 2015 10:12:04 PM UTC, comment #3: 

That fails with:

graphics/QtHandlesUtils.cc: In function 'Matrix QtHandles::Utils::toRgb(const QColor&)':
graphics/QtHandlesUtils.cc:158:36: error: no matching function for call to 'QColor::getRgbF(qreal&, qreal&, qreal&) const'
   c.getRgbF (tmp[0], tmp[1], tmp[2]);

I think it would be:

diff -r 3797df921988 libgui/graphics/QtHandlesUtils.cc
--- a/libgui/graphics/QtHandlesUtils.cc Wed Apr 29 17:09:24 2015 -0700
+++ b/libgui/graphics/QtHandlesUtils.cc Thu Apr 30 22:38:27 2015 +0200
@@ -152,7 +152,12 @@
   Matrix rgb (1, 3);
   double* rgbData = rgb.fortran_vec ();

-  c.getRgbF (rgbData, rgbData+1, rgbData+2);
+  // qreal is a typedef for double except for ARM CPU
+  // architectures where it is a typedef for float. (Bug #44970)
+  qreal tmp[3];
+  c.getRgbF (tmp, tmp+1, tmp+2);
+  for (k=0; k<3; ++k)
+    rgbData[k] = tmp[k];

   return rgb;
 }

Ugly, yes, but I don't have another suggestion.

Orion Poplawski <opoplawski>
Thu 30 Apr 2015 09:58:27 PM UTC, comment #2: 

Is it only one location that this happens?  Or is the assumption that qreal = double all over the Qt code?  If it's just one or two locations then we can probably hack something together as suggested in comment #1.

Rik <rik5>
Group administrator
Thu 30 Apr 2015 08:39:45 PM UTC, comment #1: 

http://koji.fedoraproject.org/koji/getfile?taskID=9608836&name=build.log&offset=-4000

http://doc.qt.io/qt-4.8/qtglobal.html#qreal-typedef
says:
typedef qreal
Typedef for double on all platforms except for those using CPUs with ARM architectures. On ARM-based platforms, qreal is a typedef for float for performance reasons.

This causes the problem in

Matrix
toRgb (const QColor& c)
{
  Matrix rgb (1, 3);
  double* rgbData = rgb.fortran_vec ();

  c.getRgbF (rgbData, rgbData+1, rgbData+2);

  return rgb;
}


I think this is a ugly patch but just to give an idea:

diff -r 3797df921988 libgui/graphics/QtHandlesUtils.cc
--- a/libgui/graphics/QtHandlesUtils.cc Wed Apr 29 17:09:24 2015 -0700
+++ b/libgui/graphics/QtHandlesUtils.cc Thu Apr 30 22:38:27 2015 +0200
@@ -152,7 +152,12 @@
   Matrix rgb (1, 3);
   double* rgbData = rgb.fortran_vec ();

-  c.getRgbF (rgbData, rgbData+1, rgbData+2);
+  // qreal is a typedef for double except for ARM CPU
+  // architectures where it is a typedef for float. (Bug #44970)
+  qreal tmp[3];
+  c.getRgbF (tmp[0], tmp[1], tmp[2]);
+  for (k=0; k<3; ++k)
+    rgbData[k] = tmp[k];

   return rgb;
 }


Andreas Weber <andy1978>
Group Member
Thu 30 Apr 2015 08:08:27 PM UTC, original submission:  

graphics/QtHandlesUtils.cc: In function 'Matrix QtHandles::Utils::toRgb(const QColor&)':
graphics/QtHandlesUtils.cc:155:43: error: no matching function for call to 'QColor::getRgbF(double*&, double*, double*) const'
   c.getRgbF (rgbData, rgbData+1, rgbData+2);
                                           ^
In file included from /usr/include/QtGui/qpalette.h:46:0,
                 from /usr/include/QtGui/qwidget.h:50,
                 from /usr/include/QtGui/QWidget:1,
                 from graphics/Container.h:26,
                 from graphics/QtHandlesUtils.cc:37:
/usr/include/QtGui/qcolor.h:114:10: note: candidate: void QColor::getRgbF(qreal*, qreal*, qreal*, qreal*) const
     void getRgbF(qreal *r, qreal *g, qreal *b, qreal *a = 0) const;
          ^
/usr/include/QtGui/qcolor.h:114:10: note:   no known conversion for argument 1 from 'double*' to 'qreal* {aka float*}'
Makefile:3422: recipe for target 'graphics/graphics_libgui_graphics_la-QtHandlesUtils.lo' failed


Orion Poplawski <opoplawski>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by opoplawski (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-02 jwe Release4.0.0-rc4 4.0.0
    2015-05-02 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2015-05-02 rik5 StatusFixed Ready For Test
        Open/ClosedClosed Open
    2015-05-02 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2015-05-01 mtmiller CategoryNone Configuration and Build System
        StatusNone Patch Submitted
    2015-04-30 andy1978 SummaryBuild fails on arm Build fails on ARM because qreal is a typedef for float

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code