[WP34s] Build error on linux 64bit
#1

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
+

#2

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

#3

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.

#4

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.

#5

I had no choice. :-(

#6

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...

#7

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.

#8

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

#9

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.

#10

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.



Possibly Related Threads…
Thread Author Replies Views Last Post
  Is Linux common among us RPN types? db (martinez, ca.) 46 15,946 12-11-2013, 08:25 PM
Last Post: Paul Guertin
  EMU41; Dosbox on Linux; Excruciatingly sloooow Geir Isene 9 3,044 12-01-2013, 05:10 PM
Last Post: Geir Isene
  MS advert shows spreadsheet with obvious error BruceH 3 2,146 11-14-2013, 09:50 AM
Last Post: Bill (Smithville, NJ)
  HP Prime: Rounding error in determinant Stephan Matthys 3 1,607 10-25-2013, 09:29 PM
Last Post: Walter B
  Prime Error or Mine? toml_12953 12 3,531 10-22-2013, 10:35 AM
Last Post: toml_12953
  Explaination on How to Reset Caculator in Users guie: error Harold A Climer 5 2,513 10-15-2013, 02:11 AM
Last Post: cyrille de Brébisson
  Repair of HP-34C - Error 0 and Error 9 Jeff Kearns 3 1,644 10-11-2013, 12:29 PM
Last Post: Randy
  Do You Think a Listing Error Was Made? Jim Johnson 13 3,775 09-04-2013, 09:23 AM
Last Post: Eddie W. Shore
  Building WP 34s emulator on Linux Eric Smith 3 1,494 07-25-2013, 03:03 PM
Last Post: Marcus von Cube, Germany
  HP Prime: Error reports : Here Patrice 111 22,320 07-24-2013, 05:52 PM
Last Post: Thomas Klemm

Forum Jump: