• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2022 Huawei Technologies Co., Ltd.
2# Licensed under the Mulan PSL v2.
3# You can use this software according to the terms and conditions of the Mulan
4# PSL v2.
5# You may obtain a copy of Mulan PSL v2 at:
6#     http://license.coscl.org.cn/MulanPSL2
7# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
8# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
9# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10# See the Mulan PSL v2 for more details.
11
12# common compile parameters
13CFLAGS += -Wall -Werror
14CFLAGS += -Wdate-time -Wfloat-equal -Wshadow
15CFLAGS += -fno-short-enums
16CFLAGS += -fno-omit-frame-pointer
17CFLAGS += -Wextra -nostdinc
18CFLAGS += -march=armv8-a -fPIC
19CFLAGS += -pipe
20CFLAGS += -fno-common -fsigned-char
21CFLAGS += -ftrivial-auto-var-init=zero
22CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
23
24ifeq ($(CONFIG_GCC),y)
25    CFLAGS += -W
26    CFLAGS += -fstack-protector
27    CFLAGS += -Os -fno-peephole -fno-peephole2
28else
29    # set compile parameters
30    CFLAGS += -fstack-protector-strong
31    CFLAGS += -funwind-tables
32    CFLAGS += -Oz
33    CFLAGS += -munaligned-access -fmax-type-align=1
34    CFLAGS += -flto -fvisibility=default -fsanitize=cfi -fno-sanitize-cfi-cross-dso
35    CFLAGS += -fno-exceptions
36    ifeq ($(TARGET_IS_ARM64),y)
37        CFLAGS += --target=aarch64-linux-gnu
38    else
39        CFLAGS += --target=arm-linux-gnu
40        CFLAGS += -mfloat-abi=soft
41    endif
42    # set LD flags
43    LDFLAGS += -z max-page-size=4096
44    # enable XOM
45    ifeq ($(TARGET_IS_ARM64),y)
46        LDFLAGS += --execute-only
47    endif
48endif
49
50# common LDFLAGS
51LDFLAGS += -s -z text -z now -z relro -z noexecstack -shared
52