Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions toolchains/clang/clang_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def _clang_toolchain_config_info_impl(ctx):
common_features.output_format,
common_features.coverage,
common_features.misc,
common_features.generate_linkmap,
],
)
return toolchain_config_info
Expand Down
19 changes: 19 additions & 0 deletions toolchains/features/common/impl/clang.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,24 @@ _OPT_FEATURE = feature(
provides = ["compilation_mode"],
)

_GENERATE_LINKMAP_FEATURE = feature(
name = "generate_linkmap",
enabled = True,
flag_sets = [
flag_set(
actions = _LD_ALL_ACTIONS,
flag_groups = [
flag_group(
flags = [
"-Wl,-Map=%{output_execpath}.map", # if is_linux else "-Wl,-map,%{output_execpath}.map",
],
expand_if_available = "output_execpath",
),
],
),
],
)

# Leaving for compatibility
_OUTPUT_FORMAT_FEATURE = feature(
name = "output_format",
Expand Down Expand Up @@ -333,4 +351,5 @@ def GetClangCommonFeatures(include_paths, sysroot = "", architecture = "native",
output_format = _OUTPUT_FORMAT_FEATURE,
coverage = _COVERAGE_FEATURE,
misc = _MISC,
generate_linkmap = _GENERATE_LINKMAP_FEATURE,
)
19 changes: 19 additions & 0 deletions toolchains/features/common/impl/gcc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,24 @@ _OUTPUT_FORMAT_FEATURE = feature(
],
)

_GENERATE_LINKMAP_FEATURE = feature(
name = "generate_linkmap",
enabled = True,
flag_sets = [
flag_set(
actions = _LD_ALL_ACTIONS,
flag_groups = [
flag_group(
flags = [
"-Wl,-Map=%{output_execpath}.map", # if is_linux else "-Wl,-map,%{output_execpath}.map",
Copy link
Author

@Zob314 Zob314 Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented section is from the upstream linkmap PR. Evidently Linux requires a capital M, and macOS requires a lower case m. But in the upstream commit it seems to be based on the target system, so maybe all versions of arm-none-eabi-gcc use the capital M?
I figured I'd leave the extra code here as a hint for people who run into issues.

],
expand_if_available = "output_execpath",
),
],
),
],
)

_MISC_FEATURE = feature(
name = "misc",
enabled = True,
Expand Down Expand Up @@ -313,4 +331,5 @@ def GetGccCommonFeatures(include_paths, sysroot = "", architecture = "native", f
output_format = _OUTPUT_FORMAT_FEATURE,
misc = _MISC_FEATURE,
coverage = _COVERAGE_FEATURE,
generate_linkmap = _GENERATE_LINKMAP_FEATURE,
)
5 changes: 5 additions & 0 deletions toolchains/features/common/types.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CC_ALL_COMMON_FEATURES_INFO = {
"fastbuild": "Compile quickly, for fast development",
"output_format": "The output format of the compilers *.stripped target, (default binary)",
"coverage": "A set of features that don't fit in any other categories",
"generate_linkmap": "Generates a mapfile during the link stage",
"misc": "A set of features that don't fit in any other categories",
"type_name": "The type name for this provider",
}
Expand All @@ -40,6 +41,7 @@ def all_common_features(
fastbuild,
output_format,
coverage,
generate_linkmap,
misc):
""" all_common_features represents the minimal set of features that should be implemented for a portable toolchain

Expand All @@ -55,6 +57,7 @@ def all_common_features(
fastbuild: Configure the fastbuild mode, to speed up developement
output_format: The output format for the {target}.stripped target (default binary)
coverage: Feature for instrumenting code coverage
generate_linkmap: Generates a mapfile during the link stage
misc: The set of features that don't fit anywhere else

Returns:
Expand All @@ -71,6 +74,7 @@ def all_common_features(
fastbuild,
output_format,
coverage,
generate_linkmap,
misc,
]
for arg in args:
Expand All @@ -91,6 +95,7 @@ def all_common_features(
fastbuild = fastbuild,
output_format = output_format,
coverage = coverage,
generate_linkmap = generate_linkmap,
misc = misc,
type_name = "cc_all_common_feature_info",
)
1 change: 1 addition & 0 deletions toolchains/features/embedded/impl/gcc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ _SYS_SPEC_FEATURE = feature(
"-lc",
"-lstdc++",
"-lnosys",
"-specs=nano.specs",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed from the map files that this was not being included in the link flags, despite it being included in the compiler flags. This was causing the final binary to use much more flash than necessary.

],
),
],
Expand Down
1 change: 1 addition & 0 deletions toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def _gcc_arm_none_toolchain_config_info_impl(ctx):
common_features.opt,
common_features.fastbuild,
common_features.output_format,
common_features.generate_linkmap,
embedded_features.exceptions,
embedded_features.runtime_type_information,
embedded_features.sys_spec,
Expand Down