xref: /aosp_15_r20/external/pigweed/pw_toolchain/host_gcc/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# Copyright 2020 The Pigweed Authors
2*61c4878aSAndroid Build Coastguard Worker#
3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of
5*61c4878aSAndroid Build Coastguard Worker# the License at
6*61c4878aSAndroid Build Coastguard Worker#
7*61c4878aSAndroid Build Coastguard Worker#     https://www.apache.org/licenses/LICENSE-2.0
8*61c4878aSAndroid Build Coastguard Worker#
9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under
13*61c4878aSAndroid Build Coastguard Worker# the License.
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Workerimport("//build_overrides/pigweed.gni")
16*61c4878aSAndroid Build Coastguard Worker
17*61c4878aSAndroid Build Coastguard Worker# Disable obnoxious ABI warning.
18*61c4878aSAndroid Build Coastguard Worker#
19*61c4878aSAndroid Build Coastguard Worker# GCC 7.1 adds an over-zealous ABI warning with little useful information
20*61c4878aSAndroid Build Coastguard Worker# on how to resolve the issue. The warning you get is:
21*61c4878aSAndroid Build Coastguard Worker#
22*61c4878aSAndroid Build Coastguard Worker#   note: parameter passing for argument of type '...' changed in GCC 7.1
23*61c4878aSAndroid Build Coastguard Worker#
24*61c4878aSAndroid Build Coastguard Worker# There is no other information, and searching for the error is needed to
25*61c4878aSAndroid Build Coastguard Worker# understand what is happening. For upstream Pigweed, we compile from
26*61c4878aSAndroid Build Coastguard Worker# source so this is irrelevant; so disable it.
27*61c4878aSAndroid Build Coastguard Worker#
28*61c4878aSAndroid Build Coastguard Worker# See: https://gcc.gnu.org/gcc-7/changes.html (search for "psabi").
29*61c4878aSAndroid Build Coastguard Worker#      https://gcc.gnu.org/ml/gcc/2017-05/msg00073.html
30*61c4878aSAndroid Build Coastguard Workerconfig("disable_psabi_warning") {
31*61c4878aSAndroid Build Coastguard Worker  cflags = [ "-Wno-psabi" ]
32*61c4878aSAndroid Build Coastguard Worker}
33*61c4878aSAndroid Build Coastguard Worker
34*61c4878aSAndroid Build Coastguard Workerconfig("mingw_z_format") {
35*61c4878aSAndroid Build Coastguard Worker  if (host_os == "win") {
36*61c4878aSAndroid Build Coastguard Worker    # MinGW can't handle %z format specifiers without this flag enabled. This
37*61c4878aSAndroid Build Coastguard Worker    # flag is deprecated in future versions of MinGW, and should be replaced by
38*61c4878aSAndroid Build Coastguard Worker    # setting __MINGW_FEATURES__=__MINGW_ANSI_STDIO__ when switching to a
39*61c4878aSAndroid Build Coastguard Worker    # version of MinGW that uses the new flags.
40*61c4878aSAndroid Build Coastguard Worker    cflags = [ "-D__USE_MINGW_ANSI_STDIO=1" ]
41*61c4878aSAndroid Build Coastguard Worker  }
42*61c4878aSAndroid Build Coastguard Worker}
43*61c4878aSAndroid Build Coastguard Worker
44*61c4878aSAndroid Build Coastguard Worker# GCC needs the -pthread option to support multithreading. This must be
45*61c4878aSAndroid Build Coastguard Worker# specified to build e.g. pw_thread_stl.
46*61c4878aSAndroid Build Coastguard Workerconfig("threading_support") {
47*61c4878aSAndroid Build Coastguard Worker  ldflags = [ "-pthread" ]
48*61c4878aSAndroid Build Coastguard Worker}
49