Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to compile for Raspbian (Pi) #14

Closed
SnowLeopard71 opened this issue Feb 21, 2014 · 10 comments
Closed

Fixes to compile for Raspbian (Pi) #14

SnowLeopard71 opened this issue Feb 21, 2014 · 10 comments
Labels

Comments

@SnowLeopard71
Copy link

Nice to have a non-java SPV client -- finally something that the Pi can handle!
I had to make the following additions in order to compile cleanly for Raspbian:
Added to Makefile to fix assembler messages (Rd and Rm should be different in mul)

CFLAGS += -Dlinux -ccc-host-triple armv6-unknown-eabi -march=armv6 -mfpu=vfp -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfloat-abi=hard

Added to block-store.c, txdb.c, and config.c for the PATH_MAX define

#include <linux/limits.h>

Added to hash.c, ncui.c, and txdb.c to fix "_undefined reference to `__isoc99_sscanf'" linker error

#define _GNU_SOURCE

I haven't forked and created a pull request as I don't know the proper way to include these changes so they don't break other platforms.
FYI: uname -m returns armv6l, and uname -i & uname -p both return unknown.

@mx4
Copy link
Contributor

mx4 commented Feb 24, 2014

It seems that the CFLAGS addition were due to you using a crosscompiler, however I'll look to incorporating the PATH_MAX & sscanf fixes. Thanks!

@mx4
Copy link
Contributor

mx4 commented Feb 25, 2014

On second thought, file.h already #include's <linux/limits.h> to pull PATH_MAX's definition and all the files using PATH_MAX also #include file.h:

[u@foo git/bitc/src]$ grep PATH_MAX *
addrbook.c: char path[PATH_MAX];
block-store.c: char bsPath[PATH_MAX];
file.c: char file0[PATH_MAX];
file.c: char file1[PATH_MAX];
file.h:// PATH_MAX
txdb.c: char txdbPath[PATH_MAX];
util.c: char filePath[PATH_MAX];
[u@foo git/bitc/src]$ grep file.h *
addrbook.c:#include "file.h"
block-store.c:#include "file.h"
config.c:#include "file.h"
file.c:#include "file.h"
main.c:#include "file.h"
txdb.c:#include "file.h"
util.c:#include "file.h"
wallet.c:#include "file.h"

So it's not clear that #including <linux/limits.h> in these files will help.

Also the problem related to ___isoc99_sscanf appears to be due to the use of a non-standard library, so I'm tempted to just punt on this bug.

Note that I've had a report from a bitcointalk user that bitc was compiling & running great on a raspberry pi running raspbian 7.2. So this looks like an issue with your environment.

@mx4 mx4 added the wontfix label Feb 25, 2014
@mx4 mx4 closed this as completed Feb 25, 2014
@SnowLeopard71
Copy link
Author

What user on bitcointalk?
It does not compile cleanly on a fully updated raspbian 7.2, I just tried again.
If I change 'CC = clang' to 'CC = gcc', it still fails:

 $ make
 CC    src/MurmurHash3.c
 CC    src/addrbook.c
 CC    src/base58.c
 CC    src/bitc_ui.c
 CC    src/block-store.c
 CC    src/bloom.c
 CC    src/btc-message.c
 CC    src/cJSON.c
 CC    src/config.c
 CC    src/crypt.c
 CC    src/file.c
 CC    src/fx.c
 CC    src/hash.c
 CC    src/hashtable.c
 CC    src/ip_info.c
 CC    src/key.c
 CC    src/main.c
src/main.c: In function âmainâ:
src/main.c:1164:9: error: declaration of âgetpassâ shadows a global declaration [-Werror=shadow]
cc1: all warnings being treated as errors
make: *** [bld/main.o] Error 1

@mx4
Copy link
Contributor

mx4 commented Feb 25, 2014

This was user "fronti".

What happens if you rename all usages of the variable 'getpass' to 'getpassword'? Does this compile fine? If not, can you give me ssh access to your raspberry pi?

@SnowLeopard71
Copy link
Author

Problem appears to be clang on Pi. The results above included the CFLAGS that you said to comment out.
Here's an attempt at patching the Makefile to use gcc when on a Pi:

--- bitc.1/Makefile     2014-02-21 13:43:59.103515150 -0500
+++ bitc/Makefile       2014-02-25 15:37:24.718274495 -0500
@@ -1,7 +1,13 @@

 OS=$(shell uname -s)
+MACH=$(shell uname -m)

+ifeq ($(MACH), armv6l)
+CC = gcc
+else
 CC = clang
+endif
+
 ASAN = 0

 ###
@@ -9,8 +15,10 @@
 ###

 CFLAGS  = -O1 -MMD -g
+ifeq ($(CC), clang)
 CFLAGS += -Wall -Werror -Wshadow
 CFLAGS += -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers
+endif

 CFLAGS += -fno-omit-frame-pointer
 CFLAGS += -fstack-protector

@SnowLeopard71
Copy link
Author

Actually, -Wall -Werror can be left in, it's only -Wgshadow that is a problem.
(Please forgive my noobness).

@mx4
Copy link
Contributor

mx4 commented Feb 25, 2014

Should be fixed-up now. Can you please git pull, then make and let me know how that goes? Thanks.

@SnowLeopard71
Copy link
Author

Nope... ARCH vs MACH as variable not selecting compiler right, and it only compiles after removing -Wgshadow -Wextra
The errors those flags give:
src/poll.c:75:53: error: declaration of âpollâ shadows a global declaration [-Werror=shadow]
src/poll.c:200:4: error: comparison is always true due to limited range of data type [-Werror=type-limits]

@mx4
Copy link
Contributor

mx4 commented Feb 25, 2014

Yes, sorry about that. What about now?

@SnowLeopard71
Copy link
Author

That did it! Nice clean compile :)
Took maybe 2 minutes to startup and get to 'online'.
Now this issues just needs to be marked "fixed" instead of "won't fix" :)
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants