Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Linux - OpenCL detection is unreliable #557

Closed
bobsummerwill opened this issue Jun 7, 2016 · 16 comments · Fixed by ethereum/webthree-helpers#196
Closed

Linux - OpenCL detection is unreliable #557

bobsummerwill opened this issue Jun 7, 2016 · 16 comments · Fixed by ethereum/webthree-helpers#196
Assignees
Labels

Comments

@bobsummerwill
Copy link
Contributor

Multiple people have hit issues with OpenCL detection in their Linux builds.

I don't know if it is distro-specific? Are all the issues occurring on non-Ubuntu distros?

Need to investigate.

See, for example, #552 (comment)

And I should search from the previous reports of this and see if I can spot a pattern.

@bobsummerwill
Copy link
Contributor Author

So, as per #552 (comment), @wainersec, the issue looks like it might be related to the syntax of the command-line, do you think?

Because -lname usually doesn't include a fully qualified path, does it? Instead, library paths are usually added, and the -lname are usually without paths.

Maybe different versions of GGC or Clang can or cannot cope with this.

Could you look at the fully qualified command-line which is within the generated makefiles? Are other external libraries being composed differently?

@bobsummerwill
Copy link
Contributor Author

Hmm - yeah - check this out:

https://github.com/ethereum/webthree-helpers/blob/develop/cmake/UseOpenCL.cmake#L9

That "smells" like the problem. Perhaps that workaround is OK for Ubuntu but broken for other distros?

The command-line composition likely works in a different way when not "hacked in" like this.

Could you try removing that conditional?

So replace:

    if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND ETHASHCL)
        # workaround for https://github.com/ethereum/alethzero/issues/69
        # force linking to libOpenCL as early as possible
        target_link_libraries(${TARGET} "-Wl,--no-as-needed -l${OpenCL_LIBRARIES} -Wl,--as-needed")
    else()
        target_link_libraries(${TARGET} ${OpenCL_LIBRARIES})
    endif()

With

target_link_libraries(${TARGET} ${OpenCL_LIBRARIES})

@bobsummerwill
Copy link
Contributor Author

CC @chfast. Hello, Pawel!

This is in relation to ethereum/alethzero#69.

CC @chriseth. So funnily enough it looks like we have found the root cause here of the "sometimes OpenCL detection doesn't seem to work on Linux" issue which I was pondering changing the default on yesterday.

@w-sec
Copy link

w-sec commented Jun 7, 2016

Just replaced those lines but it is still not working. Trying workarround.

@bobsummerwill
Copy link
Contributor Author

You would need to replace those lines, re-run cmake, then re-run make.

If you got the same issue, I would suspect that you were using the same makefile.

@w-sec
Copy link

w-sec commented Jun 7, 2016

No, used new one.

@bobsummerwill
Copy link
Contributor Author

See #557 too.

@w-sec
Copy link

w-sec commented Jun 7, 2016

I think the error is dragged from before, at FindOpenCL.make. OpenCL_LIBRARIES and OpenCL_INCLUDE_DIRS are not getting defined I think.

@bobsummerwill
Copy link
Contributor Author

And you got the exact some error message? About the -l/usr/... ?
That doesn't sound right. Could you try just blowing away the whole build directory please, and then share the gist?

@w-sec
Copy link

w-sec commented Jun 7, 2016

Yes, same error. I tried deleting the directory and cloning again. https://gist.github.com/wainersec/296d651d58f663ed150f27cb05a14d49

@bobsummerwill
Copy link
Contributor Author

OK - so the info we are still missing is the full command-line which make is trying to execute.

Please can you grep your makefiles, and try to find the exact fully-expanded command-line? Or I think there is a make "flag" for showing the command-lines it would execute, rather than running them, right?

That would be even better.

@w-sec
Copy link

w-sec commented Jun 7, 2016

This is the gist for the --recon flag of make (the function you just mentioned) https://gist.github.com/wainersec/f865721f2866a50b3ff22b7f30bd17f3

@w-sec
Copy link

w-sec commented Jun 7, 2016

Just found the full command:
/usr/bin/c++ -fPIC -std=c++11 -fpermissive -O2 -g -DETH_RELEASE -shared -Wl,-soname,libethash-cl.so -o libethash-cl.so CMakeFiles/ethash-cl.dir/ethash_cl_miner.cpp.o -lcryptopp ../libethash/libethash.so -Wl,--no-as-needed -l/usr/lib64/libOpenCL.so -Wl,--as-needed -Wl,--no-as-needed -l/usr/lib64/libOpenCL.so -Wl,--as-needed -lcryptopp -Wl,-rpath,/home/limechain/Dev/webthree-umbrella/build/libethereum/libethash:

It is found in libethereum/libethash-cl/CMakeFiles/ethash-cl.dir/link.txt

@bobsummerwill
Copy link
Contributor Author

Oh, delightful ... it looks like that workaround got cut-and-pasted in two places.

See https://github.com/ethereum/webthree-helpers/pull/196/files. I have updated the PR to fix both sites. Please could you try applying both changes, and re-generating from scratch? Thanks!

And you will need the cmake -DGUI=0

@w-sec
Copy link

w-sec commented Jun 7, 2016

Yay! ld error is gone. New PR works perfect. But just got another error, it has to be with devcrypto and solidity. Should I create a new issue? https://gist.github.com/wainersec/6ba3b7a9ca8fb86e8af8581c58486c7f Thanks.

@bobsummerwill
Copy link
Contributor Author

Let's head back to your original issue.

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

Successfully merging a pull request may close this issue.

2 participants