0

I'm trying to build gas and gold linkers. But while building them I'm facing the following errors: I'm using gcc (Ubuntu 8.4.0-3ubuntu2) 8.4.0 to build it.

yyscript.c:2204:12: error: ‘YYEMPTY’ undeclared (first use in this function); did you mean ‘YYCOPY’?
   yychar = YYEMPTY; /* Cause a token to be read.  */
            ^~~~~~~
            YYCOPY
yyscript.c:2204:12: note: each undeclared identifier is reported only once for each function it appears in
yyscript.c:2320:17: error: ‘YYEOF’ undeclared (first use in this function); did you mean ‘SIZEOF’?
   if (yychar <= YYEOF)
                 ^~~~~
                 SIZEOF
yyscript.c:2326:22: error: ‘YYerror’ undeclared (first use in this function); did you mean ‘yyerror’?
   else if (yychar == YYerror)
                      ^~~~~~~
                      yyerror
yyscript.c:2332:16: error: ‘YYUNDEF’ undeclared (first use in this function); did you mean ‘YYENOMEM’?
       yychar = YYUNDEF;
                ^~~~~~~
                YYENOMEM

The source code of the build script is given below:

echo
echo -e "${BLUE}===================== build gas && gold ===========================${NC}"
echo

if [ ! -f ${PWD_PATH}/succeed/binutils ]; then
    wget -c 'https://ftp.gnu.org/gnu/binutils/binutils-2.30.tar.xz'
    tar xvJf binutils-2.30.tar.xz
    rm -r binutils-2.30/gas
    rm -r binutils-2.30/gold

    cp -r ${SRC_PATH}/binutils/gas-2.30 ${GAS_DIR}

    cp -r ${SRC_PATH}/binutils/gold-2.30 ${GOLD_DIR}

    cp $PROTODEF_DIR/$C_HDR $GAS_DIR

    cp $PROTODEF_DIR/$CC_HDR ${GOLD_DIR}/
    cp $PROTODEF_DIR/$PROTO_C ${GOLD_DIR}/

    eval "cd $PWD_PATH/binutils-2.30 && mkdir -p build && cd build"

    CFLAGS="`pkg-config --cflags 'libprotobuf-c >= 1.0.0'` -fcommon" LDFLAGS=`pkg-config --libs 'libprotobuf-c >= 1.0.0'` \
            ../configure --enable-gold --prefix=${PWD_PATH}/executable_binutils \
            --disable-werror --enable-shared \
             --enable-ld=default \
         --enable-plugins    \
             --enable-64-bit-bfd \
             --with-system-zlib \
            && make -j$(nproc)
            # && make install
    echo "done" > ${PWD_PATH}/succeed/binutils
fi

echo
echo -e "${GREEN}[*] build gas&&gold succeed!${NC}"

GAS_PATH=$PWD_PATH/binutils-2.30/build/gas/as-new
GOLD_PATH=$PWD_PATH/binutils-2.30/build/gold/ld-new

How can I fix this and what could be the source of this error?

NobinPegasus
  • 545
  • 2
  • 16
  • Why are you removing the gas and gold src directories from the unpacked tarfile, and then replacing them with something else? Looks like those sources are corrupt. yyscript.c is a generated file, generated by bison, and in a clean build directory, those tokens should all be defined. – Cary Coutant Apr 27 '23 at 19:58

0 Answers0