Is there way to treat Makefile warnings as errors and halt compilation - linux

I used --just-print,--print-data-base, and --warn-undefined-variables command line options to debug makefile.
Is there a way to stop makefile when an warning is found in makefile. Just like werror flag treat warning as error in case of GCC.

Related

How to suppress warnings from external packages?

My stack build shows warning from external packages, like:
happy > /tmp/stack-d6caed253e9f21bf/happy-1.20.0/src/ProduceGLRCode.lhs:224:12: warning: [-Wincomplete-uni-patterns]
176happy > Pattern match(es) are non-exhaustive
There's not much I can do about external code, and I don't want to see these warnings. However, I still want to build my project strictly with GHC options -Wall -Werror.
Is there a way to suppress the warnings from external packages? I'm using stack with hpack. Note that the solution has to work from command line, since updating stack.yaml is not possible due to a large number of projects involved.
Things I've tried:
In stack.yaml:
ghc-options:
"$targets": -Wall -Werror
"$everything": -w
Combined with --verbosity warn from command line, this works, but I couldn't find a way to specify the above ghc-options from the command line.
In stack.yaml:
apply-ghc-options: targets
This doesn't work, warning from external packages are still visible. Besides, I couldn't find a way to specify the above apply-ghc-options from the command line.
P.S: Opened a ticket on GitHub after getting no answer here.

Is it possible to compile NASA Parallel Benchmarks (NPB) files in Linux using gfortran and openmpi?

I am attempting to run NPB benchmarking on my RHEL7.3 install but come into a similar issue as the question asked here
Error while building NAS benchmarks
Trying to make the BT benchmark, which is in fortran, I get the following error:
cd BT; make NPROCS=16 CLASS=W SUBTYPE= VERSION=
make[1]: Entering directory '/mnt/npb_install/NPB3.3-MPI/BT'
make[2]: Entering directory '/mnt/npb_install/NPB3.3-MPI/sys'
make[2]: Nothing to be done for 'all'
make[2]: Leaving directory '/mnt/npb_install/NPB3.3-MPI/sys'
../sys/setparams bt 16 W
make[2]: Entering directory '/mnt/npb_install/NPB3.3-MPI/BT'
make[3]: Entering directory '/mnt/npb_install/NPB3.3-MPI/BT'
gfortran -O -o ../bin/bt.W.16 bt.o make_set.o initialize.o exact_solution.o exact_rhs.o set_constants.o adi.o define.o copy_faces.o rhs.o solve_subs.o x_solve.o y_solve.o z_solve.o add.o error.o verifiy.o setup_mpi.o ../common/print_results.o ../common/timers.o btio.o -L/usr/lib/openmpi-x84_64/ -lmpi
/bin/ld: cannot find -lmpi
collect2: error: ld returned 1 exit status
make[3]: *** [bt-bt] Error 1
make[3]: Leaving direc.......
However I am not using Intel MPI but rather OpenMPI, though I don't full understand the implication of that.
My make.def file has the following mpi related settings
#-------------------------------------
# This is the fortran compiler usedd for MPI programs
#-----------------------------------------
MPIF77 = gfortran
# This links MPI fortran programs; usually the same as ${MPIF77}
FLINK = ${MPIF77}
#------------------------------------------
# These macros are passed to the linker to help link with MPI correctly
#-------------------------------------------
FMPI_LIB = -L/usr/lib/openmpi/lib/ -lmpi
#-----------------------------------------
# These macros are passed to the compiler to help find 'mpif.h'
#------------------------------------------
FMPI_INC = -I/usr/include/openmpi-x86_64/
Similar to those posted in the above question.
From the error, I assume that the input parameters -lmpi is not a valid input parameter for gfortran when compiling but removing it leads to a screen full of undefined references like:
file.f:(.text+0x123): undefined reference to 'mpi_whatever_'
Is it possible to compile NPB with gfortran? Or am I clearly doing something wrong here?
I have seen that using ifort is another option but I thought I'd ask the question before moving towards that possible solution
After hacking at it I resolved the issue with the following fixes, not sure what did it.
OpenMPI may have not been installed properly (was unable to call mpicc or other wrappers/comps), to fix it I ran the following commands
module avail
#displayed the openmpi-x86_64 module
module add open-x86_64
which mpirun
#displayed location of mpirun
The more likely fix was simply changing gfortran in the make.def file to mpif77

What does -fprofile-arcs linker option mean?

I want to have code covergage in my application, so in premake.lua I added the following:
if options["coverage"] then
tinsert(package.buildoptions, {"-fprofile-arcs", "-ftest-coverage"})
tinsert(package.links, "gcov")
end
then I ran the following command:
premake --coverage --target gnu ; make
That did not work until I added the following :
if options["coverage"] then
tinsert(package.buildoptions, {"-fprofile-arcs", "-ftest-coverage"})
tinsert(package.linkoptions, {"-fprofile-arcs"})
tinsert(package.links, "gcov")
end
Which was a solution posed on the Internet. My problem is that I found 0 documentation on this -fprofile-arcs linker flag... What does it do? and where is it documented?
This option is not given to the linker. It is interpreted by the compiler driver(gcc, g++).
When compiling, this option is just passed to the compiler (cc1, cc1plus).
When linking, the effect of the options is that the compiler driver just includes the -lgcov on the linker command line.

CMake finds the correct library, but VC++ attempts to link with something else

I have a CMake module to locate FreeGLUT:
FIND_PATH(FREEGLUT_INCLUDE_DIR NAMES GL/freeglut.h)
FIND_LIBRARY(FREEGLUT_LIBRARY NAMES freeglut freeglut_static)
SET(FREEGLUT_LIBRARIES ${FREEGLUT_LIBRARY})
SET(FREEGLUT_INCLUDE_DIRS ${FREEGLUT_INCLUDE_DIR})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FreeGLUT DEFAULT_MSG FREEGLUT_LIBRARY FREEGLUT_INCLUDE_DIR)
MARK_AS_ADVANCED(FREEGLUT_INCLUDE_DIR FREEGLUT_LIBRARY)
It works fine and locates freeglut_static.lib when I generate NMake Makefiles on Windows. I'm attempting to statically link FreeGLUT into my DLL:
FIND_PACKAGE(FreeGLUT REQUIRED)
ADD_LIBRARY(vti SHARED ${VTI_SOURCES})
ADD_DEFINITIONS("-DBUILD_VTI=1 -DFREEGLUT_STATIC=1")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${FREEGLUT_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(vti ${FREEGLUT_LIBRARIES})
My source code builds correctly, but when it gets to the linking stage, VC++ fails with:
LINK : fatal error LNK1104: cannot open file 'freeglut.lib'
Which is strange since freeglut.lib isn't mentioned anywhere that I can see in the generated NMake makefiles. It should be trying to link with freeglut_static.lib, which CMake locates and sets in FREEGLUT_LIBRARIES.
What might be causing this?
This is caused with pragma directives in FreeGLUT code (see freeglut_std.h). Using FREEGLUT_STATIC should really fix that for you, but I think you should pass it to CMake without quotes: ADD_DEFINITIONS(-DBUILD_VTI -DFREEGLUT_STATIC)

Problem in Cross-Compiling libSDL for MIPS Platform

I was trying to compile libSDL-1.2.14 for my mips platform.
But it was not successful.
These were the steps that I tried out :
export PATH=/opt/mips-4.3/bin:$PATH
Went inside the libSDL-1.2.14 source folder.
Gave a "./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu"
Executed the "make" command
This was the error received :
cc1: warning: include location
"/usr/include" is unsafe for
cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In
function 'DMA_WaitAudio':
./src/audio/dma/SDL_dmaaudio.c:167:
error: can't find a register in class
'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167:
error: 'asm' operand has impossible
constraints make: *
[build/SDL_dmaaudio.lo] Error 1
But then i reconfigured the make file by giving the following commands :
make clean
./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu CPPFLAGS=-I/opt/mips-4.3/mips-linux-gnu/libc/usr/include/
make
NOTE : /opt/mips-4.3/mips-linux-gnu/libc/usr/include/ - This is the path where you can locate the select.h file for the mips Platform.
It contains the definitions of the macros FD_ZERO and FD_SET.
Still I am getting the same error.
cc1: warning: include location
"/usr/include" is unsafe for
cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In
function 'DMA_WaitAudio':
./src/audio/dma/SDL_dmaaudio.c:167:
error: can't find a register in class
'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167:
error: 'asm' operand has impossible
constraints make: *
[build/SDL_dmaaudio.lo] Error 1
Please help me with some valuable pointers.
Thanks,
Sen
First, don't set the path to the cross-compiler as the first part of your PATH, set it as last:
export PATH=$PATH:<path to cross-compiler>
It's safer this way. Second, run ./configure --help to get all the options. What that error message would say if it was smarter is the following:
You're trying to cross-compile since you're setting the --host flag
But you're not changing any of the other options for where to find includes and libs for the target environment
I'm going to use /usr/include by default
But that's for the host system which will not work when cross-compiling
Check what other configure options you need to set to tell the configure script where to find the .h files (includes) and the libraries for your target. These usually come with the cross-compiler that you download. Also, you should probably set the CROSS_COMPILE environment variable to the cross-compiler prefix before running configure. The prefix is the part before gcc in a cross-compiler, assuming you're using GCC as your cross-compiler.

Resources