Skip to content
Snippets Groups Projects
Commit 2babef04 authored by Izzard, Robert Dr (Maths & Physics)'s avatar Izzard, Robert Dr (Maths & Physics)
Browse files

more updates for meson build with optimizatio

parent b79772f3
No related branches found
No related tags found
No related merge requests found
......@@ -75,14 +75,18 @@ postlibs = ['-lc','-lm','-ldl']
have_gnu99 = compiler.has_argument('-std=gnu99')
have_avx = compiler.has_argument('-mavx')
# global C flags
#add_global_arguments('-DALIGNSIZE=16 -fPIC -std=gnu99 -Wall -Wformat-signedness -Wformat -Wstrict-prototypes -mtune=native -march=native -DCPUFREQ=3500 -DLINUX -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -fPIC -fno-stack-protector -rdynamic -fsignaling-nans -fno-finite-math-only -Og -D__DIFF_STARDATA__ -DGIT_REVISION="$(GIT_REVISION)" -DGIT_URL="$(GIT_URL)" -DGIT_BRANCH="$(GIT_BRANCH)" -D__HAVE_AVX__ -mavx -D__HAVE_DRAND48__ -D__HAVE_GSL__ -DUSE_GSL -I/home/izzard/include -D__HAVE_LIBBACKTRACE__ -D__HAVE_LIBBFD__ -D__HAVE_LIBBSD__ -D__HAVE_LIBIBERTY__ -D__HAVE_LIBMEMOIZE__ -D__HAVE_LIBRINTERPOLATE__ -D__HAVE_MALLOC_H__ -D__HAVE_PKG_CONFIG__ -D__HAVE_VALGRIND__ -D__SHOW_STARDATA__ -fsignaling-nans -fno-finite-math-only -ffast-math -fsignaling-nans -fno-finite-math-only -DCC="\"gcc\"" -DCFLAGS="\" -DALIGNSIZE=16 -fPIC -std=gnu99 -Wall -Wformat-signedness -Wformat -Wstrict-prototypes -mtune=native -march=native -DCPUFREQ=3500 -DLINUX -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -fPIC -fno-stack-protector -rdynamic -fsignaling-nans -fno-finite-math-only -Og -D__DIFF_STARDATA__ -DGIT_REVISION="$(GIT_REVISION)" -DGIT_URL="$(GIT_URL)" -DGIT_BRANCH="$(GIT_BRANCH)" -D__HAVE_AVX__ -mavx -D__HAVE_DRAND48__ -D__HAVE_GSL__ -DUSE_GSL -I_slash_home_slash_izzard_slash_include -D__HAVE_LIBBACKTRACE__ -D__HAVE_LIBBFD__ -D__HAVE_LIBBSD__ -D__HAVE_LIBIBERTY__ -D__HAVE_LIBMEMOIZE__ -D__HAVE_LIBRINTERPOLATE__ -D__HAVE_MALLOC_H__ -D__HAVE_PKG_CONFIG__ -D__HAVE_VALGRIND__ -D__SHOW_STARDATA__ -fsignaling-nans -fno-finite-math-only -ffast-math -fsignaling-nans -fno-finite-math-only\"" -DINCDIRS="\"-I. -I_slash_usr_slash_include -I_slash_home_slash_izzard_slash_include -I_slash_usr_slash_include_slash_libiberty \"" -DLD="\"gcc\"" -DLIBDIRS="\" -L. -L_slash_home_slash_izzard_slash_lib \"" -DLIBS="\" -L_slash_home_slash_izzard_slash_lib -lgsl -lgslcblas -lm -lbacktrace -lbfd -lbsd -lmemoize -lrinterpolate -lc -lm -ldl\""')
############################################################
# default C flags (compiler options)
# TODO: do not omit frame pointer if profile guided
cflags = ['-fPIC','-std=gnu99','-DALIGNSIZE=16']
cflags = ['-fPIC','-DALIGNSIZE=16']
if have_gnu99
cflags += [ '-std=gnu99' ]
endif
if have_avx
cflags += [ '-mavx' ]
endif
############################################################
# optional C flags
......@@ -175,17 +179,18 @@ libgsl_dep = dependency('gsl')
############################################################
# dependencies that usually have no pkg-config
# THESE NEED TO BE SET IN $LIBRARY_PATH (or $LIBPATH on Windoze)
#
# required system libraries
libc_dep = compiler.find_library('c', required: true)
libm_dep = compiler.find_library('m', required: true)
############################################################
# dependencies
#
###########
### GSL ###
###########
#######
# GSL #
#
# todo : https://mesonbuild.com/Reference-tables.html see "Dependency lookup methods"
if libgsl_dep.found()
cflags += run_command('sh','-c','gsl-config --cflags').stdout().strip().split(' ')
......@@ -199,7 +204,7 @@ endif
#############################
# optional libraries #
# libbacktrace, libbfd etc. #
#############################
#
foreach libname : ['gsl','bfd','backtrace','bsd','iberty','memoize','rinterpolate']
_dep = compiler.find_library(libname,required:false)
if _dep.found()
......@@ -210,7 +215,7 @@ endforeach
###########
# drand48 #
###########
#
if compiler.sizeof('drand48_r',
prefix : '#include <stdlib.h>') > 0
cflags += '-D__HAVE_DRAND48__'
......@@ -218,42 +223,42 @@ endif
############
# malloc.h #
############
#
if compiler.has_header('malloc.h')
cflags += '-D__HAVE_MALLOC_H__'
endif
#################################
# pkg-config (external command) #
#################################
#
if run_command('pkg-config','--version').returncode() == 0
cflags += '-D__HAVE_PKG_CONFIG__'
endif
###########################
# valgrind (header files) #
###########################
#
if compiler.has_header('valgrind/valgrind.h')
cflags += '-D__HAVE_VALGRIND__'
endif
###################
# show_starstruct #
###################
#
if run_command('sh','-c','meson/make_starstruct.sh').returncode() == 0
cflags += '-D__SHOW_STARDATA__'
endif
###################
# diff_starstruct #
###################
#
if run_command('sh','-c','meson/diff_starstruct.sh').returncode() == 0
cflags += '-D__DIFF_STARDATA__'
endif
########################
# Unsupported features #
########################
#
if compiler.get_id() != 'gcc' and compiler.get_id() != 'clang'
cflags += '-UBACKTRACE'
endif
......@@ -279,23 +284,27 @@ incdirs += [my_incdirs]
############################################################
# data objects
#
data_objects = run_command('meson/data_object_list.sh').stdout().strip().split(' ')
############################################################
# source files
#
c_sourcefiles = run_command('meson/c_sourcefiles.sh',).stdout().strip().split('\n')
h_sourcefiles = run_command('meson/h_sourcefiles.sh',).stdout().strip().split('\n')
############################################################
# full list of libraries with which we wish to link
#
libs = libs + postlibs
############################################################
# extra quoted flags to pass into binary_c
############################################################
#
cflags_quoted = ' '.join(cflags) # turn to string
cflags_with_O = cflags + [ '-O' + get_option('optimization') ] # cflags with -O<n>
cflags_quoted = ' '.join(cflags_with_O) # turn to string
cflags_quoted = ''.join(cflags_quoted.split('"')) # remove "
cflags_quoted = '-DCFLAGS=' + ''.join(['"', cflags_quoted , '"']) # surround in " ... "
cc_quoted = '-DCC="' + compiler.get_id() + '"'
......@@ -307,8 +316,14 @@ libdirs_quoted = '_slash_'.join(libdirs_quoted.split('/')) # deslash
libs_quoted = '-DLIBS=' + ''.join(['"', ' '.join(libs),'"'])
libs_quoted = '_slash_'.join(libs_quoted.split('/'))
quoted_cflags_list = [ cflags_quoted, cc_quoted, incdirs_quoted, ld_quoted, libdirs_quoted, libs_quoted ]
# hence a quoted version of the cflags
quoted_cflags_list = [ cflags_quoted,
cc_quoted,
incdirs_quoted,
ld_quoted,
libdirs_quoted,
libs_quoted,
]
############################################################
# compiler warning flags
......@@ -325,17 +340,21 @@ cflags += warn_flags
############################################################
# make precompiled headers (PCH)
#
if compiler.get_id() == 'clang'
_pch = binary_c_src + '/binary_c.h.pch'
_pch = binary_c_src + '/binary_c.h.pch' # old binary_c
_pch = 'binary_c.h.pch'
use_pch_cflags = [ '-include-pch', _pch ]
pch_cflags = [ ]
_opt = '-O' + get_option('optimization') # required
pch_cflags = [ _opt ]
pch_sourcefiles = [ 'binary_c.h.pch' ]
pch_post = [ '-o', _pch ]
else
_gch = binary_c_src + '/binary_c.h.gch'
_gch = binary_c_src + '/binary_c.h.gch' # old binary_c
_gch = 'binary_c.h.gch'
use_pch_cflags = [ ] # -include is not required
pch_cflags = [ '-x', 'c-header' ]
_opt = '-O' + get_option('optimization') # required for __OPTIMIZE_
pch_cflags = [ _opt, '-x', 'c-header' ]
pch_sourcefiles = [ 'binary_c.h.gch' ]
pch_post = [ ]
endif
......@@ -359,8 +378,10 @@ precompiled_headers = custom_target(
############################################################
#
# symlink shared_library to binary_c/src directory
# run: ninja libbinary_c_symlink
#
libbinary_c_symlink = custom_target(
'libbinary_c_symlink',
build_by_default: false,
......@@ -371,12 +392,12 @@ libbinary_c_symlink = custom_target(
############################################################
#
# make shared library
# run: ninja libbinary_c.so
#
binary_c_shared_library = shared_library(
'binary_c',
build_by_default : false,
install: true,
#install_dir: binary_c_src,
sources : [c_sourcefiles, h_sourcefiles, precompiled_headers],
include_directories: include_directories(incdirs),
dependencies : [ libgsl_dep ],
......@@ -388,8 +409,10 @@ binary_c_shared_library = shared_library(
############################################################
#
# make executable
# run: ninja binary_c
#
binary_c_executable = executable(
'binary_c',
install: true,
......@@ -403,8 +426,10 @@ binary_c_executable = executable(
############################################################
#
# symlink executable to binary_c directory
# run : ninja binary_c_symlnik
#
binary_c_symlink = custom_target('symlink_binary_c',
build_by_default: true,
output: ['binary_c_symlink'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment