Blame buildflags.mak

Packit 961e70
#
Packit 961e70
#  This file is provided under a dual BSD/GPLv2 license.  When using or
Packit 961e70
#  redistributing this file, you may do so under either license.
Packit 961e70
#
Packit 961e70
#  GPL LICENSE SUMMARY
Packit 961e70
#
Packit 961e70
#  Copyright(c) 2016 Intel Corporation.
Packit 961e70
#
Packit 961e70
#  This program is free software; you can redistribute it and/or modify
Packit 961e70
#  it under the terms of version 2 of the GNU General Public License as
Packit 961e70
#  published by the Free Software Foundation.
Packit 961e70
#
Packit 961e70
#  This program is distributed in the hope that it will be useful, but
Packit 961e70
#  WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 961e70
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 961e70
#  General Public License for more details.
Packit 961e70
#
Packit 961e70
#  Contact Information:
Packit 961e70
#  Intel Corporation, www.intel.com
Packit 961e70
#
Packit 961e70
#  BSD LICENSE
Packit 961e70
#
Packit 961e70
#  Copyright(c) 2016 Intel Corporation.
Packit 961e70
#
Packit 961e70
#  Redistribution and use in source and binary forms, with or without
Packit 961e70
#  modification, are permitted provided that the following conditions
Packit 961e70
#  are met:
Packit 961e70
#
Packit 961e70
#    * Redistributions of source code must retain the above copyright
Packit 961e70
#      notice, this list of conditions and the following disclaimer.
Packit 961e70
#    * Redistributions in binary form must reproduce the above copyright
Packit 961e70
#      notice, this list of conditions and the following disclaimer in
Packit 961e70
#      the documentation and/or other materials provided with the
Packit 961e70
#      distribution.
Packit 961e70
#    * Neither the name of Intel Corporation nor the names of its
Packit 961e70
#      contributors may be used to endorse or promote products derived
Packit 961e70
#      from this software without specific prior written permission.
Packit 961e70
#
Packit 961e70
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 961e70
#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 961e70
#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 961e70
#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 961e70
#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 961e70
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 961e70
#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 961e70
#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 961e70
#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 961e70
#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 961e70
#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 961e70
#
Packit 961e70
#  Copyright (c) 2003-2016 Intel Corporation. All rights reserved.
Packit 961e70
#
Packit 961e70
Packit 961e70
# set top_srcdir and include this file
Packit 961e70
Packit 961e70
ifeq (,$(top_srcdir))
Packit 961e70
$(error top_srcdir must be set to include makefile fragment)
Packit 961e70
endif
Packit 961e70
Packit 961e70
export os ?= $(shell uname -s | tr '[A-Z]' '[a-z]')
Packit 961e70
export arch := $(shell uname -m | sed -e 's,\(i[456]86\|athlon$$\),i386,')
Packit 961e70
Packit Service 7ed5cc
ifeq (${CCARCH},$(filter ${CCARCH},gcc gcc4 icc clang))
Packit Service 7ed5cc
	export CC := ${CCARCH}
Packit 961e70
else
Packit Service 7ed5cc
	anerr := $(error Unknown C compiler arch: ${CCARCH})
Packit Service 7ed5cc
endif
Packit 961e70
Packit 961e70
ifeq (${FCARCH},gfortran)
Packit 961e70
	export FC := gfortran
Packit 961e70
else
Packit 961e70
	anerr := $(error Unknown Fortran compiler arch: ${FCARCH})
Packit 961e70
endif # gfortran
Packit 961e70
Packit 961e70
BASECFLAGS := $(BASE_FLAGS) -pthread
Packit 961e70
LDFLAGS += $(BASE_FLAGS)
Packit 961e70
ASFLAGS += $(BASE_FLAGS)
Packit 961e70
Packit 961e70
ifeq ($(PSM2_MOCK_TESTING),1)
Packit 961e70
BASECFLAGS += -DPSM2_MOCK_TESTING=1
Packit 961e70
unexport LINKER_SCRIPT
Packit 961e70
# We skip the linker script for mock testing version, we want all symbols
Packit 961e70
# to be reachable from outside the library
Packit 961e70
else
Packit 961e70
LINKER_SCRIPT := -Wl,--version-script $(LINKER_SCRIPT_FILE)
Packit 961e70
endif
Packit 961e70
Packit 961e70
WERROR := -Werror
Packit 961e70
INCLUDES := -I$(top_srcdir)/include -I$(top_srcdir)/mpspawn -I$(top_srcdir)/include/$(os)-$(arch)
Packit 961e70
Packit 961e70
#
Packit 961e70
# use IFS provided hfi1_user.h if installed.
Packit 961e70
#
Packit 961e70
IFS_HFI_HEADER_PATH := /usr/include/uapi
Packit 961e70
INCLUDES += -I${IFS_HFI_HEADER_PATH}
Packit 961e70
Packit 961e70
BASECFLAGS +=-Wall $(WERROR)
Packit 961e70
Packit 961e70
#
Packit 961e70
# test if compiler supports 32B(AVX2)/64B(AVX512F) move instruction.
Packit 961e70
#
Packit 961e70
ifeq (${CC},icc)
Packit Service 7ed5cc
	ifeq ($(PSM_DISABLE_AVX2),)
Packit Service 7ed5cc
		MAVX2=-xATOM_SSE4.2 -DPSM_AVX512
Packit Service 7ed5cc
	else
Packit Service 7ed5cc
		MAVX2=-march=core-avx-i
Packit Service 7ed5cc
	endif
Packit 961e70
else
Packit Service 7ed5cc
	ifeq ($(PSM_DISABLE_AVX2),)
Packit Service 7ed5cc
		MAVX2=-mavx2
Packit Service 7ed5cc
	else
Packit Service 7ed5cc
		MAVX2=-mavx
Packit Service 7ed5cc
	endif
Packit 961e70
endif
Packit 961e70
Packit 961e70
ifneq (icc,${CC})
Packit Service 7ed5cc
	ifeq ($(PSM_DISABLE_AVX2),)
Packit Service 7ed5cc
		RET := $(shell echo "int main() {}" | ${CC} ${MAVX2} -E -dM -xc - 2>&1 | grep -q AVX2 ; echo $$?)
Packit Service 7ed5cc
	else
Packit Service 7ed5cc
		RET := $(shell echo "int main() {}" | ${CC} ${MAVX2} -E -dM -xc - 2>&1 | grep -q AVX ; echo $$?)
Packit Service 7ed5cc
		$(warning ***NOTE TO USER**** Disabling AVX2 will harm performance)
Packit Service 7ed5cc
	endif
Packit Service 7ed5cc
Packit Service 7ed5cc
	ifeq (0,${RET})
Packit Service 7ed5cc
		BASECFLAGS += ${MAVX2}
Packit Service 7ed5cc
	else
Packit Service 7ed5cc
		$(error Compiler does not support ${MAVX2} )
Packit Service 7ed5cc
	endif
Packit 961e70
else
Packit Service 7ed5cc
		BASECFLAGS += ${MAVX2}
Packit 961e70
endif
Packit 961e70
Packit 961e70
# This support is dynamic at runtime, so is OK to enable as long as compiler can generate
Packit 961e70
# the code.
Packit 961e70
ifneq (,${PSM_AVX512})
Packit Service 7ed5cc
	ifneq (icc,${CC})
Packit Service 7ed5cc
		RET := $(shell echo "int main() {}" | ${CC} -mavx512f -E -dM -xc - 2>&1 | grep -q AVX512 ; echo $$?)
Packit Service 7ed5cc
		ifeq (0,${RET})
Packit Service 7ed5cc
			BASECFLAGS += -mavx512f
Packit Service 7ed5cc
		else
Packit Service 7ed5cc
			$(error Compiler does not support AVX512 )
Packit Service 7ed5cc
		endif
Packit Service 7ed5cc
		BASECFLAGS += -DPSM_AVX512
Packit Service 7ed5cc
	endif
Packit 961e70
endif
Packit 961e70
Packit 961e70
#
Packit 961e70
# feature test macros for drand48_r
Packit 961e70
#
Packit 961e70
BASECFLAGS += -D_DEFAULT_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE
Packit 961e70
Packit 961e70
ifneq (,${HFI_BRAKE_DEBUG})
Packit Service 7ed5cc
	BASECFLAGS += -DHFI_BRAKE_DEBUG
Packit Service 7ed5cc
endif
Packit Service 7ed5cc
ifneq (,${PSM_FI})
Packit Service 7ed5cc
	BASECFLAGS += -DPSM_FI
Packit 961e70
endif
Packit 961e70
ifneq (,${PSM_DEBUG})
Packit Service 7ed5cc
	BASECFLAGS += -O -g3 -DPSM_DEBUG -D_HFI_DEBUGGING -funit-at-a-time -Wp,-D_FORTIFY_SOURCE=2
Packit 961e70
else
Packit Service 7ed5cc
	BASECFLAGS += -O3 -g3
Packit 961e70
endif
Packit 961e70
ifneq (,${PSM_COVERAGE}) # This check must come after PSM_DEBUG to override optimization setting
Packit Service 7ed5cc
	BASECFLAGS += -O -fprofile-arcs -ftest-coverage
Packit Service 7ed5cc
	LDFLAGS += -fprofile-arcs
Packit 961e70
endif
Packit 961e70
ifneq (,${PSM_LOG})
Packit Service 7ed5cc
	 BASECFLAGS += -DPSM_LOG
Packit 961e70
ifneq (,${PSM_LOG_FAST_IO})
Packit Service 7ed5cc
	 BASECFLAGS += -DPSM_LOG_FAST_IO
Packit Service 7ed5cc
	 PSM2_ADDITIONAL_GLOBALS += psmi_log_fini;psmi_log_message;
Packit 961e70
endif
Packit 961e70
endif
Packit 961e70
ifneq (,${PSM_PERF})
Packit Service 7ed5cc
	 BASECFLAGS += -DRDPMC_PERF_FRAMEWORK
Packit 961e70
endif
Packit 961e70
ifneq (,${PSM_HEAP_DEBUG})
Packit Service 7ed5cc
	 BASECFLAGS += -DPSM_HEAP_DEBUG
Packit Service 7ed5cc
	 PSM2_ADDITIONAL_GLOBALS += _psmi_heapdebug_val_heapallocs;
Packit 961e70
endif
Packit 961e70
ifneq (,${PSM_PROFILE})
Packit Service 7ed5cc
	BASECFLAGS += -DPSM_PROFILE
Packit 961e70
endif
Packit Service 7ed5cc
BASECFLAGS += -DNVIDIA_GPU_DIRECT
Packit 961e70
ifneq (,${PSM_CUDA})
Packit Service 7ed5cc
	BASECFLAGS += -DPSM_CUDA
Packit Service 7ed5cc
	CUDA_HOME ?= /usr/local/cuda
Packit Service 7ed5cc
	INCLUDES += -I$(CUDA_HOME)/include
Packit 961e70
endif
Packit 961e70
Packit 961e70
BASECFLAGS += -fpic -fPIC -D_GNU_SOURCE
Packit 961e70
Packit Service 06b8d9
ASFLAGS += -g3 -fpic
Packit 961e70
Packit 961e70
BASECFLAGS += ${OPA_CFLAGS}
Packit 961e70
Packit 961e70
ifeq (${CCARCH},icc)
Packit Service 7ed5cc
	BASECFLAGS += -fpic -fPIC -D_GNU_SOURCE -DPACK_STRUCT_STL=packed,
Packit Service 7ed5cc
	LDFLAGS += -static-intel
Packit 961e70
else
Packit Service 7ed5cc
	LDFLAGS += -Wl,--build-id
Packit Service 7ed5cc
	ifeq (${CCARCH},$(filter ${CCARCH},gcc clang))
Packit Service 7ed5cc
		BASECFLAGS += -funwind-tables -Wno-strict-aliasing -Wformat-security
Packit 961e70
	else
Packit Service 7ed5cc
		ifneq (${CCARCH},gcc4)
Packit Service 7ed5cc
			$(error Unknown compiler arch "${CCARCH}")
Packit Service 7ed5cc
		endif # gcc4
Packit 961e70
	endif # gcc
Packit 961e70
endif # icc
Packit 961e70
Packit 961e70
# We run export here to ensure all the above setup is in the environment
Packit 961e70
# for sub makes. However, we exclude this during clean and distclean
Packit 961e70
# to avoid resolution of some variables that don't need to be resolved
Packit 961e70
# and avoid unnecessary missing file warnings during cleanup.
Packit 961e70
ifneq ($(MAKECMDGOALS), clean)
Packit 961e70
ifneq ($(MAKECMDGOALS), distclean)
Packit 961e70
export
Packit 961e70
endif
Packit 961e70
endif
Packit 961e70