diff --git a/toolchains/clang/clang_toolchain.bzl b/toolchains/clang/clang_toolchain.bzl index c4ff56d..e91632a 100644 --- a/toolchains/clang/clang_toolchain.bzl +++ b/toolchains/clang/clang_toolchain.bzl @@ -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 diff --git a/toolchains/features/common/impl/clang.bzl b/toolchains/features/common/impl/clang.bzl index f6baadd..9187f9f 100644 --- a/toolchains/features/common/impl/clang.bzl +++ b/toolchains/features/common/impl/clang.bzl @@ -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", @@ -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, ) diff --git a/toolchains/features/common/impl/gcc.bzl b/toolchains/features/common/impl/gcc.bzl index 7f22e16..bbb4b3d 100644 --- a/toolchains/features/common/impl/gcc.bzl +++ b/toolchains/features/common/impl/gcc.bzl @@ -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", + ], + expand_if_available = "output_execpath", + ), + ], + ), + ], +) + _MISC_FEATURE = feature( name = "misc", enabled = True, @@ -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, ) diff --git a/toolchains/features/common/types.bzl b/toolchains/features/common/types.bzl index 8b0faa9..a19f819 100644 --- a/toolchains/features/common/types.bzl +++ b/toolchains/features/common/types.bzl @@ -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", } @@ -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 @@ -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: @@ -71,6 +74,7 @@ def all_common_features( fastbuild, output_format, coverage, + generate_linkmap, misc, ] for arg in args: @@ -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", ) diff --git a/toolchains/features/embedded/impl/gcc.bzl b/toolchains/features/embedded/impl/gcc.bzl index 7da3ebf..700aeb2 100644 --- a/toolchains/features/embedded/impl/gcc.bzl +++ b/toolchains/features/embedded/impl/gcc.bzl @@ -92,6 +92,7 @@ _SYS_SPEC_FEATURE = feature( "-lc", "-lstdc++", "-lnosys", + "-specs=nano.specs", ], ), ], diff --git a/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl b/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl index e33fa14..02a14f9 100644 --- a/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl +++ b/toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl @@ -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,