linaro-swg / optee_examples

OP-TEE Sample Applications
Other
163 stars 140 forks source link

If both my ta and ca codes need to be written in Cpp language, where should I modify the makefile? #111

Closed oldoldcoder closed 8 months ago

oldoldcoder commented 8 months ago
  1. Regarding the host file, I modified gcc to g++ and added a link library, but I haven’t had time to verify whether it is feasible.
image
  1. Regarding the compilation rules of TA files, it seems to be in ta_dev_kit.mk. I tried to go to the ta_dev_kit.mk folder to modify the content to complete the compilation of CPP, but I have not yet found the corresponding rules in ta_dev_kit.
image

3.The letter C in CMakeList.txt seems to mean that the file is in C language? I can't confirm

image

In general, I want to know what modifications need to be made to the makefile to make it run properly when I have to use CPP

jbech-linaro commented 8 months ago
  1. Regarding the host file, I modified gcc to g++ and added a link library, but I haven’t had time to verify whether it is feasible.

Yes, that should work, but remember that you also will need to add/enable GMP and NTL in Buildroot. If you're lucky they already exist and it can just be enabled with a BR2_... flag. Here is how we enable OpenSSL for example: https://github.com/OP-TEE/build/blob/master/common.mk#L279 . If GMP and NTL doesn't exist in Buildroot, then there is more work to do, since you basically need to add them by your self (and enable like shown here). How that is done is more of a Buildroot forum question.

  1. Regarding the compilation rules of TA files, it seems to be in ta_dev_kit.mk. I tried to go to the ta_dev_kit.mk folder to modify the content to complete the compilation of CPP, but I have not yet found the corresponding rules in ta_dev_kit.

See below.

3.The letter C in CMakeList.txt seems to mean that the file is in C language? I can't confirm

Correct.

In general, I want to know what modifications need to be made to the makefile to make it run properly when I have to use CPP

OP-TEE only has limited C++ support and you might hit a dead end for now, please see this FAQ.

Also, this is fully unrelated to OP-TEE, but very much about NTL itself. Some time ago, I was a bit involved in this DARPA project. Back then we also used NTL, however at that time it wasn't possible to cross compile NTL for Arm, where the main reason was that the build process creates intermediate binaries that it uses for the rest of the build process. I.e., NTL started out by compiling a binary called MakeDesc, that it tries to run shortly after as another build stage. When building with an Arm toolchain, it obviously produces an Arm binary, but since we’re cross compiling on an x86-based system we couldn't run this newly produced binary and the build step fails. The NTL community is aware of this issue, but at the time they had no plans to change it. As a temporary workaround we built the binaries on an Arm-based machine and checked in those as prebuilt binaries to the build git.

oldoldcoder commented 8 months ago

@jbech-linaro Thank for your reply ,I mean that may be I found answer in "https://github.com/OP-OS/issue#Experimental support for C++ in TAs (#3693)" At the same time, I found the implementation of C and have now completed the preparation test. Thank you for all your eager replies.