Skip to content

LevelBld#1852

Merged
WeiqunZhang merged 1 commit intoAMReX-Codes:developmentfrom
WeiqunZhang:levelbld
Mar 17, 2021
Merged

LevelBld#1852
WeiqunZhang merged 1 commit intoAMReX-Codes:developmentfrom
WeiqunZhang:levelbld

Conversation

@WeiqunZhang
Copy link
Copy Markdown
Member

@WeiqunZhang WeiqunZhang commented Mar 7, 2021

In Amr class, we need to get LevelBld* and use it to build AmrLevels.
Previously, Amr called a function LevelBld* getLevelBld() to get that.
The problem was that getLevelBld was not defined by amrex but it was being
called by amrex. This caused issues in building amrex as a shared library
on Mac and Windows, because they do not support weak symbols.

In this PR, the constructors of Amr now take LevelBld* as an argument.
This is unfortunately a breaking change. However, it's a compile time
failure and it's easy to fix.

The following codes need updates:

  • IAMR
  • PeleC
  • Castro
  • Nyx

@WeiqunZhang
Copy link
Copy Markdown
Member Author

@jrood-nrel

@WeiqunZhang
Copy link
Copy Markdown
Member Author

The issue has been addressed by #1836 for Mac.

@ax3l
Copy link
Copy Markdown
Member

ax3l commented Mar 15, 2021

@WeiqunZhang since this PR gets rid of weak-symbols, is it ok for everyone to continue to pursue it?

#1836 is a pretty invasive work-around/hack for macOS and does not solve the general unavailability of weak symbols on Windows. I would like to remove all linker-magic on Linux and macOS, too since this simplifies downstream dependency management, and the PR here would make that possible.

Totally orthogonal to the weak symbols, we need to handle globals manually on Windows, which is not related to this PR: #1847 (comment)

@WeiqunZhang WeiqunZhang reopened this Mar 15, 2021
@maximumcats
Copy link
Copy Markdown
Member

I was OK with this from the Castro side. It would have required a slight bit of reshuffling since our LevelBld* object is not currently visible from main() and thus could not be directly handed to the Amr constructor, but it should be straightforward to adjust that if we want to do this.

@ax3l
Copy link
Copy Markdown
Member

ax3l commented Mar 15, 2021

We just chatted on Slack and continue with this PR 🎉

@WeiqunZhang
Copy link
Copy Markdown
Member Author

You can add this line to the main.cpp, amrex::LevelBld* getLevelBld ();.

I considered adding this line a Header in amrex, but decided not to do it.

In Amr class, we need to get LevelBld* and use it to build AmrLevels.
Previously, Amr called a function `LevelBld* getLevelBld()` to get that.
The problem was that `getLevelBld` was not defined by amrex but it was being
called by amrex.  This caused issues in building amrex as a shared library
on Mac and Windows, because they do not support weak symbols.

In this PR, the constructors of Amr now take `LevelBld*` as an argument.
This is unfortunately a breaking change.  However, it's a compile time
failure and it's easy to fix.
Copy link
Copy Markdown
Contributor

@cgilet cgilet left a comment

Choose a reason for hiding this comment

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

Works for IAMR with the one line addition to main.cpp

@WeiqunZhang
Copy link
Copy Markdown
Member Author

@jrood-nrel Is PeleC ready for the change?

@jrood-nrel
Copy link
Copy Markdown
Contributor

Yes, we will update PeleC when you merge this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants