diff --git a/arm/build/config/win/BUILD.gn b/arm/build/config/win/BUILD.gn deleted file mode 100644 index 65fcb4e3..00000000 --- a/arm/build/config/win/BUILD.gn +++ /dev/null @@ -1,680 +0,0 @@ -# Copyright 2023 The Chromium Authors and Alex313031 -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//build/config/c++/c++.gni") -import("//build/config/chrome_build.gni") -import("//build/config/clang/clang.gni") -import("//build/config/compiler/compiler.gni") -import("//build/config/rust.gni") -import("//build/config/sanitizers/sanitizers.gni") -import("//build/config/win/control_flow_guard.gni") -import("//build/config/win/visual_studio_version.gni") -import("//build/timestamp.gni") -import("//build/toolchain/goma.gni") -import("//build/toolchain/rbe.gni") -import("//build/toolchain/toolchain.gni") - -assert(is_win) - -declare_args() { - # Turn this on to have the linker output extra timing information. - win_linker_timing = false - - # possible values for target_winuwp_version: - # "10" - Windows UWP 10 - # "8.1" - Windows RT 8.1 - # "8.0" - Windows RT 8.0 - target_winuwp_version = "10" - - # possible values: - # "app" - Windows Store Applications - # "phone" - Windows Phone Applications - # "system" - Windows Drivers and Tools - # "server" - Windows Server Applications - # "desktop" - Windows Desktop Applications - target_winuwp_family = "app" - - # Set this to use clang-style diagnostics format instead of MSVC-style, which - # is useful in e.g. Emacs compilation mode. - # E.g.: - # Without this, clang emits a diagnostic message like this: - # foo/bar.cc(12,34): error: something went wrong - # and with this switch, clang emits it like this: - # foo/bar.cc:12:34: error: something went wrong - use_clang_diagnostics_format = false -} - -# This is included by reference in the //build/config/compiler config that -# is applied to all targets. It is here to separate out the logic that is -# Windows-only. -config("compiler") { - if (current_cpu == "x86") { - asmflags = [ - # When /safeseh is specified, the linker will only produce an image if it - # can also produce a table of the image's safe exception handlers. This - # table specifies for the operating system which exception handlers are - # valid for the image. Note that /SAFESEH isn't accepted on the command - # line, only /safeseh. This is only accepted by ml.exe, not ml64.exe. - "/safeseh", - ] - } - - cflags = [ - "/Gy", # Enable function-level linking. - "/FS", # Preserve previous PDB behavior. - "/bigobj", # Some of our files are bigger than the regular limits. - "/utf-8", # Assume UTF-8 by default to avoid code page dependencies. - ] - - if (is_clang) { - cflags += [ - "/Zc:twoPhase", - - # Consistently use backslash as the path separator when expanding the - # __FILE__ macro when targeting Windows regardless of the build - # environment. - "-ffile-reproducible", - ] - } - - # Force C/C++ mode for the given GN detected file type. This is necessary - # for precompiled headers where the same source file is compiled in both - # modes. - cflags_c = [ "/TC" ] - cflags_cc = [ "/TP" ] - - cflags += [ - # Work around crbug.com/526851, bug in VS 2015 RTM compiler. - # "/Zc:sizedDealloc-", - ] - - if (is_clang) { - # Required to make the 19041 SDK compatible with clang-cl. - # See https://crbug.com/1089996 issue #2 for details. - cflags += [ "/D__WRL_ENABLE_FUNCTION_STATICS__" ] - - # Tell clang which version of MSVC to emulate. - cflags += [ "-fmsc-version=1934" ] - - if (is_component_build) { - cflags += [ - # Do not export inline member functions. This makes component builds - # faster. This is similar to -fvisibility-inlines-hidden. - "/Zc:dllexportInlines-", - ] - } - - if (current_cpu == "x86") { - if (host_cpu == "x86" || host_cpu == "x64") { - cflags += [ "-m32" ] - } else { - cflags += [ "--target=i386-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] - } - } else if (current_cpu == "x64") { - if (host_cpu == "x86" || host_cpu == "x64") { - cflags += [ "-m64" ] - } else { - cflags += [ "--target=x86_64-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] - } - } else if (current_cpu == "arm64") { - cflags += [ "--target=aarch64-pc-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] - } else { - assert(false, "unknown current_cpu " + current_cpu) - } - - # Chrome currently requires SSE3. Clang supports targeting any Intel - # microarchitecture. MSVC only supports a subset of architectures, and the - # next step after SSE2 will be AVX. - # "/fp:fast", enables FMA. - if (current_cpu == "x86" || current_cpu == "x64") { - cflags += [ - "/O2", - "-mavx", - "-maes", - "-mpclmul", - "/clang:-O3", - "/clang:-mavx", - "/clang:-maes", - "/clang:-mpclmul", - "-Xclang", "-O3", - "-Wno-unused-command-line-argument", - ] - } - - # Enable ANSI escape codes if something emulating them is around (cmd.exe - # doesn't understand ANSI escape codes by default). Make sure to not enable - # this if goma/remoteexec is in use, because this will lower cache hits. - if (!use_goma && !use_remoteexec && - exec_script("//build/win/use_ansi_codes.py", [], "trim string") == - "True") { - cflags += [ "-fansi-escape-codes" ] - } - - if (use_clang_diagnostics_format) { - cflags += [ "/clang:-fdiagnostics-format=clang" ] - } - } - - # Disabled with cc_wrapper because of https://github.com/mozilla/sccache/issues/264 - if (use_lld && !use_thin_lto && (is_clang || !use_goma) && cc_wrapper == "") { - # /Brepro lets the compiler not write the mtime field in the .obj output. - # link.exe /incremental relies on this field to work correctly, but lld - # never looks at this timestamp, so it's safe to pass this flag with - # lld and get more deterministic compiler output in return. - # In LTO builds, the compiler doesn't write .obj files containing mtimes, - # so /Brepro is ignored there. - cflags += [ "/Brepro" ] - } - - ldflags = [] - - if (use_lld) { - # lld defaults to writing the current time in the pe/coff header. - # For build reproducibility, pass an explicit timestamp. See - # build/compute_build_timestamp.py for how the timestamp is chosen. - # (link.exe also writes the current time, but it doesn't have a flag to - # override that behavior.) - ldflags += [ "/TIMESTAMP:" + build_timestamp ] - - # Don't look for libpaths in %LIB%, similar to /X in cflags above. - ldflags += [ "/lldignoreenv" ] - ldflags += [ "/opt:lldlto=3", ] - } - - # Some binaries create PDBs larger than 4 GiB. Increasing the PDB page size - # to 8 KiB allows 8 GiB PDBs. The larger page size also allows larger block maps - # which is a PDB limit that was hit in https://crbug.com/1406510. The page size - # can easily be increased in the future to allow even larger PDBs or larger - # block maps. - # This flag requires lld-link.exe or link.exe from VS 2022 or later to create - # the PDBs, and tools from circa 22H2 or later to consume the PDBs. - ldflags += [ "/pdbpagesize:8192" ] - - if (!is_debug && !is_component_build) { - # Enable standard linker optimizations like GC (/OPT:REF) and ICF in static - # release builds. - # Release builds always want these optimizations, so enable them explicitly. - ldflags += [ - "/OPT:REF", - "/OPT:ICF", - "/INCREMENTAL:NO", - "/FIXED:NO", - "/OPT:lldlto=3", - ] - - if (use_lld) { - # String tail merging leads to smaller binaries, but they don't compress - # as well, leading to increased mini_installer size (crbug.com/838449). - # ldflags += [ "/OPT:NOLLDTAILMERGE" ] - ldflags += [ "/OPT:LLDTAILMERGE" ] - } - - # TODO(siggi): Is this of any use anymore? - # /PROFILE ensures that the PDB file contains FIXUP information (growing the - # PDB file by about 5%) but does not otherwise alter the output binary. It - # is enabled opportunistically for builds where it is not prohibited (not - # supported when incrementally linking, or using /debug:fastlink). - # ldflags += [ "/PROFILE" ] - } - - # arflags apply only to static_libraries. The normal linker configs are only - # set for executable and shared library targets so arflags must be set - # elsewhere. Since this is relatively contained, we just apply them in this - # more general config and they will only have an effect on static libraries. - arflags = [ - # "No public symbols found; archive member will be inaccessible." This - # means that one or more object files in the library can never be - # pulled in to targets that link to this library. It's just a warning that - # the source file is a no-op. - "/ignore:4221", - ] -} - -# This is included by reference in the //build/config/compiler:runtime_library -# config that is applied to all targets. It is here to separate out the logic -# that is Windows-only. Please see that target for advice on what should go in -# :runtime_library vs. :compiler. -config("runtime_library") { - cflags = [] - cflags_cc = [] - - # Defines that set up the CRT. - defines = [ - "__STD_C", - "_CRT_RAND_S", - "_CRT_SECURE_NO_DEPRECATE", - "_SCL_SECURE_NO_DEPRECATE", - ] - - # Defines that set up the Windows SDK. - defines += [ - "_ATL_NO_OPENGL", - "_WINDOWS", - "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", - "PSAPI_VERSION=2", - "WIN32", - "_SECURE_ATL", - ] - - if (current_os == "winuwp") { - # When targeting Windows Runtime, certain compiler/linker flags are - # necessary. - defines += [ - "WINUWP", - "__WRL_NO_DEFAULT_LIB__", - ] - if (target_winuwp_family == "app") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ] - } else if (target_winuwp_family == "phone") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP" ] - } else if (target_winuwp_family == "system") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SYSTEM" ] - } else if (target_winuwp_family == "server") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SERVER" ] - } else { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] - } - cflags_cc += [ "/EHsc" ] - - # This warning is given because the linker cannot tell the difference - # between consuming WinRT APIs versus authoring WinRT within static - # libraries as such this warning is always given by the linker. Since - # consuming WinRT APIs within a library is legitimate but authoring - # WinRT APis is not allowed, this warning is disabled to ignore the - # legitimate consumption of WinRT APIs within static library builds. - arflags = [ "/IGNORE:4264" ] - - if (target_winuwp_version == "10") { - defines += [ "WIN10=_WIN32_WINNT_WIN10" ] - } else if (target_winuwp_version == "8.1") { - defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] - } else if (target_winuwp_version == "8.0") { - defines += [ "WIN8=_WIN32_WINNT_WIN8" ] - } - } else { - # When not targeting Windows Runtime, make sure the WINAPI family is set - # to desktop. - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] - } -} - -# Chromium only supports Windowes 10+. -# Some third-party libraries assume that these defines set what version of -# Windows is available at runtime. Targets using these libraries need to -# manually override this config for their compiles. -config("winver") { - defines = [ - "NTDDI_VERSION=NTDDI_WIN10_NI", - - # We can't say `=_WIN32_WINNT_WIN10` here because some files do - # `#if WINVER < 0x0600` without including windows.h before, - # and then _WIN32_WINNT_WIN10 isn't yet known to be 0x0A00. - "_WIN32_WINNT=0x0A00", - "WINVER=0x0A00", - ] -} - -# Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. -config("sdk_link") { - if (current_cpu == "x86") { - ldflags = [ - "/SAFESEH", # Not compatible with x64 so use only for x86. - "/largeaddressaware", - ] - } -} - -# This default linker setup is provided separately from the SDK setup so -# targets who want different library configurations can remove this and specify -# their own. -config("common_linker_setup") { - ldflags = [ - "/FIXED:NO", - "/ignore:4199", - "/ignore:4221", - "/NXCOMPAT", - "/DYNAMICBASE", - ] - - if (win_linker_timing) { - ldflags += [ - "/time", - "/verbose:incr", - ] - } -} - -config("default_cfg_compiler") { - # Emit table of address-taken functions for Control-Flow Guard (CFG). - # This is needed to allow functions to be called by code that is built - # with CFG enabled, such as system libraries. - # The CFG guards are only emitted if |win_enable_cfg_guards| is enabled. - if (win_enable_cfg_guards) { - if (is_clang) { - cflags = [ "/guard:cf" ] - } - rustflags = [ "-Ccontrol-flow-guard" ] - } else { - if (is_clang) { - cflags = [ "/guard:cf,nochecks" ] - } - rustflags = [ "-Ccontrol-flow-guard=nochecks" ] - } -} - -# To disable CFG guards for a target, remove the "default_cfg_compiler" -# config, and add "disable_guards_cfg_compiler" config. -config("disable_guards_cfg_compiler") { - # Emit table of address-taken functions for Control-Flow Guard (CFG). - # This is needed to allow functions to be called by code that is built - # with CFG enabled, such as system libraries. - if (is_clang) { - cflags = [ "/guard:cf,nochecks" ] - } - rustflags = [ "-Ccontrol-flow-guard=nochecks" ] -} - -config("cfi_linker") { - # Control Flow Guard (CFG) - # https://msdn.microsoft.com/en-us/library/windows/desktop/mt637065.aspx - # /DYNAMICBASE (ASLR) is turned off in debug builds, therefore CFG cannot be - # turned on either. - # ASan and CFG leads to slow process startup. Chromium's test runner uses - # lots of child processes, so this means things are really slow. Disable CFG - # for now. https://crbug.com/846966 - if (!is_debug && !is_asan) { - # Turn on CFG bitmap generation and CFG load config. - ldflags = [ "/guard:cf" ] - } -} - -# This is a superset of all the delayloads needed for chrome.exe, chrome.dll, -# chrome_child.dll, and chrome_elf.dll. The linker will automatically ignore -# anything which is not linked to the binary at all. -# Most of the dlls are simply not required at startup (or at all, depending -# on how the browser is used). The following dlls are interconnected and need to -# be delayloaded together to ensure user32 does not load too early or at all, -# depending on the process type: user32, gdi32, comctl32, comdlg32, cryptui, -# d3d9, dwmapi, imm32, msi, ole32, oleacc, rstrtmgr, shell32, shlwapi, and -# uxtheme. -# There are some exceptions to this list which need to be declared separately. -# Some dlls cannot be delayloaded by chrome_child.dll due to the sandbox -# restrictions that prevent them from being loaded properly. Those dlls are -# specified in the separate config below. -# This config should also be used for any test binary whose goal is to run -# tests with the full browser. -config("delayloads") { - ldflags = [ - "/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll", - "/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll", - "/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll", - "/DELAYLOAD:comctl32.dll", - "/DELAYLOAD:comdlg32.dll", - "/DELAYLOAD:credui.dll", - "/DELAYLOAD:cryptui.dll", - "/DELAYLOAD:d3d11.dll", - "/DELAYLOAD:d3d9.dll", - "/DELAYLOAD:dwmapi.dll", - "/DELAYLOAD:dxgi.dll", - "/DELAYLOAD:dxva2.dll", - "/DELAYLOAD:esent.dll", - "/DELAYLOAD:gdi32.dll", - "/DELAYLOAD:hid.dll", - "/DELAYLOAD:imagehlp.dll", - "/DELAYLOAD:imm32.dll", - "/DELAYLOAD:msi.dll", - "/DELAYLOAD:netapi32.dll", - "/DELAYLOAD:ncrypt.dll", - "/DELAYLOAD:ole32.dll", - "/DELAYLOAD:oleacc.dll", - "/DELAYLOAD:propsys.dll", - "/DELAYLOAD:psapi.dll", - "/DELAYLOAD:rpcrt4.dll", - "/DELAYLOAD:rstrtmgr.dll", - "/DELAYLOAD:setupapi.dll", - "/DELAYLOAD:shell32.dll", - "/DELAYLOAD:shlwapi.dll", - "/DELAYLOAD:uiautomationcore.dll", - "/DELAYLOAD:urlmon.dll", - "/DELAYLOAD:user32.dll", - "/DELAYLOAD:usp10.dll", - "/DELAYLOAD:uxtheme.dll", - "/DELAYLOAD:wer.dll", - "/DELAYLOAD:wevtapi.dll", - "/DELAYLOAD:wininet.dll", - "/DELAYLOAD:winusb.dll", - "/DELAYLOAD:wsock32.dll", - "/DELAYLOAD:wtsapi32.dll", - ] -} - -config("delayloads_not_for_child_dll") { - ldflags = [ - "/DELAYLOAD:advapi32.dll", - "/DELAYLOAD:crypt32.dll", - "/DELAYLOAD:dbghelp.dll", - "/DELAYLOAD:dhcpcsvc.dll", - "/DELAYLOAD:dwrite.dll", - "/DELAYLOAD:iphlpapi.dll", - "/DELAYLOAD:oleaut32.dll", - "/DELAYLOAD:secur32.dll", - "/DELAYLOAD:uiautomationcore.dll", - "/DELAYLOAD:userenv.dll", - "/DELAYLOAD:winhttp.dll", - "/DELAYLOAD:winmm.dll", - "/DELAYLOAD:winspool.drv", - "/DELAYLOAD:wintrust.dll", - "/DELAYLOAD:ws2_32.dll", - ] -} - -# CRT -------------------------------------------------------------------------- - -# Configures how the runtime library (CRT) is going to be used. -# See https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx for a reference of -# what each value does. -config("default_crt") { - if (is_component_build) { - # Component mode: dynamic CRT. Since the library is shared, it requires - # exceptions or will give errors about things not matching, so keep - # exceptions on. - configs = [ ":dynamic_crt" ] - } else { - if (current_os == "winuwp") { - # https://blogs.msdn.microsoft.com/vcblog/2014/06/10/the-great-c-runtime-crt-refactoring/ - # contains a details explanation of what is happening with the Windows - # CRT in Visual Studio releases related to Windows store applications. - configs = [ ":dynamic_crt" ] - } else { - # Desktop Windows: static CRT. - configs = [ ":static_crt" ] - } - } -} - -# Use this to force use of the release CRT when building perf-critical build -# tools that need to be fully optimized even in debug builds, for those times -# when the debug CRT is part of the bottleneck. This also avoids *implicitly* -# defining _DEBUG. -config("release_crt") { - if (is_component_build) { - cflags = [ "/MD" ] - - if (rust_prebuilt_stdlib) { - rustflags = [ "-Ctarget-feature=-crt-static" ] - } else { - # /MD specifies msvcrt.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. Once - # https://github.com/rust-lang/rust/issues/39016 is resolved we should - # instead tell rustc which CRT to use (static/dynamic + release/debug). - rustflags = [ "-Clink-arg=msvcrt.lib" ] - } - - if (use_custom_libcxx) { - # On Windows, including libcpmt[d]/msvcprt[d] explicitly links the C++ - # standard library, which libc++ needs for exception_ptr internals. - ldflags = [ "/DEFAULTLIB:msvcprt.lib" ] - } - } else { - cflags = [ "/MT" ] - - if (rust_prebuilt_stdlib) { - rustflags = [ "-Ctarget-feature=+crt-static" ] - } else { - # /MT specifies libcmt.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. Once - # https://github.com/rust-lang/rust/issues/39016 is resolved we should - # instead tell rustc which CRT to use (static/dynamic + release/debug). - rustflags = [ "-Clink-arg=libcmt.lib" ] - } - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:libcpmt.lib" ] - } - } -} - -config("dynamic_crt") { - if (is_debug) { - # This pulls in the DLL debug CRT and defines _DEBUG - cflags = [ "/MDd" ] - - # /MDd specifies msvcrtd.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. - # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should - # instead tell rustc which CRT to use (static/dynamic + release/debug). We - # can't support prebuilt stdlib in this path until then. - rustflags = [ "-Clink-arg=msvcrtd.lib" ] - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:msvcprtd.lib" ] - } - } else { - cflags = [ "/MD" ] - - if (rust_prebuilt_stdlib) { - rustflags = [ "-Ctarget-feature=-crt-static" ] - } else { - # /MD specifies msvcrt.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. - # Once https://github.com/rust-lang/rust/issues/39016 is resolved we - # should instead tell rustc which CRT to use (static/dynamic + - # release/debug). - rustflags = [ "-Clink-arg=msvcrt.lib" ] - } - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:msvcprt.lib" ] - } - } -} - -config("static_crt") { - if (is_debug) { - # This pulls in the static debug CRT and defines _DEBUG - cflags = [ "/MTd" ] - - # /MTd specifies libcmtd.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. - # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should - # instead tell rustc which CRT to use (static/dynamic + release/debug). We - # can't support prebuilt stdlib in this path until then. - rustflags = [ "-Clink-arg=libcmtd.lib" ] - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:libcpmtd.lib" ] - } - } else { - cflags = [ "/MT" ] - - if (rust_prebuilt_stdlib) { - rustflags = [ "-Ctarget-feature=+crt-static" ] - } else { - # /MT specifies libcmt.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. - # Once https://github.com/rust-lang/rust/issues/39016 is resolved we - # should instead tell rustc which CRT to use (static/dynamic + - # release/debug). - rustflags = [ "-Clink-arg=libcmt.lib" ] - } - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:libcpmt.lib" ] - } - } -} - -# Subsystem -------------------------------------------------------------------- - -# This is appended to the subsystem to specify a minimum version. -if (current_cpu == "x64") { - # The number after the comma is the minimum required OS version. - # 5.02 = Windows Server 2003. - subsystem_version_suffix = ",10.0" -} else if (current_cpu == "arm64") { - # Windows ARM64 requires Windows 10. - subsystem_version_suffix = ",10.0" -} else { - # 5.01 = Windows XP. - subsystem_version_suffix = ",10.0" -} - -config("console") { - ldflags = [ "/SUBSYSTEM:CONSOLE$subsystem_version_suffix" ] -} -config("windowed") { - ldflags = [ "/SUBSYSTEM:WINDOWS$subsystem_version_suffix" ] -} - -# Incremental linking ---------------------------------------------------------- - -# Applies incremental linking or not depending on the current configuration. -config("default_incremental_linking") { - # Enable incremental linking for debug builds and all component builds - any - # builds where performance is not job one. - # TODO(thakis): Always turn this on with lld, no reason not to. - if (is_debug || is_component_build) { - ldflags = [ "/INCREMENTAL" ] - if (use_lld) { - # lld doesn't use ilk files and doesn't really have an incremental link - # mode; the only effect of the flag is that the .lib file timestamp isn't - # updated if the .lib doesn't change. - # TODO(thakis): Why pass /OPT:NOREF for lld, but not otherwise? - # TODO(thakis): /INCREMENTAL is on by default in link.exe, but not in - # lld. - ldflags += [ "/OPT:NOREF" ] - } - } else { - ldflags = [ "/INCREMENTAL:NO" ] - } -} - -# Character set ---------------------------------------------------------------- - -# Not including this config means "ansi" (8-bit system codepage). -config("unicode") { - defines = [ - "_UNICODE", - "UNICODE", - ] -} - -# Lean and mean ---------------------------------------------------------------- - -# Some third party code might not compile with WIN32_LEAN_AND_MEAN so we have -# to have a separate config for it. Remove this config from your target to -# get the "bloaty and accommodating" version of windows.h. -config("lean_and_mean") { - defines = [ "WIN32_LEAN_AND_MEAN" ] -} - -# Nominmax -------------------------------------------------------------------- - -# Some third party code defines NOMINMAX before including windows.h, which -# then causes warnings when it's been previously defined on the command line. -# For such targets, this config can be removed. - -config("nominmax") { - defines = [ "NOMINMAX" ] -} diff --git a/other/AVX2/build/config/win/BUILD.gn b/other/AVX2/build/config/win/BUILD.gn index 53ff66b0..debb6802 100644 --- a/other/AVX2/build/config/win/BUILD.gn +++ b/other/AVX2/build/config/win/BUILD.gn @@ -109,16 +109,16 @@ config("compiler") { if (host_cpu == "x86" || host_cpu == "x64") { cflags += [ "-m32" ] } else { - cflags += [ "--target=i386-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] + cflags += [ "--target=i386-windows" ] } } else if (current_cpu == "x64") { if (host_cpu == "x86" || host_cpu == "x64") { cflags += [ "-m64" ] } else { - cflags += [ "--target=x86_64-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] + cflags += [ "--target=x86_64-windows" ] } } else if (current_cpu == "arm64") { - cflags += [ "--target=aarch64-pc-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] + cflags += [ "--target=aarch64-pc-windows" ] } else { assert(false, "unknown current_cpu " + current_cpu) } @@ -397,18 +397,32 @@ config("cfi_linker") { } # This is a superset of all the delayloads needed for chrome.exe, chrome.dll, -# chrome_child.dll, and chrome_elf.dll. The linker will automatically ignore -# anything which is not linked to the binary at all. -# Most of the dlls are simply not required at startup (or at all, depending -# on how the browser is used). The following dlls are interconnected and need to -# be delayloaded together to ensure user32 does not load too early or at all, -# depending on the process type: user32, gdi32, comctl32, comdlg32, cryptui, -# d3d9, dwmapi, imm32, msi, ole32, oleacc, rstrtmgr, shell32, shlwapi, and -# uxtheme. -# There are some exceptions to this list which need to be declared separately. -# Some dlls cannot be delayloaded by chrome_child.dll due to the sandbox -# restrictions that prevent them from being loaded properly. Those dlls are -# specified in the separate config below. +# and chrome_elf.dll. The linker will automatically ignore anything which is not +# linked to the binary at all (it is harmless to have an unmatched /delayload). +# +# We delayload most libraries as the dlls are simply not required at startup (or +# at all, depending on the process type). In unsandboxed process they will load +# when first needed. +# +# Some dlls open handles when they are loaded, and we may not want them to be +# loaded in renderers or other sandboxed processes. Conversely, some dlls must +# be loaded before sandbox lockdown. +# +# Some dlls themselves load others - in particular, to avoid unconditionally +# loading user32.dll - we require that the following dlls are all delayloaded: +# user32, gdi32, comctl32, comdlg32, cryptui, d3d9, dwmapi, imm32, msi, ole32, +# oleacc, rstrtmgr, shell32, shlwapi, and uxtheme. +# +# Advapi32.dll is unconditionally loaded at process startup on Windows 10, but +# on Windows 11 it is not, which makes it worthwhile to delay load it. +# Additionally, advapi32.dll exports several functions that are forwarded to +# other DLLs such as cryptbase.dll. If calls to those functions are present but +# there are some processes where the functions are never called then delay +# loading of advapi32.dll avoids pulling in those DLLs (such as cryptbase.dll) +# unnecessarily, even if advapi32.dll itself is loaded. +# +# This config applies to chrome.exe, chrome.dll, chrome_elf.dll (& others). +# # This config should also be used for any test binary whose goal is to run # tests with the full browser. config("delayloads") { @@ -416,6 +430,7 @@ config("delayloads") { "/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll", "/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll", "/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll", + "/DELAYLOAD:advapi32.dll", "/DELAYLOAD:comctl32.dll", "/DELAYLOAD:comdlg32.dll", "/DELAYLOAD:credui.dll", @@ -456,9 +471,10 @@ config("delayloads") { ] } +# This config (along with `:delayloads`) applies to chrome.exe & chrome_elf.dll. +# Entries should not appear in both configs. config("delayloads_not_for_child_dll") { ldflags = [ - "/DELAYLOAD:advapi32.dll", "/DELAYLOAD:crypt32.dll", "/DELAYLOAD:dbghelp.dll", "/DELAYLOAD:dhcpcsvc.dll", @@ -466,7 +482,6 @@ config("delayloads_not_for_child_dll") { "/DELAYLOAD:iphlpapi.dll", "/DELAYLOAD:oleaut32.dll", "/DELAYLOAD:secur32.dll", - "/DELAYLOAD:uiautomationcore.dll", "/DELAYLOAD:userenv.dll", "/DELAYLOAD:winhttp.dll", "/DELAYLOAD:winmm.dll", @@ -651,6 +666,10 @@ config("default_incremental_linking") { # TODO(thakis): /INCREMENTAL is on by default in link.exe, but not in # lld. ldflags += [ "/OPT:NOREF" ] + + # TODO(crbug.com/1444129): Mixing incremental and icf produces an error + # in lld-link. + ldflags += [ "/OPT:NOICF" ] } } else { ldflags = [ "/INCREMENTAL:NO" ] diff --git a/other/SSE2/README.md b/other/SSE2/README.md deleted file mode 100644 index bc671082..00000000 --- a/other/SSE2/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Thorium AVX2 - -This directory contains build config files for compiling __32 Bit__ Thorium/Chromium with [SSE2](https://en.wikipedia.org/wiki/SSE2) - diff --git a/other/SSE2/build/config/compiler/BUILD.gn b/other/SSE2/build/config/compiler/BUILD.gn deleted file mode 100644 index fee3664b..00000000 --- a/other/SSE2/build/config/compiler/BUILD.gn +++ /dev/null @@ -1,3028 +0,0 @@ -# Copyright 2023 The Chromium Authors and Alex313031. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//build/buildflag_header.gni") -import("//build/config/android/config.gni") -import("//build/config/c++/c++.gni") -import("//build/config/chrome_build.gni") -import("//build/config/chromeos/args.gni") -import("//build/config/chromeos/ui_mode.gni") -import("//build/config/clang/clang.gni") -import("//build/config/compiler/compiler.gni") -import("//build/config/coverage/coverage.gni") -import("//build/config/dcheck_always_on.gni") -import("//build/config/gclient_args.gni") -import("//build/config/host_byteorder.gni") -import("//build/config/rust.gni") -import("//build/config/sanitizers/sanitizers.gni") -import("//build/config/ui.gni") -import("//build/toolchain/cc_wrapper.gni") -import("//build/toolchain/goma.gni") -import("//build/toolchain/rbe.gni") -import("//build/toolchain/toolchain.gni") -import("//build_overrides/build.gni") - -if (current_cpu == "arm" || current_cpu == "arm64") { - import("//build/config/arm.gni") -} -if (current_cpu == "mipsel" || current_cpu == "mips64el" || - current_cpu == "mips" || current_cpu == "mips64") { - import("//build/config/mips.gni") -} -if (is_mac) { - import("//build/config/apple/symbols.gni") -} -if (is_ios) { - import("//build/config/ios/ios_sdk.gni") -} -if (is_nacl) { - # To keep NaCl variables out of builds that don't include NaCl, all - # variables defined in nacl/config.gni referenced here should be protected by - # is_nacl conditions. - import("//build/config/nacl/config.gni") -} - -lld_path = "" -if (!is_clang) { - declare_args() { - # This allows overriding the location of lld. - lld_path = rebase_path("$clang_base_path/bin", root_build_dir) - } -} else { - # clang looks for lld next to it, no need for -B. - lld_path = "" -} - -declare_args() { - # Normally, Android builds are lightly optimized, even for debug builds, to - # keep binary size down. Setting this flag to true disables such optimization - android_full_debug = false - - # Compile in such a way as to make it possible for the profiler to unwind full - # stack frames. Setting this flag has a large effect on the performance of the - # generated code than just setting profiling, but gives the profiler more - # information to analyze. - # Requires profiling to be set to true. - enable_full_stack_frames_for_profiling = false - - # When we are going to use gold we need to find it. - # This is initialized below, after use_gold might have been overridden. - gold_path = "" - - # Whether to enable LLVM's Polly optimizations. See https://polly.llvm.org/ - use_polly = false - - # Enable fatal linker warnings. Building Chromium with certain versions - # of binutils can cause linker warning. - fatal_linker_warnings = true - - # Build with C++ RTTI enabled. Chromium builds without RTTI by default, - # but some sanitizers are known to require it, like CFI diagnostics - # and UBsan variants. - use_rtti = use_cfi_diag || is_ubsan_vptr || is_ubsan_security - - # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided - # optimization that GCC supports. It used by ChromeOS in their official - # builds. To use it, set auto_profile_path to the path to a file containing - # the needed gcov profiling data. - auto_profile_path = "" - - # Path to an AFDO profile to use while building with clang, if any. Empty - # implies none. - clang_sample_profile_path = "" - - # Some configurations have default sample profiles. If this is true and - # clang_sample_profile_path is empty, we'll fall back to the default. - # - # We currently only have default profiles for Chromium in-tree, so we disable - # this by default for all downstream projects, since these profiles are likely - # nonsensical for said projects. - clang_use_default_sample_profile = - chrome_pgo_phase == 0 && build_with_chromium && is_official_build && - (is_android || chromeos_is_browser_only) - - # This configuration is used to select a default profile in Chrome OS based on - # the microarchitectures we are using. This is only used if - # clang_use_default_sample_profile is true and clang_sample_profile_path is - # empty. - chromeos_afdo_platform = "atom" - - # Emit debug information for profiling wile building with clang. - # Only enable this for ChromeOS official builds for AFDO. - clang_emit_debug_info_for_profiling = is_chromeos_device && is_official_build - - # Turn this on to have the compiler output extra timing information. - compiler_timing = false - - # Turn this on to use ghash feature of lld for faster debug link on Windows. - # http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.html - use_ghash = true - - # Whether to enable ThinLTO optimizations. Turning ThinLTO optimizations on - # can substantially increase link time and binary size, but they generally - # also make binaries a fair bit faster. - # - # TODO(gbiv): We disable optimizations by default on most platforms because - # the space overhead is too great. We should use some mixture of profiles and - # optimization settings to better tune the size increase. - thin_lto_enable_optimizations = - (is_chromeos || is_android || is_win || is_linux || is_mac || - (is_ios && use_lld)) && is_official_build - - # Initialize all local variables with a pattern. This flag will fill - # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the - # rest with 0xAA. This makes behavior of uninitialized memory bugs consistent, - # recognizable in the debugger, and crashes on memory accesses through - # uninitialized pointers. - # - # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and - # needs to be evaluated before enabling it there as well. - init_stack_vars = !(is_android && is_official_build) - - # Zero init has favorable performance/size tradeoffs for Chrome OS - # but was not evaluated for other platforms. - init_stack_vars_zero = is_chromeos - - # This argument is to control whether enabling text section splitting in the - # final binary. When enabled, the separated text sections with prefix - # '.text.hot', '.text.unlikely', '.text.startup' and '.text.exit' will not be - # merged to '.text' section. This allows us to identify the hot code section - # ('.text.hot') in the binary which may be mlocked or mapped to huge page to - # reduce TLB misses which gives performance improvement on cpu usage. - # The gold linker by default has text section splitting enabled. - use_text_section_splitting = false - - # Turn off the --call-graph-profile-sort flag for lld by default. Enable - # selectively for targets where it's beneficial. - enable_call_graph_profile_sort = chrome_pgo_phase == 2 - - # Enable DWARF v5. - use_dwarf5 = false - - # Override this to put full paths to PDBs in Windows PE files. This helps - # windbg and Windows Performance Analyzer with finding the PDBs in some local- - # build scenarios. This is never needed for bots or official builds. Because - # this puts the output directory in the DLLs/EXEs it breaks build determinism. - # Bugs have been reported to the windbg/WPA teams and this workaround will be - # removed when they are fixed. - use_full_pdb_paths = false - - # Enable -H, which prints the include tree during compilation. - # For use by tools/clang/scripts/analyze_includes.py - show_includes = false - - # Enable Profi algorithm. Profi can infer block and edge counts. - # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers - # TODO(crbug.com/1375958i:) Possibly enable this for Android too. - use_profi = is_chromeos - - # If true, linker crashes will be rerun with `--reproduce` which causes - # a reproducer file to be saved. - save_reproducers_on_lld_crash = false - - # Allow projects that wish to stay on C++17 to override Chromium's default. - # TODO(crbug.com/1402249): evaluate removing this end of 2023 - use_cxx17 = false - - # Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a - # shadow call stack in register x18. Hence, x18 must not be used by the OS - # or libraries. We assume that to be the case for high end Android - # configurations. For more details see - # https://clang.llvm.org/docs/ShadowCallStack.html - enable_shadow_call_stack = false -} - -declare_args() { - # Set to true to use icf, Identical Code Folding. - # - # icf=all is broken in older golds, see - # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # chromeos binutils has been patched with the fix, so always use icf there. - # The bug only affects x86 and x64, so we can still use ICF when targeting - # other architectures. - # - # lld doesn't have the bug. - use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && - !use_clang_coverage && current_os != "zos" && - !(is_android && use_order_profiling) && - (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" || - current_cpu == "x64")))) -} - -if (is_android || (is_chromeos_ash && is_chromeos_device)) { - # Set the path to use orderfile for linking Chrome - # Note that this is for using only one orderfile for linking - # the Chrome binary/library. - declare_args() { - chrome_orderfile_path = "" - - if (defined(default_chrome_orderfile)) { - # Allow downstream tools to set orderfile path with - # another variable. - chrome_orderfile_path = default_chrome_orderfile - } else if (is_chromeos_ash && is_chromeos_device) { - if (chromeos_afdo_platform == "arm" || - chromeos_afdo_platform == "arm-exp") { - chrome_orderfile_path = "//chromeos/profiles/chromeos.arm.orderfile.txt" - } else { - chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt" - } - } - } -} - -assert(!(llvm_force_head_revision && use_goma), - "can't use goma with trunk clang") -assert(!(llvm_force_head_revision && use_remoteexec), - "can't use rbe with trunk clang") - -# default_include_dirs --------------------------------------------------------- -# -# This is a separate config so that third_party code (which would not use the -# source root and might have conflicting versions of some headers) can remove -# this and specify their own include paths. -config("default_include_dirs") { - include_dirs = [ - "//", - root_gen_dir, - ] -} - -# Compiler instrumentation can introduce dependencies in DSOs to symbols in -# the executable they are loaded into, so they are unresolved at link-time. -config("no_unresolved_symbols") { - if (!using_sanitizer && - (is_linux || is_chromeos || is_android || is_fuchsia)) { - ldflags = [ - "-Wl,-z,defs", - "-Wl,--as-needed", - ] - } -} - -# compiler --------------------------------------------------------------------- -# -# Base compiler configuration. -# -# See also "runtime_library" below for related stuff and a discussion about -# where stuff should go. Put warning related stuff in the "warnings" config. - -config("compiler") { - asmflags = [] - cflags = [] - cflags_c = [] - cflags_cc = [] - cflags_objc = [] - cflags_objcc = [] - rustflags = [] - ldflags = [] - defines = [] - configs = [] - rustflags = [] - - # System-specific flags. If your compiler flags apply to one of the - # categories here, add it to the associated file to keep this shared config - # smaller. - if (is_win) { - configs += [ "//build/config/win:compiler" ] - } else if (is_android) { - configs += [ "//build/config/android:compiler" ] - } else if (is_linux || is_chromeos) { - configs += [ "//build/config/linux:compiler" ] - } else if (is_nacl) { - configs += [ "//build/config/nacl:compiler" ] - } else if (is_mac) { - configs += [ "//build/config/mac:compiler" ] - } else if (is_ios) { - configs += [ "//build/config/ios:compiler" ] - } else if (is_fuchsia) { - configs += [ "//build/config/fuchsia:compiler" ] - } else if (current_os == "aix") { - configs += [ "//build/config/aix:compiler" ] - } else if (current_os == "zos") { - configs += [ "//build/config/zos:compiler" ] - } - - configs += [ - # See the definitions below. - ":clang_revision", - ":rustc_revision", - ":compiler_cpu_abi", - ":compiler_codegen", - ":compiler_deterministic", - ] - - # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr - # operations (e.g. dereferencing) into defined behavior. This avoids deletion - # of some security-critical code: see https://crbug.com/1139129. - # Nacl does not support the flag. And, we still want UBSAN to catch undefined - # behavior related to nullptrs, so do not add this flag if UBSAN is enabled. - # GCC seems to have some bugs compiling constexpr code when this is defined, - # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913 - # TODO(mpdenton): remove is_clang once GCC bug is fixed. - if (!is_nacl && !is_ubsan && is_clang) { - cflags += [ "-fno-delete-null-pointer-checks" ] - } - - # Don't emit the GCC version ident directives, they just end up in the - # .comment section or debug info taking up binary size, and makes comparing - # .o files built with different compiler versions harder. - if (!is_win || is_clang) { - cflags += [ "-fno-ident" ] - } - - # In general, Windows is totally different, but all the other builds share - # some common compiler and linker configuration. - if (!is_win) { - # Common POSIX compiler flags setup. - # -------------------------------- - cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 - - # Stack protection. ShadowCallStack and Stack protector address the same - # problems. Therefore, we only enable one or the other. Clang advertises SCS as - # a stronger alternative to StackProtector, so we give SCS precedence over SP. - if (enable_shadow_call_stack) { - # On Aarch64, SCS requires the x18 register to be unused because it will hold - # a pointer to the shadow stack. For Android we know that Clang doesn't use - # x18 by default. On other OSs adding "-ffixed-x18" might be required. - assert(is_android) - - scs_parameters = [ - "-fsanitize=shadow-call-stack", - "-fno-stack-protector", - ] - cflags += scs_parameters - ldflags += scs_parameters - } else { - if (is_apple) { - # The strong variant of the stack protector significantly increases - # binary size, so only enable it in debug mode. - if (is_debug) { - cflags += [ "-fstack-protector-strong" ] - } else { - cflags += [ "-fstack-protector" ] - } - } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) { - # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it. - # See also https://crbug.com/533294 - if (current_os != "zos") { - cflags += [ "--param=ssp-buffer-size=4" ] - } - - # The x86 toolchain currently has problems with stack-protector. - if (is_android && current_cpu == "x86") { - cflags += [ "-fno-stack-protector" ] - } else if (current_os != "aix") { - # Not available on aix. - cflags += [ "-fstack-protector" ] - } - } - } - - if (use_lld) { - ldflags += [ "-fuse-ld=lld" ] - if (lld_path != "") { - ldflags += [ "-B$lld_path" ] - } - } - - # ADDED BY ALEX313031 FOR THORIUM - if (is_clang && is_android && !is_ubsan && !is_ubsan_security) { - cflags += [ "-fwrapv" ] - } - - # Linker warnings. - if (fatal_linker_warnings && !is_apple && current_os != "aix" && - current_os != "zos") { - ldflags += [ "-Wl,--fatal-warnings" ] - } - if (fatal_linker_warnings && is_apple) { - ldflags += [ "-Wl,-fatal_warnings" ] - } - } - - if (is_clang && is_debug) { - # Allow comparing the address of references and 'this' against 0 - # in debug builds. Technically, these can never be null in - # well-defined C/C++ and Clang can optimize such checks away in - # release builds, but they may be used in asserts in debug builds. - cflags_cc += [ - "-Wno-undefined-bool-conversion", - "-Wno-tautological-undefined-compare", - ] - } - - # Non-Apple Posix and Fuchsia compiler flags setup. - # ----------------------------------- - if ((is_posix && !is_apple) || is_fuchsia) { - if (enable_profiling) { - if (!is_debug) { - cflags += [ "-g" ] - - if (enable_full_stack_frames_for_profiling) { - cflags += [ - "-fno-inline", - "-fno-optimize-sibling-calls", - ] - } - } - } - - # Explicitly pass --build-id to ld. Compilers used to always pass this - # implicitly but don't any more (in particular clang when built without - # ENABLE_LINKER_BUILD_ID=ON). - if (is_official_build) { - # The sha1 build id has lower risk of collision but is more expensive to - # compute, so only use it in the official build to avoid slowing down - # links. - ldflags += [ "-Wl,--build-id=sha1" ] - } else if (current_os != "aix" && current_os != "zos") { - ldflags += [ "-Wl,--build-id" ] - } - - if (!is_android) { - defines += [ - # _FILE_OFFSET_BITS=64 should not be set on Android in order to maintain - # the behavior of the Android NDK from earlier versions. - # See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html - "_FILE_OFFSET_BITS=64", - "_LARGEFILE_SOURCE", - "_LARGEFILE64_SOURCE", - ] - } - - if (!is_nacl) { - if (exclude_unwind_tables) { - cflags += [ - "-fno-unwind-tables", - "-fno-asynchronous-unwind-tables", - ] - rustflags += [ "-Cforce-unwind-tables=no" ] - defines += [ "NO_UNWIND_TABLES" ] - } else { - cflags += [ "-funwind-tables" ] - rustflags += [ "-Cforce-unwind-tables=yes" ] - } - } - } - - # Apple compiler flags setup. - # --------------------------------- - if (is_apple) { - # On Intel, clang emits both Apple's "compact unwind" information and - # DWARF eh_frame unwind information by default, for compatibility reasons. - # This flag limits emission of eh_frame information to functions - # whose unwind information can't be expressed in the compact unwind format - # (which in practice means almost everything gets only compact unwind - # entries). This reduces object file size a bit and makes linking a bit - # faster. - # On arm64, this is already the default behavior. - if (current_cpu == "x64") { - asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ] - cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ] - } - } - - # Linux/Android/Fuchsia common flags setup. - # --------------------------------- - if (is_linux || is_chromeos || is_android || is_fuchsia) { - asmflags += [ "-fPIC" ] - cflags += [ "-fPIC" ] - ldflags += [ "-fPIC" ] - rustflags += [ "-Crelocation-model=pic" ] - - if (!is_clang) { - # Use pipes for communicating between sub-processes. Faster. - # (This flag doesn't do anything with Clang.) - cflags += [ "-pipe" ] - } - - ldflags += [ - "-Wl,-z,noexecstack", - "-Wl,-z,relro", - ] - - if (!is_component_build) { - ldflags += [ "-Wl,-z,now" ] - } - } - - # Linux-specific compiler flags setup. - # ------------------------------------ - if (use_gold) { - ldflags += [ "-fuse-ld=gold" ] - if (!is_android) { - # On Android, this isn't needed. gcc in the NDK knows to look next to - # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed - # above. - if (gold_path != "") { - ldflags += [ "-B$gold_path" ] - } - - ldflags += [ - # Experimentation found that using four linking threads - # saved ~20% of link time. - # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36 - # Only apply this to the target linker, since the host - # linker might not be gold, but isn't used much anyway. - "-Wl,--threads", - "-Wl,--thread-count=4", - ] - } - - # TODO(thestig): Make this flag work with GN. - #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) { - # ldflags += [ - # "-Wl,--detect-odr-violations", - # ] - #} - } - - if (use_icf && (!is_apple || use_lld)) { - ldflags += [ "-Wl,--icf=all" ] - } - - if (is_linux || is_chromeos) { - cflags += [ "-pthread" ] - # Do not use the -pthread ldflag here since it becomes a no-op - # when using -nodefaultlibs, which would cause an unused argument - # error. "-lpthread" is added in //build/config:default_libs. - } - - # Clang-specific compiler flags setup. - # ------------------------------------ - if (is_clang) { - cflags += [ "-fcolor-diagnostics" ] - - # Enable -fmerge-all-constants. This used to be the default in clang - # for over a decade. It makes clang non-conforming, but is fairly safe - # in practice and saves some binary size. We might want to consider - # disabling this (https://bugs.llvm.org/show_bug.cgi?id=18538#c13), - # but for now it looks like our build might rely on it - # (https://crbug.com/829795). - cflags += [ "-fmerge-all-constants" ] - } - - if (use_lld) { - # TODO(thakis): Make the driver pass --color-diagnostics to the linker - # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics - # in ldflags instead. - if (is_win) { - # On Windows, we call the linker directly, instead of calling it through - # the driver. - ldflags += [ "--color-diagnostics" ] - } else { - ldflags += [ "-Wl,--color-diagnostics" ] - } - } - - # Enable text section splitting only on linux when using lld for now. Other - # platforms can be added later if needed. - if ((is_linux || is_chromeos) && use_lld && use_text_section_splitting) { - ldflags += [ "-Wl,-z,keep-text-section-prefix" ] - } - - if (is_clang && !is_nacl && current_os != "zos") { - cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ] - if (save_reproducers_on_lld_crash && use_lld) { - ldflags += [ - "-fcrash-diagnostics=all", - "-fcrash-diagnostics-dir=" + clang_diagnostic_dir, - ] - } - - # TODO(hans): Remove this once Clang generates better optimized debug info - # by default. https://crbug.com/765793 - cflags += [ - "-mllvm", - "-instcombine-lower-dbg-declare=0", - ] - if (!is_debug && use_thin_lto && is_a_target_toolchain) { - if (is_win) { - ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ] - } else { - ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ] - } - } - - # TODO(crbug.com/1235145): Investigate why/if this should be needed. - if (is_win) { - cflags += [ "/clang:-ffp-contract=off" ] - } else { - cflags += [ "-ffp-contract=off" ] - } - } - - # C11/C++11 compiler flags setup. - # --------------------------- - if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) || - current_os == "aix") { - if (is_clang) { - standard_prefix = "c" - - # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be - # defined by the compiler. However, lots of code relies on the - # non-standard features that _GNU_SOURCE enables, so define it manually. - defines += [ "_GNU_SOURCE" ] - - if (is_nacl) { - # Undefine __STRICT_ANSI__ to get non-standard features which would - # otherwise not be enabled by NaCl's sysroots. - cflags += [ "-U__STRICT_ANSI__" ] - } - } else { - # Gcc does not support ##__VA_ARGS__ when in standards-conforming mode, - # but we use this feature in several places in Chromium. - # TODO(thomasanderson): Replace usages of ##__VA_ARGS__ with the - # standard-compliant __VA_OPT__ added by C++20, and switch the gcc build - # to -std=c*. - standard_prefix = "gnu" - } - - cflags_c += [ "-std=${standard_prefix}11" ] - if (is_nacl && !is_nacl_saigo) { - # This is for the pnacl_newlib toolchain. It's only used to build - # a few independent ppapi test files that don't pull in any other - # dependencies. - cflags_cc += [ "-std=${standard_prefix}++14" ] - if (is_clang) { - cflags_cc += [ "-fno-trigraphs" ] - } - } else if (is_clang) { - if (use_cxx17) { - cflags_cc += [ "-std=${standard_prefix}++17" ] - } else { - cflags_cc += [ "-std=${standard_prefix}++20" ] - } - } else { - # The gcc bots are currently using GCC 9, which is not new enough to - # support "c++20"/"gnu++20". - cflags_cc += [ "-std=${standard_prefix}++2a" ] - } - } else if (is_win) { - cflags_c += [ "/std:c11" ] - if (use_cxx17 || (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) { - cflags_cc += [ "/std:c++17" ] - } else { - cflags_cc += [ "/std:c++20" ] - } - } else if (!is_nacl) { - # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either - # gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any - # more, but there are still a few buildbots using it, so until those are - # turned off we need the !is_nacl clause and the (is_nacl && is_clang) - # clause, above. - cflags_c += [ "-std=c11" ] - - if (use_cxx17) { - cflags_cc += [ "-std=c++17" ] - } else { - cflags_cc += [ "-std=c++20" ] - } - } - - if (is_clang && current_os != "zos") { - # C++17 removes trigraph support, but clang still warns that it ignores - # them when seeing them. Don't. - cflags_cc += [ "-Wno-trigraphs" ] - } - - if (use_relative_vtables_abi) { - cflags_cc += [ "-fexperimental-relative-c++-abi-vtables" ] - ldflags += [ "-fexperimental-relative-c++-abi-vtables" ] - } - - # Add flags for link-time optimization. These flags enable - # optimizations/transformations that require whole-program visibility at link - # time, so they need to be applied to all translation units, and we may end up - # with miscompiles if only part of the program is compiled with LTO flags. For - # that reason, we cannot allow targets to enable or disable these flags, for - # example by disabling the optimize configuration. - # TODO(pcc): Make this conditional on is_official_build rather than on gn - # flags for specific features. - if (!is_debug && use_thin_lto && is_a_target_toolchain) { - assert(use_lld, "LTO is only supported with lld") - - cflags += [ - "-flto=thin", - "-fsplit-lto-unit", - ] - - # Limit the size of the ThinLTO cache to the lesser of 10% of - # available disk space, 40GB and 100000 files. - # cache_policy = "cache_size=10%:cache_size_bytes=40g:cache_size_files=100000" - - # An import limit of 30 has better performance (per speedometer) and lower - # binary size than the default setting of 100. - # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO - # should be able to better manage binary size increases on its own. - import_instr_limit = 30 - - if (is_win) { - ldflags += [ - "/opt:lldltojobs=all", - "-mllvm:-import-instr-limit=$import_instr_limit", - "-mllvm:-import-hot-multiplier=15", - "-mllvm:-import-cold-multiplier=4", - "-mllvm:-disable-auto-upgrade-debug-info", - # "/lldltocache:" + - # rebase_path("$root_out_dir/thinlto-cache", root_build_dir), - # "/lldltocachepolicy:$cache_policy", - ] - } else { - ldflags += [ "-flto=thin" ] - - # Enabling ThinLTO on Chrome OS too, in an effort to reduce the memory - # usage in crbug.com/1038040. Note this will increase build time in - # Chrome OS. - - # In ThinLTO builds, we run at most one link process at a time, - # and let it use all cores. - # TODO(thakis): Check if '=0' (that is, number of cores, instead - # of "all" which means number of hardware threads) is faster. - ldflags += [ "-Wl,--thinlto-jobs=all" ] - if (is_apple) { - ldflags += [ - "-Wl,-cache_path_lto," + - rebase_path("$root_out_dir/thinlto-cache", root_build_dir), - "-Wcrl,object_path_lto", - ] - } else { - ldflags += - [ "-Wl,-O3" ] - } - - # ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ] - - if (is_chromeos) { - # ARM was originally set lower than x86 to keep the size - # bloat of ThinLTO to <10%, but that's potentially no longer true. - # FIXME(inglorion): maybe tune these? - # TODO(b/271459198): Revert limit on amd64 to 30 when fixed. - import_instr_limit = 30 - } else if (is_android) { - # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win - # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB. - import_instr_limit = 30 - } - - ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ] - - if (!is_chromeos) { - # TODO(https://crbug.com/972449): turn on for ChromeOS when that - # toolchain has this flag. - # We only use one version of LLVM within a build so there's no need to - # upgrade debug info, which can be expensive since it runs the verifier. - ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ] - } - } - - # TODO(https://crbug.com/1211155): investigate why this isn't effective on - # arm32. - if (!is_android || current_cpu == "arm64") { - cflags += [ "-fwhole-program-vtables" ] - - # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match - # behaviour. Rust needs to know the linker will be doing LTO in this case - # or it rejects the Zsplit-lto-unit flag. - rustflags += [ - "-Zsplit-lto-unit", - "-Clinker-plugin-lto=yes", - ] - - if (!is_win) { - ldflags += [ "-fwhole-program-vtables" ] - } - } - - # This flag causes LTO to create an .ARM.attributes section with the correct - # architecture. This is necessary because LLD will refuse to link a program - # unless the architecture revision in .ARM.attributes is sufficiently new. - # TODO(pcc): The contents of .ARM.attributes should be based on the - # -march flag passed at compile time (see llvm.org/pr36291). - if (current_cpu == "arm") { - ldflags += [ "-march=$arm_arch" ] - } - } - - if (compiler_timing) { - if (is_clang && !is_nacl) { - cflags += [ "-ftime-trace" ] - } else if (is_win) { - cflags += [ - # "Documented" here: - # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/ - "/d2cgsummary", - ] - } - } - - # Pass flag to LLD so Android builds can allow debuggerd to properly symbolize - # stack crashes (http://crbug.com/919499). - if (use_lld && is_android) { - ldflags += [ "-Wl,--no-rosegment" ] - } - - # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by - # --no-undefined-version. - if (use_lld && !is_win && !is_mac && !is_ios) { - ldflags += [ "-Wl,--undefined-version" ] - } - - if (use_lld && is_apple) { - ldflags += [ "-Wl,--strict-auto-link" ] - } - - # LLD does call-graph-sorted binary layout by default when profile data is - # present. On Android this increases binary size due to more thinks for long - # jumps. Turn it off by default and enable selectively for targets where it's - # beneficial. - if (use_lld && !enable_call_graph_profile_sort) { - if (is_win) { - ldflags += [ "/call-graph-profile-sort:no" ] - } else { - ldflags += [ "-Wl,--no-call-graph-profile-sort" ] - } - } - - if (is_clang && !is_nacl && show_includes) { - if (is_win) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") - cflags += [ - "/clang:-H", - "/clang:-fshow-skipped-includes", - ] - } else { - cflags += [ - "-H", - "-fshow-skipped-includes", - ] - } - } - - # This flag enforces that member pointer base types are complete. It helps - # prevent us from running into problems in the Microsoft C++ ABI (see - # https://crbug.com/847724). - if (is_clang && !is_nacl && target_os != "chromeos" && - (is_win || use_custom_libcxx)) { - cflags += [ "-fcomplete-member-pointers" ] - } - - # Use DWARF simple template names, with the following exceptions: - # - # * Windows is not supported as it doesn't use DWARF. - # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode - # lldb doesn't have the needed changes yet. - # TODO(crbug.com/1379070): Remove if the upstream default ever changes. - if (is_clang && !is_nacl && !is_win && !is_apple) { - cflags_cc += [ "-gsimple-template-names" ] - } - - # MLGO specific flags. These flags enable an ML-based inliner trained on - # Chrome on Android (arm32) with ThinLTO enabled, optimizing for size. - # The "release" ML model is embedded into clang as part of its build. - # Currently, the ML inliner is only enabled when targeting Android due to: - # a) Android is where size matters the most. - # b) MLGO presently has the limitation of only being able to embed one model - # at a time; It is unclear if the embedded model is beneficial for - # non-Android targets. - # MLGO is only officially supported on linux. - if (use_ml_inliner && is_a_target_toolchain) { - assert( - is_android && host_os == "linux", - "MLGO is currently only supported for targeting Android on a linux host") - if (use_thin_lto) { - ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ] - } - } - - if (clang_embed_bitcode) { - assert(!use_thin_lto, - "clang_embed_bitcode is only supported in non-ThinLTO builds") - cflags += [ - "-Xclang", - "-fembed-bitcode=all", - ] - } - - if (lld_emit_indexes_and_imports) { - assert(use_thin_lto, - "lld_emit_indexes_and_imports is only supported with ThinLTO builds") - ldflags += [ - "-Wl,--save-temps=import", - "-Wl,--thinlto-emit-index-files", - ] - } - - # Pass the same C/C++ flags to the objective C/C++ compiler. - cflags_objc += cflags_c - cflags_objcc += cflags_cc - - # Assign any flags set for the C compiler to asmflags so that they are sent - # to the assembler. The Windows assembler takes different types of flags - # so only do so for posix platforms. - if (is_posix || is_fuchsia) { - asmflags += cflags - asmflags += cflags_c - } - - if (is_chromeos_device && !is_nacl) { - # On ChromeOS devices, we want to ensure we're using Chrome's allocator - # symbols for all C++ new/delete operator overloads. PartitionAlloc - # and other local allocators should always take precedence over system or - # preloaded allocators. These are the mangled symbol names. - # See b/280115910 for details. - ldflags += [ - "-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv", - "-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t", - "-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv", - "-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm", - "-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t", - "-Wl,--export-dynamic-symbol=_Znam,-u,_Znam", - "-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t", - "-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm", - "-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t", - "-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t", - "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t", - "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t", - "-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t", - "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t", - "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t", - "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t", - "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t", - "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t", - "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t", - ] - } - - # Rust compiler flags setup. - # --------------------------- - rustflags += [ - # Overflow checks are optional in Rust, but even if switched - # off they do not cause undefined behavior (the overflowing - # behavior is defined). Because containers are bounds-checked - # in safe Rust, they also can't provoke buffer overflows. - # As such these checks may be less important in Rust than C++. - # But in (simplistic) testing they have negligible performance - # overhead, and this helps to provide consistent behavior - # between different configurations, so we'll keep them on until - # we discover a reason to turn them off. - "-Coverflow-checks=on", - - # By default Rust passes `-nodefaultlibs` to the linker, however this - # conflicts with our `--unwind=none` flag for Android dylibs, as the latter - # is then unused and produces a warning/error. So this removes the - # `-nodefaultlibs` from the linker invocation from Rust, which would be used - # to compile dylibs on Android, such as for constructing unit test APKs. - "-Cdefault-linker-libraries", - - # To make Rust .d files compatible with ninja - "-Zdep-info-omit-d-target", - - # If a macro panics during compilation, show which macro and where it is - # defined. - "-Zmacro-backtrace", - - # For deterministic builds, keep the local machine's current working - # directory from appearing in build outputs. - "-Zremap-cwd-prefix=.", - - # Full RUSTC optimizations. - "-Copt-level=3", "-Ctarget-feature=+sse2", - ] - - if (!is_win || force_rustc_color_output) { - # Colorize error output. The analogous flag is passed for clang. This must - # be platform-gated since rustc will unconditionally output ANSI escape - # sequences, ignoring the platform, when stderr is not a terminal. - rustflags += [ "--color=always" ] - } - if (rust_abi_target != "") { - rustflags += [ "--target=$rust_abi_target" ] - } - if (!use_thin_lto) { - # Don't include bitcode if it won't be used. - rustflags += [ "-Cembed-bitcode=no" ] - } - if (is_official_build) { - rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", "-Ctarget-feature=+sse2", ] - } - if (!rust_prebuilt_stdlib) { - # When building against the Chromium Rust stdlib (which we compile) always - # abort instead of unwinding when panic occurs. In official builds, panics - # abort immediately (this is configured in the stdlib) to keep binary size - # down. So we unconditionally match behaviour in unofficial too. - rustflags += [ - "-Cpanic=abort", - "-Zpanic_abort_tests", - ] - } - - # Normally, this would be defined in the `runtime_library` config but NaCl - # saigo libc++ does not use the custom hermetic libc++. Unfortunately, there - # isn't really a better config to add this define for the define to - # consistently apply in both Chromium and non-Chromium code *and* non-NaCl - # and NaCl code. - # - # TODO(https://crbug.com/702997): Move this back to the `runtime_library` - # config when NaCl is removed. - if (use_safe_libcxx) { - defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] - } -} - -# The BUILDCONFIG file sets this config on targets by default, which means when -# building with ThinLTO, no optimization is performed in the link step. -config("thinlto_optimize_default") { - if (!is_debug && use_thin_lto && is_a_target_toolchain) { - lto_opt_level = 3 - - if (is_win) { - ldflags = [ "/opt:lldlto=" + lto_opt_level ] - ldflags += [ "-mllvm:-enable-pre=false", ] - # ldflags += [ "-opt:lldltocgo=" + lto_opt_level ] - } else { - ldflags = [ "-Wl,--lto-O" + lto_opt_level ] - ldflags += [ "-Wl,--lto-CGO" + lto_opt_level ] - # ldflags += [ "-Wl,-mllvm,-enable-pre=false", ] - } - - # We always point Rust to a linker that performs LTO, so we don't want Rust - # to preemptively do so during compilation too or they conflict. But we do - # want Rust to generate LTO metadata in order for the linker to do its job. - rustflags = [ "-Clinker-plugin-lto=yes" ] - } -} - -# Use this to enable optimization in the ThinLTO link step for select targets -# when thin_lto_enable_optimizations is set by doing: -# -# configs -= [ "//build/config/compiler:thinlto_optimize_default" ] -# configs += [ "//build/config/compiler:thinlto_optimize_max" ] -# -# Since it makes linking significantly slower and more resource intensive, only -# use it on important targets such as the main browser executable or dll. -config("thinlto_optimize_max") { - if (!is_debug && use_thin_lto && is_a_target_toolchain) { - if (thin_lto_enable_optimizations) { - lto_opt_level = 3 - } else { - lto_opt_level = 3 - } - - if (is_win) { - ldflags = [ "/opt:lldlto=" + lto_opt_level ] - ldflags += [ "-mllvm:-enable-pre=false", ] - # ldflags += [ "-opt:lldltocgo=" + lto_opt_level ] - } else { - ldflags = [ "-Wl,--lto-O" + lto_opt_level ] - ldflags += [ "-Wl,--lto-CGO" + lto_opt_level ] - # ldflags += [ "-Wl,-mllvm,-enable-pre=false", ] - } - - # We always point Rust to a linker that performs LTO, so we don't want Rust - # to preemptively do so during compilation too or they conflict. But we do - # want Rust to generate LTO metadata in order for the linker to do its job. - rustflags = [ "-Clinker-plugin-lto=yes" ] - } -} - -# This provides the basic options to select the target CPU and ABI. -# It is factored out of "compiler" so that special cases can use this -# without using everything that "compiler" brings in. Options that -# tweak code generation for a particular CPU do not belong here! -# See "compiler_codegen", below. -config("compiler_cpu_abi") { - cflags = [] - ldflags = [] - defines = [] - - configs = [] - if (is_chromeos) { - configs += [ "//build/config/chromeos:compiler_cpu_abi" ] - } - - # TODO(https://crbug.com/1383873): Remove this once figured out. - if (is_apple && current_cpu == "arm64") { - cflags += [ "-fno-global-isel" ] - ldflags += [ "-fno-global-isel" ] - } - - if ((is_posix && !is_apple) || is_fuchsia) { - # CPU architecture. We may or may not be doing a cross compile now, so for - # simplicity we always explicitly set the architecture. - if (current_cpu == "x64") { - cflags += [ - "-m64", - "-O3", - "-mmmx", - "-mfxsr", - "-msse2", - ] - ldflags += [ "-m64", "-Wl,-O3", "-msse2", "-Wl,-mllvm,-import-instr-limit=30", "-Wl,-mllvm,-import-hot-multiplier=15", "-Wl,-mllvm,-import-cold-multiplier=4", ] - } else if (current_cpu == "x86") { - cflags += [ "-m32" ] - ldflags += [ "-m32", "-Wl,-O3", "-msse2", ] - if (!is_nacl) { - cflags += [ - "-mfpmath=sse", - "-O3", - "-msse2", - ] - } - } else if (target_cpu == "arm64") { - if (!is_android && !is_nacl) { - cflags += [ "-O3", "-Wno-unused-command-line-argument", ] - ldflags += [ "-Wl,-O3", "-Wno-unused-command-line-argument", ] - } - } else if (current_cpu == "arm") { - if (is_clang && !is_android && !is_nacl && - !(is_chromeos_lacros && is_chromeos_device)) { - cflags += [ "--target=arm-linux-gnueabihf", "-O3", "-Wno-unused-command-line-argument", ] - ldflags += [ "--target=arm-linux-gnueabihf", "-Wl,-O3", "-Wno-unused-command-line-argument", ] - } - if (!is_nacl) { - cflags += [ - "-march=$arm_arch", - "-mfloat-abi=$arm_float_abi", - ] - } - if (arm_tune != "") { - cflags += [ "-mtune=$arm_tune" ] - } - } else if (current_cpu == "arm64") { - if (is_clang && !is_android && !is_nacl && !is_fuchsia && - !(is_chromeos_lacros && is_chromeos_device)) { - cflags += [ "--target=aarch64-linux-gnu", "-O3", "-Wno-unused-command-line-argument", ] - ldflags += [ "--target=aarch64-linux-gnu", "-Wl,-O3", "-Wno-unused-command-line-argument", ] - } - if (is_android) { - cflags += [ "-O3", ] - ldflags += [ "-Wl,-O3", ] - } - } else if (current_cpu == "mipsel" && !is_nacl) { - ldflags += [ "-Wl,--hash-style=sysv" ] - if (custom_toolchain == "") { - if (is_clang) { - if (is_android) { - cflags += [ "--target=mipsel-linux-android", "-O3", ] - ldflags += [ "--target=mipsel-linux-android" ] - } else { - cflags += [ "--target=mipsel-linux-gnu", "-O3", ] - ldflags += [ "--target=mipsel-linux-gnu" ] - } - } else { - cflags += [ "-EL" ] - ldflags += [ "-EL" ] - } - } - - if (mips_arch_variant == "r6") { - cflags += [ "-mno-odd-spreg" ] - ldflags += [ "-mips32r6" ] - if (is_clang) { - cflags += [ - "-march=mipsel", - "-mcpu=mips32r6", - ] - } else { - cflags += [ - "-mips32r6", - "-Wa,-mips32r6", - ] - if (is_android) { - ldflags += [ "-Wl,-melf32ltsmip" ] - } - } - if (mips_use_msa == true) { - cflags += [ - "-mmsa", - "-mfp64", - ] - } - } else if (mips_arch_variant == "r2") { - ldflags += [ "-mips32r2" ] - if (is_clang) { - cflags += [ - "-march=mipsel", - "-mcpu=mips32r2", - ] - } else { - cflags += [ - "-mips32r2", - "-Wa,-mips32r2", - ] - if (mips_float_abi == "hard" && mips_fpu_mode != "") { - cflags += [ "-m$mips_fpu_mode" ] - } - } - } else if (mips_arch_variant == "r1") { - ldflags += [ "-mips32" ] - if (is_clang) { - cflags += [ - "-march=mipsel", - "-mcpu=mips32", - ] - } else { - cflags += [ - "-mips32", - "-Wa,-mips32", - ] - } - } else if (mips_arch_variant == "loongson3") { - defines += [ "_MIPS_ARCH_LOONGSON" ] - cflags += [ - "-march=loongson3a", - "-mno-branch-likely", - "-Wa,-march=loongson3a", - ] - } - - if (mips_dsp_rev == 1) { - cflags += [ "-mdsp" ] - } else if (mips_dsp_rev == 2) { - cflags += [ "-mdspr2" ] - } - - cflags += [ "-m${mips_float_abi}-float" ] - } else if (current_cpu == "mips" && !is_nacl) { - ldflags += [ "-Wl,--hash-style=sysv" ] - if (custom_toolchain == "") { - if (is_clang) { - cflags += [ "--target=mips-linux-gnu" ] - ldflags += [ "--target=mips-linux-gnu" ] - } else { - cflags += [ "-EB" ] - ldflags += [ "-EB" ] - } - } - - if (mips_arch_variant == "r6") { - cflags += [ - "-mips32r6", - "-Wa,-mips32r6", - ] - if (mips_use_msa == true) { - cflags += [ - "-mmsa", - "-mfp64", - ] - } - } else if (mips_arch_variant == "r2") { - cflags += [ - "-mips32r2", - "-Wa,-mips32r2", - ] - if (mips_float_abi == "hard" && mips_fpu_mode != "") { - cflags += [ "-m$mips_fpu_mode" ] - } - } else if (mips_arch_variant == "r1") { - cflags += [ - "-mips32", - "-Wa,-mips32", - ] - } - - if (mips_dsp_rev == 1) { - cflags += [ "-mdsp" ] - } else if (mips_dsp_rev == 2) { - cflags += [ "-mdspr2" ] - } - - cflags += [ "-m${mips_float_abi}-float" ] - } else if (current_cpu == "mips64el") { - cflags += [ "-D__SANE_USERSPACE_TYPES__" ] - ldflags += [ "-Wl,--hash-style=sysv" ] - if (custom_toolchain == "") { - if (is_clang) { - if (is_android) { - cflags += [ "--target=mips64el-linux-android" ] - ldflags += [ "--target=mips64el-linux-android" ] - } else { - cflags += [ "--target=mips64el-linux-gnuabi64" ] - ldflags += [ "--target=mips64el-linux-gnuabi64" ] - } - } else { - cflags += [ - "-EL", - "-mabi=64", - ] - ldflags += [ - "-EL", - "-mabi=64", - ] - } - } - - if (mips_arch_variant == "r6") { - if (is_clang) { - cflags += [ - "-march=mips64el", - "-mcpu=mips64r6", - ] - } else { - cflags += [ - "-mips64r6", - "-Wa,-mips64r6", - ] - ldflags += [ "-mips64r6" ] - } - if (mips_use_msa == true) { - cflags += [ - "-mmsa", - "-mfp64", - ] - } - } else if (mips_arch_variant == "r2") { - ldflags += [ "-mips64r2" ] - if (is_clang) { - cflags += [ - "-march=mips64el", - "-mcpu=mips64r2", - ] - } else { - cflags += [ - "-mips64r2", - "-Wa,-mips64r2", - ] - } - } else if (mips_arch_variant == "loongson3") { - defines += [ "_MIPS_ARCH_LOONGSON" ] - cflags += [ - "-march=loongson3a", - "-mno-branch-likely", - "-Wa,-march=loongson3a", - ] - } - } else if (current_cpu == "mips64") { - ldflags += [ "-Wl,--hash-style=sysv" ] - if (custom_toolchain == "") { - if (is_clang) { - cflags += [ "--target=mips64-linux-gnuabi64" ] - ldflags += [ "--target=mips64-linux-gnuabi64" ] - } else { - cflags += [ - "-EB", - "-mabi=64", - ] - ldflags += [ - "-EB", - "-mabi=64", - ] - } - } - - if (mips_arch_variant == "r6") { - cflags += [ - "-mips64r6", - "-Wa,-mips64r6", - ] - ldflags += [ "-mips64r6" ] - - if (mips_use_msa == true) { - cflags += [ - "-mmsa", - "-mfp64", - ] - } - } else if (mips_arch_variant == "r2") { - cflags += [ - "-mips64r2", - "-Wa,-mips64r2", - ] - ldflags += [ "-mips64r2" ] - } - } else if (current_cpu == "ppc64") { - if (current_os == "aix") { - cflags += [ "-maix64" ] - ldflags += [ "-maix64" ] - } else { - cflags += [ "-m64" ] - ldflags += [ "-m64" ] - } - } else if (current_cpu == "riscv64") { - if (is_clang && !is_android) { - cflags += [ "--target=riscv64-linux-gnu" ] - ldflags += [ "--target=riscv64-linux-gnu" ] - } - cflags += [ "-mabi=lp64d" ] - } else if (current_cpu == "loong64") { - if (is_clang) { - cflags += [ "--target=loongarch64-linux-gnu" ] - ldflags += [ "--target=loongarch64-linux-gnu" ] - } - cflags += [ - "-mabi=lp64d", - "-mcmodel=medium", - ] - } else if (current_cpu == "s390x") { - cflags += [ "-m64" ] - ldflags += [ "-m64" ] - } - } - - asmflags = cflags -} - -# This provides options to tweak code generation that are necessary -# for particular Chromium code or for working around particular -# compiler bugs (or the combination of the two). -config("compiler_codegen") { - configs = [] - cflags = [] - ldflags = [] - - if (is_nacl) { - configs += [ "//build/config/nacl:compiler_codegen" ] - } - - if (current_cpu == "arm64" && !is_win && is_clang) { - # Disable outlining everywhere on arm64 except Win. For more information see - # crbug.com/931297 for Android and crbug.com/1410297 for iOS. - # TODO(crbug.com/1411363): Enable this on Windows if possible. - cflags += [ "-mno-outline" ] - - # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 - # has been resolved, and -mno-outline is obeyed by the linker during - # ThinLTO. - ldflags += [ "-Wl,-mllvm,-enable-machine-outliner=never" ] - } - - asmflags = cflags -} - -# This provides options that make the build deterministic, so that the same -# revision produces the same output, independent of the name of the build -# directory and of the computer the build is done on. -# The relative path from build dir to source dir makes it into the build -# outputs, so it's recommended that you use a build dir two levels deep -# (e.g. "out/Release") so that you get the same "../.." path as all the bots -# in your build outputs. -config("compiler_deterministic") { - cflags = [] - ldflags = [] - swiftflags = [] - - # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for - # deterministic build. See https://crbug.com/314403 - if (!is_official_build) { - if (is_win && !is_clang) { - cflags += [ - "/wd4117", # Trying to define or undefine a predefined macro. - "/D__DATE__=", - "/D__TIME__=", - "/D__TIMESTAMP__=", - ] - } else { - cflags += [ - "-Wno-builtin-macro-redefined", - "-D__DATE__=", - "-D__TIME__=", - "-D__TIMESTAMP__=", - ] - } - } - - # Makes builds independent of absolute file path. - if (is_clang && strip_absolute_paths_from_debug_symbols) { - # If debug option is given, clang includes $cwd in debug info by default. - # For such build, this flag generates reproducible obj files even we use - # different build directory like "out/feature_a" and "out/feature_b" if - # we build same files with same compile flag. - # Other paths are already given in relative, no need to normalize them. - if (is_nacl) { - # TODO(https://crbug.com/1231236): Use -ffile-compilation-dir= here. - cflags += [ - "-Xclang", - "-fdebug-compilation-dir", - "-Xclang", - ".", - ] - } else { - # -ffile-compilation-dir is an alias for both -fdebug-compilation-dir= - # and -fcoverage-compilation-dir=. - cflags += [ "-ffile-compilation-dir=." ] - swiftflags += [ "-file-compilation-dir=." ] - } - if (!is_win) { - # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167) - asmflags = [ "-Wa,-fdebug-compilation-dir,." ] - } - - if (is_win && use_lld) { - if (symbol_level == 2 || (is_clang && using_sanitizer)) { - # Absolutize source file paths for PDB. Pass the real build directory - # if the pdb contains source-level debug information and if linker - # reproducibility is not critical. - ldflags += [ "/PDBSourcePath:" + rebase_path(root_build_dir) ] - } else { - # Use a fake fixed base directory for paths in the pdb to make the pdb - # output fully deterministic and independent of the build directory. - ldflags += [ "/PDBSourcePath:o:\fake\prefix" ] - } - } - } - - # Tells the compiler not to use absolute paths when passing the default - # paths to the tools it invokes. We don't want this because we don't - # really need it and it can mess up the goma cache entries. - if (is_clang && (!is_nacl || is_nacl_saigo)) { - cflags += [ "-no-canonical-prefixes" ] - - # Same for links: Let the compiler driver invoke the linker - # with a relative path and pass relative paths to built-in - # libraries. Not needed on Windows because we call the linker - # directly there, not through the compiler driver. - # We don't link on goma, so this change is just for cleaner - # internal linker invocations, for people who work on the build. - if (!is_win) { - ldflags += [ "-no-canonical-prefixes" ] - } - } -} - -config("clang_revision") { - if (is_clang && clang_base_path == default_clang_base_path) { - update_args = [ - "--print-revision", - "--verify-version=$clang_version", - ] - if (llvm_force_head_revision) { - update_args += [ "--llvm-force-head-revision" ] - } - clang_revision = exec_script("//tools/clang/scripts/update.py", - update_args, - "trim string") - - # This is here so that all files get recompiled after a clang roll and - # when turning clang on or off. (defines are passed via the command line, - # and build system rebuild things when their commandline changes). Nothing - # should ever read this define. - defines = [ "CR_CLANG_REVISION=\"$clang_revision\"" ] - } -} - -config("rustc_revision") { - if (rustc_revision != "") { - # Similar to the above config, this is here so that all files get recompiled - # after a rustc roll. Nothing should ever read this cfg. This will not be - # set if a custom toolchain is used. - rustflags = [ - "--cfg", - "cr_rustc_revision=\"$rustc_revision\"", - ] - } -} - -config("compiler_arm_fpu") { - if (current_cpu == "arm" && !is_ios && !is_nacl) { - cflags = [ "-mfpu=$arm_fpu" ] - if (!arm_use_thumb) { - cflags += [ "-marm" ] - } - asmflags = cflags - } -} - -config("compiler_arm_thumb") { - if (current_cpu == "arm" && arm_use_thumb && is_posix && - !(is_apple || is_nacl)) { - cflags = [ "-mthumb" ] - } -} - -config("compiler_arm") { - if (current_cpu == "arm" && is_chromeos) { - # arm is normally the default mode for clang, but on chromeos a wrapper - # is used to pass -mthumb, and therefor change the default. - cflags = [ "-marm" ] - } -} - -# runtime_library ------------------------------------------------------------- -# -# Sets the runtime library and associated options. -# -# How do you determine what should go in here vs. "compiler" above? Consider if -# a target might choose to use a different runtime library (ignore for a moment -# if this is possible or reasonable on your system). If such a target would want -# to change or remove your option, put it in the runtime_library config. If a -# target wants the option regardless, put it in the compiler config. - -config("runtime_library") { - configs = [] - - # The order of this config is important: it must appear before - # android:runtime_library. This is to ensure libc++ appears before - # libandroid_support in the -isystem include order. Otherwise, there will be - # build errors related to symbols declared in math.h. - if (use_custom_libcxx) { - configs += [ "//build/config/c++:runtime_library" ] - } - - # Rust and C++ both provide intrinsics for LLVM to call for math operations. We - # want to use the C++ intrinsics, not the ones in the Rust compiler_builtins - # library. The Rust symbols are marked as weak, so that they can be replaced by - # the C++ symbols. This config ensures the C++ symbols exist and are strong in - # order to cause that replacement to occur by explicitly linking in clang's - # compiler-rt library. - if (is_clang && toolchain_has_rust) { - configs += [ "//build/config/clang:compiler_builtins" ] - } - - # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia - # configuration. - if (is_posix || is_fuchsia) { - configs += [ "//build/config/posix:runtime_library" ] - } - - # System-specific flags. If your compiler flags apply to one of the - # categories here, add it to the associated file to keep this shared config - # smaller. - if (is_win) { - configs += [ "//build/config/win:runtime_library" ] - } else if (is_linux || is_chromeos) { - configs += [ "//build/config/linux:runtime_library" ] - if (is_chromeos) { - configs += [ "//build/config/chromeos:runtime_library" ] - } - } else if (is_ios) { - configs += [ "//build/config/ios:runtime_library" ] - } else if (is_mac) { - configs += [ "//build/config/mac:runtime_library" ] - } else if (is_android) { - configs += [ "//build/config/android:runtime_library" ] - } - - if (is_component_build) { - defines = [ "COMPONENT_BUILD" ] - } -} - -# default_warnings ------------------------------------------------------------ -# -# Collects all warning flags that are used by default. This is used as a -# subconfig of both chromium_code and no_chromium_code. This way these -# flags are guaranteed to appear on the compile command line after -Wall. -config("default_warnings") { - cflags = [] - cflags_c = [] - cflags_cc = [] - ldflags = [] - - if (is_win) { - if (treat_warnings_as_errors) { - cflags += [ "/WX" ] - } - if (fatal_linker_warnings) { - arflags = [ "/WX" ] - ldflags = [ "/WX" ] - } - defines = [ - # Without this, Windows headers warn that functions like wcsnicmp - # should be spelled _wcsnicmp. But all other platforms keep spelling - # it wcsnicmp, making this warning unhelpful. We don't want it. - "_CRT_NONSTDC_NO_WARNINGS", - - # TODO(thakis): winsock wants us to use getaddrinfo instead of - # gethostbyname. Fires mostly in non-Chromium code. We probably - # want to remove this define eventually. - "_WINSOCK_DEPRECATED_NO_WARNINGS", - ] - if (!is_clang) { - # TODO(thakis): Remove this once - # https://swiftshader-review.googlesource.com/c/SwiftShader/+/57968 has - # rolled into angle. - cflags += [ "/wd4244" ] - } - } else { - if (is_apple && !is_nacl) { - # When compiling Objective-C, warns if a method is used whose - # availability is newer than the deployment target. - cflags += [ "-Wunguarded-availability" ] - } - - if (is_ios) { - # When compiling Objective-C, warns if a selector named via @selector has - # not been defined in any visible interface. - cflags += [ "-Wundeclared-selector" ] - } - - # Suppress warnings about ABI changes on ARM (Clang doesn't give this - # warning). - if (current_cpu == "arm" && !is_clang) { - cflags += [ "-Wno-psabi" ] - } - - if (!is_clang) { - cflags_cc += [ - # See comment for -Wno-c++11-narrowing. - "-Wno-narrowing", - ] - - # -Wno-class-memaccess warns about hash table and vector in blink. - # But the violation is intentional. - if (!is_nacl) { - cflags_cc += [ "-Wno-class-memaccess" ] - } - - # -Wunused-local-typedefs is broken in gcc, - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63872 - cflags += [ "-Wno-unused-local-typedefs" ] - - # Don't warn about "maybe" uninitialized. Clang doesn't include this - # in -Wall but gcc does, and it gives false positives. - cflags += [ "-Wno-maybe-uninitialized" ] - cflags += [ "-Wno-deprecated-declarations" ] - - # -Wcomment gives too many false positives in the case a - # backslash ended comment line is followed by a new line of - # comments - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61638 - cflags += [ "-Wno-comments" ] - - # -Wpacked-not-aligned complains all generated mojom-shared-internal.h - # files. - cflags += [ "-Wno-packed-not-aligned" ] - } - } - - # Common Clang and GCC warning setup. - if (!is_win || is_clang) { - cflags += [ - # Disables. - "-Wno-missing-field-initializers", # "struct foo f = {0};" - "-Wno-unused-parameter", # Unused function parameters. - ] - - if (!is_nacl || is_nacl_saigo) { - cflags += [ - # An ABI compat warning we don't care about, https://crbug.com/1102157 - # TODO(thakis): Push this to the (few) targets that need it, - # instead of having a global flag. - "-Wno-psabi", - ] - } - } - - if (is_clang) { - cflags += [ - "-Wloop-analysis", - - # TODO(thakis): This used to be implied by -Wno-unused-function, - # which we no longer use. Check if it makes sense to remove - # this as well. http://crbug.com/316352 - "-Wno-unneeded-internal-declaration", - ] - - if (!is_nacl || is_nacl_saigo) { - if (is_win) { - # TODO(thakis): https://crbug.com/617318 - # Currently goma can not handle case sensitiveness for windows well. - cflags += [ "-Wno-nonportable-include-path" ] - } - - cflags += [ - "-Wenum-compare-conditional", - - # Ignore warnings about MSVC optimization pragmas. - # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 - "-Wno-ignored-pragma-optimize", - ] - - if (!is_nacl) { - cflags += [ - # TODO(crbug.com/1343975) Evaluate and possibly enable. - "-Wno-deprecated-builtins", - - # TODO(crbug.com/1352183) Evaluate and possibly enable. - "-Wno-bitfield-constant-conversion", - - # TODO(crbug.com/1412713) Evaluate and possibly enable. - "-Wno-deprecated-this-capture", - ] - - if (llvm_force_head_revision) { - # TODO(https://crbug.com/1448905): Evaluate and possibly enable. - cflags += [ "-Wno-builtin-macro-redefined" ] - } - } - } - } - - # Rust warnings - - # Require `unsafe` blocks even in `unsafe` fns. This is intended to become - # an error by default eventually; see - # https://github.com/rust-lang/rust/issues/71668 - rustflags = [ "-Dunsafe_op_in_unsafe_fn" ] -} - -# prevent_unsafe_narrowing ---------------------------------------------------- -# -# Warnings that prevent narrowing or comparisons of integer types that are -# likely to cause out-of-bound read/writes or Undefined Behaviour. In -# particular, size_t is used for memory sizes, allocation, indexing, and -# offsets. Using other integer types along with size_t produces risk of -# memory-safety bugs and thus security exploits. -# -# In order to prevent these bugs, allocation sizes were historically limited to -# sizes that can be represented within 31 bits of information, allowing `int` to -# be safely misused instead of `size_t` (https://crbug.com/169327). In order to -# support increasing the allocation limit we require strictly adherence to -# using the correct types, avoiding lossy conversions, and preventing overflow. -# To do so, enable this config and fix errors by converting types to be -# `size_t`, which is both large enough and unsigned, when dealing with memory -# sizes, allocations, indices, or offsets.In cases where type conversion is not -# possible or is superfluous, use base::strict_cast<> or base::checked_cast<> -# to convert to size_t as needed. -# See also: https://docs.google.com/document/d/1CTbQ-5cQjnjU8aCOtLiA7G6P0i5C6HpSDNlSNq6nl5E -# -# To enable in a GN target, use: -# configs += [ "//build/config/compiler:prevent_unsafe_narrowing" ] - -config("prevent_unsafe_narrowing") { - if (is_clang) { - cflags = [ - "-Wshorten-64-to-32", - "-Wimplicit-int-conversion", - "-Wsign-compare", - "-Wsign-conversion", - ] - if (!is_nacl) { - cflags += [ - # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while - # fixing types to be sign-correct. - "-Wtautological-unsigned-zero-compare", - ] - } - } -} - -# chromium_code --------------------------------------------------------------- -# -# Toggles between higher and lower warnings for code that is (or isn't) -# part of Chromium. - -config("chromium_code") { - if (is_win) { - if (is_clang) { - cflags = [ "/W4" ] # Warning level 4. - - # Opt in to additional [[nodiscard]] on standard library methods. - defines = [ "_HAS_NODISCARD" ] - } - } else { - cflags = [ "-Wall" ] - if (treat_warnings_as_errors) { - cflags += [ "-Werror" ] - - # The compiler driver can sometimes (rarely) emit warnings before calling - # the actual linker. Make sure these warnings are treated as errors as - # well. - ldflags = [ "-Werror" ] - } - if (is_clang) { - # Enable extra warnings for chromium_code when we control the compiler. - cflags += [ "-Wextra" ] - } - - if (treat_warnings_as_errors) { - # Turn rustc warnings into the "deny" lint level, which produce compiler - # errors. The equivalent of -Werror for clang/gcc. - # - # Note we apply the actual lint flags in config("compiler"). All warnings - # are suppressed in third-party crates. - rustflags = [ "-Dwarnings" ] - } - - # In Chromium code, we define __STDC_foo_MACROS in order to get the - # C99 macros on Mac and Linux. - defines = [ - "__STDC_CONSTANT_MACROS", - "__STDC_FORMAT_MACROS", - ] - - if (!is_debug && !using_sanitizer && current_cpu != "s390x" && - current_cpu != "s390" && current_cpu != "ppc64" && - current_cpu != "mips" && current_cpu != "mips64" && - current_cpu != "riscv64" && current_cpu != "loong64") { - # Non-chromium code is not guaranteed to compile cleanly with - # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are - # disabled, so only do that for Release build. - defines += [ "_FORTIFY_SOURCE=2" ] - } - - if (is_apple) { - cflags_objc = [ "-Wimplicit-retain-self" ] - cflags_objcc = [ "-Wimplicit-retain-self" ] - } - - if (is_mac) { - cflags_objc += [ "-Wobjc-missing-property-synthesis" ] - cflags_objcc += [ "-Wobjc-missing-property-synthesis" ] - } - } - - if (is_clang) { - cflags += [ - # Warn on missing break statements at the end of switch cases. - # For intentional fallthrough, use [[fallthrough]]. - "-Wimplicit-fallthrough", - - # Warn on unnecessary extra semicolons outside of function definitions. - "-Wextra-semi", - ] - - # TODO(thakis): Enable this more often, https://crbug.com/346399 - # use_fuzzing_engine_with_lpm: https://crbug.com/1063180 - if ((!is_nacl || is_nacl_saigo) && !use_fuzzing_engine_with_lpm) { - cflags += [ "-Wunreachable-code-aggressive" ] - } - - # Thread safety analysis is broken under nacl: https://crbug.com/982423. - if (!is_nacl || is_nacl_saigo) { - cflags += [ - # Thread safety analysis. See base/thread_annotations.h and - # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html - "-Wthread-safety", - ] - } - } - - configs = [ - ":default_warnings", - ":noshadowing", - ] -} - -config("no_chromium_code") { - cflags = [] - cflags_cc = [] - defines = [] - - if (is_win) { - cflags += [ "/O2" ] - } else { - cflags += [ "-O3" ] - } - - if (is_win) { - if (is_clang) { - cflags += [ "/W3" ] # Warning level 3. - } - cflags += [ - "/wd4800", # Disable warning when forcing value to bool. - "/wd4267", # TODO(jschuh): size_t to int. - ] - } else { - # GCC may emit unsuppressible warnings so don't add -Werror for no chromium - # code. crbug.com/589724 - if (treat_warnings_as_errors && is_clang) { - cflags += [ "-Werror" ] - ldflags = [ "-Werror" ] - } - if (is_clang && !is_nacl) { - # TODO(thakis): Remove !is_nacl once - # https://codereview.webrtc.org/1552863002/ made its way into chromium. - cflags += [ "-Wall" ] - } - } - - if (is_clang) { - cflags += [ - # Lots of third-party libraries have unused variables. Instead of - # suppressing them individually, we just blanket suppress them here. - "-Wno-unused-variable", - - # Similarly, we're not going to fix all the C++11 narrowing issues in - # third-party libraries. - "-Wno-c++11-narrowing", - ] - if (!is_nacl) { - cflags += [ - # Disabled for similar reasons as -Wunused-variable. - "-Wno-unused-but-set-variable", - - # TODO(https://crbug.com/1202159): Clean up and enable. - "-Wno-misleading-indentation", - ] - } - } - - # Suppress all warnings in third party, as Cargo does: - # https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints - rustflags = [ "--cap-lints=allow" ] - - configs = [ ":default_warnings" ] -} - -# noshadowing ----------------------------------------------------------------- -# -# Allows turning -Wshadow on. - -config("noshadowing") { - # This flag has to be disabled for nacl because the nacl compiler is too - # strict about shadowing. - if (is_clang && (!is_nacl || is_nacl_saigo) && !llvm_force_head_revision) { - cflags = [ "-Wshadow" ] - } -} - -# rtti ------------------------------------------------------------------------ -# -# Allows turning Run-Time Type Identification on or off. - -config("rtti") { - if (is_win) { - cflags_cc = [ "/GR" ] - } else { - cflags_cc = [ "-frtti" ] - } -} - -config("no_rtti") { - # Some sanitizer configs may require RTTI to be left enabled globally - if (!use_rtti) { - if (is_win) { - cflags_cc = [ "/GR-" ] - } else { - cflags_cc = [ "-fno-rtti" ] - cflags_objcc = cflags_cc - } - } -} - -# export_dynamic --------------------------------------------------------------- -# -# Ensures all exported symbols are added to the dynamic symbol table. This is -# necessary to expose Chrome's custom operator new() and operator delete() (and -# other memory-related symbols) to libraries. Otherwise, they might -# (de)allocate memory on a different heap, which would spell trouble if pointers -# to heap-allocated memory are passed over shared library boundaries. -config("export_dynamic") { - # TODO(crbug.com/1052397): Revisit after target_os flip is completed. - if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) { - ldflags = [ "-rdynamic" ] - } -} - -# thin_archive ----------------------------------------------------------------- -# -# Enables thin archives on posix, and on windows when the lld linker is used. -# Regular archives directly include the object files used to generate it. -# Thin archives merely reference the object files. -# This makes building them faster since it requires less disk IO, but is -# inappropriate if you wish to redistribute your static library. -# This config is added to the global config, so thin archives should already be -# enabled. If you want to make a distributable static library, you need to do 2 -# things: -# 1. Set complete_static_lib so that all dependencies of the library make it -# into the library. See `gn help complete_static_lib` for details. -# 2. Remove the thin_archive config, so that the .a file actually contains all -# .o files, instead of just references to .o files in the build directoy -config("thin_archive") { - # The macOS and iOS default linker ld64 does not support reading thin - # archives. - # TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer - # confuses lldb. - if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) { - arflags = [ "-T" ] - } else if (is_win && use_lld) { - arflags = [ "/llvmlibthin" ] - } -} - -# exceptions ------------------------------------------------------------------- -# -# Allows turning Exceptions on or off. -# Note: exceptions are disallowed in Google code. - -config("exceptions") { - if (is_win) { - # Enables exceptions in the STL. - if (!use_custom_libcxx) { - defines = [ "_HAS_EXCEPTIONS=1" ] - } - cflags_cc = [ "/EHsc" ] - } else { - cflags_cc = [ "-fexceptions" ] - cflags_objcc = cflags_cc - } -} - -config("no_exceptions") { - if (is_win) { - # Disables exceptions in the STL. - # libc++ uses the __has_feature macro to control whether to use exceptions, - # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also - # breaks libc++ because it depends on MSVC headers that only provide certain - # declarations if _HAS_EXCEPTIONS is 1. Those MSVC headers do not use - # exceptions, despite being conditional on _HAS_EXCEPTIONS. - if (!use_custom_libcxx) { - defines = [ "_HAS_EXCEPTIONS=0" ] - } - } else { - cflags_cc = [ "-fno-exceptions" ] - cflags_objcc = cflags_cc - } -} - -# Warnings --------------------------------------------------------------------- - -# Generate a warning for code that might emit a static initializer. -# See: //docs/static_initializers.md -# See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion -config("wglobal_constructors") { - if (is_clang) { - cflags = [ "-Wglobal-constructors" ] - } -} - -# This will generate warnings when using Clang if code generates exit-time -# destructors, which will slow down closing the program. -# TODO(thakis): Make this a blocklist instead, http://crbug.com/101600 -config("wexit_time_destructors") { - if (is_clang) { - cflags = [ "-Wexit-time-destructors" ] - } -} - -# Some code presumes that pointers to structures/objects are compatible -# regardless of whether what they point to is already known to be valid. -# gcc 4.9 and earlier had no way of suppressing this warning without -# suppressing the rest of them. Here we centralize the identification of -# the gcc 4.9 toolchains. -config("no_incompatible_pointer_warnings") { - cflags = [] - if (is_clang) { - cflags += [ "-Wno-incompatible-pointer-types" ] - } else if (current_cpu == "mipsel" || current_cpu == "mips64el") { - cflags += [ "-w" ] - } else if (is_chromeos_ash && current_cpu == "arm") { - cflags += [ "-w" ] - } -} - -# Optimization ----------------------------------------------------------------- -# -# The BUILDCONFIG file sets the "default_optimization" config on targets by -# default. It will be equivalent to either "optimize" (release) or -# "no_optimize" (debug) optimization configs. -# -# You can override the optimization level on a per-target basis by removing the -# default config and then adding the named one you want: -# -# configs -= [ "//build/config/compiler:default_optimization" ] -# configs += [ "//build/config/compiler:optimize_max" ] - -# Shared settings for both "optimize" and "optimize_max" configs. -# IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags. - - common_optimize_on_cflags = [ "-O3", ] - common_optimize_on_ldflags = [ "-Wl,-O3", ] - -if (is_win) { - - common_optimize_on_cflags = [] - common_optimize_on_ldflags = [] - - common_optimize_on_cflags += [ - "/Ob2", # Both explicit and auto inlining. - "/Oy-", # Disable omitting frame pointers, must be after /O2. - "/Zc:inline", # Remove unreferenced COMDAT (faster links). - ] - if (!is_asan) { - common_optimize_on_cflags += [ - # Put data in separate COMDATs. This allows the linker - # to put bit-identical constants at the same address even if - # they're unrelated constants, which saves binary size. - # This optimization can't be used when ASan is enabled because - # it is not compatible with the ASan ODR checker. - "/Gw", - ] - } - - common_optimize_on_cflags += [ - "-Xclang", "-freroll-loops", - "-mllvm", "-enable-cond-stores-vec", - "-mllvm", "-slp-vectorize-hor-store", - "-mllvm", "-adce-remove-loops", - "-mllvm", "-enable-cse-in-irtranslator", - "-mllvm", "-enable-cse-in-legalizer", - "-mllvm", "-scalar-evolution-use-expensive-range-sharpening", - "-mllvm", "-loop-rotate-multi", - "-mllvm", "-enable-loop-distribute", - "-mllvm", "-enable-unroll-and-jam", - "-mllvm", "-interleave-small-loop-scalar-reduction", - "-mllvm", "-aggressive-ext-opt", - "-mllvm", "-enable-interleaved-mem-accesses", - "-mllvm", "-enable-masked-interleaved-mem-accesses", - "-mllvm", "-enable-gvn-hoist", - "-mllvm", "-enable-dfa-jump-thread", - "/O2", - "/clang:-O3", - "/clang:-mavx", - "/clang:-maes", - "/clang:-mpclmul", - "-Xclang", "-O3", - ] - - common_optimize_on_ldflags += [ - "-mllvm:-enable-cond-stores-vec", - "-mllvm:-slp-vectorize-hor-store", - "-mllvm:-adce-remove-loops", - "-mllvm:-enable-cse-in-irtranslator", - "-mllvm:-enable-cse-in-legalizer", - "-mllvm:-scalar-evolution-use-expensive-range-sharpening", - "-mllvm:-loop-rotate-multi", - "-mllvm:-enable-loop-distribute", - "-mllvm:-enable-unroll-and-jam", - "-mllvm:-interleave-small-loop-scalar-reduction", - "-mllvm:-aggressive-ext-opt", - "-mllvm:-enable-interleaved-mem-accesses", - "-mllvm:-enable-masked-interleaved-mem-accesses", - "-mllvm:-enable-gvn-hoist", - "-mllvm:-enable-dfa-jump-thread", - ] - - if (use_polly == true) { - common_optimize_on_ldflags += [ - "-mllvm:-polly", - "-mllvm:-polly-detect-profitability-min-per-loop-insts=40", - "-mllvm:-polly-invariant-load-hoisting", - "-mllvm:-polly-run-dce", - "-mllvm:-polly-vectorizer=stripmine", - ] - } - - # /OPT:ICF is not desirable in Debug builds, since code-folding can result in - # misleading symbols in stack traces. - if (!is_debug && !is_component_build) { - common_optimize_on_ldflags += [ "/OPT:ICF" ] # Redundant COMDAT folding. - } - - if (is_official_build) { - common_optimize_on_ldflags += [ "/OPT:REF" ] # Remove unreferenced data. - # TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772 - } -} else { - common_optimize_on_cflags = [] - common_optimize_on_ldflags = [] - - common_optimize_on_cflags += [ - "-freroll-loops", - "-mllvm", "-enable-cond-stores-vec", - "-mllvm", "-slp-vectorize-hor-store", - "-mllvm", "-adce-remove-loops", - "-mllvm", "-enable-cse-in-irtranslator", - "-mllvm", "-enable-cse-in-legalizer", - "-mllvm", "-scalar-evolution-use-expensive-range-sharpening", - "-mllvm", "-loop-rotate-multi", - "-mllvm", "-enable-loop-distribute", - "-mllvm", "-enable-unroll-and-jam", - "-mllvm", "-interleave-small-loop-scalar-reduction", - "-mllvm", "-aggressive-ext-opt", - "-mllvm", "-enable-interleaved-mem-accesses", - "-mllvm", "-enable-masked-interleaved-mem-accesses", - "-mllvm", "-enable-gvn-hoist", - "-mllvm", "-enable-dfa-jump-thread", - "-O3", - ] - - common_optimize_on_ldflags += [ - "-freroll-loops", - "-Wl,-mllvm,-enable-cond-stores-vec", - "-Wl,-mllvm,-slp-vectorize-hor-store", - "-Wl,-mllvm,-adce-remove-loops", - "-Wl,-mllvm,-enable-cse-in-irtranslator", - "-Wl,-mllvm,-enable-cse-in-legalizer", - "-Wl,-mllvm,-scalar-evolution-use-expensive-range-sharpening", - "-Wl,-mllvm,-loop-rotate-multi", - "-Wl,-mllvm,-enable-loop-distribute", - "-Wl,-mllvm,-enable-unroll-and-jam", - "-Wl,-mllvm,-interleave-small-loop-scalar-reduction", - "-Wl,-mllvm,-aggressive-ext-opt", - "-Wl,-mllvm,-enable-interleaved-mem-accesses", - "-Wl,-mllvm,-enable-masked-interleaved-mem-accesses", - "-Wl,-mllvm,-enable-gvn-hoist", - "-Wl,-mllvm,-enable-dfa-jump-thread", - "-Wl,-O3", - ] - - if (use_polly == true) { - common_optimize_on_ldflags += [ - "-Wl,-mllvm,-polly", - "-Wl,-mllvm,-polly-detect-profitability-min-per-loop-insts=40", - "-Wl,-mllvm,-polly-invariant-load-hoisting", - "-Wl,-mllvm,-polly-run-dce", - "-Wl,-mllvm,-polly-vectorizer=stripmine", - ] - } - - if (is_android) { - # TODO(jdduke) Re-enable on mips after resolving linking - # issues with libc++ (crbug.com/456380). - if (current_cpu != "mipsel" && current_cpu != "mips64el") { - common_optimize_on_ldflags += [ - # Warn in case of text relocations. - "-Wl,--warn-shared-textrel", - ] - } - } - - if (is_apple) { - common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] - - if (is_official_build) { - common_optimize_on_ldflags += [ - "-Wl,-no_data_in_code_info", - "-Wl,-no_function_starts", - ] - } - } else if (current_os != "aix" && current_os != "zos") { - # Non-Mac Posix flags. - # Aix does not support these. - - common_optimize_on_cflags += [ - # Put data and code in their own sections, so that unused symbols - # can be removed at link time with --gc-sections. - "-fdata-sections", - "-ffunction-sections", - "-funique-section-names", - ] - if ((!is_nacl || is_nacl_saigo) && is_clang) { - # We don't care about unique section names, this makes object files a bit - # smaller. - # common_optimize_on_cflags += [ "-fno-unique-section-names" ] - } - - common_optimize_on_ldflags += [ - # Specifically tell the linker to perform optimizations. - # See http://lwn.net/Articles/192624/ . - # -O2 enables string tail merge optimization in gold and lld. - "-Wl,-O3", - "-Wl,--gc-sections", - ] - } -} - -config("default_stack_frames") { - if (!is_win) { - if (enable_frame_pointers) { - cflags = [ "-fno-omit-frame-pointer" ] - - # Omit frame pointers for leaf functions on x86, otherwise building libyuv - # gives clang's register allocator issues, see llvm.org/PR15798 / - # crbug.com/233709 - if (is_clang && current_cpu == "x86" && !is_apple) { - cflags += [ "-momit-leaf-frame-pointer" ] - } - } else { - cflags = [ "-fomit-frame-pointer" ] - } - } - # On Windows, the flag to enable framepointers "/Oy-" must always come after - # the optimization flag [e.g. "/O2"]. The optimization flag is set by one of - # the "optimize" configs, see rest of this file. The ordering that cflags are - # applied is well-defined by the GN spec, and there is no way to ensure that - # cflags set by "default_stack_frames" is applied after those set by an - # "optimize" config. Similarly, there is no way to propagate state from this - # config into the "optimize" config. We always apply the "/Oy-" config in the - # definition for common_optimize_on_cflags definition, even though this may - # not be correct. -} - -# Default "optimization on" config. -config("optimize") { - if (is_win) { - if (chrome_pgo_phase != 2) { - # Favor size over speed, /O1 must be before the common flags. - # /O1 implies /Os and /GF. - cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] - rustflags = [ "-Copt-level=3" ] - } else { - # PGO requires all translation units to be compiled with /O2. The actual - # optimization level will be decided based on the profiling data. - cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] - - # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage - # suggests not using an explicit `-Copt-level` at all, and the default is - # to optimize for performance like `/O2` for clang. - rustflags = [ "-Copt-level=3" ] - } - } else if (optimize_for_size) { - # Favor size over speed. - if (is_clang) { - cflags = [ "-O3" ] + common_optimize_on_cflags - - if (use_ml_inliner && is_a_target_toolchain) { - cflags += [ - "-mllvm", - "-enable-ml-inliner=release", - ] - } - } else { - cflags = [ "-O3" ] + common_optimize_on_cflags - } - - # Like with `-Oz` on Clang, `-Copt-level=z` will also turn off loop - # vectorization. - rustflags = [ "-Copt-level=3" ] - } else if (is_chromeos) { - # TODO(gbiv): This is partially favoring size over speed. CrOS exclusively - # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at - # any cost" (AKA -Oz). It'd be nice to: - # - Make `optimize_for_size` apply to all platforms where we're optimizing - # for size by default (so, also Windows) - # - Investigate -Oz here, maybe just for ARM? - cflags = [ "-O3" ] + common_optimize_on_cflags - - # Similar to clang, we optimize with `-Copt-level=s` to keep loop - # vectorization while otherwise optimizing for size. - rustflags = [ "-Copt-level=3" ] - } else { - cflags = [ "-O3" ] + common_optimize_on_cflags - - # The `-O3` for clang turns on extra optimizations compared to the standard - # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable - # to use. - rustflags = [ "-Copt-level=3" ] - } - ldflags = common_optimize_on_ldflags -} - -# Turn off optimizations. -config("no_optimize") { - if (is_win) { - cflags = [ - "/Od", # Disable optimization. - "/Ob0", # Disable all inlining (on by default). - "/GF", # Enable string pooling (off by default). - ] - - if (target_cpu == "arm64") { - # Disable omitting frame pointers for no_optimize build because stack - # traces on Windows ARM64 rely on it. - cflags += [ "/Oy-" ] - } - } else if (is_android && !android_full_debug) { - # On Android we kind of optimize some things that don't affect debugging - # much even when optimization is disabled to get the binary size down. - if (is_clang) { - cflags = [ "-O3" ] + common_optimize_on_cflags - } else { - cflags = [ "-O3" ] + common_optimize_on_cflags - } - - if (!is_component_build) { - # Required for library partitions. Without this all symbols just end up - # in the base partition. - ldflags = [ "-Wl,--gc-sections" ] - } - } else if (is_fuchsia) { - # On Fuchsia, we optimize for size here to reduce the size of debug build - # packages so they can be run in a KVM. See crbug.com/910243 for details. - cflags = [ "-O3" ] - } else { - cflags = [ "-O3" ] - ldflags = [] - } -} - -# Turns up the optimization level. On Windows, this implies whole program -# optimization and link-time code generation which is very expensive and should -# be used sparingly. -config("optimize_max") { - if (is_nacl && is_nacl_irt) { - # The NaCl IRT is a special case and always wants its own config. - # Various components do: - # if (!is_debug) { - # configs -= [ "//build/config/compiler:default_optimization" ] - # configs += [ "//build/config/compiler:optimize_max" ] - # } - # So this config has to have the selection logic just like - # "default_optimization", below. - configs = [ "//build/config/nacl:irt_optimize" ] - } else { - ldflags = common_optimize_on_ldflags - if (is_win) { - # Favor speed over size, /O2 must be before the common flags. - # /O2 implies /Ot, /Oi, and /GF. - cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags - } else if (optimize_for_fuzzing) { - cflags = [ "-O3" ] + common_optimize_on_cflags - } else { - cflags = [ "-O3" ] + common_optimize_on_cflags - } - rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse2", ] - } -} - -# This config can be used to override the default settings for per-component -# and whole-program optimization, optimizing the particular target for speed -# instead of code size. This config is exactly the same as "optimize_max" -# except that we use -O3 instead of -O2 on non-win, non-IRT platforms. -# -# TODO(crbug.com/621335) - rework how all of these configs are related -# so that we don't need this disclaimer. -config("optimize_speed") { - if (is_nacl && is_nacl_irt) { - # The NaCl IRT is a special case and always wants its own config. - # Various components do: - # if (!is_debug) { - # configs -= [ "//build/config/compiler:default_optimization" ] - # configs += [ "//build/config/compiler:optimize_max" ] - # } - # So this config has to have the selection logic just like - # "default_optimization", below. - configs = [ "//build/config/nacl:irt_optimize" ] - } else { - ldflags = common_optimize_on_ldflags - if (is_win) { - # Favor speed over size, /O2 must be before the common flags. - # /O2 implies /Ot, /Oi, and /GF. - cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags - } else if (optimize_for_fuzzing) { - cflags = [ "-O3" ] + common_optimize_on_cflags - } else { - cflags = [ "-O3" ] + common_optimize_on_cflags - } - rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse2", ] - } -} - -config("optimize_fuzzing") { - cflags = [ "-O3" ] + common_optimize_on_cflags - rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse2", ] - ldflags = common_optimize_on_ldflags - visibility = [ ":default_optimization" ] -} - -# The default optimization applied to all targets. This will be equivalent to -# either "optimize" or "no_optimize", depending on the build flags. -config("default_optimization") { - if (is_nacl && is_nacl_irt) { - # The NaCl IRT is a special case and always wants its own config. - # It gets optimized the same way regardless of the type of build. - configs = [ "//build/config/nacl:irt_optimize" ] - } else if (is_debug) { - configs = [ ":no_optimize" ] - } else if (optimize_for_fuzzing) { - assert(!is_win, "Fuzzing optimize level not supported on Windows") - - # Coverage build is quite slow. Using "optimize_for_fuzzing" makes it even - # slower as it uses "-O1" instead of "-O3". Prevent that from happening. - assert(!use_clang_coverage, - "optimize_for_fuzzing=true should not be used with " + - "use_clang_coverage=true.") - configs = [ ":optimize_fuzzing" ] - } else { - configs = [ ":optimize" ] - } -} - -_clang_sample_profile = "" -if (is_clang && is_a_target_toolchain) { - if (clang_sample_profile_path != "") { - _clang_sample_profile = clang_sample_profile_path - } else if (clang_use_default_sample_profile) { - assert(build_with_chromium, - "Our default profiles currently only apply to Chromium") - assert(is_android || is_chromeos || is_castos, - "The current platform has no default profile") - if (is_android || is_castos) { - _clang_sample_profile = "//chrome/android/profiles/afdo.prof" - } else { - assert( - chromeos_afdo_platform == "atom" || - chromeos_afdo_platform == "bigcore" || - chromeos_afdo_platform == "arm" || - chromeos_afdo_platform == "arm-exp", - "Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.") - _clang_sample_profile = - "//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof" - } - } -} - -# Clang offers a way to assert that AFDO profiles are accurate, which causes it -# to optimize functions not represented in a profile more aggressively for size. -# This config can be toggled in cases where shaving off binary size hurts -# performance too much. -config("afdo_optimize_size") { - if (_clang_sample_profile != "" && sample_profile_is_accurate) { - cflags = [ "-fprofile-sample-accurate" ] - } -} - -# GCC and clang support a form of profile-guided optimization called AFDO. -# There are some targeted places that AFDO regresses, so we provide a separate -# config to allow AFDO to be disabled per-target. -config("afdo") { - if (is_clang) { - cflags = [] - if (clang_emit_debug_info_for_profiling) { - # Add the following flags to generate debug info for profiling. - cflags += [ "-gline-tables-only" ] - if (!is_nacl) { - cflags += [ "-fdebug-info-for-profiling" ] - } - } - if (_clang_sample_profile != "") { - assert(chrome_pgo_phase == 0, "AFDO can't be used in PGO builds") - rebased_clang_sample_profile = - rebase_path(_clang_sample_profile, root_build_dir) - cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ] - if (use_profi) { - cflags += [ "-fsample-profile-use-profi" ] - } - inputs = [ _clang_sample_profile ] - } - } else if (auto_profile_path != "" && is_a_target_toolchain) { - cflags = [ "-fauto-profile=${auto_profile_path}" ] - inputs = [ auto_profile_path ] - } -} - -# Symbols ---------------------------------------------------------------------- - -# The BUILDCONFIG file sets the "default_symbols" config on targets by -# default. It will be equivalent to one the three specific symbol levels. -# -# You can override the symbol level on a per-target basis by removing the -# default config and then adding the named one you want: -# -# configs -= [ "//build/config/compiler:default_symbols" ] -# configs += [ "//build/config/compiler:symbols" ] - -# A helper config that all configs passing /DEBUG to the linker should -# include as sub-config. -config("win_pdbaltpath") { - visibility = [ - ":minimal_symbols", - ":symbols", - ] - - # /DEBUG causes the linker to generate a pdb file, and to write the absolute - # path to it in the executable file it generates. This flag turns that - # absolute path into just the basename of the pdb file, which helps with - # build reproducibility. Debuggers look for pdb files next to executables, - # so there's minimal downside to always using this. However, post-mortem - # debugging of Chromium crash dumps and ETW tracing can be complicated by this - # switch so an option to omit it is important. - if (!use_full_pdb_paths) { - ldflags = [ "/pdbaltpath:%_PDB%" ] - } -} - -# Full symbols. -config("symbols") { - rustflags = [] - if (is_win) { - if (is_clang) { - cflags = [ - # Debug information in the .obj files. - "/Z7", - - # Disable putting the compiler command line into the debug info to - # prevent some types of non-determinism. - "-gno-codeview-command-line", - ] - } else { - cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. - } - - if (is_clang && use_lld && use_ghash) { - cflags += [ "-gcodeview-ghash" ] - ldflags = [ "/DEBUG:GHASH" ] - } else { - ldflags = [ "/DEBUG" ] - } - - # All configs using /DEBUG should include this: - configs = [ ":win_pdbaltpath" ] - } else { - cflags = [] - if (is_mac && enable_dsyms) { - # If generating dSYMs, specify -fno-standalone-debug. This was - # originally specified for https://crbug.com/479841 because dsymutil - # could not handle a 4GB dSYM file. But dsymutil from Xcodes prior to - # version 7 also produces debug data that is incompatible with Breakpad - # dump_syms, so this is still required (https://crbug.com/622406). - cflags += [ "-fno-standalone-debug" ] - } - - # On aix -gdwarf causes linker failures due to thread_local variables. - if (!is_nacl && current_os != "aix") { - if (use_dwarf5) { - cflags += [ "-gdwarf-5" ] - rustflags += [ "-Zdwarf-version=5" ] - } else if (!is_apple) { - # Recent clang versions default to DWARF5 on Linux, and Android is about - # to switch. TODO: Adopt that in controlled way. - # Apple platforms still default to 4, so the flag is not needed there. - cflags += [ "-gdwarf-4" ] - rustflags += [ "-Zdwarf-version=4" ] - } - } - - # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see - # elsewhere in this file), so they can't have build-dir-independent output. - # Moreover pnacl does not support newer flags such as -fdebug-prefix-map - # Disable symbols for nacl object files to get deterministic, - # build-directory-independent output. - # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are - # part of chromium release (other nacl toolchains are used only for tests). - if ((!is_nacl || is_nacl_saigo) && current_os != "zos") { - cflags += [ "-g2" ] - } - - if (!is_nacl && is_clang && !is_tsan && !is_asan) { - # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has - # to be manually enabled. - # - # It is skipped in tsan and asan because enabling it causes some - # formatting changes in the output which would require fixing bunches - # of expectation regexps. - cflags += [ "-gdwarf-aranges" ] - } - - if (is_apple) { - swiftflags = [ "-g" ] - } - - if (use_debug_fission) { - cflags += [ "-gsplit-dwarf" ] - } - asmflags = cflags - ldflags = [] - - # Split debug info with all thinlto builds except nacl and apple. - # thinlto requires -gsplit-dwarf in ldflags. - if (use_debug_fission && use_thin_lto && !is_nacl && !is_apple) { - ldflags += [ "-gsplit-dwarf" ] - } - - # TODO(thakis): Figure out if there's a way to make this go for 32-bit, - # currently we get "warning: - # obj/native_client/src/trusted/service_runtime/sel_asm/nacl_switch_32.o: - # DWARF info may be corrupt; offsets in a range list entry are in different - # sections" there. Maybe just a bug in nacl_switch_32.S. - _enable_gdb_index = - symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && - # Disable on non-fission 32-bit Android because it pushes - # libcomponents_unittests over the 4gb size limit. - !(is_android && !use_debug_fission && current_cpu != "x64" && - current_cpu != "arm64") - if (_enable_gdb_index) { - if (is_clang) { - # This flag enables the GNU-format pubnames and pubtypes sections, - # which lld needs in order to generate a correct GDB index. - # TODO(pcc): Try to make lld understand non-GNU-format pubnames - # sections (llvm.org/PR34820). - cflags += [ "-ggnu-pubnames" ] - } - ldflags += [ "-Wl,--gdb-index" ] - } - } - - configs = [] - - # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS - # https://b/243982712. - if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && - !is_nacl && current_cpu == "arm") { - configs += [ "//build/config:compress_debug_sections" ] - } - - if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") { - if (is_apple) { - # TODO(https://crbug.com/1050118): Investigate missing debug info on mac. - # Make sure we don't use constructor homing on mac. - cflags += [ - "-Xclang", - "-debug-info-kind=limited", - ] - } else { - # Use constructor homing for debug info. This option reduces debug info - # by emitting class type info only when constructors are emitted. - cflags += [ - "-Xclang", - "-fuse-ctor-homing", - ] - } - } - rustflags += [ "-g", "-Copt-level=3", "-Ctarget-feature=+sse2", ] -} - -# Minimal symbols. -# This config guarantees to hold symbol for stack trace which are shown to user -# when crash happens in unittests running on buildbot. -config("minimal_symbols") { - rustflags = [] - if (is_win) { - # Functions, files, and line tables only. - cflags = [] - - if (is_clang) { - cflags += [ - # Disable putting the compiler command line into the debug info to - # prevent some types of non-determinism. - "-gno-codeview-command-line", - ] - } - if (is_clang && use_lld && use_ghash) { - cflags += [ "-gcodeview-ghash" ] - ldflags = [ "/DEBUG:GHASH" ] - } else { - ldflags = [ "/DEBUG" ] - } - - # All configs using /DEBUG should include this: - configs = [ ":win_pdbaltpath" ] - - # Enable line tables for clang. MSVC doesn't have an equivalent option. - if (is_clang) { - # -gline-tables-only is the same as -g1, but clang-cl only exposes the - # former. - cflags += [ "-gline-tables-only" ] - } - } else { - cflags = [] - if (is_mac && !use_dwarf5) { - # clang defaults to DWARF2 on macOS unless mac_deployment_target is - # at least 10.11. - # TODO(thakis): Remove this once mac_deployment_target is 10.11. - cflags += [ "-gdwarf-4" ] - rustflags += [ "-Zdwarf-version=4" ] - } else if (!use_dwarf5 && !is_nacl && current_os != "aix") { - # On aix -gdwarf causes linker failures due to thread_local variables. - # Recent clang versions default to DWARF5 on Linux, and Android is about - # to switch. TODO: Adopt that in controlled way. - cflags += [ "-gdwarf-4" ] - rustflags += [ "-Zdwarf-version=4" ] - } - - if (use_dwarf5 && !is_nacl) { - cflags += [ "-gdwarf-5" ] - rustflags += [ "-Zdwarf-version=5" ] - } - - # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see - # elsewhere in this file), so they can't have build-dir-independent output. - # Moreover pnacl does not support newer flags such as -fdebug-prefix-map - # Disable symbols for nacl object files to get deterministic, - # build-directory-independent output. - # Keeping -g1 for saigo as it's the only toolchain whose artifacts that are - # part of chromium release (other nacl toolchains are used only for tests). - if (!is_nacl || is_nacl_saigo) { - cflags += [ "-g1" ] - } - - if (!is_nacl && is_clang && !is_tsan && !is_asan) { - # See comment for -gdwarf-aranges in config("symbols"). - cflags += [ "-gdwarf-aranges" ] - } - - ldflags = [] - if (is_android && is_clang) { - # Android defaults to symbol_level=1 builds, but clang, unlike gcc, - # doesn't emit DW_AT_linkage_name in -g1 builds. - # -fdebug-info-for-profiling enables that (and a bunch of other things we - # don't need), so that we get qualified names in stacks. - # TODO(thakis): Consider making clang emit DW_AT_linkage_name in -g1 mode; - # failing that consider doing this on non-Android too. - cflags += [ "-fdebug-info-for-profiling" ] - } - - asmflags = cflags - } - rustflags += [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+sse2", ] -} - -# This configuration contains function names only. That is, the compiler is -# told to not generate debug information and the linker then just puts function -# names in the final debug information. -config("no_symbols") { - if (is_win) { - ldflags = [ "/DEBUG:NONE" ] - - # All configs using /DEBUG should include this: - configs = [ ":win_pdbaltpath" ] - } else { - cflags = [ "-g0" ] - asmflags = cflags - } -} - -# Default symbols. -config("default_symbols") { - if (symbol_level == 0) { - configs = [ ":no_symbols" ] - } else if (symbol_level == 1) { - configs = [ ":minimal_symbols" ] - } else if (symbol_level == 2) { - configs = [ ":symbols" ] - } else { - assert(false) - } - - # This config is removed by base unittests apk. - if (is_android && is_clang && strip_debug_info) { - configs += [ ":strip_debug" ] - } -} - -config("strip_debug") { - if (!defined(ldflags)) { - ldflags = [] - } - ldflags += [ "-Wl,--strip-debug" ] -} - -if (is_apple) { - # On macOS and iOS, this enables support for ARC (automatic reference - # counting). See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. - # - # -fobjc-arc enables ARC overall. - # - # ARC does not add exception handlers to pure Objective-C code, but does add - # them to Objective-C++ code with the rationale that C++ pervasively adds them - # in for exception safety. However, exceptions are banned in Chromium code for - # C++ and exceptions in Objective-C code are intended to be fatal, so - # -fno-objc-arc-exceptions is specified to disable these unwanted exception - # handlers. - config("enable_arc") { - common_flags = [ - "-fobjc-arc", - "-fno-objc-arc-exceptions", - ] - cflags_objc = common_flags - cflags_objcc = common_flags - } -} - -if (is_chromeos_ash && is_chromeos_device) { - # This config is intended to be a temporary to facilitate - # the transition to use orderfile in Chrome OS. Once orderfile - # use becomes a default in Chrome OS, this config should not - # be needed. - config("use_orderfile_for_hugepage") { - if (chrome_orderfile_path != "") { - defines = [ "CHROMEOS_ORDERFILE_USE" ] - } - } -} - -if (is_android || (is_chromeos_ash && is_chromeos_device)) { - # Use orderfile for linking Chrome on Android and Chrome OS. - # This config enables using an orderfile for linking in LLD. - config("chrome_orderfile_config") { - # Don't try to use an orderfile with call graph sorting, except on Android, - # where we care about memory used by code, so we still want to mandate - # ordering. - if (chrome_orderfile_path != "" && - (is_android || !enable_call_graph_profile_sort)) { - assert(use_lld) - _rebased_orderfile = rebase_path(chrome_orderfile_path, root_build_dir) - ldflags = [ - "-Wl,--symbol-ordering-file", - "-Wl,$_rebased_orderfile", - "-Wl,--no-warn-symbol-ordering", - ] - inputs = [ chrome_orderfile_path ] - } - } -} - -# Initialize all variables on the stack if needed. -config("default_init_stack_vars") { - cflags = [] - if (init_stack_vars && is_clang && !is_nacl && !using_sanitizer) { - if (init_stack_vars_zero) { - cflags += [ "-ftrivial-auto-var-init=zero" ] - } else { - cflags += [ "-ftrivial-auto-var-init=pattern" ] - } - } -} - -buildflag_header("compiler_buildflags") { - header = "compiler_buildflags.h" - - flags = [ - "CLANG_PGO=$chrome_pgo_phase", - "SYMBOL_LEVEL=$symbol_level", - ] -} - -config("cet_shadow_stack") { - if (enable_cet_shadow_stack && is_win) { - assert(target_cpu == "x64") - ldflags = [ "/CETCOMPAT" ] - } -} diff --git a/other/SSE2/build/config/win/BUILD.gn b/other/SSE2/build/config/win/BUILD.gn deleted file mode 100644 index edd495c6..00000000 --- a/other/SSE2/build/config/win/BUILD.gn +++ /dev/null @@ -1,680 +0,0 @@ -# Copyright 2023 The Chromium Authors and Alex313031 -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//build/config/c++/c++.gni") -import("//build/config/chrome_build.gni") -import("//build/config/clang/clang.gni") -import("//build/config/compiler/compiler.gni") -import("//build/config/rust.gni") -import("//build/config/sanitizers/sanitizers.gni") -import("//build/config/win/control_flow_guard.gni") -import("//build/config/win/visual_studio_version.gni") -import("//build/timestamp.gni") -import("//build/toolchain/goma.gni") -import("//build/toolchain/rbe.gni") -import("//build/toolchain/toolchain.gni") - -assert(is_win) - -declare_args() { - # Turn this on to have the linker output extra timing information. - win_linker_timing = false - - # possible values for target_winuwp_version: - # "10" - Windows UWP 10 - # "8.1" - Windows RT 8.1 - # "8.0" - Windows RT 8.0 - target_winuwp_version = "10" - - # possible values: - # "app" - Windows Store Applications - # "phone" - Windows Phone Applications - # "system" - Windows Drivers and Tools - # "server" - Windows Server Applications - # "desktop" - Windows Desktop Applications - target_winuwp_family = "app" - - # Set this to use clang-style diagnostics format instead of MSVC-style, which - # is useful in e.g. Emacs compilation mode. - # E.g.: - # Without this, clang emits a diagnostic message like this: - # foo/bar.cc(12,34): error: something went wrong - # and with this switch, clang emits it like this: - # foo/bar.cc:12:34: error: something went wrong - use_clang_diagnostics_format = false -} - -# This is included by reference in the //build/config/compiler config that -# is applied to all targets. It is here to separate out the logic that is -# Windows-only. -config("compiler") { - if (current_cpu == "x86") { - asmflags = [ - # When /safeseh is specified, the linker will only produce an image if it - # can also produce a table of the image's safe exception handlers. This - # table specifies for the operating system which exception handlers are - # valid for the image. Note that /SAFESEH isn't accepted on the command - # line, only /safeseh. This is only accepted by ml.exe, not ml64.exe. - "/safeseh", - ] - } - - cflags = [ - "/Gy", # Enable function-level linking. - "/FS", # Preserve previous PDB behavior. - "/bigobj", # Some of our files are bigger than the regular limits. - "/utf-8", # Assume UTF-8 by default to avoid code page dependencies. - ] - - if (is_clang) { - cflags += [ - "/Zc:twoPhase", - - # Consistently use backslash as the path separator when expanding the - # __FILE__ macro when targeting Windows regardless of the build - # environment. - "-ffile-reproducible", - ] - } - - # Force C/C++ mode for the given GN detected file type. This is necessary - # for precompiled headers where the same source file is compiled in both - # modes. - cflags_c = [ "/TC" ] - cflags_cc = [ "/TP" ] - - cflags += [ - # Work around crbug.com/526851, bug in VS 2015 RTM compiler. - # "/Zc:sizedDealloc-", - ] - - if (is_clang) { - # Required to make the 19041 SDK compatible with clang-cl. - # See https://crbug.com/1089996 issue #2 for details. - cflags += [ "/D__WRL_ENABLE_FUNCTION_STATICS__" ] - - # Tell clang which version of MSVC to emulate. - cflags += [ "-fmsc-version=1934" ] - - if (is_component_build) { - cflags += [ - # Do not export inline member functions. This makes component builds - # faster. This is similar to -fvisibility-inlines-hidden. - "/Zc:dllexportInlines-", - ] - } - - if (current_cpu == "x86") { - if (host_cpu == "x86" || host_cpu == "x64") { - cflags += [ "-m32" ] - } else { - cflags += [ "--target=i386-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] - } - } else if (current_cpu == "x64") { - if (host_cpu == "x86" || host_cpu == "x64") { - cflags += [ "-m64" ] - } else { - cflags += [ "--target=x86_64-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] - } - } else if (current_cpu == "arm64") { - cflags += [ "--target=aarch64-pc-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] - } else { - assert(false, "unknown current_cpu " + current_cpu) - } - - # Chrome currently requires SSE3. Clang supports targeting any Intel - # microarchitecture. MSVC only supports a subset of architectures, and the - # next step after SSE2 will be AVX. - # "/fp:fast", enables FMA. - if (current_cpu == "x86" || current_cpu == "x64") { - cflags += [ - "/O2", - "-mmmx", - "-mfxsr", - "-msse2", - "/clang:-O3", - "/clang:-mmmx", - "/clang:-mfxsr", - "/clang:-msse2", - "-Xclang", "-O3", - "-Wno-unused-command-line-argument", - ] - } - - # Enable ANSI escape codes if something emulating them is around (cmd.exe - # doesn't understand ANSI escape codes by default). Make sure to not enable - # this if goma/remoteexec is in use, because this will lower cache hits. - if (!use_goma && !use_remoteexec && - exec_script("//build/win/use_ansi_codes.py", [], "trim string") == - "True") { - cflags += [ "-fansi-escape-codes" ] - } - - if (use_clang_diagnostics_format) { - cflags += [ "/clang:-fdiagnostics-format=clang" ] - } - } - - # Disabled with cc_wrapper because of https://github.com/mozilla/sccache/issues/264 - if (use_lld && !use_thin_lto && (is_clang || !use_goma) && cc_wrapper == "") { - # /Brepro lets the compiler not write the mtime field in the .obj output. - # link.exe /incremental relies on this field to work correctly, but lld - # never looks at this timestamp, so it's safe to pass this flag with - # lld and get more deterministic compiler output in return. - # In LTO builds, the compiler doesn't write .obj files containing mtimes, - # so /Brepro is ignored there. - cflags += [ "/Brepro" ] - } - - ldflags = [] - - if (use_lld) { - # lld defaults to writing the current time in the pe/coff header. - # For build reproducibility, pass an explicit timestamp. See - # build/compute_build_timestamp.py for how the timestamp is chosen. - # (link.exe also writes the current time, but it doesn't have a flag to - # override that behavior.) - ldflags += [ "/TIMESTAMP:" + build_timestamp ] - - # Don't look for libpaths in %LIB%, similar to /X in cflags above. - ldflags += [ "/lldignoreenv" ] - ldflags += [ "/opt:lldlto=3", ] - } - - # Some binaries create PDBs larger than 4 GiB. Increasing the PDB page size - # to 8 KiB allows 8 GiB PDBs. The larger page size also allows larger block maps - # which is a PDB limit that was hit in https://crbug.com/1406510. The page size - # can easily be increased in the future to allow even larger PDBs or larger - # block maps. - # This flag requires lld-link.exe or link.exe from VS 2022 or later to create - # the PDBs, and tools from circa 22H2 or later to consume the PDBs. - ldflags += [ "/pdbpagesize:8192" ] - - if (!is_debug && !is_component_build) { - # Enable standard linker optimizations like GC (/OPT:REF) and ICF in static - # release builds. - # Release builds always want these optimizations, so enable them explicitly. - ldflags += [ - "/OPT:REF", - "/OPT:ICF", - "/INCREMENTAL:NO", - "/FIXED:NO", - "/OPT:lldlto=3", - ] - - if (use_lld) { - # String tail merging leads to smaller binaries, but they don't compress - # as well, leading to increased mini_installer size (crbug.com/838449). - # ldflags += [ "/OPT:NOLLDTAILMERGE" ] - ldflags += [ "/OPT:LLDTAILMERGE" ] - } - - # TODO(siggi): Is this of any use anymore? - # /PROFILE ensures that the PDB file contains FIXUP information (growing the - # PDB file by about 5%) but does not otherwise alter the output binary. It - # is enabled opportunistically for builds where it is not prohibited (not - # supported when incrementally linking, or using /debug:fastlink). - # ldflags += [ "/PROFILE" ] - } - - # arflags apply only to static_libraries. The normal linker configs are only - # set for executable and shared library targets so arflags must be set - # elsewhere. Since this is relatively contained, we just apply them in this - # more general config and they will only have an effect on static libraries. - arflags = [ - # "No public symbols found; archive member will be inaccessible." This - # means that one or more object files in the library can never be - # pulled in to targets that link to this library. It's just a warning that - # the source file is a no-op. - "/ignore:4221", - ] -} - -# This is included by reference in the //build/config/compiler:runtime_library -# config that is applied to all targets. It is here to separate out the logic -# that is Windows-only. Please see that target for advice on what should go in -# :runtime_library vs. :compiler. -config("runtime_library") { - cflags = [] - cflags_cc = [] - - # Defines that set up the CRT. - defines = [ - "__STD_C", - "_CRT_RAND_S", - "_CRT_SECURE_NO_DEPRECATE", - "_SCL_SECURE_NO_DEPRECATE", - ] - - # Defines that set up the Windows SDK. - defines += [ - "_ATL_NO_OPENGL", - "_WINDOWS", - "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", - "PSAPI_VERSION=2", - "WIN32", - "_SECURE_ATL", - ] - - if (current_os == "winuwp") { - # When targeting Windows Runtime, certain compiler/linker flags are - # necessary. - defines += [ - "WINUWP", - "__WRL_NO_DEFAULT_LIB__", - ] - if (target_winuwp_family == "app") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ] - } else if (target_winuwp_family == "phone") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP" ] - } else if (target_winuwp_family == "system") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SYSTEM" ] - } else if (target_winuwp_family == "server") { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SERVER" ] - } else { - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] - } - cflags_cc += [ "/EHsc" ] - - # This warning is given because the linker cannot tell the difference - # between consuming WinRT APIs versus authoring WinRT within static - # libraries as such this warning is always given by the linker. Since - # consuming WinRT APIs within a library is legitimate but authoring - # WinRT APis is not allowed, this warning is disabled to ignore the - # legitimate consumption of WinRT APIs within static library builds. - arflags = [ "/IGNORE:4264" ] - - if (target_winuwp_version == "10") { - defines += [ "WIN10=_WIN32_WINNT_WIN10" ] - } else if (target_winuwp_version == "8.1") { - defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] - } else if (target_winuwp_version == "8.0") { - defines += [ "WIN8=_WIN32_WINNT_WIN8" ] - } - } else { - # When not targeting Windows Runtime, make sure the WINAPI family is set - # to desktop. - defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] - } -} - -# Chromium only supports Windowes 10+. -# Some third-party libraries assume that these defines set what version of -# Windows is available at runtime. Targets using these libraries need to -# manually override this config for their compiles. -config("winver") { - defines = [ - "NTDDI_VERSION=NTDDI_WIN10_NI", - - # We can't say `=_WIN32_WINNT_WIN10` here because some files do - # `#if WINVER < 0x0600` without including windows.h before, - # and then _WIN32_WINNT_WIN10 isn't yet known to be 0x0A00. - "_WIN32_WINNT=0x0A00", - "WINVER=0x0A00", - ] -} - -# Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. -config("sdk_link") { - if (current_cpu == "x86") { - ldflags = [ - "/SAFESEH", # Not compatible with x64 so use only for x86. - "/largeaddressaware", - ] - } -} - -# This default linker setup is provided separately from the SDK setup so -# targets who want different library configurations can remove this and specify -# their own. -config("common_linker_setup") { - ldflags = [ - "/FIXED:NO", - "/ignore:4199", - "/ignore:4221", - "/NXCOMPAT", - "/DYNAMICBASE", - ] - - if (win_linker_timing) { - ldflags += [ - "/time", - "/verbose:incr", - ] - } -} - -config("default_cfg_compiler") { - # Emit table of address-taken functions for Control-Flow Guard (CFG). - # This is needed to allow functions to be called by code that is built - # with CFG enabled, such as system libraries. - # The CFG guards are only emitted if |win_enable_cfg_guards| is enabled. - if (win_enable_cfg_guards) { - if (is_clang) { - cflags = [ "/guard:cf" ] - } - rustflags = [ "-Ccontrol-flow-guard" ] - } else { - if (is_clang) { - cflags = [ "/guard:cf,nochecks" ] - } - rustflags = [ "-Ccontrol-flow-guard=nochecks" ] - } -} - -# To disable CFG guards for a target, remove the "default_cfg_compiler" -# config, and add "disable_guards_cfg_compiler" config. -config("disable_guards_cfg_compiler") { - # Emit table of address-taken functions for Control-Flow Guard (CFG). - # This is needed to allow functions to be called by code that is built - # with CFG enabled, such as system libraries. - if (is_clang) { - cflags = [ "/guard:cf,nochecks" ] - } - rustflags = [ "-Ccontrol-flow-guard=nochecks" ] -} - -config("cfi_linker") { - # Control Flow Guard (CFG) - # https://msdn.microsoft.com/en-us/library/windows/desktop/mt637065.aspx - # /DYNAMICBASE (ASLR) is turned off in debug builds, therefore CFG cannot be - # turned on either. - # ASan and CFG leads to slow process startup. Chromium's test runner uses - # lots of child processes, so this means things are really slow. Disable CFG - # for now. https://crbug.com/846966 - if (!is_debug && !is_asan) { - # Turn on CFG bitmap generation and CFG load config. - ldflags = [ "/guard:cf" ] - } -} - -# This is a superset of all the delayloads needed for chrome.exe, chrome.dll, -# chrome_child.dll, and chrome_elf.dll. The linker will automatically ignore -# anything which is not linked to the binary at all. -# Most of the dlls are simply not required at startup (or at all, depending -# on how the browser is used). The following dlls are interconnected and need to -# be delayloaded together to ensure user32 does not load too early or at all, -# depending on the process type: user32, gdi32, comctl32, comdlg32, cryptui, -# d3d9, dwmapi, imm32, msi, ole32, oleacc, rstrtmgr, shell32, shlwapi, and -# uxtheme. -# There are some exceptions to this list which need to be declared separately. -# Some dlls cannot be delayloaded by chrome_child.dll due to the sandbox -# restrictions that prevent them from being loaded properly. Those dlls are -# specified in the separate config below. -# This config should also be used for any test binary whose goal is to run -# tests with the full browser. -config("delayloads") { - ldflags = [ - "/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll", - "/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll", - "/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll", - "/DELAYLOAD:comctl32.dll", - "/DELAYLOAD:comdlg32.dll", - "/DELAYLOAD:credui.dll", - "/DELAYLOAD:cryptui.dll", - "/DELAYLOAD:d3d11.dll", - "/DELAYLOAD:d3d9.dll", - "/DELAYLOAD:dwmapi.dll", - "/DELAYLOAD:dxgi.dll", - "/DELAYLOAD:dxva2.dll", - "/DELAYLOAD:esent.dll", - "/DELAYLOAD:gdi32.dll", - "/DELAYLOAD:hid.dll", - "/DELAYLOAD:imagehlp.dll", - "/DELAYLOAD:imm32.dll", - "/DELAYLOAD:msi.dll", - "/DELAYLOAD:netapi32.dll", - "/DELAYLOAD:ncrypt.dll", - "/DELAYLOAD:ole32.dll", - "/DELAYLOAD:oleacc.dll", - "/DELAYLOAD:propsys.dll", - "/DELAYLOAD:psapi.dll", - "/DELAYLOAD:rpcrt4.dll", - "/DELAYLOAD:rstrtmgr.dll", - "/DELAYLOAD:setupapi.dll", - "/DELAYLOAD:shell32.dll", - "/DELAYLOAD:shlwapi.dll", - "/DELAYLOAD:uiautomationcore.dll", - "/DELAYLOAD:urlmon.dll", - "/DELAYLOAD:user32.dll", - "/DELAYLOAD:usp10.dll", - "/DELAYLOAD:uxtheme.dll", - "/DELAYLOAD:wer.dll", - "/DELAYLOAD:wevtapi.dll", - "/DELAYLOAD:wininet.dll", - "/DELAYLOAD:winusb.dll", - "/DELAYLOAD:wsock32.dll", - "/DELAYLOAD:wtsapi32.dll", - ] -} - -config("delayloads_not_for_child_dll") { - ldflags = [ - "/DELAYLOAD:advapi32.dll", - "/DELAYLOAD:crypt32.dll", - "/DELAYLOAD:dbghelp.dll", - "/DELAYLOAD:dhcpcsvc.dll", - "/DELAYLOAD:dwrite.dll", - "/DELAYLOAD:iphlpapi.dll", - "/DELAYLOAD:oleaut32.dll", - "/DELAYLOAD:secur32.dll", - "/DELAYLOAD:uiautomationcore.dll", - "/DELAYLOAD:userenv.dll", - "/DELAYLOAD:winhttp.dll", - "/DELAYLOAD:winmm.dll", - "/DELAYLOAD:winspool.drv", - "/DELAYLOAD:wintrust.dll", - "/DELAYLOAD:ws2_32.dll", - ] -} - -# CRT -------------------------------------------------------------------------- - -# Configures how the runtime library (CRT) is going to be used. -# See https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx for a reference of -# what each value does. -config("default_crt") { - if (is_component_build) { - # Component mode: dynamic CRT. Since the library is shared, it requires - # exceptions or will give errors about things not matching, so keep - # exceptions on. - configs = [ ":dynamic_crt" ] - } else { - if (current_os == "winuwp") { - # https://blogs.msdn.microsoft.com/vcblog/2014/06/10/the-great-c-runtime-crt-refactoring/ - # contains a details explanation of what is happening with the Windows - # CRT in Visual Studio releases related to Windows store applications. - configs = [ ":dynamic_crt" ] - } else { - # Desktop Windows: static CRT. - configs = [ ":static_crt" ] - } - } -} - -# Use this to force use of the release CRT when building perf-critical build -# tools that need to be fully optimized even in debug builds, for those times -# when the debug CRT is part of the bottleneck. This also avoids *implicitly* -# defining _DEBUG. -config("release_crt") { - if (is_component_build) { - cflags = [ "/MD" ] - - if (rust_prebuilt_stdlib) { - rustflags = [ "-Ctarget-feature=-crt-static" ] - } else { - # /MD specifies msvcrt.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. Once - # https://github.com/rust-lang/rust/issues/39016 is resolved we should - # instead tell rustc which CRT to use (static/dynamic + release/debug). - rustflags = [ "-Clink-arg=msvcrt.lib" ] - } - - if (use_custom_libcxx) { - # On Windows, including libcpmt[d]/msvcprt[d] explicitly links the C++ - # standard library, which libc++ needs for exception_ptr internals. - ldflags = [ "/DEFAULTLIB:msvcprt.lib" ] - } - } else { - cflags = [ "/MT" ] - - if (rust_prebuilt_stdlib) { - rustflags = [ "-Ctarget-feature=+crt-static" ] - } else { - # /MT specifies libcmt.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. Once - # https://github.com/rust-lang/rust/issues/39016 is resolved we should - # instead tell rustc which CRT to use (static/dynamic + release/debug). - rustflags = [ "-Clink-arg=libcmt.lib" ] - } - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:libcpmt.lib" ] - } - } -} - -config("dynamic_crt") { - if (is_debug) { - # This pulls in the DLL debug CRT and defines _DEBUG - cflags = [ "/MDd" ] - - # /MDd specifies msvcrtd.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. - # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should - # instead tell rustc which CRT to use (static/dynamic + release/debug). We - # can't support prebuilt stdlib in this path until then. - rustflags = [ "-Clink-arg=msvcrtd.lib" ] - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:msvcprtd.lib" ] - } - } else { - cflags = [ "/MD" ] - - if (rust_prebuilt_stdlib) { - rustflags = [ "-Ctarget-feature=-crt-static" ] - } else { - # /MD specifies msvcrt.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. - # Once https://github.com/rust-lang/rust/issues/39016 is resolved we - # should instead tell rustc which CRT to use (static/dynamic + - # release/debug). - rustflags = [ "-Clink-arg=msvcrt.lib" ] - } - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:msvcprt.lib" ] - } - } -} - -config("static_crt") { - if (is_debug) { - # This pulls in the static debug CRT and defines _DEBUG - cflags = [ "/MTd" ] - - # /MTd specifies libcmtd.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. - # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should - # instead tell rustc which CRT to use (static/dynamic + release/debug). We - # can't support prebuilt stdlib in this path until then. - rustflags = [ "-Clink-arg=libcmtd.lib" ] - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:libcpmtd.lib" ] - } - } else { - cflags = [ "/MT" ] - - if (rust_prebuilt_stdlib) { - rustflags = [ "-Ctarget-feature=+crt-static" ] - } else { - # /MT specifies libcmt.lib as the CRT library. Rust needs to agree, so - # we specify it explicitly. - # Once https://github.com/rust-lang/rust/issues/39016 is resolved we - # should instead tell rustc which CRT to use (static/dynamic + - # release/debug). - rustflags = [ "-Clink-arg=libcmt.lib" ] - } - - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:libcpmt.lib" ] - } - } -} - -# Subsystem -------------------------------------------------------------------- - -# This is appended to the subsystem to specify a minimum version. -if (current_cpu == "x64") { - # The number after the comma is the minimum required OS version. - # 5.02 = Windows Server 2003. - subsystem_version_suffix = ",10.0" -} else if (current_cpu == "arm64") { - # Windows ARM64 requires Windows 10. - subsystem_version_suffix = ",10.0" -} else { - # 5.01 = Windows XP. - subsystem_version_suffix = ",10.0" -} - -config("console") { - ldflags = [ "/SUBSYSTEM:CONSOLE$subsystem_version_suffix" ] -} -config("windowed") { - ldflags = [ "/SUBSYSTEM:WINDOWS$subsystem_version_suffix" ] -} - -# Incremental linking ---------------------------------------------------------- - -# Applies incremental linking or not depending on the current configuration. -config("default_incremental_linking") { - # Enable incremental linking for debug builds and all component builds - any - # builds where performance is not job one. - # TODO(thakis): Always turn this on with lld, no reason not to. - if (is_debug || is_component_build) { - ldflags = [ "/INCREMENTAL" ] - if (use_lld) { - # lld doesn't use ilk files and doesn't really have an incremental link - # mode; the only effect of the flag is that the .lib file timestamp isn't - # updated if the .lib doesn't change. - # TODO(thakis): Why pass /OPT:NOREF for lld, but not otherwise? - # TODO(thakis): /INCREMENTAL is on by default in link.exe, but not in - # lld. - ldflags += [ "/OPT:NOREF" ] - } - } else { - ldflags = [ "/INCREMENTAL:NO" ] - } -} - -# Character set ---------------------------------------------------------------- - -# Not including this config means "ansi" (8-bit system codepage). -config("unicode") { - defines = [ - "_UNICODE", - "UNICODE", - ] -} - -# Lean and mean ---------------------------------------------------------------- - -# Some third party code might not compile with WIN32_LEAN_AND_MEAN so we have -# to have a separate config for it. Remove this config from your target to -# get the "bloaty and accommodating" version of windows.h. -config("lean_and_mean") { - defines = [ "WIN32_LEAN_AND_MEAN" ] -} - -# Nominmax -------------------------------------------------------------------- - -# Some third party code defines NOMINMAX before including windows.h, which -# then causes warnings when it's been previously defined on the command line. -# For such targets, this config can be removed. - -config("nominmax") { - defines = [ "NOMINMAX" ] -} diff --git a/other/SSE2/thor_ver b/other/SSE2/thor_ver deleted file mode 100644 index 8418d008..00000000 --- a/other/SSE2/thor_ver +++ /dev/null @@ -1 +0,0 @@ -SSE2 diff --git a/other/SSE2/win32_args.gn b/other/SSE2/win32_args.gn deleted file mode 100644 index 241621af..00000000 --- a/other/SSE2/win32_args.gn +++ /dev/null @@ -1,84 +0,0 @@ -google_api_key = "" -google_default_client_id = "" -google_default_client_secret = "" -visual_studio_version = "2022" -msvc_use_sse2 = true -# clang_base_path = "/usr/lib/llvm-16" -# clang_version = "16" -# use_polly = true -target_os = "win" -target_cpu = "x86" -is_official_build = true -is_debug = false -enable_stripping = true -dcheck_always_on = false -exclude_unwind_tables = true -# enable_debugallocation = false -enable_iterator_debugging = false -disable_fieldtrial_testing_config = true -enable_reporting = false -enable_resource_allowlist_generation = false -enable_profiling = false -is_component_build = false -symbol_level = 0 -enable_nacl = false -optimize_webui = true -enable_webui_tab_strip = true -is_clang = true -treat_warnings_as_errors = false -# llvm_force_head_revision = true -use_lld = true -v8_symbol_level = 0 -v8_enable_fast_torque = true -v8_enable_builtins_optimization = true -v8_enable_maglev = true -v8_enable_turbofan = true -use_v8_context_snapshot = true -blink_symbol_level = 0 -enable_precompiled_headers = false -media_use_ffmpeg = true -media_use_libvpx = true -# enable_hls_sample_aes = true -enable_hls_demuxer = true -enable_ink = false -enable_discovery = false -enable_cros_media_app = false -proprietary_codecs = true -ffmpeg_branding = "Chrome" -# Set to false for Polly build -clang_use_chrome_plugins = true -enable_ffmpeg_video_decoders = true -is_component_ffmpeg = false -use_webaudio_ffmpeg = false -use_webaudio_pffft = true -# enable_av1_decoder = true -# enable_dav1d_decoder = true -enable_library_cdms = true -enable_widevine = true -bundle_widevine_cdm = true -# enable_widevine_cdm_component = true -# enable_media_foundation_widevine_cdm = true -ignore_missing_widevine_signing_cert = true -enable_media_drm_storage = true -# enable_media_overlay = true -enable_hangout_services_extension = true -rtc_use_h264 = true -rtc_include_ilbc = true -# rtc_build_with_neon = true -rtc_build_examples = false -rtc_enable_avx2 = false -enable_vr = true -use_vr_assets_component = true -enable_platform_hevc = true -enable_hevc_parser_and_hw_decoder = true -enable_platform_ac3_eac3_audio = true -enable_platform_dolby_vision = true -enable_platform_encrypted_dolby_vision = true -enable_platform_mpeg_h_audio = true -enable_platform_dts_audio = true -enable_mse_mpeg2ts_stream_parser = true -use_text_section_splitting = true -use_thin_lto = true -thin_lto_enable_optimizations = true -chrome_pgo_phase = 2 -pgo_data_path = "/home/alex/chromium/src/chrome/build/pgo_profiles/chrome-win32-5845-1692121706-2bf741a507a4b74a6fe504d4b652b559596b90f8.profdata" diff --git a/other/SSE3/build/config/win/BUILD.gn b/other/SSE3/build/config/win/BUILD.gn index 0eddf06c..92d3df4e 100644 --- a/other/SSE3/build/config/win/BUILD.gn +++ b/other/SSE3/build/config/win/BUILD.gn @@ -109,16 +109,16 @@ config("compiler") { if (host_cpu == "x86" || host_cpu == "x64") { cflags += [ "-m32" ] } else { - cflags += [ "--target=i386-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] + cflags += [ "--target=i386-windows" ] } } else if (current_cpu == "x64") { if (host_cpu == "x86" || host_cpu == "x64") { cflags += [ "-m64" ] } else { - cflags += [ "--target=x86_64-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] + cflags += [ "--target=x86_64-windows" ] } } else if (current_cpu == "arm64") { - cflags += [ "--target=aarch64-pc-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] + cflags += [ "--target=aarch64-pc-windows" ] } else { assert(false, "unknown current_cpu " + current_cpu) } @@ -386,18 +386,32 @@ config("cfi_linker") { } # This is a superset of all the delayloads needed for chrome.exe, chrome.dll, -# chrome_child.dll, and chrome_elf.dll. The linker will automatically ignore -# anything which is not linked to the binary at all. -# Most of the dlls are simply not required at startup (or at all, depending -# on how the browser is used). The following dlls are interconnected and need to -# be delayloaded together to ensure user32 does not load too early or at all, -# depending on the process type: user32, gdi32, comctl32, comdlg32, cryptui, -# d3d9, dwmapi, imm32, msi, ole32, oleacc, rstrtmgr, shell32, shlwapi, and -# uxtheme. -# There are some exceptions to this list which need to be declared separately. -# Some dlls cannot be delayloaded by chrome_child.dll due to the sandbox -# restrictions that prevent them from being loaded properly. Those dlls are -# specified in the separate config below. +# and chrome_elf.dll. The linker will automatically ignore anything which is not +# linked to the binary at all (it is harmless to have an unmatched /delayload). +# +# We delayload most libraries as the dlls are simply not required at startup (or +# at all, depending on the process type). In unsandboxed process they will load +# when first needed. +# +# Some dlls open handles when they are loaded, and we may not want them to be +# loaded in renderers or other sandboxed processes. Conversely, some dlls must +# be loaded before sandbox lockdown. +# +# Some dlls themselves load others - in particular, to avoid unconditionally +# loading user32.dll - we require that the following dlls are all delayloaded: +# user32, gdi32, comctl32, comdlg32, cryptui, d3d9, dwmapi, imm32, msi, ole32, +# oleacc, rstrtmgr, shell32, shlwapi, and uxtheme. +# +# Advapi32.dll is unconditionally loaded at process startup on Windows 10, but +# on Windows 11 it is not, which makes it worthwhile to delay load it. +# Additionally, advapi32.dll exports several functions that are forwarded to +# other DLLs such as cryptbase.dll. If calls to those functions are present but +# there are some processes where the functions are never called then delay +# loading of advapi32.dll avoids pulling in those DLLs (such as cryptbase.dll) +# unnecessarily, even if advapi32.dll itself is loaded. +# +# This config applies to chrome.exe, chrome.dll, chrome_elf.dll (& others). +# # This config should also be used for any test binary whose goal is to run # tests with the full browser. config("delayloads") { @@ -405,6 +419,7 @@ config("delayloads") { "/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll", "/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll", "/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll", + "/DELAYLOAD:advapi32.dll", "/DELAYLOAD:comctl32.dll", "/DELAYLOAD:comdlg32.dll", "/DELAYLOAD:credui.dll", @@ -445,9 +460,10 @@ config("delayloads") { ] } +# This config (along with `:delayloads`) applies to chrome.exe & chrome_elf.dll. +# Entries should not appear in both configs. config("delayloads_not_for_child_dll") { ldflags = [ - "/DELAYLOAD:advapi32.dll", "/DELAYLOAD:crypt32.dll", "/DELAYLOAD:dbghelp.dll", "/DELAYLOAD:dhcpcsvc.dll", @@ -455,7 +471,6 @@ config("delayloads_not_for_child_dll") { "/DELAYLOAD:iphlpapi.dll", "/DELAYLOAD:oleaut32.dll", "/DELAYLOAD:secur32.dll", - "/DELAYLOAD:uiautomationcore.dll", "/DELAYLOAD:userenv.dll", "/DELAYLOAD:winhttp.dll", "/DELAYLOAD:winmm.dll", @@ -640,6 +655,10 @@ config("default_incremental_linking") { # TODO(thakis): /INCREMENTAL is on by default in link.exe, but not in # lld. ldflags += [ "/OPT:NOREF" ] + + # TODO(crbug.com/1444129): Mixing incremental and icf produces an error + # in lld-link. + ldflags += [ "/OPT:NOICF" ] } } else { ldflags = [ "/INCREMENTAL:NO" ] diff --git a/src/build/config/win/BUILD.gn b/src/build/config/win/BUILD.gn index 65fcb4e3..f5e5af4c 100644 --- a/src/build/config/win/BUILD.gn +++ b/src/build/config/win/BUILD.gn @@ -109,16 +109,16 @@ config("compiler") { if (host_cpu == "x86" || host_cpu == "x64") { cflags += [ "-m32" ] } else { - cflags += [ "--target=i386-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] + cflags += [ "--target=i386-windows" ] } } else if (current_cpu == "x64") { if (host_cpu == "x86" || host_cpu == "x64") { cflags += [ "-m64" ] } else { - cflags += [ "--target=x86_64-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] + cflags += [ "--target=x86_64-windows" ] } } else if (current_cpu == "arm64") { - cflags += [ "--target=aarch64-pc-windows", "/clang:-O3", "-Xclang", "-O3", "-Wno-unused-command-line-argument", ] + cflags += [ "--target=aarch64-pc-windows" ] } else { assert(false, "unknown current_cpu " + current_cpu) } @@ -390,18 +390,32 @@ config("cfi_linker") { } # This is a superset of all the delayloads needed for chrome.exe, chrome.dll, -# chrome_child.dll, and chrome_elf.dll. The linker will automatically ignore -# anything which is not linked to the binary at all. -# Most of the dlls are simply not required at startup (or at all, depending -# on how the browser is used). The following dlls are interconnected and need to -# be delayloaded together to ensure user32 does not load too early or at all, -# depending on the process type: user32, gdi32, comctl32, comdlg32, cryptui, -# d3d9, dwmapi, imm32, msi, ole32, oleacc, rstrtmgr, shell32, shlwapi, and -# uxtheme. -# There are some exceptions to this list which need to be declared separately. -# Some dlls cannot be delayloaded by chrome_child.dll due to the sandbox -# restrictions that prevent them from being loaded properly. Those dlls are -# specified in the separate config below. +# and chrome_elf.dll. The linker will automatically ignore anything which is not +# linked to the binary at all (it is harmless to have an unmatched /delayload). +# +# We delayload most libraries as the dlls are simply not required at startup (or +# at all, depending on the process type). In unsandboxed process they will load +# when first needed. +# +# Some dlls open handles when they are loaded, and we may not want them to be +# loaded in renderers or other sandboxed processes. Conversely, some dlls must +# be loaded before sandbox lockdown. +# +# Some dlls themselves load others - in particular, to avoid unconditionally +# loading user32.dll - we require that the following dlls are all delayloaded: +# user32, gdi32, comctl32, comdlg32, cryptui, d3d9, dwmapi, imm32, msi, ole32, +# oleacc, rstrtmgr, shell32, shlwapi, and uxtheme. +# +# Advapi32.dll is unconditionally loaded at process startup on Windows 10, but +# on Windows 11 it is not, which makes it worthwhile to delay load it. +# Additionally, advapi32.dll exports several functions that are forwarded to +# other DLLs such as cryptbase.dll. If calls to those functions are present but +# there are some processes where the functions are never called then delay +# loading of advapi32.dll avoids pulling in those DLLs (such as cryptbase.dll) +# unnecessarily, even if advapi32.dll itself is loaded. +# +# This config applies to chrome.exe, chrome.dll, chrome_elf.dll (& others). +# # This config should also be used for any test binary whose goal is to run # tests with the full browser. config("delayloads") { @@ -409,6 +423,7 @@ config("delayloads") { "/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll", "/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll", "/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll", + "/DELAYLOAD:advapi32.dll", "/DELAYLOAD:comctl32.dll", "/DELAYLOAD:comdlg32.dll", "/DELAYLOAD:credui.dll", @@ -449,9 +464,10 @@ config("delayloads") { ] } +# This config (along with `:delayloads`) applies to chrome.exe & chrome_elf.dll. +# Entries should not appear in both configs. config("delayloads_not_for_child_dll") { ldflags = [ - "/DELAYLOAD:advapi32.dll", "/DELAYLOAD:crypt32.dll", "/DELAYLOAD:dbghelp.dll", "/DELAYLOAD:dhcpcsvc.dll", @@ -459,7 +475,6 @@ config("delayloads_not_for_child_dll") { "/DELAYLOAD:iphlpapi.dll", "/DELAYLOAD:oleaut32.dll", "/DELAYLOAD:secur32.dll", - "/DELAYLOAD:uiautomationcore.dll", "/DELAYLOAD:userenv.dll", "/DELAYLOAD:winhttp.dll", "/DELAYLOAD:winmm.dll", @@ -644,6 +659,10 @@ config("default_incremental_linking") { # TODO(thakis): /INCREMENTAL is on by default in link.exe, but not in # lld. ldflags += [ "/OPT:NOREF" ] + + # TODO(crbug.com/1444129): Mixing incremental and icf produces an error + # in lld-link. + ldflags += [ "/OPT:NOICF" ] } } else { ldflags = [ "/INCREMENTAL:NO" ] diff --git a/src/chrome/app/chromium_strings.grd b/src/chrome/app/chromium_strings.grd index e7b15227..d29cadde 100644 --- a/src/chrome/app/chromium_strings.grd +++ b/src/chrome/app/chromium_strings.grd @@ -425,9 +425,18 @@ If you update this file, be sure also to update google_chrome_strings.grd. --> Not used in Thorium. Placeholder to keep resource maps in sync. - - Not used in Thorium. Placeholder to keep resource maps in sync. - + + + + Terms of Service + + + + + Not used in Thorium. Placeholder to keep resource maps in sync. + + + To get future Thorium updates, you'll need macOS 10.15 or later. This computer is using macOS 10.13. @@ -683,11 +692,9 @@ Permissions you've already given to websites and apps may apply to this account. desc="Subpage summary of warning for Deep Scanning."> Thorium recommends scanning this file because it may be dangerous - - - - Thorium blocked this archive file because it may hide malware + + Thorium blocks some downloads @@ -770,11 +777,14 @@ Permissions you've already given to websites and apps may apply to this account. This extension contains malware and is unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info. - - This extension violates the Chrome Web Store policy, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info. + + This extension violates the Thorium Web Store policy, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info. - This extension was unpublished by its developer, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info. + This extension was unpublished by its developer, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info. + + + Thorium recommends you review this extension @@ -945,9 +955,18 @@ Permissions you've already given to websites and apps may apply to this account. - - Customize Thorium - + + + + Customize Thorium for Testing + + + + + Customize Thorium + + + @@ -1057,17 +1076,19 @@ Permissions you've already given to websites and apps may apply to this account. - + {NUM_DEVICES, plural, - =0 {A Thorium extension was accessing HID devices} - =1 {A Thorium extension is accessing 1 HID device} - other {A Thorium extension is accessing # HID devices}} + =0 {1 HID device was being accessed by one or more Thorium extensions} + =1 {1 HID device is being accessed by one or more Thorium extensions} + other {# HID devices are being accessed by one or more Thorium extensions}} - + + + {NUM_DEVICES, plural, - =0 {Thorium extensions were accessing HID devices} - =1 {Thorium extensions are accessing HID devices} - other {Thorium extensions are accessing # HID devices}} + =0 {1 USB device was being accessed by one or more Thorium extensions} + =1 {1 USB device is being accessed by one or more Thorium extensions} + other {# USB devices are being accessed by one or more Thorium extensions}} @@ -1473,8 +1494,8 @@ Permissions you've already given to websites and apps may apply to this account. {COUNT, plural, - =1 {Your organization automatically deletes browsing data when Thorium isn't used for 1 minute. This could include history, autofill, and downloads. Your existing tabs will remain open.} - other {Your organization automatically deletes browsing data when Thorium isn't used for # minutes. This could include history, autofill, and downloads. Your existing tabs will remain open.}} + =1 {Your organization automatically deletes browsing data when Thorium isn't used for 1 minute. This could include history, autofill, and downloads. Your tabs will stay open.} + other {Your organization automatically deletes browsing data when Thorium isn't used for # minutes. This could include history, autofill, and downloads. Your tabs will stay open.}} {COUNT, plural, @@ -1491,13 +1512,11 @@ Permissions you've already given to websites and apps may apply to this account. Help us improve Thorium + - - Your parent has turned off "Permissions for sites, apps and extensions" for Thorium. Adding this $1extension is not allowed. - - - Your parent has turned off "Permissions for sites, apps and extensions" for Thorium. Enabling this $1extension is not allowed. + + Your parent has turned off "Permissions for sites, apps and extensions" for Thorium @@ -1534,9 +1553,6 @@ Permissions you've already given to websites and apps may apply to this account. Set up your new Thorium profile - - Customize your Thorium profile - Each profile holds its own Thorium info like bookmarks, history, passwords, and more @@ -1580,6 +1596,17 @@ Permissions you've already given to websites and apps may apply to this account. + + + Set Thorium as your default browser + + + Use Thorium anytime you click links in messages, documents, and other apps + + + Thorium logo inside a computer screen. + + You can switch between Thorium profiles here diff --git a/src/chrome/app/generated_resources.grd b/src/chrome/app/generated_resources.grd index a52ead15..ab810ecd 100644 --- a/src/chrome/app/generated_resources.grd +++ b/src/chrome/app/generated_resources.grd @@ -311,6 +311,11 @@ are declared in tools/grit/grit_rule.gni. + + + + + @@ -545,6 +550,12 @@ are declared in tools/grit/grit_rule.gni. &Disable Live Caption + + Fill in form + + + Addresses and more + &Back @@ -757,6 +768,9 @@ are declared in tools/grit/grit_rule.gni. Just once + + Recognize visual layout semantics + Use enhanced spell check @@ -1044,6 +1058,9 @@ are declared in tools/grit/grit_rule.gni. Just once + + Recognize Visual Layout Semantics + Use Enhanced Spell Check @@ -1594,6 +1611,12 @@ are declared in tools/grit/grit_rule.gni. Managed by your parent + + Profile managed by $1example.com + + + Your browser and profile are managed + Tips for Thorium @@ -2177,10 +2200,22 @@ are declared in tools/grit/grit_rule.gni. desc="Message shown on chrome://downloads when a download is being scanned"> This file is being scanned. + + This file might be a virus or malware. You can send it to Google to check if it's unsafe. + + + Scanning for malware... + This file could let attackers steal your personal information. + + This file might be a virus or malware. You can send it to Google to check if it's unsafe. + Security checks are done @@ -2201,6 +2236,10 @@ are declared in tools/grit/grit_rule.gni. This file is encrypted. Ask its owner to decrypt. + + Scan failed. This file might be a virus or malware. + Review + + Open anyway + Scan + + Scan for malware + Open + + Open anyway + @@ -2729,6 +2780,30 @@ are declared in tools/grit/grit_rule.gni. + + + Recent Download History + + + Full Download History + + + + + Recent download history + + + Full download history + + + + Show full download history in a new tab + Recent Downloads @@ -2777,6 +2852,22 @@ are declared in tools/grit/grit_rule.gni. desc="When a download has finished deep scanning and the result is safe, let the user know."> Scan is done + + Insecure download blocked + + + Suspicious download blocked + + + Dangerous download blocked + + + Unverified download blocked + Blocked @@ -2789,6 +2880,10 @@ are declared in tools/grit/grit_rule.gni. desc="Let the user know the download is suspicious and may need additional safety checks"> Suspicious + + Scan failed + I understand this download will harm my computer @@ -2797,10 +2892,26 @@ are declared in tools/grit/grit_rule.gni. desc="Label for the Continue button on the blocked download bubble subpage."> Continue download + + Download insecure file + + + Download suspicious file + + + Download unverified file + Delete + + Delete from history + $1bla.exe $2blocked dangerous more details @@ -2823,7 +2934,7 @@ are declared in tools/grit/grit_rule.gni. - Open anyway + Download anyway @@ -2837,6 +2948,10 @@ are declared in tools/grit/grit_rule.gni. desc="Label for the button prompting to retry a failed download."> Try again + + Open anyway + Out of storage space @@ -2901,13 +3016,41 @@ are declared in tools/grit/grit_rule.gni. desc="Status text for a download item when the file could not be finished."> Couldn’t finish download - - Insecure download - - - This file may have been read or edited because this site isn't using a secure connection + This site isn't using a secure connection and the file may have been tampered with + + + This file is dangerous + + + This file is deceptive and may make unexpected changes to your device + + + This file type isn't commonly downloaded and it may be dangerous + + + This file isn't commonly downloaded and it may be dangerous + + + This file can't be verified because Safe Browsing is off + + + Learn why $1Thorium blocks some downloads + + + $1Turn on Safe Browsing to make downloading files safer + + + Turn on Safe Browsing @@ -2962,18 +3105,12 @@ are declared in tools/grit/grit_rule.gni. Your organization blocked this file because it is too big for a security check. You can open files up to 50 MB. - This file might be a virus or malware. - -You can send it to Google to check if it's unsafe. Scans usually take a few seconds. - - - Analysis done by $1Google Safe Browsing + desc="Subpage summary of warning for a file where we recommend sending the file for deep scanning."> + This file might be a virus or malware.$1You can send it to Google Safe Browsing to check if it's unsafe. Scans usually take a few seconds. - Google Safe Browsing + desc="Additional text describing the process of deep scanning a download"> + Learn more about malware scans @@ -2983,6 +3120,10 @@ You can send it to Google to check if it's unsafe. Scans usually take a few seco desc="Subpage secondary text when download deep scanning is in progress"> Scanning for malware... + + Checking with your organization's security policies... + Delete file @@ -3123,6 +3264,10 @@ You can send it to Google to check if it's unsafe. Scans usually take a few seco desc="Accessibility label for retry button."> Retry $1bla.exe + + Open $1bla.exe anyway + Don't show when downloads finish @@ -3137,13 +3282,17 @@ You can send it to Google to check if it's unsafe. Scans usually take a few seco - - This file contains malware that can compromise your personal or social network accounts + This file can harm your personal and social network accounts - - This file contains malware that can compromise your personal or social network accounts, including $1john@google.com + This file can harm your personal and social network accounts, including $1john@google.com + + + This file may hide malware @@ -3616,6 +3765,9 @@ You can send it to Google to check if it's unsafe. Scans usually take a few seco Notifications are automatically blocked for all sites except ones you allow + + Location requests are automatically blocked for all sites except ones you allow + Allow for this site @@ -3655,11 +3807,15 @@ You can send it to Google to check if it's unsafe. Scans usually take a few seco Allow for this site - - - These sites can use info they’ve saved about you as you browse $1example.com. + + These sites can use info they've saved about you as you browse $1parent.com + + + Embedded content on this site can use info they've saved about you + + + Embedded content on this site can't use info they've saved about you - @@ -3699,6 +3855,81 @@ You can send it to Google to check if it's unsafe. Scans usually take a few seco Cookies are files created by websites. There are two types of cookies: First-party cookies are created by the site you visit. The site is shown on the address bar. Third-party cookies are created by other sites. These sites own some of the content, like ads or images, that you see on the website you visit. + + + Third-party cookies blocked + + + Third-party cookies allowed + + + Site not working? + + + Try temporarily allowing third-party cookies, which means less protection but site features are more likely to work + + + Try allowing third-party cookies, which means less protection but site features are more likely to work + + + {COUNT, plural, + =0 {Thorium will block cookies again today} + =1 {Thorium will block cookies again tomorrow} + other {# days until Thorium blocks cookies again}} + + + You allowed this site to use third-party cookies. This means that most site features should work, but you have less protection. + + + You allowed third-party cookies for this site + + + This means that most site features should work, but you have less protection + + + Send feedback + + + Help us improve Thorium by telling us why you allowed third-party cookies + + + Reloading $1example.com... + + + Third-party cookies + + + Tell us why you allowed third-party cookies on this site + + + {COUNT, plural, + =1 {1 site blocked} + other {# sites blocked}} + + + {COUNT, plural, + =1 {1 site allowed} + other {# sites allowed}} + + + Third-party cookies allowed + + + Third-party cookies blocked + + + Third-party cookies blocked + + + If you visit a site that uses cookies, you may need to temporarily enable cookies to make all site features work. + + + Close + + + See how + + @@ -4905,6 +5136,9 @@ You can send it to Google to check if it's unsafe. Scans usually take a few seco Read and change your bookmarks + + Read and change entries in the reading list + Read data you copy and paste @@ -5389,6 +5623,9 @@ You can send it to Google to check if it's unsafe. Scans usually take a few seco Allow $13? + + Allowed + Click to allow "$1Extension A" on $2google.com @@ -5598,6 +5835,10 @@ You can send it to Google to check if it's unsafe. Scans usually take a few seco Activate the extension + + Parent permission request failed. + + Select the root directory of the extension to pack. To update an extension, also select the private key file to reuse. @@ -5707,6 +5948,15 @@ Keep your key file in a safe place. You will need it to create new versions of y Uninstall + + + ''' • ''' + + + {NUM_EXTENSIONS, plural, + =1 {Remove extension?} + other {Remove # extensions?}} + "$1Extension Manager" would like to remove this extension. @@ -5945,7 +6195,10 @@ Keep your key file in a safe place. You will need it to create new versions of y Extensions - More actions + more options + + + Select to see more options for $1MyExtension Pin extension @@ -5992,6 +6245,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Extensions are blocked on this site + + Extensions installed by your administrator can still read and change sites + Extensions can request access to this site @@ -6187,6 +6443,35 @@ Keep your key file in a safe place. You will need it to create new versions of y + + {NUM_SUB_APP_INSTALLS, plural, + =1 {Install app?} + other {Install apps?} + } + + + + {NUM_SUB_APP_INSTALLS, plural, + =1 {"{APP_NAME}Citrix" ({DOMAIN}citrix.com) would like to install the following app on this device:} + other {"{APP_NAME}Citrix" ({DOMAIN}citrix.com) would like to install the following apps on this device:} + } + + + + {NUM_SUB_APP_INSTALLS, plural, + =1 {Permissions that you allow for "{APP_NAME}Citrix" will also be allowed for this app.} + other {Permissions that you allow for "{APP_NAME}Citrix" will also be allowed for these apps.} + } + + + + Install + + + + No thanks + + Customize and control $1GMail @@ -6405,6 +6690,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Quickly use a strong password + + Edit password + @@ -6422,6 +6710,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Quickly Use a Strong Password + + Edit Password + @@ -6557,6 +6848,20 @@ Keep your key file in a safe place. You will need it to create new versions of y App ($1com.netflix.mediaclient) + + Got it + + + $1Elisa Becket has shared a password with you for $2amazon.com. You can use it in the sign-in form. + + + There are passwords shared with you for $1amazon.com. You can use them in the sign-in form. + + + {NUM_PASSWORDS, plural, + =1 {New password for this site} + other {New passwords for this site}} + Save your passwords? @@ -7043,6 +7348,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Edit shortcut + + More actions for $1YouTube shortcut + *.jpeg, *.jpg, *.png @@ -7172,17 +7480,20 @@ Keep your key file in a safe place. You will need it to create new versions of y Color and theme - - Classic Thorium + + Default Thorium - + Thorium Colors Change theme - - Reset to Classic Thorium + + Reset to Default Thorium + + + Follow device colors Uploaded image @@ -7244,6 +7555,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Default color + + Grey default color + Color based on theme @@ -7313,6 +7627,36 @@ Keep your key file in a safe place. You will need it to create new versions of y Dark purple + + Blue + + + Grey + + + Aqua + + + Green + + + Viridian + + + Citron + + + Apricot + + + Rose + + + Fuchsia + + + Violet + You won't see this specific message again @@ -7326,7 +7670,13 @@ Keep your key file in a safe place. You will need it to create new versions of y Dark - System + Device + + + You can find older colors in the Thorium Web Store + + + Find themes @@ -7345,9 +7695,15 @@ Keep your key file in a safe place. You will need it to create new versions of y Hide $1Office Chairs - + Never show $1shopping suggestions + + Don't show $1shopping suggestions + + + More actions for $1shopping suggestions + Customize cards @@ -7444,6 +7800,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Google Drive files + + Drive + Drive files @@ -7459,12 +7818,12 @@ Keep your key file in a safe place. You will need it to create new versions of y Super Duper Module - - Even Better Module - From your Google Drive + + From Your Drive + You’re seeing suggested files to help you easily get back to your most recent activity in Google Drive. <br> @@ -7673,21 +8032,36 @@ Keep your key file in a safe place. You will need it to create new versions of y <br> You can manage settings from the card menu or see more options in Customize Thorium. + + You’re seeing suggested searches and shopping discounts that might interest you based on your recent activity. + <br> + <br> + You can manage settings from this card anytime or see more options in Customize Thorium. + Journeys this type of card + + No longer interested + Journeys card this card + + Mark as done and hide + Open all in new tab group + + Open in side panel + Show all searches for $1Office Chairs @@ -7944,7 +8318,7 @@ Keep your key file in a safe place. You will need it to create new versions of y No results found - There are no bookmarks that match your search. + There are no bookmarks that match your search ($11) @@ -8042,6 +8416,12 @@ Keep your key file in a safe place. You will need it to create new versions of y Select + + Results found in $1All Bookmarks + + + In other folders + @@ -8066,6 +8446,12 @@ Keep your key file in a safe place. You will need it to create new versions of y Text formatting + + Display + + + Font size + Font @@ -8076,7 +8462,7 @@ Keep your key file in a safe place. You will need it to create new versions of y Increase font-size - Theme + Color theme Line height @@ -8117,6 +8503,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Getting ready + + Back + To show a simplified view of this page, open the side panel and select Reading mode @@ -8318,6 +8707,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Can't save card right now + + Save CVC + Save IBAN @@ -8406,6 +8798,9 @@ Keep your key file in a safe place. You will need it to create new versions of y Get Started + + No Thanks + @@ -8417,15 +8812,18 @@ Keep your key file in a safe place. You will need it to create new versions of y Get started + + No thanks + You can access it on Google Password Manager. - - To use your saved passwords on your phone, download Thorium for iOS and sync your account. + + To use your saved passwords on your phone, download Thorium for iOS and sign in to your Google Account. - - To use your saved passwords on your phone, follow the QR code, download Thorium for iOS and sync your account. + + To use your saved passwords on your phone, follow the QR code, download Thorium for iOS and sign in to your Google Account. @@ -8588,6 +8986,22 @@ Keep your key file in a safe place. You will need it to create new versions of y Thorium tip + + See what extensions can read or change a site + + + From here, you can see and manage extension permissions for the site you're on + + + {NUM_EXTENSIONS, plural, + =1 {Choose if this extension can read or change this site} + other {Choose if these extensions can read or change this site}} + + + {NUM_EXTENSIONS, plural, + =1 {To manage it, open Extensions} + other {To manage them, open Extensions}} + New! Control your music, videos, and more. @@ -8745,6 +9159,17 @@ Keep your key file in a safe place. You will need it to create new versions of y Try using the side panel for bookmarks, journeys, and more + + + Thorium theme colors have been refreshed to work better for everyone, whether you’re in dark or light mode + + + Customize the appearance of Thorium and this page + + + Customize themes + + Customize Thorium to give your browser a new look @@ -8772,6 +9197,16 @@ Keep your key file in a safe place. You will need it to create new versions of y Open the menu + + + Click “Passwords and Autofill” + + + + + Click “Passwords and autofill” + + Click “Settings” @@ -8984,6 +9419,9 @@ Check your passwords anytime in $1Google Protect your passwords + + New password received + Import Passwords To Thorium @@ -9302,10 +9740,22 @@ Check your passwords anytime in $1Google None available + + + A site is playing media + + (Thorium error pages) + + Embedded content + + + Go to embedded content settings + + @@ -9538,6 +9988,9 @@ Check your passwords anytime in $1Google Close tabs to the left + + Close all tabs + Focus this tab @@ -9635,6 +10088,9 @@ Check your passwords anytime in $1Google Close Tabs to the Left + + Close All Tabs + Focus This Tab @@ -9815,6 +10271,9 @@ Check your passwords anytime in $1Google Save group + + Unsave group + New tab in group @@ -9844,6 +10303,9 @@ Check your passwords anytime in $1Google Save Group + + Unsave Group + New Tab in Group @@ -10118,7 +10580,10 @@ Check your passwords anytime in $1Google Your administrator recommends a specific value for this setting. - This setting can't be changed by a child user. + This setting isn't available for your account. + + + This setting is managed by a parent. @@ -10829,6 +11294,18 @@ Check your passwords anytime in $1Google Your <a href="$1">browser is managed</a> by $2example.com + + Your <a href="$1">profile is managed</a> by $2example.com + + + Your <a href="$1">browser is managed</a> by your organization and your <a href="$1">profile is managed</a> by $2bar.com + + + Your <a href="$1">browser is managed</a> by $2foo.com and your <a href="$1">profile is managed</a> by $3bar.com + + + Your <a href="$1">browser and profile are managed</a> by $2google.com + Your <a href="$1">browser is managed</a> by your parent @@ -11213,23 +11690,23 @@ Check your passwords anytime in $1Google - Share device signals? + Share information about your device? - Share signals + Share - Close profile + Decline and close profile - This profile is managed by $1example.com. To continue using this managed profile, your organization requires you to share your device signals. + To use your device with your $1example.com profile, your organization needs information about the device. -Device signals can include information about your browser, OS, device, installed software, and files. +This can include information about installed software, files, your browser, and the device’s operating system. - This profile is managed by your organization. To continue using this managed profile, your organization requires you to share your device signals. + To use your device with your organization profile, your organization needs information about the device. -Device signals can include information about your browser, OS, device, installed software, and files. +This can include information about installed software, files, your browser, and the device’s operating system. @@ -12529,7 +13006,7 @@ Please help our engineers fix this problem. Tell us what happened right before y Location is turned off in Mac System Preferences - Turn on "Thorium" in Location Services on your Mac + Turn on "Google Thorium" in Location Services on your Mac @@ -13053,6 +13530,9 @@ Please help our engineers fix this problem. Tell us what happened right before y Linux apps + + Bruschetta apps + @@ -13097,6 +13577,18 @@ Please help our engineers fix this problem. Tell us what happened right before y Also share system audio. This device will be muted to prevent feedback. + + Also share system audio + + + Also share tab audio + + + To share audio, share a tab instead + + + To share audio, share a tab or screen instead + Entire Screen @@ -13463,6 +13955,9 @@ Please help our engineers fix this problem. Tell us what happened right before y Extensions + + Display + File Info @@ -13494,13 +13989,19 @@ Please help our engineers fix this problem. Tell us what happened right before y - + HID settings About HID devices + + USB settings + + + About USB devices + @@ -13509,9 +14010,15 @@ Please help our engineers fix this problem. Tell us what happened right before y =2 {Extensions accessing devices: {1}Google Translate, {2}Secure Shell} other {Extensions accessing devices: {1}Google Translate, {2}Secure Shell +{3} more}} + + {NUM_EXTENSION, plural, + =1 {{1}Google Translate is accessing USB devices} + =2 {Extensions accessing devices: {1}Google Translate, {2}Secure Shell} + other {Extensions accessing devices: {1}Google Translate, {2}Secure Shell +{3} more}} + - + {NUM_CONNECTION, plural, =0 {Extension "{1}Google Translate" was accessing devices} =1 {Extension "{1}Google Translate" is accessing {0} device} @@ -13811,10 +14318,10 @@ Please help our engineers fix this problem. Tell us what happened right before y - Browse fast with Thorium + Browse fast with Google Thorium - Browse safely with Thorium + Browse safely with Google Thorium Browse smart with Thorium @@ -13832,7 +14339,7 @@ Please help our engineers fix this problem. Tell us what happened right before y Switch to a smart and secure browser - Alex313031 recommends Thorium + Google recommends Thorium Open Thorium @@ -14643,6 +15150,9 @@ Please help our engineers fix this problem. Tell us what happened right before y Please enter a reason for uploading this data: + + Please enter a reason for downloading this data: + $110/$2280 @@ -14788,6 +15298,16 @@ Please help our engineers fix this problem. Tell us what happened right before y other {Uninstalling "{APP_NAME}Citrix" will also uninstall these apps:}} + + {NUM_SUB_APPS, plural, + =1 {{APP_NAME}Citrix uninstalled an app} + other {{APP_NAME}Citrix uninstalled # apps}} + + + + Go to the "{APP_NAME}Citrix" app to manage installed and streamed apps + + Speech recognition service @@ -14944,7 +15464,7 @@ Please help our engineers fix this problem. Tell us what happened right before y - Select image area to search + Select an area to search with Lens @@ -15349,25 +15869,34 @@ Please help our engineers fix this problem. Tell us what happened right before y - - - + + Lorem ipsum dolor sit amet - - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore. + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut - - First button + labore - - Second button + Button + + + Lorem ipsum dolor sit amet + + + + Protected Audiences Debugging is enabled. + diff --git a/src/chrome/app/settings_chromium_strings.grdp b/src/chrome/app/settings_chromium_strings.grdp index baaee90d..45316a74 100644 --- a/src/chrome/app/settings_chromium_strings.grdp +++ b/src/chrome/app/settings_chromium_strings.grdp @@ -108,7 +108,7 @@ - This is a secondary installation of Chromium, and cannot be made your default browser. + This is a secondary installation of Thorium, and cannot be made your default browser. @@ -145,8 +145,8 @@ Sites will probably work as you expect but won't remember you after you close all Thorium windows - - Always clear site data from your device when you close Thorium + + Always delete site data from your device when you close Thorium @@ -165,9 +165,15 @@ Choose whether to include Thorium history for more personalized experiences in Google services + + If you also save your bookmarks in your Google Account, you can track product prices in Thorium and get notified when the price drops + If you also share Thorium usage reports, those reports include the URLs you visit + + Depending on your settings, Thorium may also send cookies and your current URL + @@ -330,4 +336,9 @@ Information about how Thorium manages its root certificates + + + + Thorium regularly checks to make sure your browser has the safest settings. We'll let you know if anything needs your review. + diff --git a/src/chrome/app/settings_strings.grdp b/src/chrome/app/settings_strings.grdp index 008590f5..583ae12f 100644 --- a/src/chrome/app/settings_strings.grdp +++ b/src/chrome/app/settings_strings.grdp @@ -47,6 +47,10 @@ Report an issue + + Privacy policy + + Send feedback @@ -128,21 +132,19 @@ Automatically translates captions - + Automatically creates captions for media in Thorium browser (currently available in English). Audio and captions are processed locally and never leave the device. - + Automatically creates captions for media in Thorium browser. Audio and captions are processed locally and never leave the device. - - - Automatically creates captions for English audio and video. Audio and captions never leave your device. - - - Automatically creates captions for audio and video. Audio and captions never leave your device. - - + + Automatically creates captions for English audio and video. Audio and captions never leave your device. + + + Automatically creates captions for audio and video. Audio and captions never leave your device. + Downloading speech recognition files... $117% @@ -155,6 +157,9 @@ Can't install speech files. Your device needs to be updated. Restart your device and try again. + + Hide profanity + Navigate pages with a text cursor @@ -230,6 +235,9 @@ Thorium Colors + + Mode + Show home button @@ -387,9 +395,6 @@ Title - - Type - Enable Autofill to fill out forms in a single click @@ -417,9 +422,6 @@ Edit in Google Pay - - (Virtual card enabled) - Virtual card turned on @@ -684,9 +686,12 @@ Automatically sign in to sites and apps using saved credentials. If turned off, you'll be asked for confirmation every time before signing in to a site or app. - + Warn you if passwords are exposed in a data breach + + Warn you if a password was compromised in a data breach + When you sign in to your Google Account, this feature is turned on. @@ -1408,7 +1413,7 @@ Browsing history - Signs you out of most sites. + Signs you out of most sites Signs you out of most sites. You'll stay signed in to your Google Account so your synced data can be cleared. @@ -1644,9 +1649,6 @@ Websites will show content in your preferred languages, when possible - - Offer to translate pages in this language - Use Google Translate @@ -2074,7 +2076,7 @@ When on, a list of sites you visit that guess your interests appears here - It can take up to a week for a list of sites to appear here based on your browsing history + No sites to show right now List of recent sites you visited that can suggest ads to other sites as you keep browsing @@ -2225,10 +2227,10 @@ You'll browse faster because content is proactively loaded based on your current webpage visit - You'll get improved suggestions in the address bar + From the address bar, you can open page info to see additional info about the page you're visiting - URLs you visit are sent to Google to predict what sites you might visit next + URLs you visit are sent to Google to predict what sites you might visit next and to show you additional info about the page you're visiting Choose whether to sync history @@ -2290,6 +2292,15 @@ Detects and warns you about dangerous events when they happen + + Choose whether to get additional search suggestions + + + When you click or type in the address bar or search box, you'll see suggestions from your default search engine. This is off in Incognito. + + + What you type in the address bar or search box is sent to your default search engine + @@ -2402,6 +2413,14 @@ Permissions allowed again for $1www.example.com + + + Automatically remove permissions from unused sites + + + + To protect your data, remove permissions from sites you haven't visited in 2 months. Doesn't stop notifications. + Updates @@ -2585,6 +2604,9 @@ Standard protection against websites, downloads, and extensions that are known to be dangerous + + Protects against sites, downloads, and extensions that are known to be dangerous. If a page does something suspicious, URLs and bits of page content are sent to Google Safe Browsing. + Show standard protection details @@ -3241,7 +3263,7 @@ Not allowed to use your microphone - Sites usually connect to MIDI devices for features for creating and editing music + Sites usually connect to MIDI devices for creating and editing music Sites can ask to connect to MIDI devices @@ -3722,7 +3744,7 @@ Remove - Clear on exit + Delete on exit Usage @@ -3761,19 +3783,16 @@ Reset permissions - Clear data - - - Clear data + Delete data Including third-party cookies on this site - - Clear all data? + + Delete all data? - - Clear displayed data? + + Delete displayed data? These sites are in a group defined by $1google.com. Sites in a group can see your activity in the group. @@ -3787,11 +3806,11 @@ Total storage used by displayed sites: $18 GB - - Clear all data + + Delete all data - - Clear displayed data + + Delete displayed data Show site details for $1google.com @@ -3807,20 +3826,20 @@ Show sites in same group - - Clear data and permissions + + Delete data and permissions - - This will clear $18 GB of data stored by sites + + This will delete $18 GB of data stored by sites - - This will clear $18 GB of data stored by displayed sites + + This will delete $18 GB of data stored by displayed sites - - This will clear $18 GB of data stored by sites and installed apps + + This will delete $18 GB of data stored by sites and installed apps - - This will clear $18 GB of data stored by displayed sites and installed apps + + This will delete $18 GB of data stored by displayed sites and installed apps You'll be signed out of all sites, including in open tabs @@ -3831,8 +3850,8 @@ Reset site permissions for $1www.example.com? - - Clear site data? + + Delete site data? All data stored by $1www.example.com will be deleted. @@ -3843,32 +3862,32 @@ You’ll be signed out of this site, including in open tabs - - Any offline data will be cleared + + Any offline data will be deleted Data that affects ad personalization is deleted - - Any offline data will be cleared + + Any offline data will be deleted - Clear site data and permissions for $1www.example.com? + Delete site data and permissions for $1www.example.com? - Clear site data and permissions for $1www.example.com and its installed app? + Delete site data and permissions for $1www.example.com and its installed app? - Clear site data for $1www.ad-tech.com partitioned on $2www.publisher.com? + Delete site data for $1www.ad-tech.com partitioned on $2www.publisher.com? - Clear site data and permissions for $1www.example.com and all sites under it? + Delete site data and permissions for $1www.example.com and all sites under it? - Clear site data and permissions for $1www.example.com, all sites under it, and its installed app? + Delete site data and permissions for $1www.example.com, all sites under it, and its installed app? - Clear site data and permissions for $1www.example.com, all sites under it, and installed apps? + Delete site data and permissions for $1www.example.com, all sites under it, and installed apps? You'll be signed out of this site, including in open tabs @@ -3877,13 +3896,13 @@ You'll be signed out of these sites, including in open tabs - Any offline data will be cleared + Any offline data will be deleted - Your chosen permissions will be reset + Your chosen permissions will be removed - Clear + Delete Remove $1google.com @@ -3892,7 +3911,7 @@ Reset - Clear + Delete Default @@ -3948,8 +3967,14 @@ Sites aren't allowed to save data on your device - - Site data is cleared from your device when you close all windows + + Site data is deleted from your device when you close all windows + + + {COUNT, plural, + =0 {Expires today} + =1 {Expires tomorrow} + other {Expires in # days}} @@ -4006,21 +4031,38 @@ - - - Sites you visit can embed content from other sites, for example images, ads, and text. These other sites can ask for permission to use info they’ve saved about you as you browse the site. + + Sites you visit can embed content from other sites, for example images, ads, and text. These other sites can ask for permission to use info they've saved about you as you browse the site. - - Sites can ask to use info they’ve saved about you + + Sites can ask to use info they've saved about you - - Sites are blocked from asking you to use info they’ve saved about you + + Sites are blocked from asking you to use info they've saved about you - - Allowed to access info they've about you while embedded in another site + + You allowed these sites to use info they've saved about you - - Not allowed to access info they've about you while embedded in another site + + You blocked these sites from using info they've saved about you + + + Remove $1google.com + + + Remove $1embedding.com from $2top-level.com + + + Show sites + + + Show less + + + can use your info as you browse + + + is blocked from using your info on @@ -4604,4 +4646,21 @@ $1Google Docs Offline (ID: $2ghbmnnjooekpmoecnnnilnnbdlolhkhi) + + + + Safety Hub + + + Go to Safety Hub + + + Safety at a glance + + + Safety recommendation + + + Safety tips + diff --git a/src/chrome/app/shared_settings_strings.grdp b/src/chrome/app/shared_settings_strings.grdp index c30dfb0a..8196cb62 100644 --- a/src/chrome/app/shared_settings_strings.grdp +++ b/src/chrome/app/shared_settings_strings.grdp @@ -304,6 +304,9 @@ Open tabs + + Saved tab groups + Wi-Fi networks diff --git a/src/chrome/browser/background/background_mode_manager.cc b/src/chrome/browser/background/background_mode_manager.cc index d5071555..fc4b890a 100644 --- a/src/chrome/browser/background/background_mode_manager.cc +++ b/src/chrome/browser/background/background_mode_manager.cc @@ -688,7 +688,7 @@ void BackgroundModeManager::StartBackgroundMode() { if (in_background_mode_) return; - startup_metric_utils::SetBackgroundModeEnabled(); + startup_metric_utils::GetBrowser().SetBackgroundModeEnabled(); // Mark ourselves as running in background mode. in_background_mode_ = true; diff --git a/src/chrome/browser/ui/browser_ui_prefs.cc b/src/chrome/browser/ui/browser_ui_prefs.cc index 496f57e0..14c80292 100644 --- a/src/chrome/browser/ui/browser_ui_prefs.cc +++ b/src/chrome/browser/ui/browser_ui_prefs.cc @@ -167,4 +167,7 @@ void RegisterBrowserUserPrefs(user_prefs::PrefRegistrySyncable* registry) { user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterListPref(prefs::kHttpAllowlist); registry->RegisterBooleanPref(prefs::kHttpsUpgradesEnabled, true); + + registry->RegisterDictionaryPref(prefs::kHttpsUpgradeFallbacks); + registry->RegisterBooleanPref(prefs::kHttpsOnlyModeAutoEnabled, false); } diff --git a/src/chrome/browser/ui/startup/infobar_utils.cc b/src/chrome/browser/ui/startup/infobar_utils.cc index 3604df11..1fc7c1a6 100644 --- a/src/chrome/browser/ui/startup/infobar_utils.cc +++ b/src/chrome/browser/ui/startup/infobar_utils.cc @@ -15,6 +15,7 @@ #include "chrome/browser/ui/session_crashed_bubble.h" #include "chrome/browser/ui/startup/automation_infobar_delegate.h" #include "chrome/browser/ui/startup/bad_flags_prompt.h" +#include "chrome/browser/ui/startup/bidding_and_auction_consented_debugging_infobar_delegate.h" #include "chrome/browser/ui/startup/default_browser_prompt.h" #include "chrome/browser/ui/startup/google_api_keys_infobar_delegate.h" #include "chrome/browser/ui/startup/obsolete_system_infobar_delegate.h" @@ -96,6 +97,11 @@ void AddInfoBarsIfNecessary(Browser* browser, if (IsAutomationEnabled()) AutomationInfoBarDelegate::Create(); + + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kProtectedAudiencesConsentedDebugToken)) { + BiddingAndAuctionConsentedDebuggingDelegate::Create(web_contents); + } } // Do not show any other info bars in Kiosk mode, because it's unlikely that diff --git a/src/components/privacy_sandbox/privacy_sandbox_prefs.cc b/src/components/privacy_sandbox/privacy_sandbox_prefs.cc deleted file mode 100644 index 53b485e9..00000000 --- a/src/components/privacy_sandbox/privacy_sandbox_prefs.cc +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2023 The Chromium Authors and Alex313031 -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/privacy_sandbox/privacy_sandbox_prefs.h" - -#include "components/pref_registry/pref_registry_syncable.h" -#include "components/prefs/pref_registry_simple.h" - -namespace prefs { - -const char kPrivacySandboxM1ConsentDecisionMade[] = - "privacy_sandbox.m1.consent_decision_made"; - -const char kPrivacySandboxM1EEANoticeAcknowledged[] = - "privacy_sandbox.m1.eea_notice_acknowledged"; - -const char kPrivacySandboxM1RowNoticeAcknowledged[] = - "privacy_sandbox.m1.row_notice_acknowledged"; - -const char kPrivacySandboxM1RestrictedNoticeAcknowledged[] = - "privacy_sandbox.m1.restricted_notice_acknowledged"; - -const char kPrivacySandboxM1PromptSuppressed[] = - "privacy_sandbox.m1.prompt_suppressed"; - -const char kPrivacySandboxM1TopicsEnabled[] = - "privacy_sandbox.m1.topics_enabled"; - -const char kPrivacySandboxM1FledgeEnabled[] = - "privacy_sandbox.m1.fledge_enabled"; - -const char kPrivacySandboxM1AdMeasurementEnabled[] = - "privacy_sandbox.m1.ad_measurement_enabled"; - -const char kPrivacySandboxM1Restricted[] = "privacy_sandbox.m1.restricted"; - -const char kPrivacySandboxM1Unrestricted[] = "privacy_sandbox.m1.unrestricted"; - -const char kPrivacySandboxApisEnabled[] = "privacy_sandbox.apis_enabled"; - -const char kPrivacySandboxApisEnabledV2[] = "privacy_sandbox.apis_enabled_v2"; - -const char kPrivacySandboxManuallyControlled[] = - "privacy_sandbox.manually_controlled"; - -const char kPrivacySandboxManuallyControlledV2[] = - "privacy_sandbox.manually_controlled_v2"; - -const char kPrivacySandboxPageViewed[] = "privacy_sandbox.page_viewed"; - -const char kPrivacySandboxTopicsDataAccessibleSince[] = - "privacy_sandbox.topics_data_accessible_since"; - -const char kPrivacySandboxBlockedTopics[] = "privacy_sandbox.blocked_topics"; - -extern const char kPrivacySandboxFledgeJoinBlocked[] = - "privacy_sandbox.fledge_join_blocked"; - -extern const char kPrivacySandboxNoticeDisplayed[] = - "privacy_sandbox.notice_displayed"; - -extern const char kPrivacySandboxConsentDecisionMade[] = - "privacy_sandbox.consent_decision_made"; - -extern const char kPrivacySandboxNoConfirmationSandboxDisabled[] = - "privacy_sandbox.no_confirmation_sandbox_disabled"; - -extern const char kPrivacySandboxNoConfirmationSandboxRestricted[] = - "privacy_sandbox.no_confirmation_sandbox_restricted"; - -extern const char kPrivacySandboxNoConfirmationSandboxManaged[] = - "privacy_sandbox.no_confirmation_sandbox_managed"; - -extern const char kPrivacySandboxNoConfirmationThirdPartyCookiesBlocked[] = - "privacy_sandbox.no_confirmation_3PC_blocked"; - -extern const char kPrivacySandboxNoConfirmationManuallyControlled[] = - "privacy_sandbox.no_confirmation_manually_controlled"; - -extern const char kPrivacySandboxDisabledInsufficientConfirmation[] = - "privacy_sandbox.disabled_insufficient_confirmation"; - -extern const char kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized[] = - "privacy_sandbox.first_party_sets_data_access_allowed_initialized"; - -extern const char kPrivacySandboxFirstPartySetsEnabled[] = - "privacy_sandbox.first_party_sets_enabled"; - -extern const char kPrivacySandboxTopicsConsentGiven[] = - "privacy_sandbox.topics_consent.consent_given"; - -extern const char kPrivacySandboxTopicsConsentLastUpdateTime[] = - "privacy_sandbox.topics_consent.last_update_time"; - -extern const char kPrivacySandboxTopicsConsentLastUpdateReason[] = - "privacy_sandbox.topics_consent.last_update_reason"; - -extern const char kPrivacySandboxTopicsConsentTextAtLastUpdate[] = - "privacy_sandbox.topics_consent.text_at_last_update"; - -extern const char kPrivacySandboxAntiAbuseInitialized[] = - "privacy_sandbox.anti_abuse_initialized"; - -} // namespace prefs - -namespace privacy_sandbox { - -void RegisterProfilePrefs(PrefRegistrySimple* registry) { - registry->RegisterBooleanPref( - prefs::kPrivacySandboxApisEnabled, true, - user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); - registry->RegisterBooleanPref(prefs::kPrivacySandboxApisEnabledV2, true); - registry->RegisterBooleanPref(prefs::kPrivacySandboxM1ConsentDecisionMade, - false); - registry->RegisterBooleanPref(prefs::kPrivacySandboxM1EEANoticeAcknowledged, - false); - registry->RegisterBooleanPref(prefs::kPrivacySandboxM1RowNoticeAcknowledged, - false); - registry->RegisterBooleanPref( - prefs::kPrivacySandboxM1RestrictedNoticeAcknowledged, false); - registry->RegisterIntegerPref(prefs::kPrivacySandboxM1PromptSuppressed, 0); - registry->RegisterBooleanPref(prefs::kPrivacySandboxM1TopicsEnabled, false); - registry->RegisterBooleanPref(prefs::kPrivacySandboxM1FledgeEnabled, false); - registry->RegisterBooleanPref(prefs::kPrivacySandboxM1AdMeasurementEnabled, - false); - registry->RegisterBooleanPref(prefs::kPrivacySandboxM1Restricted, false); - registry->RegisterBooleanPref(prefs::kPrivacySandboxM1Unrestricted, false); - - registry->RegisterBooleanPref( - prefs::kPrivacySandboxManuallyControlled, false, - user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); - registry->RegisterBooleanPref(prefs::kPrivacySandboxManuallyControlledV2, - false); - registry->RegisterBooleanPref(prefs::kPrivacySandboxPageViewed, false); - registry->RegisterTimePref(prefs::kPrivacySandboxTopicsDataAccessibleSince, - base::Time()); - registry->RegisterListPref(prefs::kPrivacySandboxBlockedTopics); - registry->RegisterDictionaryPref(prefs::kPrivacySandboxFledgeJoinBlocked); - registry->RegisterBooleanPref(prefs::kPrivacySandboxNoticeDisplayed, false); - registry->RegisterBooleanPref(prefs::kPrivacySandboxConsentDecisionMade, - false); - registry->RegisterBooleanPref( - prefs::kPrivacySandboxNoConfirmationSandboxDisabled, false); - registry->RegisterBooleanPref( - prefs::kPrivacySandboxNoConfirmationSandboxRestricted, false); - registry->RegisterBooleanPref( - prefs::kPrivacySandboxNoConfirmationSandboxManaged, false); - registry->RegisterBooleanPref( - prefs::kPrivacySandboxNoConfirmationThirdPartyCookiesBlocked, false); - registry->RegisterBooleanPref( - prefs::kPrivacySandboxNoConfirmationManuallyControlled, false); - registry->RegisterBooleanPref( - prefs::kPrivacySandboxDisabledInsufficientConfirmation, false); - registry->RegisterBooleanPref( - prefs::kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized, false); - registry->RegisterBooleanPref( - prefs::kPrivacySandboxFirstPartySetsEnabled, true, - user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); - - registry->RegisterBooleanPref(prefs::kPrivacySandboxTopicsConsentGiven, - false); - registry->RegisterTimePref(prefs::kPrivacySandboxTopicsConsentLastUpdateTime, - base::Time()); - registry->RegisterIntegerPref( - prefs::kPrivacySandboxTopicsConsentLastUpdateReason, - static_cast(TopicsConsentUpdateSource::kDefaultValue)); - registry->RegisterStringPref( - prefs::kPrivacySandboxTopicsConsentTextAtLastUpdate, ""); - registry->RegisterBooleanPref(prefs::kPrivacySandboxAntiAbuseInitialized, - false); -} - -} // namespace privacy_sandbox