Problem Installing Keystone SDK

271 views
Skip to first unread message

Ryan Luna

unread,
Feb 22, 2021, 8:46:08 PM2/22/21
to Keystone Enclave Forum

Hello,

I'm trying to install Keystone on my Ubuntu 18.04 Virtual Machine running on OSX 10.15.7.

Using RISC-V GNU version 10.2.0.

I am following the documentation here to install Keystone for use with Qemu. The toolchain is installed and working but running cmake during the installation process for the sdk is giving an error and saying its broken because the command '-rdynamic' is unknown to the compiler. I am aware that I can force the cmake test to pass but i'm afraid of breaking something else by doing that.

Has anyone had this error or know how to fix? Would really appreciate it. I have had no luck of finding a solution online and I cannot find the file where the command is being given to the compiler so that I may change it to something else like -Wl,--export-all-symbols which I found suggested here.

Below is the output from the cmake command...

ryan@ryan-VirtualBox:~/keystone-sdk/build$ cmake ..
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Check for working C compiler: /opt/riscv/bin/riscv64-unknown-elf-gcc
-- Check for working C compiler: /opt/riscv/bin/riscv64-unknown-elf-gcc -- broken
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/opt/riscv/bin/riscv64-unknown-elf-gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/ryan/keystone-sdk/build/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_eb7dd/fast"
    /usr/bin/make -f CMakeFiles/cmTC_eb7dd.dir/build.make CMakeFiles/cmTC_eb7dd.dir/build
    make[1]: Entering directory '/home/ryan/keystone-sdk/build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_eb7dd.dir/testCCompiler.c.o
    /opt/riscv/bin/riscv64-unknown-elf-gcc    -o CMakeFiles/cmTC_eb7dd.dir/testCCompiler.c.o   -c /home/ryan/keystone-sdk/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_eb7dd
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_eb7dd.dir/link.txt --verbose=1
    /opt/riscv/bin/riscv64-unknown-elf-gcc      -rdynamic CMakeFiles/cmTC_eb7dd.dir/testCCompiler.c.o  -o cmTC_eb7dd
    riscv64-unknown-elf-gcc: error: unrecognized command-line option '-rdynamic'
    CMakeFiles/cmTC_eb7dd.dir/build.make:97: recipe for target 'cmTC_eb7dd' failed
    make[1]: *** [cmTC_eb7dd] Error 1
    make[1]: Leaving directory '/home/ryan/keystone-sdk/build/CMakeFiles/CMakeTmp'
    Makefile:126: recipe for target 'cmTC_eb7dd/fast' failed
    make: *** [cmTC_eb7dd/fast] Error 2
    

 

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt


-- Configuring incomplete, errors occurred!
See also "/home/ryan/keystone-sdk/build/CMakeFiles/CMakeOutput.log".
See also "/home/ryan/keystone-sdk/build/CMakeFiles/CMakeError.log".

Dayeol Lee

unread,
Feb 22, 2021, 11:22:28 PM2/22/21
to Ryan Luna, Keystone Enclave Forum
Hi Ryan,

How did you install the toolchain?
It seems that your toolchain is installed on /opt/riscv/bin, but the cmake finds that it's broken for some reason.
Right now, the dev branch's fast-setup.sh will download the prebuilt toolchain which includes gcc 10.2.0  (See dev branch's document instead).
So I'd use the prebuilt toolchain instead if the problem persists.




--
You received this message because you are subscribed to the Google Groups "Keystone Enclave Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keystone-enclave-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keystone-enclave-forum/8b1af76b-6bbb-44cf-97a4-15d0b56ce13an%40googlegroups.com.

Ryan Luna

unread,
Feb 23, 2021, 4:04:49 PM2/23/21
to Keystone Enclave Forum
Hey Dayeol!

Thanks for the response!

I installed the toolchain per the README instructions on the github repository. As you suggested, I used fast-setup.sh and I made it past that issue. I thought I should try the manual setup to get a deeper look into the process and also because I have other versions of the riscv-gnu-toolchain from xtools and timberv (I made sure those were not included in the PATH, RISCV, or KEYSTONE_SDK_DIR variables) and wanted to make sure there weren't any dependency conflicts.

Unfortunately, I am getting another error I have yet to dig into when running make from the newly created build directory. Apparently there is a missing header file.

The following is the output...

[ 10%] Building C object examples/tests/CMakeFiles/malloc.dir/malloc/malloc.c.o
cd /home/ryan/keystone/TestBuild/examples/tests && /opt/riscv/bin/riscv64-unknown-linux-gnu-gcc  -I/home/ryan/KEYSTONE/include  -Wall -Werror   -o CMakeFiles/malloc.dir/malloc/malloc.c.o   -c /home/ryan/keystone/sdk/examples/tests/malloc/malloc.c
/home/ryan/keystone/sdk/examples/tests/malloc/malloc.c:5:10: fatal error: app/eapp_utils.h: No such file or directory
    5 | #include "app/eapp_utils.h"
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
examples/tests/CMakeFiles/malloc.dir/build.make:65: recipe for target 'examples/tests/CMakeFiles/malloc.dir/malloc/malloc.c.o' failed
make[2]: *** [examples/tests/CMakeFiles/malloc.dir/malloc/malloc.c.o] Error 1
make[2]: Leaving directory '/home/ryan/keystone/TestBuild'
CMakeFiles/Makefile2:1505: recipe for target 'examples/tests/CMakeFiles/malloc.dir/all' failed
make[1]: *** [examples/tests/CMakeFiles/malloc.dir/all] Error 2
make[1]: Leaving directory '/home/ryan/keystone/TestBuild'
Makefile:86: recipe for target 'all' failed
make: *** [all] Error 2

Dayeol Lee

unread,
Feb 23, 2021, 4:41:13 PM2/23/21
to Ryan Luna, Keystone Enclave Forum
Hi,

I'll assume that you're on the dev branch.

It seems that your KEYSTONE_SDK_DIR does not point to the SDK install directory.

The way we handle SDK has been changed in our upcoming version (v1.0).
Before changes, KEYSTONE_SDK_DIR needs to be set to the SDK's source directory, which was <keystone dir>/sdk.
After the massive refactoring, v1.0 SDK is completely built out-of-tree and has a separate install directory.

If your KEYSTONE_SDK_DIR is somehow set to <keystone src dir>/sdk, please unset it completely, and run ./fast-setup.sh again as follows.
That will build the SDK and install the SDK in a separate <keystone src dir>/sdk/build64 directory

$ unset KEYSTONE_SDK_DIR
$ ./fast-setup.sh

$ echo $KEYSTONE_SDK_DIR

Check if this prints out <keystone dir>/sdk/build64

Also, try to see inside KEYSTONE_SDK_DIR and see if lib and include directories are there.

$ ls <keystone dir>/sdk/build64
# this should show `lib` and `include` directories

After you set the SDK path correctly, I recommend you removing `examples` directory completely before you run `make` in the keystone's build directory.

Let me know if this doesn't work out.

Thanks,

Dayeol

Ryan Luna

unread,
Feb 24, 2021, 1:10:59 PM2/24/21
to Keystone Enclave Forum
I did as you have suggested but the KEYSTONE_SDK_DIR is not set after unsetting and then running ./fast-setup.sh

I am using the keystone repository. I also have installed the keystone-sdk repository. The original issue was with the keystone-sdk repo, but the fast-setup.sh file was not in there so i moved into the keystone repo to do this. I'm not sure if the issue lies there?

Thanks

Dayeol Lee

unread,
Feb 24, 2021, 2:27:42 PM2/24/21
to Ryan Luna, Keystone Enclave Forum
Hi,

Yes, "fast-setup.sh" I'm referring to is one in keystone's directory, on the dev branch:

You don't need to clone SDK separately if you run fast-setup.sh, because it will install it for you.

Please start from the keystone repo: https://github.com/keystone-enclave/keystone
It includes the SDK as the submodule.
So you should checkout to dev branch and run fast-setup.sh.

git checkout dev



Ryan Luna

unread,
Feb 26, 2021, 4:08:41 PM2/26/21
to Keystone Enclave Forum
I unistalled/removed all keystone related directories from the machine including the keystone-sdk. I cloned the keystone repo and switched to the dev branch. I ran fast-setup.sh and followed the dev document. It did not set the KEYSTONE_SDK_DIR. I received the same error with the missing header file.

Ryan Luna

unread,
Feb 26, 2021, 4:18:56 PM2/26/21
to Keystone Enclave Forum
I appologize, I had incorrectly typed the KEYSTONE_SDK_DIR path variable to check if it was set. Typing it in correctly, I found that it was set to an old path. I unset it and ran ./fast-setup.sh again and it installed the sdk properly and set the path. I believe i passed the error now but I have encountered another. Attached is a screenshot of it.
Screen Shot 2021-02-26 at 3.18.23 PM.png

Dayeol Lee

unread,
Feb 26, 2021, 4:19:02 PM2/26/21
to Ryan Luna, Keystone Enclave Forum
can you copy your source.sh generated by fast-setup.sh? (under keystone source dir)
and can you run the following before you make?

source source.sh 

Ryan Luna

unread,
Feb 26, 2021, 4:27:41 PM2/26/21
to Keystone Enclave Forum
Attached are screenshots. I unset KEYSTONE_SDK_DIR and then ran fast-setup.sh. I checked the source.sh and there is a screenshot of that. I ran cmake .. in the newly created Build directory, then make after that. The last screenshot is the error message I am getting now.
Screen Shot 2021-02-26 at 3.21.20 PM.png
Screen Shot 2021-02-26 at 3.18.23 PM.png
Screen Shot 2021-02-26 at 3.22.39 PM.png

Dayeol Lee

unread,
Feb 26, 2021, 4:37:37 PM2/26/21
to Ryan Luna, Keystone Enclave Forum
can you confirm that you have installed all dependencies 

and run makeself to see if makeself has been installed?

Ryan Luna

unread,
Feb 27, 2021, 2:47:16 AM2/27/21
to Keystone Enclave Forum
I believe I was missing a dependency. Makeself is installed. That solved the previous error but ran into another with the cross compiler when running make. Attached is the screenshot of the error.

I do apologize for the long string of errors and any inconvenience. I really appreciate the help.
Screen Shot 2021-02-27 at 1.42.59 AM.png

Dayeol Lee

unread,
Feb 27, 2021, 1:56:04 PM2/27/21
to Ryan Luna, Keystone Enclave Forum
No problem!

Can you confirm you have installed your toolchain in /home/ryan/keystone/riscv64/bin?
If you are using your own toolchain (not downloaded by fast-setup.sh), 
you should set the environment variables with the path of your toolchain.
For example,
RISCV=/opt/riscv and PATH=/opt/riscv/bin:$PATH 
instead of
RISCV=/home/ryan/keystone/riscv64/ and PATH=/home/ryan/keystone/riscv64/bin

I think the main problem is that our fast-setup.sh doesn't handle the cases when you use a custom toolchain.
So you need to change the source.sh manually.


Ryan Luna

unread,
Feb 28, 2021, 12:41:44 AM2/28/21
to Keystone Enclave Forum
Yup! Looks like that did it!

I modified the RISCV variable in source.sh to the path where my riscv toolchain was actually installed on the machine. I was able to run through the rest of the documentation for Qemu with the tests completing successfully.

Thank you so much for your help Dayeol!

If you need anything from me please let me know.
Reply all
Reply to author
Forward
0 new messages