xref: /freebsd/contrib/arm-optimized-routines/config.mk.dist (revision dd21556857e8d40f66bf5ad54754d9d52669ebf7)
1# Example config.mk
2#
3# Copyright (c) 2018-2024, Arm Limited.
4# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
5
6# Subprojects to build
7SUBS = math string networking
8
9# Target architecture: aarch64, arm or x86_64
10ARCH = aarch64
11
12# Use for cross compilation with gcc.
13#CROSS_COMPILE = aarch64-none-linux-gnu-
14
15# Compiler for the target
16CC = $(CROSS_COMPILE)gcc
17CFLAGS = -std=c99 -pipe -O3
18CFLAGS += -Wall -Wno-missing-braces
19CFLAGS += -Werror=implicit-function-declaration
20
21# Used for test case generator that is executed on the host
22HOST_CC = gcc
23HOST_CFLAGS = -std=c99 -O2
24HOST_CFLAGS += -Wall -Wno-unused-function
25
26# Enable debug info.
27HOST_CFLAGS += -g
28CFLAGS += -g
29
30ifeq ($(OS),Msys)
31  # llvm is the only available/valid native compiler
32  CC = clang
33  AR = llvm-ar
34  RANLIB = llvm-ranlib
35  HOST_CC = clang
36  SYSROOT = /c/wenv/msys2/msys64/clangarm64
37  # Common windows flags
38  COMMON_WIN_CFLAGS = -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
39  COMMON_WIN_CFLAGS += -Wno-deprecated-declarations -Wno-unused-variable
40  # For mathtest
41  HOST_CFLAGS += -I$(SYSROOT)/include
42  HOST_CFLAGS += $(COMMON_WIN_CFLAGS) -Wno-ignored-attributes
43  # Clear the default flag -fPIC, as not supported on Windows
44  CFLAGS_SHARED =
45  # For ulp.h with MPFR
46  CFLAGS += -I$(SYSROOT)/include
47  # For clang on Windows
48  CFLAGS += $(COMMON_WIN_CFLAGS)
49endif
50
51# Optimize the shared libraries on aarch64 assuming they fit in 1M.
52#CFLAGS_SHARED = -fPIC -mcmodel=tiny
53
54# Enable MTE support.
55#CFLAGS += -march=armv8.5-a+memtag -DWANT_MTE_TEST=1
56
57# Use with cross testing.
58#EMULATOR = qemu-aarch64-static
59#EMULATOR = sh -c 'scp $$1 user@host:/dir && ssh user@host /dir/"$$@"' --
60
61# Additional flags for subprojects.
62math-cflags =
63math-ldlibs =
64math-ulpflags =
65math-testflags =
66string-cflags = -falign-functions=64
67networking-cflags =
68
69ifeq ($(OS),Msys)
70  # Libraries can be installed with pacman
71  libm-libs = -lmsvcrt -lvcruntime -lucrt
72  libc-libs =
73  # Linker will look for .lib but some systems only have .dll.a,
74  # therefore we have to give absolute path to libraries.
75  # This is system dependent and might need adjusting.
76  mpfr-libs = $(SYSROOT)/lib/libmpfr.dll.a
77  gmp-libs = $(SYSROOT)/lib/libgmp.dll.a
78  mpc-libs = $(SYSROOT)/lib/libmpc.dll.a
79endif
80
81# Use if mpfr is available on the target for ulp error checking. If
82# enabling this, it is advised to disable fenv checks by uncommenting
83# the two lines at the bottom of this block.
84USE_MPFR=0
85math-cflags += -DUSE_MPFR=$(USE_MPFR)
86ifeq ($(USE_MPFR), 1)
87  math-ldlibs += $(mpfr-libs) $(gmp-libs)
88  math-ulpflags += -m
89endif
90# Disable fenv checks
91#math-ulpflags = -q -f
92#math-testflags = -nostatus
93
94# Use with gcc.
95math-cflags += -frounding-math -fexcess-precision=standard -fno-stack-protector
96math-cflags += -ffp-contract=fast -fno-math-errno
97
98# Use with clang.
99#math-cflags += -ffp-contract=fast
100
101# If defined to 1, set errno in math functions according to ISO C.  Many math
102# libraries do not set errno, so this is 0 by default.  It may need to be
103# set to 1 if math.h has (math_errhandling & MATH_ERRNO) != 0.
104WANT_ERRNO = 0
105math-cflags += -DWANT_ERRNO=$(WANT_ERRNO)
106
107# Disable/enable SVE vector math tests/tools.
108ifeq ($(ARCH),aarch64)
109  WANT_SVE_TESTS = 1
110else
111  WANT_SVE_TESTS = 0
112endif
113math-cflags += -DWANT_SVE_TESTS=$(WANT_SVE_TESTS)
114
115# If set to 1, set fenv in vector math routines.
116WANT_SIMD_EXCEPT = 0
117math-cflags += -DWANT_SIMD_EXCEPT=$(WANT_SIMD_EXCEPT)
118
119# If set to 1, enable tests for exp10.
120WANT_EXP10_TESTS = 1
121math-cflags += -DWANT_EXP10_TESTS=$(WANT_EXP10_TESTS)
122
123# If set to 1, enable tests for sinpi and cospi. These functions are
124# only supported on aarch64
125ifeq ($(ARCH),aarch64)
126  WANT_TRIGPI_TESTS = 1
127else
128  WANT_TRIGPI_TESTS = 0
129endif
130math-cflags += -DWANT_TRIGPI_TESTS=$(WANT_TRIGPI_TESTS)
131
132# Remove GNU Property Notes from asm files.
133#string-cflags += -DWANT_GNU_PROPERTY=0
134
135# Enable assertion checks.
136#networking-cflags += -DWANT_ASSERT
137
138# Avoid auto-vectorization of scalar code and unroll loops
139networking-cflags += -O2 -fno-tree-vectorize -funroll-loops
140
141# Provide *_finite symbols and some of the glibc hidden symbols
142# so libmathlib can be used with binaries compiled against glibc
143# to interpose math functions with both static and dynamic linking
144USE_GLIBC_ABI = 1
145math-cflags += -DUSE_GLIBC_ABI=$(USE_GLIBC_ABI)
146
147# Enable experimental math routines - non-C23 vector math and low-accuracy scalar
148WANT_EXPERIMENTAL_MATH = 0
149math-cflags += -DWANT_EXPERIMENTAL_MATH=$(WANT_EXPERIMENTAL_MATH)
150