macro_name CLANG

binary_name clang++

lang_flags "-std=c++11 -D_REENTRANT"

warning_flags "-Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual"
maintainer_warning_flags "-Wunreachable-code -Wdocumentation -Qunused-arguments -Werror -Wno-error=unused-parameter -Wno-error=unreachable-code -Wno-error=deprecated-declarations"

optimization_flags "-O3"
size_optimization_flags "-Os"
#sanitizer_flags "-fsanitize=address,undefined -fsanitize-coverage=edge,indirect-calls,8bit-counters -fno-sanitize-recover=undefined"
sanitizer_flags "-fsanitize=address,undefined"

shared_flags "-fPIC"
coverage_flags "--coverage"
stack_protector_flags "-fstack-protector"

visibility_build_flags "-fvisibility=hidden"
visibility_attribute '__attribute__((visibility("default")))'

<so_link_commands>
darwin        -> "$(CXX) -dynamiclib -fPIC -install_name $(INSTALLED_LIB_DIR)/{soname_abi} -current_version {darwin_so_current_ver} -compatibility_version {darwin_so_compat_ver}"

# The default works for GNU ld and several other Unix linkers
default       -> "$(CXX) -shared -fPIC -Wl,-soname,{soname_abi}"
</so_link_commands>

<binary_link_commands>
darwin        -> "$(LINKER) -headerpad_max_install_names"
linux         -> "$(LINKER) -Wl,-rpath=\$$ORIGIN"
freebsd       -> "$(LINKER) -Wl,-rpath=\$$ORIGIN"
default       -> "$(LINKER)"
llvm          -> "llvm-link"
</binary_link_commands>

<isa_flags>
sse2   -> "-msse2"
ssse3  -> "-mssse3"
sse41  -> "-msse4.1"
sse42  -> "-msse4.2"
avx2   -> "-mavx2"
bmi2   -> "-mbmi2"
aesni  -> "-maes -mpclmul -mssse3"
rdrand -> "-mrdrnd"
rdseed -> "-mrdseed"
sha    -> "-msha"
altivec -> "-maltivec"

arm32:neon    -> "-mfpu=neon"
arm64:neon    -> ""
</isa_flags>

<mach_opt>
all_llvm    -> "-emit-llvm -fno-use-cxa-atexit"

x86_32      -> "-march=SUBMODEL"
x86_64      -> "-march=SUBMODEL"
nehalem     -> "-march=corei7"
sandybridge -> "-march=corei7-avx"
ivybridge   -> "-march=core-avx-i"
</mach_opt>

<mach_abi_linking>
all!haiku -> "-pthread"

openmp  -> "-fopenmp"

x86_32  -> "-m32"
x86_64  -> "-m64"
ppc64   -> "-m64"

darwin  -> "-stdlib=libc++"
ios     -> "-stdlib=libc++"
netbsd  -> "-D_NETBSD_SOURCE"
</mach_abi_linking>
