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.

CCS v6.1 not recognizing GCC predefined macros on Linux

Other Parts Discussed in Thread: MSP430G2553

Despite having followed the instructions from the thread "CCS not recognizing GCC predefined macros", I can not get CCS v6.1 on Linux to discover the predefined macros of Redhat GNU GCC v4.9.1.

For debugging I do the following

  • In the global preferences at C/C++ -> Build -> Settings -> Tab: Discovery -> "CDT GCC Built-in Compiler Settings"
    • tick the check-box "Allocate console in the Console View"
    • OK
  • In the project preferences at "Show advances settings" -> C/C++ General -> "Preprocessor Include..." -> Tab: Providers
    • tick the check-box "CDT GCC Built-in Compiler Settings"
    • OK

Now I get to see the following output in the console named "CDT GCC Built-in Compiler Settings, GNU C":

19:38:19 **** Running scanner discovery: CDT GCC Built-in Compiler Settings ****
gcc -E -P -v -dD /home/USER/workspace_v6_1/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c 
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --enable-linker-build-id --program-suffix=-4.8 --enable-linux-futex --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.8.1 20130909 [gcc-4_8-branch revision 202388] (SUSE Linux) 
COLLECT_GCC_OPTIONS='-E' '-P' '-v' '-dD' '-mtune=generic' '-march=x86-64'
 /usr/lib64/gcc/x86_64-suse-linux/4.8/cc1 -E -quiet -v -P /home/fl/workspace_v6_1/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c -mtune=generic -march=x86-64 -dD
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib64/gcc/x86_64-suse-linux/4.8/include
 /usr/local/include
#define __STDC__ 1
#define __STDC_HOSTED__ 1
#define __GNUC__ 4
#define __GNUC_MINOR__ 8
#define __GNUC_PATCHLEVEL__ 1
[...OUTPUT TRUNCATED...]
#define __STDC_IEC_559__ 1
#define __STDC_IEC_559_COMPLEX__ 1
#define __STDC_ISO_10646__ 201103L
#define __STDC_NO_THREADS__ 1

19:38:20 Build Finished (took 91ms)

Instead of calling the MSP430 GCC it calls the system-wide GCC, which is obviously wrong.

To no avail did I try to teach CCS to call the MSP430 GCC binaries instead.

In the global preferences at C/C++ -> Build -> Settings -> Tab: Discovery -> "CDT GCC Built-in Compiler Settings"

  • "Command to get compiler specs:"
    msp430-elf-${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
  • OK

This did not work because CCS does not update the path as it seems:

19:45:22 **** Running scanner discovery: CDT GCC Built-in Compiler Settings ****
msp430-elf-gcc -E -P -v -dD /home/USER/workspace_v6_1/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c 
Cannot run program "msp430-elf-gcc": Unknown reason

Error: Program "msp430-elf-gcc" not found in PATH
PATH=[/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games]

19:45:22 Build Finished (took 14ms)

However calling the MSP430 GCC binary on the shell does work as expected:

USER@HOST:~> /home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/msp430-elf-gcc -E -P -v -dD /home/USER/workspace_v6_1/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c
Using built-in specs.
COLLECT_GCC=/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/msp430-elf-gcc
Target: msp430-elf
Configured with: /opt/redhat/msp430-14r1-167/sources/tools/configure --host=i686-redhat-linux --build=i686-redhat-linux --target=msp430-elf --prefix=/opt/redhat/msp430-14r1-167/i686-redhat-linux --enable-languages=c,c++
Thread model: single
gcc version 4.9.1 20140707 (prerelease (msp430-14r1-167)) (GNUPro 14r1) (Based on: GCC 4.8 GDB 7.7 Binutils 2.24 Newlib 2.1) (GCC)
COLLECT_GCC_OPTIONS='-E' '-P' '-v' '-dD'
 /home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../libexec/gcc/msp430-elf/4.9.1/cc1 -E -quiet -v -P -iprefix /home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/msp430-elf/4.9.1/ /home/USER/workspace_v6_1/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c -dD
ignoring nonexistent directory "/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/msp430-elf/4.9.1/../../../../msp430-elf/sys-include"
ignoring duplicate directory "/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/../../lib/gcc/msp430-elf/4.9.1/include"
ignoring duplicate directory "/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/../../lib/gcc/msp430-elf/4.9.1/include-fixed"
ignoring nonexistent directory "/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/../../lib/gcc/msp430-elf/4.9.1/../../../../msp430-elf/sys-include"
ignoring duplicate directory "/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/../../lib/gcc/msp430-elf/4.9.1/../../../../msp430-elf/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/msp430-elf/4.9.1/include
 /home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/msp430-elf/4.9.1/include-fixed
 /home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/msp430-elf/4.9.1/../../../../msp430-elf/include
End of search list.
#define __STDC__ 1
#define __STDC_HOSTED__ 1
#define __GNUC__ 4
#define __GNUC_MINOR__ 9
#define __GNUC_PATCHLEVEL__ 1
#define __VERSION__ "4.9.1 20140707 (prerelease (msp430-14r1-167)) (GNUPro 14r1) (Based on: GCC 4.8 GDB 7.7 Binutils 2.24 Newlib 2.1)"
[...OUTPUT TRUNCATED...]
#define __MSP430__ 1
#define __MSP430XGENERIC__ 1
#define __MSP430X__ 1
#define __ELF__ 1
COMPILER_PATH=/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../libexec/gcc/msp430-elf/4.9.1/:/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../libexec/gcc/:/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/msp430-elf/4.9.1/../../../../msp430-elf/bin/
LIBRARY_PATH=/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/msp430-elf/4.9.1/:/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/:/home/USER/ti-ccs-v6.1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_167/bin/../lib/gcc/msp430-elf/4.9.1/../../../../msp430-elf/lib/
COLLECT_GCC_OPTIONS='-E' '-P' '-v' '-dD'

How can I fix this myself, or is it a CCS bug?

  • Hi,

    Unfortunately I could not reproduce this issue; I am using CCSv6.1 on Ubuntu 14.04/64 but my project is really simple (a simple hello world-type of project).

    Therefore, if you haven't done so, I would definitely try some of the troubleshooting tips at the section general IDE of the page below:

    processors.wiki.ti.com/.../Troubleshooting_CCSv6

    Hope this helps,
    Rafael
  • After a CLEAN INSTALL I can still verify this behavior.


    What I did is to install a fresh CCS v6.1 from the offline installer, selected MSP430 during the install and then selected to pull in MSP430 GCC.

    So now I've got a clean installation of CCS v6.1, and now I created a new CCS project and selected the following:

    Before doing any code changes I did select the "CDT GCC Built-in Compiler Settings" as per thread "CCS not recognizing GCC predefined macros":

    Now I inserted the following lines of code into "main.c":

    #ifdef __GNUC__
    
    #ifdef __MSP430G2553__
    
    #error THIS IS THE REAL MCU
    
    #endif
    
    #endif
    

    If all would be well I would expect to not see any grayed out lines in the editor view. But I do see that only the define "__GNUC__" is detected because that's what the system installed (see my original post about those details) GCC supports, as it does not know about the MSP430 MCU's.

    To check if the define "__MSP430G2553__" is really defined, I added an error message there. When building the project it shows that it really is defined:

    So in my view this is a bug of CCS v6.1, because CDT apparently is using the system GCC instead of the CCS supplied Redhat GCC. I would think that some variables inside CDT/Eclipse are not updated accordingly.

    Can you reproduce it now?

  • Friedl,

    I guess I got confused by your mention about the hosted GCC, therefore I thought the problem at hand was the inability to find the toolchain.

    In any case, I was able to reproduce this here and it seems an issue on an Eclipse/CDT component, but I can't tell yet for sure. I filed the bug number SDSCM00051647 - you can check its status in the link SDOWP in my signature below.

    BTW, this feature works in CCSv6.0.1, as mentioned in the thread below:

    Differently than what is reported by the thread, the default settings worked fine for me, but any modifications were only picked up when I restarted CCS. What I imagine is that Eclipse needs to pick up some environment variables from the system, but again, I can't tell for sure.

    Hope this helps,

    Rafael

  • desouza said:

    I guess I got confused by your mention about the hosted GCC, therefore I thought the problem at hand was the inability to find the toolchain.

    Actually it is using the wrong toolchain. I've got a native GCC toolchain installed on the host, the host GCC.

    The command "which gcc" (or "whereis gcc") on the command shell tells you if you've got one installed:

    USER@HOST:~> which gcc
    /usr/bin/gcc
    USER@HOST:~> 
    

    If you haven't got a native gcc binary installed, install one from the systems installation repository and see how your CCS reacts.