| # Copyright 2021 The Cobalt Authors. All Rights Reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| config("platform_configuration") { |
| ldflags = [ |
| "-fuse-ld=lld", |
| "-Wl,--build-id", |
| "-Wl,--gc-sections", |
| "-Wl,-X", |
| "-Wl,-v", |
| "-Wl,-eh-frame-hdr", |
| "-Wl,--fini=__cxa_finalize", |
| "-Wl,-shared", |
| "-Wl,-L$clang_base_path", |
| "-Wl,-L/usr/lib", |
| "-Wl,-L/lib", |
| "-Wl,-u GetEvergreenSabiString", |
| ] |
| |
| if (!build_with_separate_cobalt_toolchain) { |
| ldflags += [ "-nostdlib" ] |
| } |
| cflags = [ |
| "-ffunction-sections", |
| "-fdata-sections", |
| "-fPIC", |
| "-nostdlibinc", |
| "-isystem" + rebase_path("//third_party/llvm-project/libcxxabi/include", |
| root_build_dir), |
| "-isystem" + rebase_path("//third_party/llvm-project/libunwind/include", |
| root_build_dir), |
| "-isystem" + rebase_path("//third_party/llvm-project/libcxx/include", |
| root_build_dir), |
| "-isystem" + rebase_path("//third_party/musl/include", root_build_dir), |
| "-isystem" + rebase_path("//third_party/musl/arch/generic", root_build_dir), |
| ] |
| |
| cflags_cc = [ |
| "-nostdinc++", |
| "-std=c++17", |
| ] |
| |
| defines = [ |
| # Ensure that the Starboardized __external_threading file is included. |
| "_LIBCPP_HAS_THREAD_API_EXTERNAL", |
| |
| # Ensure that only the forward declarations and type definitions are included |
| # in __external_threading. |
| "_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL", |
| |
| # Enable GNU extensions to get prototypes like ffsl. |
| "_GNU_SOURCE=1", |
| |
| "_LIBCPP_HAS_MUSL_LIBC", |
| "__STDC_FORMAT_MACROS", # so that we get PRI* |
| |
| # File format of the shared object we will generate. |
| "__ELF__", |
| |
| # Use scalar portable implementations instead of Clang/GCC vector |
| # extensions in SkVx.h. |
| "SKNX_NO_SIMD", |
| |
| # By default, <EGL/eglplatform.h> pulls in some X11 headers that have some |
| # nasty macros (|Status|, for example) that conflict with Chromium base. |
| "MESA_EGL_NO_X11_HEADERS", |
| |
| # During Evergreen updates the CRX package is kept in-memory, instead of |
| # on the file system, before getting unpacked. |
| # TODO(b/158043520): we need to make significant customizations to Chromium |
| # code to implement this feature and this macro allows us to switch back |
| # to the legacy behavior during development to verify the customizations |
| # are made cleanly. Once the feature is complete we may want to remove |
| # existing customizations that enable the legacy behavior for Cobalt builds, |
| # change IN_MEMORY_UPDATES references to USE_COBALT_CUSTOMIZATIONS |
| # references, and remove this macro. |
| "IN_MEMORY_UPDATES", |
| ] |
| |
| if (is_debug) { |
| cflags += [ |
| "-O0", |
| "-frtti", |
| "-g", |
| ] |
| } else if (is_devel) { |
| cflags += [ |
| "-O2", |
| "-frtti", |
| "-g", |
| ] |
| } else { |
| cflags += [ |
| "-gline-tables-only", |
| "-fno-rtti", |
| ] |
| } |
| |
| if (is_clang) { |
| cflags += [ |
| "-fcolor-diagnostics", |
| |
| # Default visibility to hidden, to enable dead stripping. |
| "-fvisibility=hidden", |
| |
| # Warns on switches on enums that cover all enum values but |
| # also contain a default: branch. Chrome is full of that. |
| "-Wno-covered-switch-default", |
| |
| # protobuf uses hash_map. |
| "-Wno-deprecated", |
| |
| "-fno-exceptions", |
| |
| # Enable unwind tables used by libunwind for stack traces. |
| "-funwind-tables", |
| |
| # Disable usage of frame pointers. |
| "-fomit-frame-pointer", |
| |
| # Don"t warn about the "struct foo f = {0};" initialization pattern. |
| "-Wno-missing-field-initializers", |
| |
| # Do not warn for implicit sign conversions. |
| "-Wno-sign-conversion", |
| |
| "-fno-strict-aliasing", # See http://crbug.com/32204 |
| |
| "-Wno-unnamed-type-template-args", |
| |
| # Triggered by the COMPILE_ASSERT macro. |
| "-Wno-unused-local-typedef", |
| |
| # Do not warn if a function or variable cannot be implicitly |
| # instantiated. |
| "-Wno-undefined-var-template", |
| |
| # Do not warn about an implicit exception spec mismatch. |
| "-Wno-implicit-exception-spec-mismatch", |
| |
| # It's OK not to use some input parameters. |
| "-Wno-unused-parameter", |
| "-Wno-conversion", |
| "-Wno-bitwise-op-parentheses", |
| "-Wno-shift-op-parentheses", |
| "-Wno-shorten-64-to-32", |
| "-fno-use-cxa-atexit", |
| ] |
| } |
| |
| if (is_clang_16) { |
| cflags += [ |
| # Do not remove null pointer checks. |
| "-fno-delete-null-pointer-checks", |
| ] |
| } |
| |
| if (use_asan) { |
| cflags += [ |
| "-fsanitize=address", |
| "-fno-omit-frame-pointer", |
| ] |
| |
| ldflags += [ |
| "-fsanitize=address", |
| |
| # Force linking of the helpers in sanitizer_options.cc |
| "-Wl,-u_sanitizer_options_link_helper", |
| ] |
| |
| defines += [ "ADDRESS_SANITIZER" ] |
| |
| if (asan_symbolizer_path != "") { |
| defines += [ "ASAN_SYMBOLIZER_PATH=\"${asan_symbolizer_path}\"" ] |
| } |
| } else if (use_tsan) { |
| cflags += [ |
| "-fsanitize=thread", |
| "-fno-omit-frame-pointer", |
| ] |
| |
| ldflags += [ "-fsanitize=thread" ] |
| |
| defines += [ "THREAD_SANITIZER" ] |
| } |
| } |
| |
| config("speed") { |
| cflags = [ "-O2" ] |
| } |
| |
| config("size") { |
| cflags = [ "-Os" ] |
| if (is_qa || is_gold) { |
| ldflags = [ "-Wl,--icf=safe" ] |
| } |
| } |
| |
| config("pedantic_warnings") { |
| cflags = [ |
| "-Wall", |
| "-Wextra", |
| "-Wunreachable-code", |
| ] |
| } |
| |
| config("no_pedantic_warnings") { |
| cflags = [ |
| # 'this' pointer cannot be NULL...pointer may be assumed |
| # to always convert to true. |
| "-Wno-undefined-bool-conversion", |
| |
| # Skia doesn't use overrides. |
| "-Wno-inconsistent-missing-override", |
| |
| # Do not warn for implicit type conversions that may change a value. |
| "-Wno-conversion", |
| |
| # shifting a negative signed value is undefined |
| "-Wno-shift-negative-value", |
| |
| # Width of bit-field exceeds width of its type- value will be truncated |
| "-Wno-bitfield-width", |
| "-Wno-undefined-var-template", |
| ] |
| } |