Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[JITLink][AArch32] Add explicit visibility macros to functions needed by unittests#116557

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

fsfod
Copy link
Contributor

Without these there will be missing symbol errors when building JITLinkTests for windows shared library builds with explicit symbol visibility macros are enabled.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window.

@weliveindetail
Copy link
Member

Thanks for bringing this up. These functions were never meant to be exported publically, we only want to access them for testing. Does that make a difference for the LLVM_ABI tag? Do we have similar situations anywhere else in the codebase?

In order to avoid confusion, we could also make a local LLVM_TEST_ABI redefinition with with a note. Or if this only affects Windows, we could disable the respective unittets there. What do you think?

@fsfod
Copy link
ContributorAuthor

Thanks for bringing this up. These functions were never meant to be exported publically, we only want to access them for testing. Does that make a difference for the LLVM_ABI tag? Do we have similar situations anywhere else in the codebase?

Because these are not declared in any header there wouldn't really be any expectation that these could be consumed by anything but tests.
Yes i've had to fix missing exports of internal symbols used by tests in other places of the LLVM codebase, sometimes its been internal headers which are easier to automate annotations.

In order to avoid confusion, we could also make a local LLVM_TEST_ABI redefinition with with a note

Maybe i could, but previous discussions i've had with@compnerd he wanted to avoid proliferation of lots of different symbol visibility macros.

if this only affects Windows, we could disable the respective unittets there. What do you think?

Its only affects windows atm, but in the future when default symbol visibility is changed changed to hidden for the LLVM shared library these would need the same annotations as windows

@compnerd
Copy link
Member

Maybe i could, but previous discussions i've had with@compnerd he wanted to avoid proliferation of lots of different symbol visibility macros.

We will need a macro for each shared library that we support. If we add more macros for each library, it would become a huge number and can be overwhelming for other developers not familiar with this.

Copy link
Member

@weliveindetailweliveindetail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ok, so let's keep it simple. LGTM

@fsfodfsfodforce-pushed theexported-api/arch32-jit-exports branch fromf10915e to8a51f64CompareNovember 25, 2024 15:57
@lhames
Copy link
Contributor

@compnerd Couldn't we have one globalLLVM_TEST_ABI macro? I think it's fine to claim that we're either buildingllvm-project (all libraries) for testing or we're not.

I wouldn't want these symbols leaking into the ABI of release builds.

@compnerd
Copy link
Member

@lhames it seems reasonable at first glance, but quickly breaks down.

Let's say that we are building LLVMSupport as a DLL and LLVM statically. However, becauseLLVM_TEST_ABI is defined once and doesn't consider the target's build type into consideration, we end up with:

#if defined(LLVMSupport_STATIC)#defineLLVM_TEST_ABI/**/#else#if defined(LLVMSupport_EXPORTS)#defineLLVM_TEST_ABI __declspec(dllexport)#else#defineLLVM_TEST_ABI __declspec(dllimport)#endif#endif

Now, when we build LLVM as a static library,LLVMSupport_STATIC is not defined (because it was built dynamically), and because LLVMSupport is not being built here,LLVMSupport_EXPORTS is undefined. So you end up withLLVM_TEST_ABI as__declspec(dllimport), which says that the definitions that LLVM is exporting for use in test are defined elsewhere.

Because the behaviour of the*_ABI macro is dependent on the module being built and how that module is being built, we cannot easily just use a single definition.

Now, maybe, we can get LLVM down to the small enough surface that we can have only 2 libraries (LLVMSupport and LLVM where the second one has ALL architectures enabled and is sufficient to be used for all tools and still is well under 64K entry points including data as part of the ABI). In such a case, yes, it seems reasonable to have two test ABI macros.

My concern is that we might end up having to extract each architecture backend into a separate DLL and then have the optimizations be pulled out, the assembler pulled out, and suddenly you have a set of test ABI macros.

@lhames
Copy link
Contributor

lhames commentedDec 12, 2024
edited
Loading

@compnerd Can you dllexport and then dllimport the same symbol within a static link? (Apologies for my lack of windows knowledge here). In that case I'm imagining that we could have something as simple as:

#ifndef NDEBUG#defineLLVM_UNITTEST_EXPORT__declspec(dllexport)#else#defineLLVM_UNITTEST_EXPORT#endif

Then wrap the unit test in#ifndef NDEBUG and unconditionally dllimport the decl?

@compnerd
Copy link
Member

The declaration and definition must match (that is an error). So the declaration must be__declspec(dllexport) if there is a definition. You cannot have a declaration that is__declspec(dllimport) and then a definition.

That said, if you incorrectly mark the symbol as dllimport and then define it elsewhere within the module, that is generally a linker warning (but it will try to create a thunk to workaround it).

Copy link
Contributor

@lhameslhames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@compnerd Ok. Sounds like finer grained export / import is impractical. Thanks very much for taking the time to talk that through with me!

compnerd reacted with heart emoji
@fsfodfsfodforce-pushed theexported-api/arch32-jit-exports branch from8a51f64 tocaf4427CompareJanuary 30, 2025 01:56
@weliveindetail
Copy link
Member

@fsfod Should we land this?

… by unittestsWithout these there will be missing symbol errors when building JITLinkTests forwindows shared library builds with explicit symbol visibility macros are enabled.This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window.
@fsfodfsfodforce-pushed theexported-api/arch32-jit-exports branch fromcaf4427 to2caf6aaCompareApril 20, 2025 16:59
@fsfod
Copy link
ContributorAuthor

I think so it depends on if@andrurogerz needs it for his work on annotating exports as well.

@andrurogerz
Copy link
Contributor

I think so it depends on if@andrurogerz needs it for his work on annotating exports as well.

I had to make these same patches locally to build the test against an LLVM DLL, so this PR is still relevant. If you're willing/able to merge it that'd be wonderful.

@fsfod
Copy link
ContributorAuthor

I don't have commit access so could someone merge it for me.

@weliveindetailweliveindetail merged commit01ab423 intollvm:mainJul 16, 2025
11 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lhameslhameslhames approved these changes

@weliveindetailweliveindetailweliveindetail approved these changes

@eymayeymayAwaiting requested review from eymay

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@fsfod@weliveindetail@compnerd@lhames@andrurogerz

[8]ページ先頭

©2009-2025 Movatter.jp