You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am porting command line C++ code to use on iOS. Setting aside the issue of actually passing command line arguments to an iOS app (it is possible and fully supported), calling absl::ParseCommandLine(argc, argv) on stack variables seems to fail mysteriously. Even within the same translation unit, ABSL_FLAG definitions are ignored and not present in the .o.
I thought this was an issue with my toolchain configuration (linker stripping, etc). But it turns out, it is due to ABSL_FLAGS_STRIP_NAMES being set to 0 on "mobile" targets, where "mobile" is defined to be Android, iPhone, and "embedded Apple devices".
While explicitly setting ABSL_FLAGS_STRIP_NAMES=0 fixes the issue, the name ABSL_FLAGS_STRIP_NAMES is confusing as its effect is to disable flag registration altogether: ABSL_FLAG_IMPL is defined to call absl::flags_internal::FlagRegistrar<T, /*do_register=*/false> or absl::flags_internal::FlagRegistrar<T, /*do_register=*/true>.
I am not advocating that we change the name - that's extremely disruptive.
But maybe we should better document it somewhere as this behavior is surprising (albeit rare - I don't know how many Abseil users actually want to pass flags to iOS apps. My team for one would like to do this as it conveniently lets us pass things like --stderrthreshold 0.
Describe the issue
I am porting command line C++ code to use on iOS. Setting aside the issue of actually passing command line arguments to an iOS app (it is possible and fully supported), calling
absl::ParseCommandLine(argc, argv)
on stack variables seems to fail mysteriously. Even within the same translation unit,ABSL_FLAG
definitions are ignored and not present in the.o
.I thought this was an issue with my toolchain configuration (linker stripping, etc). But it turns out, it is due to ABSL_FLAGS_STRIP_NAMES being set to 0 on "mobile" targets, where "mobile" is defined to be Android, iPhone, and "embedded Apple devices".
While explicitly setting
ABSL_FLAGS_STRIP_NAMES=0
fixes the issue, the nameABSL_FLAGS_STRIP_NAMES
is confusing as its effect is to disable flag registration altogether: ABSL_FLAG_IMPL is defined to callabsl::flags_internal::FlagRegistrar<T, /*do_register=*/false>
orabsl::flags_internal::FlagRegistrar<T, /*do_register=*/true>
.I am not advocating that we change the name - that's extremely disruptive.
But maybe we should better document it somewhere as this behavior is surprising (albeit rare - I don't know how many Abseil users actually want to pass flags to iOS apps. My team for one would like to do this as it conveniently lets us pass things like
--stderrthreshold 0
.Steps to reproduce the problem
Write a C++ library that looks like:
and call
parse()
from the iOS app. It will mysteriously complain:Building with
ABSL_FLAGS_STRIP_NAMES=0
fixes the issue.What version of Abseil are you using?
20240722.0
What operating system and version are you using?
iOS 18.0
What compiler and version are you using?
Xcode 16.0
What build system are you using?
bazel 7.1.0
Additional context
No response
The text was updated successfully, but these errors were encountered: