Skip to content

Commit

Permalink
Merge pull request #348 from keith:ks/osize
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 281091576
  • Loading branch information
swiple-rules-gardener committed Nov 21, 2019
2 parents 31bae7a + 9f4202b commit e8b14ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion swift/internal/api.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ load(
"SWIFT_FEATURE_NO_GENERATED_HEADER",
"SWIFT_FEATURE_NO_GENERATED_MODULE_MAP",
"SWIFT_FEATURE_OPT",
"SWIFT_FEATURE_OPT_USES_OSIZE",
"SWIFT_FEATURE_OPT_USES_WMO",
"SWIFT_FEATURE_SUPPORTS_LIBRARY_EVOLUTION",
"SWIFT_FEATURE_USE_GLOBAL_MODULE_CACHE",
Expand Down Expand Up @@ -300,7 +301,15 @@ def _compilation_mode_copts(feature_configuration):
# https://docs.bazel.build/versions/master/user-manual.html#flag--compilation_mode
flags = []
if is_opt:
flags.extend(["-O", "-DNDEBUG"])
flags.append("-DNDEBUG")
if _is_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE_OPT_USES_OSIZE,
):
flags.append("-Osize")
else:
flags.append("-O")

if _is_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE_OPT_USES_WMO,
Expand Down
4 changes: 4 additions & 0 deletions swift/internal/features.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ SWIFT_FEATURE_NO_GENERATED_MODULE_MAP = "swift.no_generated_module_map"
# the `-whole-module-optimization` flag (in addition to `-O`).
SWIFT_FEATURE_OPT_USES_WMO = "swift.opt_uses_wmo"

# If enabled, builds using the "opt" compilation mode will invoke `swiftc` with
# the `-Osize` flag instead of `-O`.
SWIFT_FEATURE_OPT_USES_OSIZE = "swift.opt_uses_osize"

# If enabled, Swift compilation actions will use the same global Clang module
# cache used by Objective-C compilation actions. This is disabled by default
# because under some circumstances Clang module cache corruption can cause the
Expand Down

0 comments on commit e8b14ed

Please sign in to comment.