Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

problem when compile #10

Closed
AlbertnQ opened this issue Apr 28, 2020 · 10 comments
Closed

problem when compile #10

AlbertnQ opened this issue Apr 28, 2020 · 10 comments

Comments

@AlbertnQ
Copy link

Sorry for bothering.When I tried to use the command "emconfigure cmake ..",it reports error: use 'emcmake' rather then 'emconfigure' for cmake projects. So I used ' emcmake cmake ..', it also report error,like the following:

configure: cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/samfisher/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR="/home/samfisher/emsdk/node/12.9.1_64bit/bin/node"
CMake Warning at third_party/googletest/googlemock/CMakeLists.txt:43 (project):
VERSION keyword not followed by a value or was followed by a value that
expanded to nothing.

CMake Warning at third_party/googletest/googletest/CMakeLists.txt:54 (project):
VERSION keyword not followed by a value or was followed by a value that
expanded to nothing.

-- Checking for module 'libunwind-generic'
-- No package 'libunwind-generic' found
libunwind not found. Disabling unwind tests.
CMake Error at third_party/boringssl/CMakeLists.txt:51 (message):
Could not find Go

-- Configuring incomplete, errors occurred!
See also "/home/samfisher/test/tpm-js/bulid-web/CMakeFiles/CMakeOutput.log".
See also "/home/samfisher/test/tpm-js/bulid-web/CMakeFiles/CMakeError.log".

@cfircohen
Copy link
Contributor

Thanks for submitting this issue.

What Emscripten SDK version are you using? Try dl the latest one from https://emscripten.org/docs/getting_started/downloads.html. I successfully compiled this project using the latest Emscripten SDK a couple of weeks ago.

What cmake version are you using?

@AlbertnQ
Copy link
Author

AlbertnQ commented May 13, 2020

Yes, I used the latest Emscripten SDK. And my cmake version is 3.13.3.

Now I can compile by using 'emcmake cmake..', but when I 'make -j4' ,it reported many errors:
(it seems to be caused by dependency library, such as boringssl?)

In file included from /home/samfisher/test/tpm-js/third_party/ibmswtpm2/src/AlgorithmCap.c:67:
In file included from /home/samfisher/test/tpm-js/third_party/ibmswtpm2/src/Tpm.h:67:
In file included from /home/samfisher/test/tpm-js/third_party/ibmswtpm2/src/LibSupport.h:90:
In file included from /home/samfisher/test/tpm-js/third_party/ibmswtpm2/src/TpmToOsslHash.h:72:
In file included from /home/samfisher/test/tpm-js/third_party/boringssl/include/openssl/evp.h:60:
/home/samfisher/test/tpm-js/third_party/boringssl/include/openssl/base.h:122:2: error: 
      "Unknown target CPU"
#error "Unknown target CPU"
 ^
In file included from /home/samfisher/test/tpm-js/third_party/ibmswtpm2/src/AlgorithmCap.c:67:
In file included from /home/samfisher/test/tpm-js/third_party/ibmswtpm2/src/Tpm.h:67:
In file included from /home/samfisher/test/tpm-js/third_party/ibmswtpm2/src/LibSupport.h:100:
In file included from /home/samfisher/test/tpm-js/third_party/ibmswtpm2/src/TpmToOsslSym.h:75:
/home/samfisher/test/tpm-js/third_party/boringssl/include/openssl/bn.h:165:2: error: 
      "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
#error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
 ^
/home/samfisher/test/tpm-js/third_party/boringssl/include/openssl/bn.h:219:44: error: 
      unknown type name 'BN_ULONG'
OPENSSL_EXPORT int BN_set_word(BIGNUM *bn, BN_ULONG value);
                                           ^
/home/samfisher/test/tpm-js/third_party/boringssl/include/openssl/bn.h:309:16: error: 
      unknown type name 'BN_ULONG'
OPENSSL_EXPORT BN_ULONG BN_get_word(const BIGNUM *bn);
               ^
/home/samfisher/test/tpm-js/third_party/boringssl/include/openssl/bn.h:377:43: error: 
      unknown type name 'BN_ULONG'
OPENSSL_EXPORT int BN_add_word(BIGNUM *a, BN_ULONG w);
fatal error: too many errors emitted, stopping now [-ferror-limit=]
In file included from /home/samfisher/test/tpm-js/third_party/boringssl/crypto/fipsmodule/bcm.c:31:
/home/samfisher/test/tpm-js/third_party/boringssl/crypto/fipsmodule/../internal.h:252:2: error: 
      "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
#error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
 ^
/home/samfisher/test/tpm-js/third_party/boringssl/crypto/fipsmodule/../internal.h:267:15: error: 
      unknown type name 'crypto_word_t'
static inline crypto_word_t value_barrier_w(crypto_word_t a) {
              ^
/home/samfisher/test/tpm-js/third_party/boringssl/crypto/fipsmodule/../internal.h:267:45: error: 
      unknown type name 'crypto_word_t'
static inline crypto_word_t value_barrier_w(crypto_word_t a) {
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
ERROR    root: compiler frontend failed to generate LLVM bitcode, halting
/home/samfisher/test/tpm-js/third_party/googletest/googletest/include/gtest/internal/gtest-type-util.h:43:12: fatal error: 'cxxabi.h' file not found
#  include <cxxabi.h>
           ^

@cfircohen
Copy link
Contributor

I'm having difficulty reproducing your errors. I updated emsdk to the latest version (per https://emscripten.org/docs/getting_started/downloads.html, I pulled the latest changed and ran "./emsdk install latest", "./emsdk activate latest", "source ./emsdk_env.sh"). Cloned a clean copy of tpm-js, initialized submodules ("git submodule update --init"), and built it with:
mkdir bulid-web
cd build-web
emcmake cmake ..
make -j4

You were right about changing "emconfigure cmake .." to "emcmake cmake ..", I also got that error.
But after that, the build completed successfully.

Maybe you're missing "build-essential" package?
I can maybe move the build process to a docker image. Would that work for you?

Note that if you only want to go through the code-labs, TPM-JS live web site is at: https://google.github.io/tpm-js/. Unless you want to change the codelabs, there's no real need to rebuild the project.

@AlbertnQ
Copy link
Author

Thanks for your help. If it's convenient for you, please provide docker image to me. I want to learn this framework, but I met lots of problems when building, even though I used the same instructions as you did above. Sorry for bothering.

@cfircohen
Copy link
Contributor

I added an emsdk Dockerfile and a couple of helper shell scripts in 77d7b80.

Please pull, delete your "build-web" dir if you have any and run:
$ ./dcmake
$ ./dmake -j4

The first prepares the Docker image, creates 'build-web' directory, and invokes cmake in the Docker image. You need to run this only once.

The second runs make in the Docker image.

Please give it a try.

@AlbertnQ
Copy link
Author

RUN groupadd -g $group builder \
    && useradd -u $user -g $group builder \
    && mkdir -p /home/builder \
    && chown -R builder:builder /home/builder

I think groupadd command use -g to add a new group that has a new gid, but $group gid may have been used, will it cause an error?And the second command useradd -u may be the same.

@cfircohen
Copy link
Contributor

These are arguments set by dcmake.sh and dmake.sh. Please look at the shell scripts.

@cfircohen
Copy link
Contributor

Sorry, arguments set by dinit.sh when it builds the image:

docker build
--build-arg user="$(id -u "${USER}")"
--build-arg group="$(id -g "${USER}")"
-t tpm-js-builder-image .

@AlbertnQ
Copy link
Author

Yes.
In dinit.sh,

docker build
--build-arg user="$(id -u "${USER}")"
--build-arg group="$(id -g "${USER}")"
-t tpm-js-builder-image .

User is current user's uid, and group is current user's gid, so in dockerfile,useradd and groupadd may cause error 'uid is not unique' and 'gid is not unique'.Because they are used.When I compile ,it's actually like this. After I change them, it can work normally now and I can run the web.
Thank you very much!Thanks for your help!

@cfircohen
Copy link
Contributor

I'm glad it works for you. Thanks for your interest in this project.

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

No branches or pull requests

2 participants