Skip to main content

GCC build with strange errors

GCC Build With Strange Errors

I have been fighting with these strange errors for some days, and finally I got it.

Problem

The core problem is that my C_INCLUDE_PATH and CPLUS_INCLUDE_PATH ends with a colon. Path ending with a colon will include current path, aka ./ which caused the error.

Solution

We need to remove the trailing colon, so I write a bash function for it.

# usage: removeTrailingColon str
# example:
#    C_INCLUDE_PATH=$(removeTrailingColon $C_INCLUDE_PATH)
removeTrailingColon() {
    if [[ $1 == *: ]]
    then
        local strColonRemoved=$1;
        local strColonRemoved=${strColonRemoved:0:(-1)};
        echo $strColonRemoved;
    else
        echo $1
    fi
}

Usage is like this:

export C_INCLUDE_PATH=$(removeTrailingColon $C_INCLUDE_PATH)
export CPLUS_INCLUDE_PATH=$(removeTrailingColon $CPLUS_INCLUDE_PATH)
export LD_LIBRARY_PATH=$(removeTrailingColon $LD_LIBRARY_PATH)
export LIBRARY_PATH=$(removeTrailingColon $LIBRARY_PATH)

Elaborate on problem

I'll list the error I encountered building gcc-4.7.3, so that people will be able to access it through a search engine:

In file included from ../.././gcc/c-lang.c:24:
../.././gcc/system.h:499: error: conflicting types for ‘strsignal’
/usr/include/string.h:566: note: previous declaration of ‘strsignal’ was here
In file included from ./tm.h:19,
                 from ../.././gcc/c-lang.c:26:
./options.h:3750:2: error: #error too many masks for ix86_isa_flags
In file included from ../.././gcc/input.h:25,
                 from ../.././gcc/tree.h:27,
                 from ../.././gcc/c-lang.c:27:
../.././gcc/../libcpp/include/line-map.h:208: error: ‘CHAR_BIT’ undeclared here (not in a function)
../.././gcc/../libcpp/include/line-map.h:208: error: bit-field ‘reason’ width not an integer constant
../.././gcc/../libcpp/include/line-map.h:208: warning: ‘reason’ is narrower than values of its type
In file included from ../.././gcc/tree.h:32,
                 from ../.././gcc/c-lang.c:27:
../.././gcc/real.h:87:5: error: division by zero in #if
../.././gcc/real.h:87:5: error: division by zero in #if
../.././gcc/real.h:90:6: error: division by zero in #if
../.././gcc/real.h:90:6: error: division by zero in #if
../.././gcc/real.h:93:7: error: division by zero in #if
../.././gcc/real.h:93:7: error: division by zero in #if
../.././gcc/real.h:96:8: error: division by zero in #if
../.././gcc/real.h:96:8: error: division by zero in #if
../.././gcc/real.h:99:9: error: division by zero in #if
../.././gcc/real.h:99:9: error: division by zero in #if
../.././gcc/real.h:102:10: error: division by zero in #if
../.././gcc/real.h:102:10: error: division by zero in #if
../.././gcc/real.h:105:9: error: #error "REAL_WIDTH > 6 not supported"
In file included from ../.././gcc/c-family/c-common.h:26,
                 from ../.././gcc/c-tree.h:25,
                 from ../.././gcc/c-lang.c:28:
../.././gcc/../libcpp/include/cpplib.h:225: error: bit-field ‘type’ width not an integer constant
../.././gcc/../libcpp/include/cpplib.h:225: warning: ‘type’ is narrower than values of its type
In file included from ../.././gcc/c-family/c-common.h:26,
                 from ../.././gcc/c-tree.h:25,
                 from ../.././gcc/c-lang.c:28:
../.././gcc/../libcpp/include/cpplib.h:267:3: error: #error "Cannot find a least-32-bit signed integer type"
../.././gcc/../libcpp/include/cpplib.h:269: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cppchar_t’
../.././gcc/../libcpp/include/cpplib.h:270: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cppchar_signed_t’
../.././gcc/../libcpp/include/cpplib.h:768: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cpp_interpret_charconst’
../.././gcc/../libcpp/include/cpplib.h:779: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cpp_host_to_exec_charset’
../.././gcc/../libcpp/include/cpplib.h:954: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘cpp_parse_escape’
make[2]: *** [c-lang.o] Error 1

Comments

Comments powered by Disqus