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

fix: do not dllexport symbols in core static libraries #3601

Merged
merged 30 commits into from
Mar 15, 2024
Merged

Conversation

Kha
Copy link
Member

@Kha Kha commented Mar 5, 2024

On Windows, we now compile all core .os twice, once with and without dllexport, for use in the shipped dynamic and static libraries, respectively. On other platforms, we export always as before to avoid the duplicate work.

@Kha Kha added the full-ci label Mar 5, 2024
@Kha Kha changed the title chore: unify LEAN_EXPORT and LEAN_SHARED fix: do not dllexport symbols in static libraries Mar 6, 2024
@Kha Kha changed the title fix: do not dllexport symbols in static libraries fix: do not dllexport symbols in core static libraries Mar 6, 2024
@Kha Kha marked this pull request as ready for review March 6, 2024 13:06
@Kha Kha requested a review from tydeu as a code owner March 6, 2024 13:06
@Kha
Copy link
Member Author

Kha commented Mar 6, 2024

TODO to definitely resolve #2346: do the same for user code in Lake

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 6, 2024 13:22 Inactive
@Kha Kha requested a review from kim-em as a code owner March 6, 2024 14:31
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 6, 2024 14:51 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 6, 2024 15:50 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 6, 2024 17:07 Inactive
endif
ifdef CMAKE_LIKE_OUTPUT
@echo "[ ] Building $<"
endif
@mkdir -p "$(@D)"
ifdef PROFILE
$(LEANC) -c -o $@ $< $(LEANC_OPTS) -DLEAN_EXPORTING
Copy link
Member

@tydeu tydeu Mar 6, 2024

Choose a reason for hiding this comment

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

I noticed we are running this for both the C and LLVM backend. I don't imagine this -D actually does anything when compiling the bc file. We will need to change the LLVM emitter instead:

-- we must now set symbol visibility for global.
if ps.isEmpty then
if isClosedTermName env decl.name then LLVM.setVisibility global LLVM.Visibility.hidden -- static
else if isExternal then pure () -- extern (Recall that C/LLVM funcs are extern linkage by default.)
else LLVM.setDLLStorageClass global LLVM.DLLStorageClass.export -- LEAN_EXPORT
else if !isExternal
-- An extern decl might be linked in from a different translation unit.
-- Thus, we cannot export an external declaration as we do not define it,
-- only declare its presence.
-- So, we only export non-external definitions.
then LLVM.setDLLStorageClass global LLVM.DLLStorageClass.export
return global

However, this may be a TODO for later, as configuring this to emit both the export file and the non-export is more difficult as this is part of Lean elaboration rather than a separate step.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes, I meant to flag this to @bollu @hargoniX but forgot. I don't see this being addressed before we move code generation out of the main lean invocation

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 7, 2024 16:17 Inactive
@Kha
Copy link
Member Author

Kha commented Mar 7, 2024

@tydeu I believe the only remaining issue is that supportInterpreter test binaries now fail on Windows as we've now basically implemented our own -rdynamic distinction! So Lake would need to include LEANC_SHARED_LINKER_FLAGS when building a supportInterpreter executable on Windows.

@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Mar 8, 2024

Mathlib CI status (docs):

  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 09bc477016caffe11da2fac58051c59161445ae3 --onto ae492265fec103aa834d897bf9f68c94d10f0785. (2024-03-08 20:44:38)
  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 1151d73a551e45303495f73d59cd3f617d49fd9d --onto 317adf42e92a4dbe07295bc1f0429b61bb8079fe. (2024-03-14 18:22:55)

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 8, 2024 23:55 Inactive
@tydeu
Copy link
Member

tydeu commented Mar 9, 2024

I believe I have fixed everything I can on the Lake side and everything now can function, so I will hand this back to you @Kha.

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 9, 2024 00:55 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 11, 2024 13:09 Inactive
tydeu pushed a commit to tydeu/lean4 that referenced this pull request Mar 11, 2024
tydeu pushed a commit to tydeu/lean4 that referenced this pull request Mar 13, 2024
tydeu pushed a commit to tydeu/lean4 that referenced this pull request Mar 14, 2024
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 14, 2024 17:38 Inactive
@tydeu
Copy link
Member

tydeu commented Mar 14, 2024

@Kha Added the release note. Feel free to merge when convenient.

@Kha Kha linked an issue Mar 15, 2024 that may be closed by this pull request
1 task
@Kha Kha added this pull request to the merge queue Mar 15, 2024
Merged via the queue into master with commit 3b4b2cc Mar 15, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

too many exported symbols linker error on Windows
3 participants