3

我有一个 C 程序,我想为RISCV ISA编译它。我已按照他们的说明安装工具。他们的工具工作正常,我可以编译一个“Hello world!” C 程序并运行它。但现在我想编译另一个包含多个文件的 C 程序。我试图更改makefile,而不是使用gcc,而是用他们的编译器名称替换它,riscv64-unknown-linux-gnu-gcc但我得到了:

Relocations in generic ELF (EM: 62)

错误,然后我尝试设置CC = riscv64-unknown-linux-gnu-gcc,但我收到另一个错误pthread

unrecognized command line option '-pthread'

我的问题是我应该更改 make 文件以使用他们的编译器吗?

提前感谢您的帮助。

4

1 回答 1

0
DEBUG := 0
PROFILE := 0
MRSFAST_VERSION := "3.3.1"
BUILD_DATE := "$(shell date)"

all: OPTIMIZE_FLAGS build
debug: DEBUG_FLAGS build
profile: PROFILE_FLAGS build
build: clean-executable SSE_FLAGS compile mrsfast snp_indexer clean

LDFLAGS=#-static
LIBS=-lz -lm -pthread -lpthread
CFLAGS=-fno-pic -DMRSFAST_VERSION=\"$(MRSFAST_VERSION)\" -DBUILD_DATE=\"$(BUILD_DATE)\"

objects=baseFAST.o Sort.o MrsFAST.o Common.o CommandLineParser.o RefGenome.o HashTable.o Reads.o Output.o SNPReader.o  HELP.o

compile: $(objects)

mrsfast:
ifeq ($(shell uname -s),Linux)
    gcc -w $(objects) -o $@ ${LDFLAGS} ${LIBS}
else
    gcc -Wl,-no_pie -fno-pic -w $(objects) -o $@ ${LDFLAGS} ${LIBS}
endif

snp_indexer: SNPIndexer.o
    gcc $^ -o $@ ${LDFLAGS} ${LIBS}

clean:
    @rm -f $(objects)
    @rm -f SNPIndexer.o
    @rm -f HELPstub.c
    @rm -f HELPstub.o

clean-executable:
    @rm -f mrsfast

HELP.o:
    @groff -Tascii -man ./HELP.man > HELP
ifeq ($(shell uname -s),Linux)
    @ld -r -b binary -o HELP.o HELP
else
    @touch HELPstub.c
    gcc -o HELPstub.o -c HELPstub.c
    ld -r -o HELP.o -sectcreate binary HELP HELP HELPstub.o
endif

DEBUG_FLAGS:
    $(eval CFLAGS = $(CFLAGS) -ggdb)
    $(eval LIBS = $(LIBS) -ggdb)

OPTIMIZE_FLAGS:
    $(eval CFLAGS = $(CFLAGS) -O2)

PROFILE_FLAGS:
        $(eval CFLAGS = $(CFLAGS) -pg -g)
    $(eval LIBS = $(LIBS) -pg -g)

SSE_FLAGS:
ifeq ($(shell uname -s),Linux)
ifeq ($(with-sse4),no)
        $(shell echo "-DSSE4=0")
else
            $(eval CFLAGS = $(CFLAGS) \
            $(shell gv=`gcc -dumpversion`; \
                    sc=`grep -c "sse4" /proc/cpuinfo`; \
                    echo $$sc.$$gv | awk -F. '{if($$1>0 && $$2>=4 && $$3>=4) print "-DSSE4=1 -msse4.2"; else print "-DSSE4=0"}'))
endif
else
ifeq ($(with-sse4),no)
        $(shell echo "-DSSE4=0")
else
        $(eval CFLAGS = $(CFLAGS) \
        $(shell gv=`gcc -dumpversion`; \
                sc=`sysctl -n machdep.cpu.features | grep -c "SSE4"` ;\
                echo $$sc.$$gv | awk -F. '{if($$1>0 && $$2>=4 && $$3>=4) print "-DSSE4=1 -msse4.2"; else print "-DSSE4=0"}'))
endif
endif
于 2015-02-17T09:39:00.577 回答