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.

Compiler/PRU-CGT: default include directory for PRU compiler

Part Number: PRU-CGT

Tool/software: TI C/C++ Compiler

Hello, I am setting up a make environment to compile the PRU builds. For portability, I don't want to specify any user installation specific path names in the make file. However, the PRU compiler insists on specifying the include path for standard include files (for example stdint.h) which typically are part of the installation folder. Is there a way to instruct the compiler to have it determine the default include directory relative to its installation directory?

Thanks

Brayan

  • brayan said:
    Is there a way to instruct the compiler to have it determine the default include directory relative to its installation directory?

    Unfortunately, no.  You can either use the option --include_path or the environment variable PRU_C_DIR.  For details, please search the PRU compiler manual for the sub-chapter titled The Search Path for #include Files.  Note however, this sub-chapter has an error.  Every instance of PRU_C_OPTION should be PRU_C_DIR instead.  I filed the entry CODEGEN-6173 in the SDOWP system to have this error fixed.

    Thanks and regards,

    -George

  • Thanks George for the reply. I did find the PRU_C_DIR option in the compiler manual and tried using it, but it seems to have no affect. Using PRU_C_DIR is a good resolution for me if it works, can you confirm that please?
  • If you are on a Windows system, a command similar to this one ...

    set PRU_C_DIR=C:\ti\ccsv8\tools\compiler\ti-cgt-pru_2.3.1\include;C:\ti\ccsv8\tools\compiler\ti-cgt-pru_2.3.1\lib

    ... adds that environment variable setting to the current command shell, but not the entire system.  To learn how to add environment variables to the entire system, please perform an Internet search on add environment variable windows.  

    Thanks and regards,

    -George

  • Hi George, Thanks for the details on how to add an environment variable. However, my question was the environment variable setting is not working. I have attached the screenshot. You can observe that even after having the environment variable set 'clpru' cannot resolve the path to include directories. Instead, it insists on explicitly providing them via '--include-path' command line option.

  • brayan said:
    However, my question was the environment variable setting is not working.

    I tested use of the PRU_C_DIR environment variable with the PRU v2.3.1 compiler under Ubuntu.

    A command without the default include directory specifies fails:

    "/home/mr_halfword/ti/ccs830/ccsv8/tools/compiler/ti-cgt-pru_2.3.1/bin/clpru" -v3 --include_path="/home/mr_halfword/ti/ccs830/ccsv8/ccs_base/pru/include" --include_path="/home/mr_halfword/workspace_v8/AM5728_PRU_hello" --define=am5728 --define=icss1 --define=pru0 -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --endian=little --hardware_mac=on --preproc_with_compile --preproc_dependency="hello.d_raw"  "../hello.c"
    "../hello.c", line 1: fatal error #1965: cannot open source file "stdio.h"
    1 catastrophic error detected in the compilation of "../hello.c".
    Compilation terminated.
    
    >> Compilation failure

    Whereas setting the PRU_C_DIR environment variable to the include directory for the compiler caused the build to be successful:

    (export PRU_C_DIR=/home/mr_halfword/ti/ccs830/ccsv8/tools/compiler/ti-cgt-pru_2.3.1/include;  "/home/mr_halfword/ti/ccs830/ccsv8/tools/compiler/ti-cgt-pru_2.3.1/bin/clpru" -v3 --include_path="/home/mr_halfword/ti/ccs830/ccsv8/ccs_base/pru/include" --include_path="/home/mr_halfword/workspace_v8/AM5728_PRU_hello" --define=am5728 --define=icss1 --define=pru0 -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --endian=little --hardware_mac=on --preproc_with_compile --preproc_dependency="hello.d_raw"  "../hello.c")

    brayan said:
    You can observe that even after having the environment variable set 'clpru' cannot resolve the path to include directories. Instead, it insists on explicitly providing them via '--include-path' command line option.

    Your PRU_C_DIR environment variable is set to:

    /home/brayan/ti/ccs6/tools/compiler/ti-cgt-pru_2.2.1

    Whereas the one provided via '--include-path' is:

    /home/brayan/ti/ccs6/tools/compiler/ti-cgt-pru_2.2.1/include

    I.e. try setting the value of the PRU_C_DIR environment variable to /home/brayan/ti/ccs6/tools/compiler/ti-cgt-pru_2.2.1/include

  • Hi Chester, Thanks for your reply. I tried with the PRU_C_DIR pointing to include directory, but still getting the same error. I have attached the error image.

    Below is my shell output for your reference.

    brayan@brayan-VirtualBox:~/Data/2vme/lc_2vme_pru/lc_2vme_pru$ env | grep pru
    OLDPWD=/home/brayan/Data/2vme/lc_2vme_pru
    PRU_C_DIR=/home/brayan/ti-cgt-pru_2.3.1/include
    PATH=/home/brayan/bin:/home/brayan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/brayan/ti-cgt-pru_2.3.1/bin
    PWD=/home/brayan/Data/2vme/lc_2vme_pru/lc_2vme_pru
    brayan@brayan-VirtualBox:~/Data/2vme/lc_2vme_pru/lc_2vme_pru$ scons
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    scons: `build/lc_2vme_pru0.out' is up to date.
    clpru -v3 -g --define="STDINT_HEADER=<stdint.h>" --define=am3359 --define=pru0 --diag_wrap=off --diag_warning=225 --relaxed_ansi -al --no_intrinsics --display_error_number --endian=little --hardware_mac=on --compile_only --obj_extension=.o --preproc_with_compile --obj_directory=build/firmware_bm_pru1_debug/commoncomponents/PSP/AM335X_PRU/src --include_path=/home/brayan/Data/2vme/lc_2vme_pru --include_path=/home/brayan/Data/2vme/lc_2vme_pru/commoncomponents --include_path=/home/brayan/Data/2vme/lc_2vme_pru/ssd1305 -o build/firmware_bm_pru1_debug/commoncomponents/PSP/AM335X_PRU/src/spi_am335x_pru.o /home/brayan/Data/2vme/lc_2vme_pru/commoncomponents/PSP/AM335X_PRU/src/spi_am335x_pru.c
    >> WARNING: object file specified, but linking not enabled
    [spi_am335x_pru.c]
    "/home/brayan/Data/2vme/lc_2vme_pru/commoncomponents/PSP/AM335X_PRU/src/spi_am335x_pru.c", line 6: fatal error #1965: cannot open source file "stdint.h"
    1 catastrophic error detected in the compilation of "/home/brayan/Data/2vme/lc_2vme_pru/commoncomponents/PSP/AM335X_PRU/src/spi_am335x_pru.c".
    Compilation terminated.
    
    >> Compilation failure
    scons: *** [build/firmware_bm_pru1_debug/commoncomponents/PSP/AM335X_PRU/src/spi_am335x_pru.o] Error 1
    scons: building terminated because of errors.
    brayan@brayan-VirtualBox:~/Data/2vme/lc_2vme_pru/lc_2vme_pru$ scons
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    scons: `build/lc_2vme_pru0.out' is up to date.
    clpru -v3 -g --define="STDINT_HEADER=<stdint.h>" --define=am3359 --define=pru0 --diag_wrap=off --diag_warning=225 --relaxed_ansi -al --no_intrinsics --display_error_number --endian=little --hardware_mac=on --compile_only --obj_extension=.o --preproc_with_compile --obj_directory=build/firmware_bm_pru1_debug/commoncomponents/PSP/AM335X_PRU/src --include_path=/home/brayan/Data/2vme/lc_2vme_pru --include_path=/home/brayan/Data/2vme/lc_2vme_pru/commoncomponents --include_path=/home/brayan/ti/ccsv6/tools/compiler/ti-cgt-pru_2.2.1/include --include_path=/home/brayan/Data/2vme/lc_2vme_pru/ssd1305 -o build/firmware_bm_pru1_debug/commoncomponents/PSP/AM335X_PRU/src/spi_am335x_pru.o /home/brayan/Data/2vme/lc_2vme_pru/commoncomponents/PSP/AM335X_PRU/src/spi_am335x_pru.c
    >> WARNING: object file specified, but linking not enabled
    [spi_am335x_pru.c]
    clpru -v3 -g --define="STDINT_HEADER=<stdint.h>" --define=am3359 --define=pru0 --diag_wrap=off --diag_warning=225 --relaxed_ansi -al --no_intrinsics --display_error_number --endian=little --hardware_mac=on --compile_only --obj_extension=.o --preproc_with_compile --obj_directory=build/firmware_bm_pru1_debug/lc_2vme_pru/src --include_path=/home/brayan/Data/2vme/lc_2vme_pru --include_path=/home/brayan/Data/2vme/lc_2vme_pru/commoncomponents --include_path=/home/brayan/ti/ccsv6/tools/compiler/ti-cgt-pru_2.2.1/include --include_path=/home/brayan/Data/2vme/lc_2vme_pru/ssd1305 -o build/firmware_bm_pru1_debug/lc_2vme_pru/src/main_pru1.o src/main_pru1.c
    >> WARNING: object file specified, but linking not enabled
    [main_pru1.c]
    clpru -v3 -g -z -m"build/lc_2vme_pru1.map" --stack_size=0x400 --heap_size=0x400 --reread_libs --define=PRU_CORE=1 --diag_wrap=off --display_error_number --warn_sections --xml_link_info="build/lc_2vme_pru1.xml" --rom_model lc_2vme_pru.cmd -o build/lc_2vme_pru1.out build/firmware_bm_pru1_debug/commoncomponents/PSP/AM335X_PRU/src/gpio_am335x_pru.o build/firmware_bm_pru1_debug/commoncomponents/PSP/AM335X_PRU/src/spi_am335x_pru.o build/firmware_bm_pru1_debug/commoncomponents/PSP/AM335X_PRU/src/system_clock_am335x_pru.o build/firmware_bm_pru1_debug/commoncomponents/device_drivers/ads131e0x/src/ads131e0x.o build/firmware_bm_pru1_debug/commoncomponents/device_drivers/mcp23s08/src/mcp23s08.o build/firmware_bm_pru1_debug/commoncomponents/device_drivers/ssd1305/src/ssd1305.o build/firmware_bm_pru1_debug/commoncomponents/device_drivers/adc128s022/src/adc128s022.o build/firmware_bm_pru1_debug/commoncomponents/utilities/circular_buffer/src/circular_buffer.o build/firmware_bm_pru1_debug/lc_2vme_pru/src/main_pru1.o -i"../commoncomponents/PSP/AM335X_PRU/lib" -llibc.a -lrpmsg_lib.lib
    <Linking>
    scons: done building targets.
    brayan@brayan-VirtualBox:~/Data/2vme/lc_2vme_pru/lc_2vme_pru$ 
    

  • brayan said:
    I tried with the PRU_C_DIR pointing to include directory, but still getting the same error.

    You don't get the same error.  The missing include file error is gone.  All that remains is 3 instances of this warning ...

    brayan said:
    >> WARNING: object file specified, but linking not enabled

    This warning does not prevent a successful build.  

    To avoid this warning, you need to remove this from the compile commands ...

    -o path/to/some/file.o

    On GCC and similar compilers, this is how you name the object file.  That is not the case with the TI compiler.  With the TI compiler, these two arguments mean two unrelated things.  The option -o means build with the default level of optimization.  Naming an object file is what causes the warning.  That is only valid when linking.

    All that said, I recommend you build with optimization.   You will improve on both size and speed.

    Thanks and regards,

    -George

  • Thanks George, I will use the optimizations. On the build compilation though, I still have those errors. Below I have explained the details of bash shell log I pasted in my previous reply.

    Lines 1-5 - show the definition of environment variable PRU_C_DIR with path to include files.
    Lines 6-20 - show build compilation throwing errors when include path is not specified as part of compiler options. Line 14 has the error details.
    Lines 21-34 - show successful build when include path is explicitly provided in compiler option.

    I ran these as a sequence of steps in bash terminal to show the error.
  • I apologize for overlooking ...

    brayan said:
    Lines 6-20 - show build compilation throwing errors when include path is not specified as part of compiler options

    I am unable to reproduce this behavior.  I need a test case from you.  Normally, I ask for a preprocessed file.  But that is not possible here, since the error occurs during preprocessing.  So, please try to make the test case as small as you can.  I need the C source file, plus all the files it includes (directly, or through other files).  I do not need the RTS header files.  Put all those files into a zip file, then attach that to your next post.

    Thanks and regards,

    -George

  • Hi George, we've been using Scons(python based build tool) and the code base has a lot of dependencies. Hence, in order to replicate the problem, I tried using the gmake utility that comes with CCS installation.

    I've created an example project with two versions,

    Version 1 - with include path specified in compiler option

    Version 2 - without the include path.

    to Build : execute "C:\ti\ccsv8\utils\bin\gmake -k -j 8 clean -O" command from debug folder of the project.

    Observation: Version 1 generates the build but version 2 throws the include file error. But, after defining the PRU_C_DIR environment variable version 2 is successfully able to build. So what you and chester have been saying is right. Apologies for dragging this through. I have attached the two versions of the project for your reference.pru_test_with_include_path.7zpru_test_without_include_path.7z

    PS: I still have the issue in SCONS make environment, but I think that is irrelevant to PRU CGT tools. If I am not able to fix the scons, i'll move over to gmake.

    Thanks much, and appreciate the help.