Skip to content

Commit

Permalink
pw_build: Enable fixed point types for clang builds
Browse files Browse the repository at this point in the history
Bug: b/323425639
Change-Id: Ibef2e8f50b1d1a64bee3e0dade239eb02a42320d
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/190097
Commit-Queue: Leonard Chan <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
Reviewed-by: Wyatt Hepler <[email protected]>
  • Loading branch information
PiJoules authored and CQ Bot Account committed Feb 2, 2024
1 parent 3693d2a commit a3cda56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pw_build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import("target_types.gni")
# IMPORTANT: The compilation flags in this file must be kept in sync with
# the CMake flags pw_build/CMakeLists.txt.

# TODO: b/301262374 - Provide a better way to detect the compiler type.
is_clang = defined(pw_toolchain_SCOPE.cc) &&
get_path_info(pw_toolchain_SCOPE.cc, "file") == "clang"

config("colorize_output") {
if (pw_build_COLORIZE_OUTPUT) {
cflags = [
Expand Down Expand Up @@ -67,6 +71,12 @@ config("optimize_size") {
ldflags = cflags
}

config("enable_clang_fixed_point_types") {
if (is_clang) {
cflags = [ "-ffixed-point" ]
}
}

config("enable_clang_mlinliner") {
cflags = [
# Enable ML inliner.
Expand Down Expand Up @@ -169,9 +179,7 @@ config("extra_strict_warnings") {
config("internal_strict_warnings") {
cflags = [ "-Wswitch-enum" ]

# TODO: b/301262374 - Provide a better way to detect the compiler type.
if (defined(pw_toolchain_SCOPE.cc) &&
get_path_info(pw_toolchain_SCOPE.cc, "file") == "clang") {
if (is_clang) {
cflags += [ "-Wextra-semi" ]
} else {
# TODO: b/306734552 - On GCC, this only works as a C++ flag.
Expand Down
1 change: 1 addition & 0 deletions pw_build/defaults.gni
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pigweed_default_configs = [
"$dir_pw_build:strict_warnings",
"$dir_pw_build:toolchain_cpp_standard",
"$dir_pw_build:relative_paths",
"$dir_pw_build:enable_clang_fixed_point_types",
]

# Some Projects rely on this, so it is being retained for backwards
Expand Down

0 comments on commit a3cda56

Please sign in to comment.