Fusb_darwin.cc compile fails on Mac OS X Snow Leopard with -arch x86_64

I am building from gnuradio-3.2.2.tar from Trac on an iMac9,1 with an
Intel Core 2 Duo running Mac OS X 10.6.1 (Snow Leopard), XCode version
3.2, gcc version 4.2.1.

I am following the directions at
https://radioware.nd.edu/documentation/install-guides/mac-os-x
and just got all the prerequisites from macports for this build.

I am building one component at a time. I built gnuradio-core (but
with one wrinkle - see PPS below).

The build for usrp failed, in particular the compile for
fusb_darwin.cc failed with these error messages, among others (full
compile command with output appears in PPPS below):

fusb_darwin.cc:348: error: cast from s_both<s_buffer*>* to unsigned
int loses precision
fusb_darwin.cc:391: error: cast from void* to UInt32 loses precision
… etc. …

I suspected a 32 vs. 64 bit problem so I tried typing the compile
command by hand with the -m32 option to supercede the default -arch
86x_64 option. It compiled. Looking at the output file of this
compilation, along with some others, I find:

d-128-95-165-159:legacy mrfm$ file .libs/fusb*
.libs/fusb.o: Mach-O 64-bit object x86_64
.libs/fusb_darwin.o: Mach-O object i386
.libs/fusb_sysconfig_darwin.o: Mach-O 64-bit object x86_64

So it seems fusb_darwin.cc compiles for 32 bits but not 64. This
Stackoverflow thread
discusses the general issue:

http://stackoverflow.com/questions/1455720/mac-osx-10-6-compiler-a-puzzling-experience-
with-32-vs-64-bit

It looks complicated. I’m not sure how best to proceed. Please advise.

Jon Jacky

PS - I also tried installing gnuradio-usrp from macports. It also
fails at compiling fusb_darwin.cc with the same messages (but
different line numbers, I suppose because it is 3.2 not 3.2.2). In
the macports compile commands, the -arch x86_64 option is explicit; it
does not appear in the compile commands from the Trac build.

PPS - I did have a problem building gnuradio-core: at first the
compile for gnuradio-core/src/lib/filter/float_dotprod_sse.S and
several other *sse.S files failed with messages like:

float_dotprod_sse.S:63:suffix or operands invalid for `push’

This post says the error message indicates 32-bit code where 64-bit is
expected:

http://www.opensubscriber.com/message/[email protected]/6122483.html

Just to get the build to complete, I made symbolic links from
float_dotprod_sse64.S to float_dotprod_sse.S (etc. for the other .S
files).

I also had this same problem with the macports build.

PPPS Here is the complete compile command for fusb_darwin.cc which
failed, and the output:

libtool: compile: g++ -DHAVE_CONFIG_H -I. -I…/…/…/…
-I/Users/mrfm/gnuradio-
3.2.2/usrp/host/lib/legacy
-I/Users/mrfm/gnuradio-3.2.2/usrp/firmware/include -
I/Users/mrfm/gnuradio-3.2.2/usrp/host/lib/legacy -I/opt/local/include
-I/Users/mrfm/gr-
3.2.2/include/gnuradio -g -O2 -Wall -Woverloaded-virtual -D_THREAD_SAFE
-MT fusb_darwin.lo -
MD -MP -MF .deps/fusb_darwin.Tpo -c fusb_darwin.cc -fno-common -DPIC -o
.libs/fusb_darwin.o
In file included from fusb_darwin.cc:35:
darwin_libusb.h: In function ‘char* darwin_error_str(int)’:
darwin_libusb.h:50: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:52: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:54: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:56: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:58: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:60: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:62: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:64: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:66: warning: deprecated conversion from string constant
to ‘char*’
fusb_darwin.cc: In member function ‘void
fusb_ephandle_darwin::read_issue(s_both<s_buffer*>)’:
fusb_darwin.cc:348: error: cast from ‘s_both<s_buffer
>’ to ‘unsigned
int’ loses precision
fusb_darwin.cc:383: error: cast from ‘s_both<s_buffer
>’ to ‘unsigned
int’ loses precision
fusb_darwin.cc:383: warning: format ‘%ld’ expects type ‘long int’, but
argument 4 has type ‘UInt32’
fusb_darwin.cc: In static member function ‘static void
fusb_ephandle_darwin::read_completed(void
,
io_return_t, void*)’:
fusb_darwin.cc:391: error: cast from ‘void*’ to ‘UInt32’ loses precision
fusb_darwin.cc:402: warning: format ‘%ld’ expects type ‘long int’, but
argument 3 has type ‘UInt32’
fusb_darwin.cc:402: warning: format ‘%ld’ expects type ‘long int’, but
argument 4 has type ‘UInt32’
fusb_darwin.cc:406: error: cast from ‘s_both<s_buffer*>’ to ‘unsigned
int’ loses precision
fusb_darwin.cc:406: warning: format ‘%ld’ expects type ‘long int’, but
argument 4 has type ‘UInt32’
fusb_darwin.cc: In member function ‘virtual int
fusb_ephandle_darwin::read(void
, int)’:
fusb_darwin.cc:428: warning: format ‘%ld’ expects type ‘long int’, but
argument 4 has type ‘UInt32’
fusb_darwin.cc: In member function ‘virtual int
fusb_ephandle_darwin::write(const void*, int)’:
fusb_darwin.cc:480: error: cast from ‘s_both<s_buffer*>’ to ‘unsigned
int’ loses precision
fusb_darwin.cc:480: warning: format ‘%ld’ expects type ‘long int’, but
argument 4 has type ‘UInt32’
fusb_darwin.cc: In static member function ‘static void
fusb_ephandle_darwin::write_completed(void
,
io_return_t, void*)’:
fusb_darwin.cc:495: error: cast from ‘void*’ to ‘UInt32’ loses precision
fusb_darwin.cc:504: warning: format ‘%ld’ expects type ‘long int’, but
argument 3 has type ‘UInt32’
fusb_darwin.cc:504: warning: format ‘%ld’ expects type ‘long int’, but
argument 4 has type ‘UInt32’
fusb_darwin.cc:507: error: cast from ‘s_both<s_buffer*>’ to ‘unsigned
int’ loses precision
fusb_darwin.cc:507: warning: format ‘%ld’ expects type ‘long int’, but
argument 4 has type ‘UInt32’
circular_buffer.h: In member function ‘int
circular_buffer::enqueue(T
, UInt32) [with T = char]’:
fusb_darwin.cc:409: instantiated from here
circular_buffer.h:157: warning: format ‘%ld’ expects type ‘long int’,
but argument 3 has type ‘UInt32’
circular_buffer.h:157: warning: format ‘%ld’ expects type ‘long int’,
but argument 4 has type ‘UInt32’
circular_buffer.h: In member function ‘int
circular_buffer::dequeue(T*, UInt32*) [with T = char]’:
fusb_darwin.cc:425: instantiated from here
circular_buffer.h:249: warning: format ‘%ld’ expects type ‘long int’,
but argument 3 has type ‘UInt32’
circular_buffer.h:249: warning: format ‘%ld’ expects type ‘long int’,
but argument 4 has type ‘UInt32’
make[6]: *** [fusb_darwin.lo] Error 1
make[5]: *** [all] Error 2
make[4]: *** [all-recursive] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Here is the successful compile with the -m32 option:

d-128-95-165-159:legacy mrfm$ g++ -DHAVE_CONFIG_H -I. -I…/…/…/…
-I/Users/mrfm/gnuradio-
3.2.2/usrp/host/lib/legacy
-I/Users/mrfm/gnuradio-3.2.2/usrp/firmware/include -
I/Users/mrfm/gnuradio-3.2.2/usrp/host/lib/legacy -I/opt/local/include
-I/Users/mrfm/gr-
3.2.2/include/gnuradio -g -O2 -Wall -Woverloaded-virtual -D_THREAD_SAFE
-MT fusb_darwin.lo -
MD -MP -MF .deps/fusb_darwin.Tpo -c fusb_darwin.cc -fno-common -DPIC
-m32 -o
.libs/fusb_darwin.o
In file included from fusb_darwin.cc:35:
darwin_libusb.h: In function ‘char* darwin_error_str(int)’:
darwin_libusb.h:50: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:52: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:54: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:56: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:58: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:60: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:62: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:64: warning: deprecated conversion from string constant
to ‘char*’
darwin_libusb.h:66: warning: deprecated conversion from string constant
to ‘char*’

This command produces

.libs/fusb_darwin.o: Mach-O object i386

On Thu, Oct 8, 2009 at 5:19 PM, Jonathan P Jacky [email protected]
wrote:

with one wrinkle - see PPS below).

The build for usrp failed, in particular the compile for
fusb_darwin.cc failed with these error messages, among others (full
compile command with output appears in PPPS below):

fusb_darwin.cc:348: error: cast from s_both<s_buffer*>* to unsigned int
loses precision
fusb_darwin.cc:391: error: cast from void* to UInt32 loses precision
… etc. …

Both errors are coming from pointer casts to int types. Pointers and
long types go to 8-bytes on 64-bit builds while int stays at 4-bytes
on most systems. Using long rather than int types should fix things
though I have no way test it out. Michael may be aware of other
issues.

Thomas