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

clang/ld armv7s and armv7 compilation unsupported file format which is not the architecture being linked and undefined symbols #55

Closed CallumA closed 10 years ago

CallumA commented 10 years ago

When cross-compiling for iOS on armv7s or armv7 (on OS X) ld throws this lot out:

ld: warning: ignoring file minerd-cpu-miner.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (armv7s): minerd-cpu-miner.o
ld: warning: ignoring file minerd-util.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (armv7s): minerd-util.o
ld: warning: ignoring file minerd-sha2.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (armv7s): minerd-sha2.o
ld: warning: ignoring file minerd-scrypt.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (armv7s): minerd-scrypt.o
ld: warning: ignoring file minerd-sha2-arm.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (armv7s): minerd-sha2-arm.o
ld: warning: ignoring file minerd-scrypt-arm.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (armv7s): minerd-scrypt-arm.o

and then fails with:

Undefined symbols for architecture armv7s:
  "_main", referenced from:
      start in crt1.3.1.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [minerd] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

This happens regardless of whether neon is enabled or not.

libcurl.a and libjansson.a were both compiled (for armv7(s)) and manually referenced in the Makefile.

My environment is OS X 10.9.1 with iOS 7.0 SDK set up for cross-compiling by:

$ export IPHONEOS_DEPLOYMENT_TARGET="4.3"
$ export $ CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
$ export CFLAGS="-arch [ARCH] -pipe -Os -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk"
$ export LDFLAGS="-arch [ARCH] -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk"
$ ./configure --disable-shared --enable-static --host="armv7-apple-darwin"
$ make -j `sysctl -n hw.logicalcpu_max`

Which is essentially the method on this page: http://seiryu.home.comcast.net/~seiryu/libcurl-ios.html

I have literally no clue what the error is on about to be honest, I guess it's not compiling those files for the architecture correctly. Maybe they're not compiling for armv7(s) but instead compiling for my actual system, I wouldn't know how to tell.

I assume this is an issue rather than just being me however I guess very few people have bothered to try compiling a miner on iOS, libcurl and libjansson did compile fine. Not sure quite how I'll interface with the miner once it's compiled since NSTask is not available on iOS, figured I'd work that out once I have something to experiment with.

Thanks!

pooler commented 10 years ago

Could you please post the config.log file generated by cpuminer's configure script, as well as the full output of make? (Please use a pastebin.)

CallumA commented 10 years ago

Sure, here's the config.log: http://pastebin.com/V577JDda Make output: http://pastebin.com/qDXiuxDy

pooler commented 10 years ago

Could you try including the previously exported CFLAGS in the CFLAGS passed to cpuminer's configure script (so something like CFLAGS="$CFLAGS -O3") and then rebuilding (don't forget to make clean)?

CallumA commented 10 years ago

Well, that changed things which I guess is good.

The make now outputs A LOT of "invalid operand for instruction" (took a while to find the top of that in my window). It's about 6MB of text so I've had to put it on File Dropper: http://www.filedropper.com/makeoutput

The config.log is here: http://pastebin.com/pdQ9EfCT

Thanks

pooler commented 10 years ago

Did you remember to run nomacro.pl (see README)?

CallumA commented 10 years ago

Yep, ran it again to be sure. Same result.

pooler commented 10 years ago

OK, then please restore the .S files from tarball or git and try adding "-no-integrated-as" to CFLAGS.

CallumA commented 10 years ago

Now some "ARM register expected", "shift expression expected" and "immediate expression requires a # prefix" as well as a bit of "constant expression required" and "VFP single, double or Neon quad precision register expected"

Make: http://www.filedropper.com/makeoutput2 (almost fitted on Pastebin this time) Config.log: http://pastebin.com/DL5J9R3v

pooler commented 10 years ago

OK, that makes sense given that you are on Darwin and must have a very old version of the GNU assembler. Now try again with "-no-integrated-as" after running nomacro.pl.

CallumA commented 10 years ago

Agh, forgot that!

Now I'm getting this:

Undefined symbols for architecture armv7s:
  "_inflate", referenced from:
      _inflate_stream in libcurl.a(libcurl_la-content_encoding.o)
  "_inflateEnd", referenced from:
      _inflate_stream in libcurl.a(libcurl_la-content_encoding.o)
      _Curl_unencode_gzip_write in libcurl.a(libcurl_la-content_encoding.o)
      _Curl_unencode_cleanup in libcurl.a(libcurl_la-content_encoding.o)
  "_inflateInit2_", referenced from:
      _inflate_stream in libcurl.a(libcurl_la-content_encoding.o)
      _Curl_unencode_gzip_write in libcurl.a(libcurl_la-content_encoding.o)
  "_inflateInit_", referenced from:
      _Curl_unencode_deflate_write in libcurl.a(libcurl_la-content_encoding.o)
  "_zlibVersion", referenced from:
      _curl_version in libcurl.a(libcurl_la-version.o)
      _curl_version_info in libcurl.a(libcurl_la-version.o)
      _Curl_unencode_gzip_write in libcurl.a(libcurl_la-content_encoding.o)
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [minerd] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

I'm guessing from the looks of things there was a problem with my compiling or curl and zlib not working rather than it being anything to do with your package?

Thanks again

pooler commented 10 years ago

Yes, that looks like libcurl was not compiled for the right architecture. Please try again and make sure libcurl's configure script uses your environment variables. (You should be able to check in config.log.)

fabulouspanda commented 10 years ago

Compiling for Mac OS it works for me if I replace the check for curl from the configure and replace the link to curl in the Makefile with -lcurl

edit: Sorry ignore me with the iOS specific issues!