-- Allow building pdfium on FreeBSD by treating FreeBSD as a Linux-like -- target for toolchain selection and default library configuration. -- Also disable the UBSan array-bounds/return hardening configs, which are not -- supported by the Clang used for this FreeBSD port and alter test semantics. --- build/config/BUILDCONFIG.gn.orig 2026-09-24 10:29:01 UTC +++ build/config/BUILDCONFIG.gn @@ -222,7 +222,7 @@ if (host_toolchain == "") { # TODO(dpranke): Add some sort of assert here that verifies that # no toolchain omitted host_toolchain from its toolchain_args(). - if (host_os == "linux") { + if (host_os == "linux" || host_os == "freebsd") { if (target_os != "linux") { host_toolchain = "//build/toolchain/linux:clang_$host_cpu" } else if (is_clang) { @@ -262,7 +262,7 @@ if (target_os == "android") { # Targeting android on Mac is best-effort and not guaranteed to work. assert(host_os == "linux", "Android builds are only supported on Linux.") _default_toolchain = "//build/toolchain/android:android_clang_$target_cpu" -} else if (target_os == "chromeos" || target_os == "linux") { +} else if (target_os == "chromeos" || target_os == "linux" || target_os == "freebsd") { # See comments in build/toolchain/cros/BUILD.gn about board compiles. if (is_clang) { _default_toolchain = "//build/toolchain/linux:clang_$target_cpu" @@ -335,7 +335,7 @@ is_ios = current_os == "ios" is_chromeos = current_os == "chromeos" is_fuchsia = current_os == "fuchsia" is_ios = current_os == "ios" -is_linux = current_os == "linux" +is_linux = current_os == "linux" || current_os == "freebsd" is_mac = current_os == "mac" is_wasm = current_os == "emscripten" is_watchos = current_os == "watchos" @@ -381,8 +381,6 @@ default_compiler_configs = [ "//build/config/compiler:no_rtti", "//build/config/compiler:no_unresolved_symbols", "//build/config/compiler:runtime_library", - "//build/config/compiler:sanitize_c_array_bounds", - "//build/config/compiler:sanitize_return", "//build/config/compiler:thin_archive", "//build/config/compiler:thinlto_optimize_default", "//build/config/compiler:tot_warnings", @@ -391,6 +389,13 @@ default_compiler_configs = [ "//build/config:feature_flags", ] +if (current_os != "freebsd") { + default_compiler_configs += [ + "//build/config/compiler:sanitize_c_array_bounds", + "//build/config/compiler:sanitize_return", + ] +} + if (is_win) { default_compiler_configs += [ "//build/config/win:default_cfg_compiler", @@ -625,10 +630,6 @@ foreach(_target_type, not_needed([ "strict_deps" ]) } - if (!defined(generate_modulemap)) { - generate_modulemap = default_modulemap_mode - } - if (use_libcxx_modules) { # Add a dependency needed for Clang modules builds. deps += [ "//buildtools/third_party/libc++:all_modules" ] @@ -759,10 +760,6 @@ foreach(_target_type, } } else { not_needed([ "strict_deps" ]) - } - - if (!defined(generate_modulemap)) { - generate_modulemap = default_modulemap_mode } if (use_libcxx_modules) {