pooler / cpuminer

CPU miner for Litecoin and Bitcoin
https://bitcointalk.org/index.php?topic=55038.0
Other
2.77k stars 1.21k forks source link

Doesn't build on OSX. #4

Closed juestr closed 12 years ago

juestr commented 12 years ago

Probably because as v1.38 cannot handle macros. I tried with several MacPorts gcc variants, but no avail. Is there a way to expand macros in scrypt-x64.S with a script, or maybe with as on linux and use the result?

gcc -DHAVE_CONFIG_H -I. -pthread -fno-strict-aliasing -I./compat/jansson -I/opt/local/include -O3 -MT minerd-scrypt-x64.o -MD -MP -MF .deps/minerd-scrypt-x64.Tpo -c -o minerd-scrypt-x64.o test -f 'scrypt-x64.S' || echo './'scrypt-x64.S scrypt-x64.S:182:Alignment too large: 15. assumed. scrypt-x64.S:11:expecting operand before ','; got nothing scrypt-x64.S:11:expecting operand before ','; got nothing scrypt-x64.S:11:expecting operand before ','; got nothing scrypt-x64.S:11:expecting operand before ','; got nothing scrypt-x64.S:11:suffix or operands invalid for rol' scrypt-x64.S:11:suffix or operands invalid forrol' scrypt-x64.S:11:suffix or operands invalid for rol' scrypt-x64.S:11:suffix or operands invalid forrol' scrypt-x64.S:11:expecting operand before ','; got nothing scrypt-x64.S:11:expecting operand before ','; got nothing scrypt-x64.S:11:suffix or operands invalid for rol' scrypt-x64.S:11:suffix or operands invalid forrol' .... many more lines like this following.

pooler commented 12 years ago

You are right, gas only supports macros starting from version 2.6. I don't know why Apple only provides version 1.38, which is very old (probably about 10 years old; current version is 2.22). Maybe I could provide a script that adapts the source code so that it works with older versions of gas.

juestr commented 12 years ago

I am asking for a scriptable way on SE. Maybe this turns up an easy solution.

http://stackoverflow.com/questions/9064701/gnu-as-macro-expansion

pooler commented 12 years ago

I've written a Perl script that converts assembler macros to C preprocessor macros... it's a bit rough but it should do the trick. https://gist.github.com/1705863 Please let me know if it solves the problem.

juestr commented 12 years ago

Quite a nice hack, transforming macro syntax like that :)

It works somewhat, now I get linker errors later.

gcc -O3 -pthread -o minerd minerd-cpu-miner.o minerd-util.o minerd-scrypt.o minerd-scrypt-x86.o minerd-scrypt-x64.o -L/opt/local/lib -lcurl -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -lidn -lssl -lcrypto -lssl -lcrypto -lz -lz compat/jansson/libjansson.a -lpthread ld: duplicate symbol _scrypt_core in minerd-scrypt-x64.o and minerd-scrypt-x86.o collect2: ld returned 1 exit status

juestr commented 12 years ago

Addendum: after removing *x86 object files from the Makefile manually, it actually builds and works.

pooler commented 12 years ago

As far as I can tell, the only way for the symbol _scrypt_core to be exported twice is to have both __x86_64__ and __i386__ defined at the same time, and that should never happen. Did you run the Perl script on a clean clone?

juestr commented 12 years ago

I started fresh.

I did ./autogen on a linux (x86) machine, because that's broken on my Mac too, and AFAIK the results can be distributed.

After moving the code to my Mac it now works out of the box, very nice. Don't know why it didn't earlier, but I don't care :)

juestr commented 12 years ago

In case you want to see the autogen.sh error:

configure.ac:61: error: possibly undefined macro: AC_MSG_ERROR If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation.

pooler commented 12 years ago

After ec59ed6d6d8ae0bd7cf3ebcafc338486d1fbb1c8 (version 2.1.4), an updated version of the Perl script is part of the repo.

juestr commented 12 years ago

It works perfectly, I tried it yesterday.