mirror of https://github.com/bazelbuild/rules_cc
Implement force_pic_flags as cc_args
BEGIN_PUBLIC Implement force_pic_flags as cc_args Implements the force_pic_flags feature as cc_args rules. END_PUBLIC PiperOrigin-RevId: 671764316 Change-Id: I7f04bbf46027007fc47d230d49d3334b1a6ddfac
This commit is contained in:
parent
cf6ccb93f4
commit
98ab8334e7
|
@ -15,6 +15,7 @@ cc_feature(
|
||||||
name = "experimental_replace_legacy_action_config_features",
|
name = "experimental_replace_legacy_action_config_features",
|
||||||
args = [
|
args = [
|
||||||
"//cc/toolchains/args/archiver_flags",
|
"//cc/toolchains/args/archiver_flags",
|
||||||
|
"//cc/toolchains/args/force_pic_flags",
|
||||||
"//cc/toolchains/args/linker_param_file",
|
"//cc/toolchains/args/linker_param_file",
|
||||||
],
|
],
|
||||||
feature_name = "experimental_replace_legacy_action_config_features",
|
feature_name = "experimental_replace_legacy_action_config_features",
|
||||||
|
@ -34,7 +35,6 @@ cc_feature(
|
||||||
"//cc/toolchains/features/legacy:unfiltered_compile_flags",
|
"//cc/toolchains/features/legacy:unfiltered_compile_flags",
|
||||||
"//cc/toolchains/features/legacy:user_compile_flags",
|
"//cc/toolchains/features/legacy:user_compile_flags",
|
||||||
"//cc/toolchains/features/legacy:user_link_flags",
|
"//cc/toolchains/features/legacy:user_link_flags",
|
||||||
"//cc/toolchains/features/legacy:force_pic_flags",
|
|
||||||
"//cc/toolchains/features/legacy:libraries_to_link",
|
"//cc/toolchains/features/legacy:libraries_to_link",
|
||||||
"//cc/toolchains/features/legacy:runtime_library_search_directories",
|
"//cc/toolchains/features/legacy:runtime_library_search_directories",
|
||||||
"//cc/toolchains/features/legacy:shared_flag",
|
"//cc/toolchains/features/legacy:shared_flag",
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
load("//cc/toolchains:args.bzl", "cc_args")
|
||||||
|
|
||||||
|
package(default_visibility = ["//visibility:private"])
|
||||||
|
|
||||||
|
cc_args(
|
||||||
|
name = "force_pic_flags",
|
||||||
|
actions = [
|
||||||
|
"//cc/toolchains/actions:cpp_link_executable",
|
||||||
|
"//cc/toolchains/actions:lto_index_for_executable",
|
||||||
|
],
|
||||||
|
args = select({
|
||||||
|
"@platforms//os:macos": ["-Wl,-pie"],
|
||||||
|
"//conditions:default": ["-pie"],
|
||||||
|
}),
|
||||||
|
requires_not_none = "//cc/toolchains/variables:force_pic",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
|
@ -140,6 +140,7 @@ cc_external_feature(
|
||||||
|
|
||||||
cc_external_feature(
|
cc_external_feature(
|
||||||
name = "force_pic_flags",
|
name = "force_pic_flags",
|
||||||
|
deprecation = "Use //cc/toolchains/args/force_pic_flags instead",
|
||||||
feature_name = "force_pic_flags",
|
feature_name = "force_pic_flags",
|
||||||
overridable = True,
|
overridable = True,
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,6 +18,15 @@ compare_feature_implementation(
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
compare_feature_implementation(
|
||||||
|
name = "force_pic_flags_test",
|
||||||
|
actual_implementation = "//cc/toolchains/args/force_pic_flags",
|
||||||
|
expected = select({
|
||||||
|
"@platforms//os:macos": "//tests/rule_based_toolchain/legacy_features_as_args:goldens/macos/force_pic_flags.textproto",
|
||||||
|
"//conditions:default": "//tests/rule_based_toolchain/legacy_features_as_args:goldens/unix/force_pic_flags.textproto",
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
compare_feature_implementation(
|
compare_feature_implementation(
|
||||||
name = "linker_param_file_test",
|
name = "linker_param_file_test",
|
||||||
actual_implementation = "//cc/toolchains/args/linker_param_file",
|
actual_implementation = "//cc/toolchains/args/linker_param_file",
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
enabled: false
|
||||||
|
flag_sets {
|
||||||
|
actions: "c++-link-executable"
|
||||||
|
actions: "lto-index-for-executable"
|
||||||
|
flag_groups {
|
||||||
|
expand_if_available: "force_pic"
|
||||||
|
flags: "-Wl,-pie"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name: "force_pic_flags_test"
|
|
@ -0,0 +1,10 @@
|
||||||
|
enabled: false
|
||||||
|
flag_sets {
|
||||||
|
actions: "c++-link-executable"
|
||||||
|
actions: "lto-index-for-executable"
|
||||||
|
flag_groups {
|
||||||
|
expand_if_available: "force_pic"
|
||||||
|
flags: "-pie"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name: "force_pic_flags_test"
|
Loading…
Reference in New Issue