This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6442: Arago custom SDK is missing C++ STL header files

Part Number: AM6442

SUMMARY

I am unable to use an Arago-built SDK to compile C++ programs that reference the STL.

I had the impression that I was supposed to just be able to call ${CXX} and it would work.  But it fails if I reference a STL header.  Is there another switch required to specify the path to the STL headers?

 

BACKGROUND

I have built a custom SDK using the command line

  MACHINE=am64xx-evm ARAGO_RT_ENABLE=1 bitbake multiconfig:segB1:image-lseb -c populate_sdk

It seems to work fine.  I then install the SDK to a folder in my home directory:

  cd ~/tisdk/build/arago-tmp-external-arm-glibc/deploy/sdk
  sudo ./arago-2021.09-toolchain-2021.09.sh

And I install the SDK to the folder ~/lsebsdk.  It seems to install fine.

PROBLEM: C++ STL Compile Failure

I start a new shell and source the SDK's environment setup script:

  . /home/brad/lsebsdk/environment-setup-aarch64-linux

It seems to work fine - printenv shows the expected settings.

But when I try to compile a file that includes C++ STL headers, it fails.  This is the simplest example:

  echo '#include <vector>' | ${CXX} -v -E  -

After printing out the various settings, it fails with:

  <stdin>:1:10: fatal error: vector: No such file or directory

INVESTIGATIONS

When I investigate the -v output, I see this (color highlights mine):

COLLECT_GCC_OPTIONS='-v' '-E' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../libexec/gcc/aarch64-none-linux-gnu/9.2.1/cc1 -E -quiet -v -iprefix /home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/ -isysroot /home/brad/lsebsdk/sysroots/aarch64-linux - -mlittle-endian -mabi=lp64
ignoring nonexistent directory "/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/../../../../aarch64-none-linux-gnu/include"
ignoring duplicate directory "/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/../../lib/gcc/aarch64-none-linux-gnu/9.2.1/include"
ignoring nonexistent directory "/home/brad/lsebsdk/sysroots/aarch64-linux/usr/local/include"
ignoring duplicate directory "/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/../../lib/gcc/aarch64-none-linux-gnu/9.2.1/include-fixed"
ignoring nonexistent directory "/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/../../lib/gcc/aarch64-none-linux-gnu/9.2.1/../../../../aarch64-none-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/include
/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/include-fixed
/home/brad/lsebsdk/sysroots/aarch64-linux/usr/include

As far as I can tell, the issue is that there is no "include" folder under the referenced directory - only bin and lib:

brad@MSI:~$ cd /home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/../../../../aarch64-none-linux-gnu/
brad@MSI:~/lsebsdk/sysroots/x86_64-arago-linux/usr/aarch64-none-linux-gnu$ ls
bin lib

Sleuthing a bit, if one follows the "-isysroot" path, one does find an include folder with "vector" in it:

brad@MSI:~$ cd /home/brad/lsebsdk/sysroots/aarch64-linux
brad@MSI:~/lsebsdk/sysroots/aarch64-linux$ ls
bin board-support boot dev etc home include lib media mnt proc run sbin sys tmp usr var
brad@MSI:~/lsebsdk/sysroots/aarch64-linux$ cd usr/include/c++/9.2.1/
brad@MSI:~/lsebsdk/sysroots/aarch64-linux/usr/include/c++/9.2.1$ ls vector
vector

The problem appears to be that C++ is searching for its STL headers along the -iprefix path rather than the -isysroot path.

The compiler seems to be correctly searching for C headers along the -isysroot path /home/brad/lsebsdk/sysroots/aarch64-linux/usr/include.  But it is searching for the C++ STL headers along the -iprefix path.

So it would appear that the compiler somehow needs to be told "look for your STL headers under -isysroot rather than -iprefix", OR the SDK should include a copy of (or symlink to) the sysroot STL headers found beneath the -iprefix path at

  /home/brad/lsebsdk/sysroots/aarch64-linux/usr/include/c++/9.2.1 
        in the folder
  /home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/aarch64-none-linux-gnu/usr/include/c++/9.2.1

Am I doing something wrong?  I had the impression that I was supposed to just be able to call ${CXX} and it would work.  But it doesn't.  Is there another switch to specify the path to the STL headers?  Is this a bug in the Arago SDK build?  Is there a workaround?

Thanks,
Brad

  • Partially answering my own question, but only partially.

    The As-Shipped SDK Uses a Symlink

    Further investigation reveals that the as-shipped TI Processor SDK includes a symlink of just the sort I was imagining might work as a workaround:

    brad@MSI:~/ti-processor-sdk-linux-rt-am64xx-evm-08.01.00.39/linux-devkit/sysroots/x86_64-arago-linux/usr/aarch64-none-linux-gnu$ ll include
    lrwxrwxrwx 1 brad brad 103 Apr 11 16:31 include -> /home/brad/ti-processor-sdk-linux-rt-am64xx-evm-08.01.00.39/linux-devkit/sysroots/aarch64-linux/include/

    What to Do Then?

    So one workaround is to manually add such a link to the SDK that is produced.

    That is undesirable.  What is the correct way to get this symlink to be included automatically?

    Thanks,

    Brad

  • Hi Brad,

    if you use our meta-arago based SDK, the correct way to create the toolchain/devkit installer is through the meta-toolchain-arago-tisdk bitbake target, see https://software-dl.ti.com/processor-sdk-linux/esd/AM64X/08_02_00_23/exports/docs/linux/Overview_Building_the_SDK.html. The use of the -c populate_sysroot is not supported in the context of the TI SDK. This is needed due to the way both external and internal toolchains are supported.

    However if you create your own distro you could utilize meta-ti, define your own images and create SDKs with -c populate_sdk without problems, also see here for some added context: https://lists.yoctoproject.org/g/meta-ti/topic/86495651

    Regards, Andreas

  • Hi Andreas,

    Thanks for your reply.

    Yes, I am doing the second thing you mentioned, creating a custom distro based on meta-ti, to build an image that includes libraries that are not in the TI distro, including a couple of packages that aren't even in OpenEmbedded.

    As you suggest, the images and SDK are indeed created without problem, except for this tiny issue of the symlink to the STL include folder not being created in the deployed SDK.  Once I manually create the symlink, the SDK works flawlessly.

    When I looked in the TI Processor SDK tree, I see that it somehow does have such link, while my -c populate_sdk process does not create it.

    I was looking for guidance on why this would be and how to correct it.  I reviewed the mailing list link you sent and it seems to basically talk about the steps I have already successfully completed.

    At this point, I was going to try something brute-force like a ROOTFS_POSTPROCESS_COMMAND or SDK_POSTPROCESS_COMMAND, but I have to confess that I don't really know what I'm doing at that level, and suspect that I am barking up the wrong tree, so I posted my question.  I feel like I must be doing something wrong.

    Thanks,

    Brad

  • I believe I have found the crux of what I needed to know, but still need to figure out exactly how to apply it.

    PARTIAL ANSWER

    I was indeed able to find exactly the type of "patch-up" code that I was thinking must be in the TI build stuff somewhere, that I mentioned in my last email, in meta-toolchain-arago.bb.

    I found:

    SDK_POSTPROCESS_COMMAND_prepend = "arago_sdk_fixup; "

    arago_sdk_fixup () {
      ...

      tcpath="${SDK_OUTPUT}/${SDKPATHNATIVE}${prefix_nativesdk}/${TOOLCHAIN_SYS}"
      mkdir -p $tcpath
      pushd $tcpath
      ln -s ${SDKTARGETSYSROOT}/include include
      if [ "${TOOLCHAIN_BRAND}" != "arago" ]; then
        mkdir -p libc
        cd libc
      fi
      mkdir -p usr
      ln -s ${SDKTARGETSYSROOT}/lib lib
      ln -s ${SDKTARGETSYSROOT}/usr/lib usr/lib
      ln -s ${SDKTARGETSYSROOT}/usr/include usr/include
      ...
    }

    WHAT TO DO?

    Now all I have to figure out is what I should do about that.  I can simply copy those lines to my recipe.  But should I some how instead delta my SDK off of meta-toolchain-arago-tisdk?  I want to bitbake my own custom SDK that includes things not in the stock SDK.

    I may be able to get to the finish line here on my own, but am not sure.  It seems like the right path might be to make an image that based on meta-toolchain-arago-tisdk, with a meta-toolchain-arago-tisdk.bbappend file that contains my additions?

    For something that is so complex, the documentation for building SDK's is incredibly thin.  It's one screenful on the Yocto site, and a single line in a table in the TI docs.  I'm not doing anything that complicated - just adding a couple of libraries to the SDK - but a week of searching has not led me to any guide that I've been able to find.

    FEEDBACK: Docs are confusing

    Your email (which I much appreciated), was the first time I had seen the words "SDK" and meta-toolchain-arago-tisdk in the same sentence.  I did see the letters "-tisdk" in meta-toolchain-arago-tisdk, but the word "toolchain" led me to believe that it was just a small piece of a full SDK, and that the only way to build a full SDK was with -c populate-sdk,  In fact, based on the table in section 1.2.3.2 at the link you provided, I would expect that arago-core-tisdk-bundle is what builds a Full SDK.  But its output is a tar.xz image, not a .sh installable SDK, so I was baffled by that.

    Anyway, I appreciate your help so far.  If you have any guidance about my "What to do?" question, it would be appreciated.

    Thanks,
    Brad

  • Okay, I think I have it all figured out now.  Thanks for your help, Andreas.

    SUMMARY

    It is simple to build a custom SDK based on meta-toolchain-arago-tisdk. as suggested by Andreas.

    The Arago SDK build process automatically fixes up the missing STL header file links, among other things.

    SOLUTION DETAIL

    As a simple example, I bitbaked a new recipe sdk-lseb.bb with this as the main content:

    require recipes-core/meta/meta-toolchain-arago-tisdk.bb
    TOOLCHAIN_TARGET_TASK:append = " cdk-staticdev"

    The bitbake command line does not include "-c populate_sdk".  I used simply:

    MACHINE=am64xx-evm ARAGO_RT_ENABLE=1 bitbake sdk-lseb

    This created an installable SDK arago-2021.09-aarch64-linux-tisdk.sh.  The installed SDK 

    • Includes my library libcdk.a built by my cdk recipe
    • Has the necessary symlinks for the C++ compiler to be able to find the STL headers.

    Of course you can add as many other things to the recipe as you like.

    TINY NIT

    The .sh file created by this process is not marked executable when it is complete.  Prior to running it to install the SDK you'll need to

    chmod +x arago-2021.09-aarch64-linux-tisdk.sh

    Then you can execute it and the SDK will install.  

    Hopefully this helps someone else as well.

    --Brad

  • Hi Braden,

    As for the feedback on the docs, thank you for providing that. I agree things are not documented very clearly, and some of the confusion comes from the fact that there are essentially two things referred to as SDKs:

    1. The installable "TI SDK" (via arago-core-tisdk-bundle) that has all kinds of stuff in it including but not limited to source code snapshots, helper tools, various filesystem image, custom makefiles, _and_ the actual Yocto-build SDK installer. This is what you download from TI.com

    2. The Yocto-built SDK installer (via meta-toolchain-arago-tisdk), as built directly from the Yocto sources (which is also included in 1). This is probably the only thing you really need/use once you are over the "Getting Started" honeymoon phase with your TI EVM.

    I've already added to our backlog the need to improve the documentation specifically around Yocto and some TI quirks and features associated with that, so your feedback is much appreciated and will be incorporated into that.

    Regards, Andreas

  • Hi Brad and Andreas,

    a couple of weeks ago, I had a similar issue. I would highly appreciate if you could please post some details about your internal communication.

    For me, for example, it was not clear how meta-arago, meta-psdkla and meta-ti relate to each other, and what the concept of meta-arago is.

    Any information would be super helpful, since as Brad already mentioned, the documentation about arago + SDK is "thin".

    The last post of you Andreas, really helps a lot of my understanding.

    Thank you and best regards,
    Thomas

  • Hi Thomas,

    All of the communication I have had with Andreas was in this thread.

    I likewise am still coming up the curve on all things Arago.  I seem to learn something new and useful every day.

    Brad

  • Hi Thomas,

    yes everything we discussed regarding Brad's concerns is captured in this thread. Below some additional pointers.

    meta-ti is the BSP layer

    meta-arago is what's known in Yocto terms as the "distribution layer"

    meta-processor-sdk (or meta-psdkla, depending on build/device, such as AM65x) is an extra software layer that bundles many of the examples/demos/add-ons part of the official TI SDK.

    We also have an online training that should be helpful in diving deeper into our Yocto-based SDK and how to customize it for your needs, see https://training.ti.com/customizing-yocto-based-linux-distribution-production

    If you have any specific issue and you can't find that addressed by the training series or by searching E2E posts please start a new E2E thread.

    Regards, Andreas