--push-state implemented in this patch saves the states of --as-needed,
--whole-archive and --static. It saves less number of flags than GNU linkers.
Since even GNU linkers save different flags, no one seems to care about the
details. In this patch, I tried to save the minimal number of flags to not
complicate the implementation and the siutation.
I'm not personally happy to add the --{push,pop}-state flags though.
That options seem too hacky to me. However, gcc started using the options
since GCC 8 when GNU ld is available at the build time. Thererfore, lld
is no longer a drop-in replacmenet for GNU linker for that machine
without supporting the flags.
One idea based on the difference of bfd and gold implementations.
As far I know, gold implements the true stack, but bfd - don't (https://sourceware.org/bugzilla/show_bug.cgi?id=18989#c2).
And letting users use the full power of nesting in invocations looks like a road to hell..
So should we just do it Optional<std::tuple<bool, bool, bool>> Stack?
Also, I would rename to State then.
(Or States if you decide to go with the true stack). It is consistent with the option name.