This is an archive of the discontinued LLVM Phabricator instance.

[libcxxabi] Fix cmake order dependency wrt dllexporting
ClosedPublic

Authored by ldionne on Mar 4 2022, 2:54 AM.

Details

Reviewers
mstorsjo
ldionne
Group Reviewers
Restricted Project
Restricted Project
Commits
rGebde6fc23bc0: [libcxxabi] Fix cmake order dependency wrt dllexporting
Summary

If LIBCXX_ENABLE_SHARED isn't explicitly set on the cmake command
line, isn't set in the cache, and the libcxxabi project is configured
before libcxx, then LIBCXX_ENABLE_SHARED isn't defined yet. Once
the libcxx cmake project has been parsed, LIBCXX_ENABLE_SHARED would
have been set to its default value of ON.

This makes sure that the symbols are properly dllexported in such
a configuration scenario.

Diff Detail

Event Timeline

mstorsjo created this revision.Mar 4 2022, 2:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2022, 2:54 AM
Herald added a subscriber: mgorny. · View Herald Transcript
mstorsjo requested review of this revision.Mar 4 2022, 2:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2022, 2:54 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Like I said in D120719, I am not fond of this approach because it preserves the circular dependency between libc++ and libc++abi. My primary goal is that libc++abi doesn't have to have too much knowledge about how libc++ is configured (ideally it would require no such knowledge).

To this end, we could either:

  1. Ask Windows vendors to bite the bullet and start defining LIBCXXABI_HERMETIC_STATIC_LIBRARY manually, or
  2. Set LIBCXXABI_HERMETIC_STATIC_LIBRARY to ON by default on Windows.

Like I said in D120719, I am not fond of this approach because it preserves the circular dependency between libc++ and libc++abi. My primary goal is that libc++abi doesn't have to have too much knowledge about how libc++ is configured (ideally it would require no such knowledge).

To this end, we could either:

  1. Ask Windows vendors to bite the bullet and start defining LIBCXXABI_HERMETIC_STATIC_LIBRARY manually, or
  2. Set LIBCXXABI_HERMETIC_STATIC_LIBRARY to ON by default on Windows.

I understand that you want to untangle the circular dependencies between the two libraries - I totally see the value in that. But I ask that we don't do it in a way that break users upfront without a deprecation period over a release to let users migrate to the new way of configuring the interdependencies of these libraries.

We can't blindly set the LIBCXXABI_HERMETIC_STATIC_LIBRARY to one value or another as that breaks either build config (but "breaking" the static build isn't visible in the CI setup). When building with LIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON (which is essentially the only way that works to combine the libraries on Windows), LIBCXXABI_HERMETIC_STATIC_LIBRARY would have to be set to the negation of LIBCXX_ENABLE_SHARED. (Builds with shared+static get an incorrect version for the static library though - that's a longer standing issue I've planned to look into in the future.)

After speaking offline with @mstorsjo , I suggest we go ahead with this patch, however we also add a configure-time warning and a release note saying that this behavior is deprecated and will be removed in LLVM 16.

libcxxabi/CMakeLists.txt
310

Here we can add a hard error if LIBCXXABI_HERMETIC_STATIC_LIBRARY=ON, since the two options would contradict one another.

313–318

Here we can add a warning if LIBCXXABI_HERMETIC_STATIC_LIBRARY=OFF explaining that this behavior is deprecated and will be removed in LLVM 16, asking users to set LIBCXXABI_HERMETIC_STATIC_LIBRARY=ON explicitly if they want this configuration.

After speaking offline with @mstorsjo , I suggest we go ahead with this patch, however we also add a configure-time warning and a release note saying that this behavior is deprecated and will be removed in LLVM 16.

That sounds like a reasonable timeplan to me, and the warning locations sound sensible to me, too. I'll try to amend the patch as suggested and test run it so that it behaves as expected.

ldionne commandeered this revision.Mar 7 2022, 10:44 AM
ldionne edited reviewers, added: mstorsjo; removed: ldionne.
ldionne added inline comments.
libcxxabi/CMakeLists.txt
310

Actually, we can't, because it would start erroring out if someone used LIBCXXABI_HERMETIC_STATIC_LIBRARY and the if() was satisfied above.

ldionne updated this revision to Diff 413559.Mar 7 2022, 10:45 AM

Add warning and release note.

Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2022, 10:45 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Mar 7 2022, 10:46 AM

I will land this if CI passes, since this is on the critical path for a couple other changes, and we've agreed on the direction.

This revision is now accepted and ready to land.Mar 7 2022, 10:46 AM

I will land this if CI passes, since this is on the critical path for a couple other changes, and we've agreed on the direction.

Actually, I would want to request that we defer the warning and release note for a little while. (We need to have it in place by the time LLVM 15 is finalized; the sooner before that it is settled, the better of course, but I would request to hold off of starting the deprecation cycle for it a little while.)

I was thinking of how to implement the next step for the libcxxabi<->libcxx merging for Windows (it works, but it has a number of quirks right now), and one possible path forward that I see could require further changes in how to set things up. So before telling people to migrate their setup to a new form, I think it'd be nice to wait a little if there's a different final form for LLVM 15.

I was thinking of how to implement the next step for the libcxxabi<->libcxx merging for Windows (it works, but it has a number of quirks right now), and one possible path forward that I see could require further changes in how to set things up. So before telling people to migrate their setup to a new form, I think it'd be nice to wait a little if there's a different final form for LLVM 15.

... but I see the value of actually committing _something_ so it doesn't get forgotten. Do we have a list of things to add before the next branch so that it doesn't get lost in the unlikely event I don't manage to get back to it? Or commit those bits, commented out? Or just commit them as-is and then remove them later if the final solution ends up different?

ldionne updated this revision to Diff 413591.Mar 7 2022, 12:34 PM

Comment out warning

I was thinking of how to implement the next step for the libcxxabi<->libcxx merging for Windows (it works, but it has a number of quirks right now), and one possible path forward that I see could require further changes in how to set things up. So before telling people to migrate their setup to a new form, I think it'd be nice to wait a little if there's a different final form for LLVM 15.

... but I see the value of actually committing _something_ so it doesn't get forgotten. Do we have a list of things to add before the next branch so that it doesn't get lost in the unlikely event I don't manage to get back to it?

No, we don't. We generally try to avoid being in the situation where we need to remember to do something like that.

Or commit those bits, commented out? Or just commit them as-is and then remove them later if the final solution ends up different?

Erhm, I guess I can comment the warning out, however it would be nice to soon have clarity on what's the better way of doing this instead.

I will land this now since it isn't different from what had passed CI originally.

This revision was landed with ongoing or failed builds.Mar 7 2022, 12:36 PM
This revision was automatically updated to reflect the committed changes.