131914882SAlex Richardson# Example config.mk 231914882SAlex Richardson# 3*5a02ffc3SAndrew Turner# Copyright (c) 2018-2023, Arm Limited. 4072a4ba8SAndrew Turner# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception 531914882SAlex Richardson 631914882SAlex Richardson# Subprojects to build 731914882SAlex RichardsonSUBS = math string networking 831914882SAlex Richardson 9072a4ba8SAndrew Turner# Subsubprojects to build if subproject pl is built 10072a4ba8SAndrew TurnerPLSUBS = math 11072a4ba8SAndrew Turner 1231914882SAlex Richardson# Target architecture: aarch64, arm or x86_64 1331914882SAlex RichardsonARCH = aarch64 1431914882SAlex Richardson 1531914882SAlex Richardson# Use for cross compilation with gcc. 1631914882SAlex Richardson#CROSS_COMPILE = aarch64-none-linux-gnu- 1731914882SAlex Richardson 1831914882SAlex Richardson# Compiler for the target 1931914882SAlex RichardsonCC = $(CROSS_COMPILE)gcc 2031914882SAlex RichardsonCFLAGS = -std=c99 -pipe -O3 2131914882SAlex RichardsonCFLAGS += -Wall -Wno-missing-braces 2231914882SAlex RichardsonCFLAGS += -Werror=implicit-function-declaration 2331914882SAlex Richardson 2431914882SAlex Richardson# Used for test case generator that is executed on the host 2531914882SAlex RichardsonHOST_CC = gcc 2631914882SAlex RichardsonHOST_CFLAGS = -std=c99 -O2 2731914882SAlex RichardsonHOST_CFLAGS += -Wall -Wno-unused-function 2831914882SAlex Richardson 2931914882SAlex Richardson# Enable debug info. 3031914882SAlex RichardsonHOST_CFLAGS += -g 3131914882SAlex RichardsonCFLAGS += -g 3231914882SAlex Richardson 3331914882SAlex Richardson# Optimize the shared libraries on aarch64 assuming they fit in 1M. 3431914882SAlex Richardson#CFLAGS_SHARED = -fPIC -mcmodel=tiny 3531914882SAlex Richardson 3631914882SAlex Richardson# Enable MTE support. 3731914882SAlex Richardson#CFLAGS += -march=armv8.5-a+memtag -DWANT_MTE_TEST=1 3831914882SAlex Richardson 3931914882SAlex Richardson# Use with cross testing. 4031914882SAlex Richardson#EMULATOR = qemu-aarch64-static 4131914882SAlex Richardson#EMULATOR = sh -c 'scp $$1 user@host:/dir && ssh user@host /dir/"$$@"' -- 4231914882SAlex Richardson 4331914882SAlex Richardson# Additional flags for subprojects. 4431914882SAlex Richardsonmath-cflags = 4531914882SAlex Richardsonmath-ldlibs = 4631914882SAlex Richardsonmath-ulpflags = 4731914882SAlex Richardsonmath-testflags = 4831914882SAlex Richardsonstring-cflags = 4931914882SAlex Richardsonnetworking-cflags = 5031914882SAlex Richardson 5131914882SAlex Richardson# Use if mpfr is available on the target for ulp error checking. 5231914882SAlex Richardson#math-ldlibs += -lmpfr -lgmp 5331914882SAlex Richardson#math-cflags += -DUSE_MPFR 5431914882SAlex Richardson 5531914882SAlex Richardson# Use with gcc. 5631914882SAlex Richardsonmath-cflags += -frounding-math -fexcess-precision=standard -fno-stack-protector 5731914882SAlex Richardsonmath-cflags += -ffp-contract=fast -fno-math-errno 5831914882SAlex Richardson 5931914882SAlex Richardson# Use with clang. 6031914882SAlex Richardson#math-cflags += -ffp-contract=fast 6131914882SAlex Richardson 62*5a02ffc3SAndrew Turner# Disable/enable SVE vector math code and tests. 63*5a02ffc3SAndrew Turner# If WANT_SVE_MATH is enabled, math-sve-cflags is added for SVE 64*5a02ffc3SAndrew Turner# routines only so that SVE code does not leak into scalar 65*5a02ffc3SAndrew Turner# routines. It is also necessary to add it for tools (e.g. ulp, 66*5a02ffc3SAndrew Turner# mathbench) 67072a4ba8SAndrew TurnerWANT_SVE_MATH = 0 68072a4ba8SAndrew Turnerifeq ($(WANT_SVE_MATH), 1) 69*5a02ffc3SAndrew Turner math-sve-cflags = -march=armv8-a+sve 70072a4ba8SAndrew Turnerendif 71072a4ba8SAndrew Turnermath-cflags += -DWANT_SVE_MATH=$(WANT_SVE_MATH) 72072a4ba8SAndrew Turner 73072a4ba8SAndrew Turner# If defined to 1, set errno in math functions according to ISO C. Many math 74072a4ba8SAndrew Turner# libraries do not set errno, so this is 0 by default. It may need to be 75072a4ba8SAndrew Turner# set to 1 if math.h has (math_errhandling & MATH_ERRNO) != 0. 76072a4ba8SAndrew TurnerWANT_ERRNO = 0 77072a4ba8SAndrew Turnermath-cflags += -DWANT_ERRNO=$(WANT_ERRNO) 78072a4ba8SAndrew Turner 79072a4ba8SAndrew Turner# If set to 1, set fenv in vector math routines. 80072a4ba8SAndrew TurnerWANT_SIMD_EXCEPT = 0 81072a4ba8SAndrew Turnermath-cflags += -DWANT_SIMD_EXCEPT=$(WANT_SIMD_EXCEPT) 82072a4ba8SAndrew Turner 8331914882SAlex Richardson# Disable fenv checks 8431914882SAlex Richardson#math-ulpflags = -q -f 8531914882SAlex Richardson#math-testflags = -nostatus 8631914882SAlex Richardson 8731914882SAlex Richardson# Remove GNU Property Notes from asm files. 8831914882SAlex Richardson#string-cflags += -DWANT_GNU_PROPERTY=0 8931914882SAlex Richardson 9031914882SAlex Richardson# Enable assertion checks. 9131914882SAlex Richardson#networking-cflags += -DWANT_ASSERT 9231914882SAlex Richardson 9331914882SAlex Richardson# Avoid auto-vectorization of scalar code and unroll loops 9431914882SAlex Richardsonnetworking-cflags += -O2 -fno-tree-vectorize -funroll-loops 95