gcc 在CFLAGS中为make传递-fcommon标志

x6yk4ghg  于 2023-04-06  发布在  其他
关注(0)|答案(1)|浏览(284)

binutils的构建代码:

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'`" LDFLAGS=`pkg-config --libs 'libprotobuf-c >= 1.0.0'` \
            ../configure --enable-gold --prefix=${PWD_PATH}/executable_binutils \
            --disable-werror --enable-shared \
             --enable-ld=default \
             --fcommon \
         --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

# get gcc-8.1.0
GCC_PATH="$PWD_PATH/gcc-8.1.0"
# GCC_EXE_PATH="$PWD_PATH/gcc_executable"
#GCC_EXE_PATH=""
GCC_BUILD_PATH="$PWD_PATH/build_gcc"
GCC_EXE_PATH="$PWD_PATH/executable_gcc"

# soft link gas
eval " sudo cp /usr/bin/as /usr/bin/as.old"
echo

这里我想在CFLAGS中传递-fcommon标志,因为我得到了多个定义错误。但不确定如何传递此标志。我试图在configure行及其下方添加as --fcommon,但它不起作用。
错误消息:

binutils-2.30/depcomp
binutils-2.30/config.guess
binutils-2.30/ltmain.sh
binutils-2.30/ltsugar.m4
configure: error: unrecognized option: `--fcommon'
Try `../configure --help' for more information.

[*] build gas&&gold succeed!
hmtdttj4

hmtdttj41#

configure不是编译器。不能传递编译器标志。
如果你查看autoconf文档,或者运行configure --help,你会发现:

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.
  ...
Some influential environment variables:
  ...
  CFLAGS      C compiler flags
  ...

因此,您可以将CFLAGS=-fcommon添加到configure命令行。

相关问题