使用LLVM Clang编译NAS并行基准测试会出错

时间:2019-01-19 17:56:17

标签: openmp llvm-clang

我在Linux上,正在尝试编译NPB套件(C版)link LLVM Clang编译器和LLVM OpenMP运行时库。

我编辑了包含的配置文件“ make.def”,以便与clang一起使用:

#---------------------------------------------------------------------------
#
#                SITE- AND/OR PLATFORM-SPECIFIC DEFINITIONS. 
#
#---------------------------------------------------------------------------

#---------------------------------------------------------------------------
# Items in this file will need to be changed for each platform.
# (Note these definitions are inconsistent with NPB2.1.)
#---------------------------------------------------------------------------

#---------------------------------------------------------------------------
# Parallel C:
#
# For IS, which is in C, the following must be defined:
#
# CC         - C compiler 
# CFLAGS     - C compilation arguments
# C_INC      - any -I arguments required for compiling C 
# CLINK      - C linker
# CLINKFLAGS - C linker flags
# C_LIB      - any -L and -l arguments required for linking C 
#
# compilations are done with $(CC) $(C_INC) $(CFLAGS) or
#                            $(CC) $(CFLAGS)
# linking is done with       $(CLINK) $(C_LIB) $(CLINKFLAGS)
#---------------------------------------------------------------------------

#---------------------------------------------------------------------------
# This is the C compiler used for OpenMP programs
#---------------------------------------------------------------------------
CC = clang-7
# This links C programs; usually the same as ${CC}
CLINK   = clang-7

#---------------------------------------------------------------------------
# These macros are passed to the linker 
#---------------------------------------------------------------------------
C_LIB  = -L/usr/local/lib

#---------------------------------------------------------------------------
# These macros are passed to the compiler 
#---------------------------------------------------------------------------
C_INC = -I../common -I/usr/local/include

#---------------------------------------------------------------------------
# Global *compile time* flags for C programs
#---------------------------------------------------------------------------
CFLAGS  = -fopenmp -O3
# CFLAGS = -g

#---------------------------------------------------------------------------
# Global *link time* flags. Flags for increasing maximum executable 
# size usually go here. 
#---------------------------------------------------------------------------
CLINKFLAGS = -fopenmp -O0 -Wl,-rpath,/usr/local/lib


#---------------------------------------------------------------------------
# Utilities C:
#
# This is the C compiler used to compile C utilities.  Flags required by 
# this compiler go here also; typically there are few flags required; hence 
# there are no separate macros provided for such flags.
#---------------------------------------------------------------------------
UCC = clang-7 -O


#---------------------------------------------------------------------------
# Destination of executables, relative to subdirs of the main directory. . 
#---------------------------------------------------------------------------
BINDIR  = ../bin


#---------------------------------------------------------------------------
# The variable RAND controls which random number generator 
# is used. It is described in detail in Doc/README.install. 
# Use "randi8" unless there is a reason to use another one. 
# Other allowed values are "randi8_safe", "randdp" and "randdpvec"
#---------------------------------------------------------------------------
# RAND   = randi8
# The following is highly reliable but may be slow:
RAND   = randdp


#---------------------------------------------------------------------------
# The variable WTIME is the name of the wtime source code module in the
# NPB2.x/common directory.  
# For most machines,       use wtime.c
# For SGI power challenge: use wtime_sgi64.c
#---------------------------------------------------------------------------
WTIME  = wtime.c


#---------------------------------------------------------------------------
# Enable if either Cray or IBM: 
# (no such flag for most machines: see common/wtime.h)
# This is used by the C compiler to pass the machine name to common/wtime.h,
# where the C/Fortran binding interface format is determined
#---------------------------------------------------------------------------
# MACHINE   =   -DCRAY
# MACHINE   =   -DIBM

这总是给出相同的链接错误 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用):尝试使用make suite构建它时:

cd SP; make CLASS=S
make[2]: Entering directory '/home/akan/Downloads/Benchmarks/NPB3.0-omp-C-master/SP'
make[3]: Entering directory '/home/akan/Downloads/Benchmarks/NPB3.0-omp-C-master/sys'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/akan/Downloads/Benchmarks/NPB3.0-omp-C-master/sys'
../sys/setparams sp S
make.def modified. Rebuilding npbparams.h just in case
rm -f npbparams.h
../sys/setparams sp S
clang-7  -c -I../common -I/usr/local/include -fopenmp -O3 sp.c
clang-7 -fopenmp -O0 -Wl,-rpath,/usr/local/lib -o ../bin/sp.S sp.o ../common/c_print_results.o ../common/c_timers.o ../common/c_wtime.o -L/usr/local/lib
/usr/bin/ld: cannot open output file ../bin/sp.S: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:24: recipe for target '../bin/sp.S' failed
make[2]: *** [../bin/sp.S] Error 1
make[2]: Leaving directory '/home/akan/Downloads/Benchmarks/NPB3.0-omp-C-master/SP'
Makefile:14: recipe for target 'sp' failed
make[1]: *** [sp] Error 2
make[1]: Leaving directory '/home/akan/Downloads/Benchmarks/NPB3.0-omp-C-master'
make[1]: Entering directory '/home/akan/Downloads/Benchmarks/NPB3.0-omp-C-master'

不可能用Clang编译C程序吗?还是我在make.def文件中缺少任何内容?

1 个答案:

答案 0 :(得分:1)

这里的重要错误行是:

/usr/bin/ld: cannot open output file ../bin/sp.S: No such file or directory

由于它是输出文件,因此没有这样的是指目录。创建../bin,它应该可以工作。