Skip to content

[flang] Fixing shared library builds #677

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

Merged
merged 3 commits into from
Mar 17, 2021
Merged

[flang] Fixing shared library builds #677

merged 3 commits into from
Mar 17, 2021

Conversation

Renaud-K
Copy link
Collaborator

@Renaud-K Renaud-K commented Mar 13, 2021

Builds with BUILD_SHARED_LIBS=On are broken in fir-dev.
Re-enabling them by updating new library dependencies and separating the Fortran main from the runtime.

I could not find a way with cmake to make Fortran_main.c just compile and export Fortran_main.o
add_llvm_library( libname OBJECT ...) does not work. After half a day of painful experiments I decided to make a static Fortran_main.a

…d separating the Fortran main from the runtime
…d separating the Fortran main from the runtime
Copy link
Collaborator

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

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

Thanks for having identified the issue and proposing a fix. I tried building your PR with both BUILD_SHARED_LIBS On and Off in my environment of the day (gcc 8.3 on linux, nothing very special in the cmake command) . Both builds failed for different reasons. I identified the issues and was able to fix them (see inlined comment).

Here is the code I had to change if it can help: 12ee61e

Also, I think we may want to centralize all end-to-end tests in their own folder to better control how we deal with them.

My cmake command line:

-DCMAKE_CXX_STANDARD=17 -DLLVM_BUILD_TOOLS=On -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_INSTALL_UTILS=On  -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=Off -DLLVM_ENABLE_PROJECTS="mlir;flang" -DCMAKE_CXX_FLAGS="" -DCMAKE_EXE_LINKER_FLAGS="" -DCMAKE_SHARED_LINKER_FLAGS=""

@schweitzpgi
Copy link

Also, I think we may want to centralize all end-to-end tests in their own folder to better control how we deal with them.

We do. #672

@Renaud-K Renaud-K requested a review from jeanPerier March 15, 2021 19:26
Copy link
Collaborator

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

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

I can now compile this patch with both BUILD_SHARED_LIBS On and Off, thanks !

@schweitzpgi
Copy link

I can now compile this patch with both BUILD_SHARED_LIBS On and Off, thanks !

Has @tskeith tried it on the Mac?

@tskeith
Copy link
Collaborator

tskeith commented Mar 16, 2021

I can now compile this patch with both BUILD_SHARED_LIBS On and Off, thanks !

Has @tskeith tried it on the Mac?

I just tried and got this error building lib/libFortranEvaluate.dylib:

Undefined symbols for architecture x86_64:
  "Fortran::semantics::operator<<(llvm::raw_ostream&, Fortran::semantics::Symbol const&)", referenced from:
      Fortran::semantics::Symbol::dump() const in call.cpp.o
      Fortran::semantics::Symbol::dump() const in characteristics.cpp.o
      Fortran::semantics::Symbol::dump() const in check-expression.cpp.o
      Fortran::semantics::Symbol::dump() const in constant.cpp.o
      Fortran::semantics::Symbol::dump() const in expression.cpp.o
      Fortran::semantics::Symbol::dump() const in fold.cpp.o
      Fortran::semantics::Symbol::dump() const in fold-character.cpp.o
      ...

@Renaud-K
Copy link
Collaborator Author

It rmeans that more dependencies need to be fixed. But I don't have OS X machine to run on.

@schweitzpgi
Copy link

I can now compile this patch with both BUILD_SHARED_LIBS On and Off, thanks !

Has @tskeith tried it on the Mac?

I just tried and got this error building lib/libFortranEvaluate.dylib:

Undefined symbols for architecture x86_64:
  "Fortran::semantics::operator<<(llvm::raw_ostream&, Fortran::semantics::Symbol const&)", referenced from:
      Fortran::semantics::Symbol::dump() const in call.cpp.o
      Fortran::semantics::Symbol::dump() const in characteristics.cpp.o
      Fortran::semantics::Symbol::dump() const in check-expression.cpp.o
      Fortran::semantics::Symbol::dump() const in constant.cpp.o
      Fortran::semantics::Symbol::dump() const in expression.cpp.o
      Fortran::semantics::Symbol::dump() const in fold.cpp.o
      Fortran::semantics::Symbol::dump() const in fold-character.cpp.o
      ...

[NFC] ifdef'd this so Symbol::dump() (which is the LLVM regular debug interface) is only in Debug builds now.

@Renaud-K Renaud-K merged commit e953b63 into fir-dev Mar 17, 2021
@schweitzpgi
Copy link

This broke testing.

Failed Tests (3):
  Flang :: Examples/hello.f90
  Flang :: Lower/associate-construct.f90
  Flang :: Lower/end-to-end-always-exec-loopbody.f90

schweitzpgi added a commit that referenced this pull request Mar 19, 2021
jeanPerier pushed a commit that referenced this pull request May 25, 2021
mleair pushed a commit that referenced this pull request Oct 18, 2021
jeanPerier pushed a commit that referenced this pull request Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants