Bug 14644

Summary: Please add per-toolchain CMake toolchain file which does not rely on setting up environment variables
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Jan Dorniak <jaskij>
Component: devtools / tool chainAssignee: Jagadeesh Krishnanjanappa <workjagadeesh>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: meta.mr.watcher, meta.watcher, randy.macleod, workjagadeesh
Version: 4.0   
Target Milestone: 4.0 M4   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)
Attachments:
Description Flags
cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi.toolchain.cmake
none
creates per-toolchain cmake file in the SDK
none
sample per-toolchain cmake file generated in SDK using the attached patch none

Description Jan Dorniak 2021-12-05 16:15:38 UTC
Created attachment 4845 [details]
cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi.toolchain.cmake

The life of developers using IDEs with OE's toolchain would be greatly improved by generating per-toolchain CMake toolchain files.

The toolchain files generated should have a name based on the TARGET_PREFIX of the target machine and be installated besides OEToolchainConfig.cmake

As an example/template there's an attached file I have manually written for cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi, with comments indicating which flags I believe should replace hardcoded strings.

The next steps to go from here would be:

1. Making sure which variables to use to replace the hardcoded strings
2. Generate the file in `cmake-native` when building the SDK
Comment 1 Jagadeesh Krishnanjanappa 2022-01-31 03:30:27 UTC
Created attachment 4848 [details]
creates per-toolchain cmake file in the SDK

Hi Jan,

The attached patch creates ${MULTIMACH_TARGET_SYS}-toolchain.cmake file
at ${SDK_INSTALL_DIR}/sysroots/${SDK_SYS}/usr/share/cmake/, which is 
per-toolchain CMake toolchain file containing
arch-specific values and independent of OE environment variables.

The file gets created after installing SDK toolchain installer obtained
by running "bitbake -c populate_sdk <image>".

Please try this patch let me know if any issues. If the patch works as
expected then it can be pushed for review and merge.

Note:
1. From ${SDK_INSTALL_DIR}/${SDKMACHINE}/usr/share/cmake
we need "../../../../../" rather than "../../../../" to go SDK install
directory.
2. Changes to install cmake template file(as present in the patch) and cmake-setup.py should go into cmake recipe as it overrides the some of the functions/variables specific to nativesdk. So kept the changes into cmake recipe  rather than cmake-native.


Regards,
Jagadeesh
Comment 2 Jagadeesh Krishnanjanappa 2022-01-31 03:31:24 UTC
Created attachment 4849 [details]
sample per-toolchain cmake file generated in SDK using the attached patch
Comment 3 Jagadeesh Krishnanjanappa 2022-02-01 16:56:02 UTC
Any feedback on the attached patch?

Regards
Jagadeesh
Comment 4 Randy MacLeod 2022-02-01 18:47:47 UTC
Jan, please review and/or try Jagadeesh's patch and provide feedback. Thanks.
Comment 5 Jan Dorniak 2022-03-01 01:21:28 UTC
Jagadeesh, Randy,

sorry for not replying earlier - I actually thought that replying to Bugzilla's notification would create a comment.

Back on topic, I have tested Jagadeesh's patch against current master (with the minor tweak that master uses CMake 3.22.2 and the filenames in the patch had to be adjusted accordingly).

I was able to build and SDK and install it.

Building both manually from the terminal and via IDE (JetBrains CLion), using only the generated toolchain file worked marvelously, with no issues. The project I have tested with links to two libraries: pthread and OpenMP.

I have been unable to actually test run the build binary on the target because of connection issues - but should be able to do so in the next few days.

Once again, sorry for not replying earlier.
Everything best
Jan
Comment 6 Jagadeesh Krishnanjanappa 2022-03-01 02:28:03 UTC
Hi Jan,

Thank you for taking time to test it.
I will try to push the patch for commit
in the oe-core mailing list.

Thanks Randy and Stephen for the follow-up.

Regards
Jagadeesh
Comment 7 Jagadeesh Krishnanjanappa 2022-03-01 12:12:18 UTC
I would defer submitting the patch in the mailing list until the built binary runs fine on the target.

Jan,

Please let us know if you face any issues while running the binary on the target.

Regards,
Jagadeesh
Comment 8 Randy MacLeod 2022-03-03 16:00:13 UTC
Thanks everyone. Waiting for testing results and commenting for those who track the status of bugs...
Comment 9 Randy MacLeod 2022-03-10 16:08:22 UTC
Jagadeesh any testing results?
Comment 10 Jagadeesh Krishnanjanappa 2022-03-10 16:46:30 UTC
(In reply to comment #9)
> Jagadeesh any testing results?

Hi Randy,

I do not have a setup to verify the patch. I am waiting for Jan to give testing results once he is able to solve connection issues as per comment 5.

Regards,
Jagadeesh
Comment 11 Jan Dorniak 2022-03-30 23:15:06 UTC
I am sorry for not responding earlier.

Finally got to testing this, using the files generated during my previous test.

It works just fine.

Once again, sorry for the delay
Jan

P.S.
I would change the status, but am not sure which is appropriate.
Comment 12 Jagadeesh Krishnanjanappa 2022-03-31 02:51:44 UTC
Thanks Jan.

Posted the patch for review and commit in the OE-core mailing list  [https://lists.openembedded.org/g/openembedded-core/message/163800| here]

Regards,
Jagadeesh
Comment 13 Stephen K Jolley 2022-04-01 16:52:21 UTC
Patch Posted
Comment 14 Jagadeesh Krishnanjanappa 2022-04-01 17:16:39 UTC
The patch is merged to master at https://git.openembedded.org/openembedded-core/commit/?id=42e68397ec74b3cd8ae5df45355c8f6254b48cd8.

Can we change the resolution of bug to fixed?

Regards,
Jagadeesh
Comment 15 Randy MacLeod 2022-04-05 23:21:42 UTC
@Jagadeesh, I've assigned this back to you. I think you should have been able to just click the 'take' link if you had enough info from Jan.

Anyway, there's no formal per bug testing process that I'm aware of so since there seems to be consensus that this is fixed, please go ahead and close the defect as resolved / fixed. You have already include a link to the master commit which we like to see so it seems we're done.
Comment 16 Jagadeesh Krishnanjanappa 2022-04-06 01:25:43 UTC
Moving to fixed as the patch is committed to master at .https://git.openembedded.org/openembedded-core/commit/?id=42e68397ec74b3cd8ae5df45355c8f6254b48cd8

Regards,
Jagadeesh