The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

[WP34s] Build error on linux 64bit
Message #1 Posted by Nobby K. on 7 Apr 2012, 8:51 a.m.

Hi, developers,

I have new machine and try to build wp34s. But the build is fail.

The environment is following.

OS: LinuxMint 12 x86_64 Host GCC: gcc 4.6.1 x86_64-linux-gnu(provided by official repository) Target GCC: gcc 4.6.3 arm-none-eabi(cross compiler is build by myself) wp34s: SVN rev 2766

First, To build flash image, following error occurs. cc -Wall -Werror -O1 -g -DHOSTBUILD -DREALBUILD -DXTAL -o Linux_realbuild/post_process.exe post_process.c post_process.c: In function emainf: post_process.c:73:2: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

Second, To build console emulator or QtGui, following error occures. cc -c -Wall -Werror -g -fno-common -fno-exceptions -O0 -DDEBUG -DQTGUI -o Linux_qt/obj/keys.o keys.c In file included from /usr/lib/gcc/x86_64-linux-gnu/4.6.1/include/stdint.h:3:0, from lcd.h:22, from keys.c:20: /usr/include/stdint.h:56:27: error: conflicting types for euint64_tf decNumber/decContext.h:46:32: note: previous declaration of euint64_tf was here

If OS is Ubuntu11.10(32bit), build is succeeded.

The first one, I try the flag -Wno-error=pointer-to-int-cast. Warnning occurs but Error does not. But Linux_realbuild/post_process.exe does not work. What should I do? The macro and semantics is difficult for me.

The second one, /usr/include/stdint.h is here. #if __WORDSIZE == 64 typedef unsigned long int uint64_t; #else __extension__ typedef unsigned long long int uint64_t; #endif

decNumber/decContext.h is here typedef unsigned long long int uint64_t;

#ifdef __WORDSIZE == 64 type of uint64_t is different.

The consele emulator works good. QtGui is builded without serial. I can not build qextserialport.a on x86_64 enviorment nor link it.

Can you help me? If using Linux and x86_64 machine.

Modified patch is attached.

Index: trunk/Makefile =================================================================== --- trunk/Makefile (revision 2766) +++ trunk/Makefile (working copy) @@ -333,7 +333,7 @@ $(HOSTCC) $(HOSTCFLAGS) -o $@ $<

$(UTILITIES)/post_process$(EXE): post_process.c Makefile features.h xeq.h - $(HOSTCC) $(HOSTCFLAGS) -o $@ $< + $(HOSTCC) $(HOSTCFLAGS) -Wno-error=pointer-to-int-cast -o $@ $<

xrom.c xrom_labels.h: xrom.wp34s $(XROM) $(OPCODES) Makefile features.h data.h errors.h $(HOSTCC) -E -P -x c -Ixrom -DCOMPILE_XROM xrom.wp34s > xrom_pre.wp34s Index: trunk/lcd.c =================================================================== --- trunk/lcd.c (revision 2766) +++ trunk/lcd.c (working copy) @@ -29,8 +29,8 @@ #ifdef USECURSES static unsigned char dots[400]; #ifdef __GNUC__ -#pragma GCC diagnostic ignored "-Wformat" -#pragma GCC diagnostic ignored "-Wformat-extra-args" +//#pragma GCC diagnostic ignored "-Wformat" +//#pragma GCC diagnostic ignored "-Wformat-extra-args" #endif

static void dispreg(const char n, int index) { Index: trunk/decNumber/decContext.h =================================================================== --- trunk/decNumber/decContext.h (revision 2766) +++ trunk/decNumber/decContext.h (working copy) @@ -29,6 +29,9 @@ /* extended -- must be either 0 or 1 [present only if DECSUBSET] */ /* */ /* ------------------------------------------------------------------ */ +#if defined __x86_64__ +# define __WORDSIZE 64 +#endif

#if !defined(DECCONTEXT) #define DECCONTEXT @@ -43,7 +46,11 @@ typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint64_t; +#else typedef unsigned long long int uint64_t; +#endif

/* Conditional code flag -- set this to 0 for best performance */ #define DECSUBSET 0 // 1=enable subset arithmetic Index: trunk/linux-build-arm =================================================================== --- trunk/linux-build-arm (revision 2766) +++ trunk/linux-build-arm (working copy) @@ -1,4 +1,7 @@ #!/bin/sh

-PATH="/usr/local/CodeSourcery/Sourcery_G++_Lite/bin:$PATH" -make REALBUILD=1 +#PATH="/usr/local/CodeSourcery/Sourcery_G++_Lite/bin:$PATH" +PATH="/usr/local/arm-none-eabi/bin:/usr/lib/qt4/bin:$PATH" +QMAKESPEC=/usr/lib/qt4/mkspecs/linux-g++ +make REALBUILD=1 XTAL=1 +

      
Re: [WP34s] Build error on linux 64bit
Message #2 Posted by pascal_meheut on 7 Apr 2012, 8:59 a.m.,
in response to message #1 by Nobby K.

I built qextserial on MacOSX 64 bits and Linux 32 bits but not on Linux 64 bits indeed. I'll have a look.

      
Re: [WP34s] Build error on linux 64bit
Message #3 Posted by Marcus von Cube, Germany on 7 Apr 2012, 9:56 a.m.,
in response to message #1 by Nobby K.

The post processor and much of the code relies heavily on the fact tha an int is a 32 bit entity. Does gcc-64bit come with an option to produce a 32bit executable? If yes, set it in the makefile for HOSTOPTS.

            
Re: [WP34s] Build error on linux 64bit
Message #4 Posted by Eric Smith on 7 Apr 2012, 1:21 p.m.,
in response to message #3 by Marcus von Cube, Germany

The necessary option for gcc and ld to produce 32-bit executables on a 64-bit host is "-m32".

If you want 32-bit ints, the could should really include <stdint.h> or <inttypes.h> and use int32_t instead of int (or uint32_t instead of unsigned int), as these are the ONLY numeric types that the C standard guarantees to be 32-bit.

Unfortunately the Microsoft compiler does not provide <stdint.h> and <inttypes.h>, because it is not actually a C compiler. On those rare occasions when I'm forced to use the Microsoft compiler, I write my own stdint.h that typedefs [u]int{8,16,32}_t to the appropriate Microsoft types. Whenever possible I avoid the Microsoft compiler and use GCC via MinGW.

                  
Re: [WP34s] Build error on linux 64bit
Message #5 Posted by Marcus von Cube, Germany on 7 Apr 2012, 1:28 p.m.,
in response to message #4 by Eric Smith

I had no choice. :-(

                  
Re: [WP34s] Build error on linux 64bit
Message #6 Posted by Nobby K. on 8 Apr 2012, 9:44 a.m.,
in response to message #4 by Eric Smith

Thank you, Eric.

-m32 option works good.

decNumber/decContext.h has same probrem, which you said <stdint.h> and uint32_t typedef probrem.

decNumber/decContext.h and -m32 is OK if only post_process.exe uses this. But QtGui uses that too. QtGui links Qt and other 64bit library. So decNumber/decContext.h typedef probrem should be fixed.

post_process.c is OK to use -m32.

I propose following patch.

Index: trunk/Makefile =================================================================== --- trunk/Makefile (revision 2770) +++ trunk/Makefile (working copy) @@ -66,6 +66,12 @@ ifeq ($(SYSTEM),Darwin) CFLAGS += -DFIX_64_BITS endif +# linux 64bit system requires option like Darwin +ifeq ($(SYSTEM),Linux) +ifeq "$(findstring x86_64,$(shell uname -a))" "x86_64" +CFLAGS += -DFIX_64_BITS +endif +endif else CFLAGS += -O0 -DDEBUG -DUSECURSES endif @@ -116,6 +122,13 @@ CFLAGS := -mthumb -mcpu=arm7tdmi $(OPT_CFLAGS) $(BASE_CFLAGS) CFLAGS += -DREALBUILD -Dat91sam7l128 -Iatmel

+# linux 64bit system requires -m32 host cc option +ifeq ($(SYSTEM),Linux) +ifeq "$(findstring x86_64,$(shell uname -a))" "x86_64" +HOSTCFLAGS += -m32 +endif +endif + ifeq ($(SYSTEM),Darwin) # MacOS - uses 32 bits pointer or code won't compile HOSTCFLAGS += -m32

Index: trunk/QtGui/SerialPort.txt =================================================================== --- trunk/QtGui/SerialPort.txt (revision 2770) +++ trunk/QtGui/SerialPort.txt (working copy) @@ -24,7 +24,8 @@

On Mac OSX & Linux, get the sources:

-hg clone https://code.google.com/p/qextserialport +#hg clone https://code.google.com/p/qextserialport +hg clone -u 105 https://code.google.com/qextserialport/

Then edit the src/src.pro qmake config file and make sure that the "CONFIG += staticlib" is uncommented. run 'qmake' at the top level then 'make release'.

Index: trunk/QtGui/Makefile =================================================================== --- trunk/QtGui/Makefile (revision 2770) +++ trunk/QtGui/Makefile (working copy) @@ -16,6 +16,7 @@ # Settings for Unix like environments with gcc # Creates the Console version of the emulator or the real thing

+QTSERIALDIR=../QtSerial

TOOLS=../tools

Index: trunk/decNumber/decContext.h =================================================================== --- trunk/decNumber/decContext.h (revision 2770) +++ trunk/decNumber/decContext.h (working copy) @@ -29,6 +29,9 @@ /* extended -- must be either 0 or 1 [present only if DECSUBSET] */ /* */ /* ------------------------------------------------------------------ */ +#if defined __x86_64__ +# define __WORDSIZE 64 +#endif

#if !defined(DECCONTEXT) #define DECCONTEXT @@ -43,7 +46,11 @@ typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint64_t; +#else typedef unsigned long long int uint64_t; +#endif

/* Conditional code flag -- set this to 0 for best performance */ #define DECSUBSET 0 // 1=enable subset arithmetic

      
Re: [WP34s] Build error on linux 64bit
Message #7 Posted by pascal_meheut on 7 Apr 2012, 2:33 p.m.,
in response to message #1 by Nobby K.

Ok, I have been able to build it and to run it on an Ubuntu 64 bits.

1) I reported your change to decContext.h 2) I made no other change and I'm not sure you should keep them. Especially the -Wno-error=pointer-to-int-cast 3) I got the correct version of qextserialport with "hg clone -u 105 https://code.google.com/p/qextserialport/" 4) I commented out the staticlib line in src/src.pro 5) I compiled qextserialport in 64 bits using "make release" 6) I copied it from src: "cp build/libqextserialport.a ~/wp34s/trunk/QtSerial/lib/Linux/libqextserialport.a 7) I compiled the emulator in QtGui with a simple make 8) I ran it with ./Linux/WP34s -dev

I'll see how to make the emulator natively compatible with Linux 64 bits. So far, there is still a bug because of the 64 bits: the .dat file is not 2048 bytes long. This is nothing to fix, just a #define already in place but my son is asking for me...

            
Re: [WP34s] Build error on linux 64bit
Message #8 Posted by pascal_meheut on 7 Apr 2012, 3:03 p.m.,
in response to message #7 by pascal_meheut

To fix the .dat file size, just add:

CFLAGS += -DFIX_64_BITS

in the Makefile. Right now, it is defined for MacOSX only. But it applies to any 64 bits OS.

I'll work on supporting Linux 64 bits natively when I have enough time. Right now, I'm busy with Stopwatch, generating the multi-platform emulator automatically and make WP34sFlash work reliably so this is not high-priority.

                  
Re: [WP34s] Build error on linux 64bit
Message #9 Posted by Nobby K. on 8 Apr 2012, 9:44 a.m.,
in response to message #8 by pascal_meheut

Thank you, Pascal.

Please modify trunk/QtGui/SerialPort.txt to get correct version of qextserialport.

Some BUG is found to find in trunk/QtGui/Makefile at line 174. If NO_SERIAL is defined, QTSERIALDIR is not set.

So, I can run "QtGui/Linux/WP-34s -dev" with serial good.

                        
Re: [WP34s] Build error on linux 64bit
Message #10 Posted by pascal_meheut on 8 Apr 2012, 2:11 p.m.,
in response to message #9 by Nobby K.

Thanks. I'll fix the bug and update the README. But I think I'll move to a more recent version of qextserialport as it fixes some quirks.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall