Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dllimport conflicts with exclude_from_explicit_instantiation. #40363

Open
llvmbot opened this issue Mar 9, 2019 · 23 comments · Fixed by #65961
Open

dllimport conflicts with exclude_from_explicit_instantiation. #40363

llvmbot opened this issue Mar 9, 2019 · 23 comments · Fixed by #65961
Assignees
Labels
bugzilla Issues migrated from bugzilla c++ clang:codegen confirmed Verified by a second party

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 9, 2019

Bugzilla Link 41018
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zmodem,@ldionne,@nico,@zygoloid,@rnk

Extended Description

When both dllimport and exclude_from_explicit_instantiation are passed, Clang still expects the function to have a externally available definition. But this is not the case.

For example: https://godbolt.org/z/gKOHCk

This leads to linker errors because of undefined symbols.

I think one approach would be to make Clang not inherit dllimport attributes on functions declared with exclude_from_explicit_instantiation. When dllimport is applied directly, we could emit an error for incompatible attributes.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 9, 2019

assigned to @zmodem

@rnk
Copy link
Collaborator

rnk commented Mar 11, 2019

Basically, we have two things that say the function will be externally available, one from the language (extern template) and one extension (dllimport), and then we have our own, new extension (exclude_from_expicit_instantiation), which says the opposite. I guess the "negative" available_externally attribute should win, since it only exists to say that an inline function is not available_externally.

I wonder if it makes sense to extend this attribute to work in non-template cases, consider:

class EXPORT Foo {
// Too many methods to individually annotate with EXPORT:
void baz00();
void baz01();
...
void baz99();

// One inline method that I don't want to export, for whatever reason:
int attribute((exclude_from_explicit_instantiation)) bar() {
return 42;
}
};

Obviously, the spelling "exclude_from_explicit_instantiation" doesn't make any sense, but what's really been created here is an available_externally-blocker attribute.

The same effect can also be achieved with clang-cl /Zc:dllExportInlines-, by the way: http://blog.llvm.org/2018/11/30-faster-windows-builds-with-clang-cl_14.html

Speculatively assigning to Hans since he supervised /Zc:dllExportInlines-.

@rnk
Copy link
Collaborator

rnk commented Mar 11, 2019

+Louis, since he added the attribute.

@zmodem
Copy link
Collaborator

zmodem commented Mar 12, 2019

+Louis, since he added the attribute.

(For anyone looking, that was r343790.)

I think one approach would be to make Clang not inherit dllimport
attributes on functions declared with exclude_from_explicit_instantiation.
When dllimport is applied directly, we could emit an error for incompatible
attributes.

That sounds reasonable to me.

@nico
Copy link
Contributor

nico commented Mar 15, 2019

ldionne, as author of exclude_from_explicit_instantiation could you take a look? libc++ currently needs to carry a workaround for this.

@nico
Copy link
Contributor

nico commented Nov 20, 2019

libc++ will need another workaround for this for https://bugs.chromium.org/p/chromium/issues/detail?id=923166#c44

@rnk
Copy link
Collaborator

rnk commented Nov 21, 2019

Separately from what clang should do, does Chromium use the libc++ ABI unstable macros? Can it?

If so, I would think that the "unstable ABI" build shouldn't use the exclude_from_explicit_instantiation attributes, since I believe those are only needed to stabilize the ABI.

@nico
Copy link
Contributor

nico commented Nov 26, 2019

Yes, Chromium sets _LIBCPP_ABI_UNSTABLE (except, for now, in branded CrOS builds, but that's hopefully temporary).

That sounds like a good idea to me.

(Having said that, updating libc++ in Chromium is a bit of a mess atm, so a compiler-side fix might still help Chromium earlier even if we implemented that suggestion for libc++ very soon and the compiler fix a bit later.)

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
@ldionne
Copy link
Member

ldionne commented Jul 19, 2023

Tentative fix: https://reviews.llvm.org/D155713

pfusik added a commit that referenced this issue Jul 19, 2023
#40363 caused the C++20
`str() const &` and `str() &&` to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.

Reviewed By: #libc, hans, ldionne, Mordante

Differential Revision: https://reviews.llvm.org/D155185
@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 19, 2023

@llvm/issue-subscribers-clang-codegen

pfusik added a commit that referenced this issue Aug 10, 2023
Also `istringstream::str()` and `ostringstrem::str()`.

#40363 causes `str()`
to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.

Reviewed By: #libc, thakis, philnik

Differential Revision: https://reviews.llvm.org/D157602
llvmbot pushed a commit to llvm/llvm-project-release-prs that referenced this issue Aug 16, 2023
Also `istringstream::str()` and `ostringstrem::str()`.

llvm/llvm-project#40363 causes `str()`
to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.

Reviewed By: #libc, thakis, philnik

Differential Revision: https://reviews.llvm.org/D157602

(cherry picked from commit 090996f)
tru pushed a commit to llvm/llvm-project-release-prs that referenced this issue Aug 21, 2023
Also `istringstream::str()` and `ostringstrem::str()`.

llvm/llvm-project#40363 causes `str()`
to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.

Reviewed By: #libc, thakis, philnik

Differential Revision: https://reviews.llvm.org/D157602

(cherry picked from commit 090996f)
zmodem added a commit to zmodem/llvm-project that referenced this issue Sep 11, 2023
…stantiation members

during explicit instantiation.

Fixes llvm#40363
kstoimenov pushed a commit to kstoimenov/llvm-project that referenced this issue Sep 14, 2023
…stantiation members during explicit instantiation (llvm#65961)

This is a continuation of https://reviews.llvm.org/D155713

Fixes llvm#40363
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this issue Sep 19, 2023
…stantiation members during explicit instantiation (llvm#65961)

This is a continuation of https://reviews.llvm.org/D155713

Fixes llvm#40363
@zmodem
Copy link
Collaborator

zmodem commented Sep 20, 2023

I had to revert my patch due to #66909

@zmodem zmodem reopened this Sep 20, 2023
@AlexVlx AlexVlx closed this as completed Sep 20, 2023
@zmodem
Copy link
Collaborator

zmodem commented Sep 21, 2023

Not sure why this was marked completed again. The fix was reverted in 700f683

@zmodem zmodem reopened this Sep 21, 2023
@AlexVlx
Copy link
Contributor

AlexVlx commented Sep 21, 2023

Not sure why this was marked completed again. The fix was reverted in 700f683

Apologies for this, there appears to be an issue around merging / pushing into private forks that causes behaviour such as the above. It has happened before and it is rather obnoxious:(

@skatrak
Copy link
Contributor

skatrak commented Sep 21, 2023

Sorry, didn't mean to close this. Not sure how that happened.

@skatrak skatrak reopened this Sep 21, 2023
@zmodem
Copy link
Collaborator

zmodem commented Sep 21, 2023

No problem, I guess it's a github thing :)

@pfusik
Copy link
Contributor

pfusik commented Sep 21, 2023

I reported this unwanted closing at https://support.github.com/ticket/personal/0/2342354. Not sure if that's visible to others.

@Endilll
Copy link
Contributor

Endilll commented Sep 21, 2023

Unfortunately, it's not visible to me.

@pfusik
Copy link
Contributor

pfusik commented Sep 26, 2023

GitHub support replied regarding the unwanted closing:

I took a further look at this and I understand where your concern is coming from. It might seem unusual that a commit in one person’s repository, in this case, skatrak/llvm-project-rocm, can close an issue in a different repository like llvm/llvm-project.
However, this is actually a feature of GitHub and is part of the expected behavior. When a user, like skatrak, who has write permissions in both repositories, links a pull request to an issue in a different repository and merges the commit into the default branch, the linked issue will close. This is because the commit message contains specific keywords that trigger this action. Here’s the GitHub documentation explaining this feature: Linking a pull request to an issue.
I get that this could be worrisome, considering a scenario where someone with less than good intentions pushes multiple commits to their own repo with “Fixes” keywords in the messages. It's important to note, though, that this action can only happen if the user has the necessary permissions in the repository where the issue exists. So, it is crucial to manage permissions carefully.

@skatrak
Copy link
Contributor

skatrak commented Sep 26, 2023

GitHub support replied regarding the unwanted closing:

I took a further look at this and I understand where your concern is coming from. It might seem unusual that a commit in one person’s repository, in this case, skatrak/llvm-project-rocm, can close an issue in a different repository like llvm/llvm-project.
However, this is actually a feature of GitHub and is part of the expected behavior. When a user, like skatrak, who has write permissions in both repositories, links a pull request to an issue in a different repository and merges the commit into the default branch, the linked issue will close. This is because the commit message contains specific keywords that trigger this action. Here’s the GitHub documentation explaining this feature: Linking a pull request to an issue.
I get that this could be worrisome, considering a scenario where someone with less than good intentions pushes multiple commits to their own repo with “Fixes” keywords in the messages. It's important to note, though, that this action can only happen if the user has the necessary permissions in the repository where the issue exists. So, it is crucial to manage permissions carefully.

Thank you for looking into this. Now I'm kind of scared to update the default branch of my not-quite-a-fork of llvm-project (it's actually a fork of an independent mirror that pulls from llvm-project in set intervals). Do we know if reverting a commit that automatically closed an issue also re-opens the issue automatically? If that's the case maybe what happened is that my local "fork" push happened to include the fix but not the revert, but I happened to push it after the revert had been done upstream, so it closed back the issue.

If that wasn't it I fear that I will close every open issue that was automatically closed at one point via a "Fixes ..." commit message every time I update my fork, so I'll just avoid it from now on. And sorry for taking the conversation here off the rails, since it's not at all related to the issue.

@ldionne
Copy link
Member

ldionne commented Sep 26, 2023

@pfusik Thanks a lot for looking into this with Github support. Can you bring that up in a Discourse thread and ping @tstellar and @tru ? I think this is something we need to carefully consider because LLVM is in the situation where a lot of people have write access to the repository, so this could happen quite often. I'm not so worried about people having bad intentions, but I am pretty worried about people doing it by mistake or even via automergers since those are quite common.

@tru
Copy link
Collaborator

tru commented Sep 26, 2023

Not sure we can do much about this? An action that would check every closed issue and see where it comes from and reopen in that case is the only thing I can think about.

@ldionne
Copy link
Member

ldionne commented Sep 27, 2023

The only other thing I can think about is to change the way LLVM does business and restrict who has direct push access, and to go exclusively through PRs. That wouldn't solve this issue entirely, but it would make it less likely to happen.

@tru
Copy link
Collaborator

tru commented Sep 27, 2023

The only other thing I can think about is to change the way LLVM does business and restrict who has direct push access, and to go exclusively through PRs. That wouldn't solve this issue entirely, but it would make it less likely to happen.

That seems like a very disruptive change and I am not sure it would be a very positive one for the community. But yeah.

blueboxd pushed a commit to blueboxd/libcxx that referenced this issue Sep 29, 2023
llvm/llvm-project#40363 caused the C++20
`str() const &` and `str() &&` to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.

Reviewed By: #libc, hans, ldionne, Mordante

Differential Revision: https://reviews.llvm.org/D155185

NOKEYCHECK=True
GitOrigin-RevId: 8ecb9591646d4b0326ea7547b99d300336c6c423
blueboxd pushed a commit to blueboxd/libcxx that referenced this issue Sep 29, 2023
Also `istringstream::str()` and `ostringstrem::str()`.

llvm/llvm-project#40363 causes `str()`
to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.

Reviewed By: #libc, thakis, philnik

Differential Revision: https://reviews.llvm.org/D157602

NOKEYCHECK=True
GitOrigin-RevId: 090996f4a1186b1522e1225b6779d74ce9da250c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ clang:codegen confirmed Verified by a second party
Projects
None yet
Development

Successfully merging a pull request may close this issue.