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

Further improve LLVM building #18606

Merged
merged 13 commits into from
Oct 28, 2021
Merged

Further improve LLVM building #18606

merged 13 commits into from
Oct 28, 2021

Conversation

mppf
Copy link
Member

@mppf mppf commented Oct 22, 2021

For #18589

Continuing #18551

About static vs dynamic linking of LLVM libraries:

This PR addresses #18589 by adjusting the chpl link to use -lclang-cpp (which is a dynamic library) instead of several static libraries when using CHPL_LLVM=system. It adjusts chpl to always link statically with LLVM and Clang libraries when using CHPL_LLVM=bundled.

Additionally, it handles a few follow-ups to #18551 including removing code that is not needed and addressing an issue with gasnet-mpi configurations with a custom GCC.

About the presence of -clang-cpp on various system-installs of LLVM:

  • It is present on:
    • CentOS 8 (LLVM 11 .so provided by clang-devel)
    • Fedora 34 (but that system uses LLVM 12)
    • Ubuntu 21.10
    • Debian 11 Bullseye which has LLVM 11
    • FreeBSD 13
    • FreeBSD 12.1
  • It is not present on these systems that only have older LLVM versions:
    • Debian 9 Stretch (only has LLVM 7)
    • Debian 10 Buster (only has LLVM 7)

Future work:

  • chpl builds on a CLE 6 Cray XC
  • make succeeds and hello builds and runs on an XC
  • full local testing
  • bundled LLVM on Mac OS X
  • system LLVM on Mac OS X
  • bundled LLVM on Ubuntu
  • system LLVM on Uuntu

Reviewed by @ronawho - thanks!

And also adjust makefiles to remove cases for LLVM 9/10
now as 11 is the current requirement.

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
Need to check that this works OK -- e334bb3
enabled this logic and said "Otherwise if the PrgEnv module isn't loaded,
problems finding libstdc++."

If we can't use the dylib on Crays then we will need to put back in the
static library link strings for the clang libraries.

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
Removes
    util/config/gather-cray-prgenv-arguments.bash
    util/config/gather-pe-chapel-pkgconfig-libs.bash

and makes adjustments to Makefiles and chplenv scripts to allow that.

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
I haven't seen a problem with it yet but I don't want to get in to
changing it in this PR.

See PR chapel-lang#3531 and PR chapel-lang#11615 for some history in this area.

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
Only does something with e.g. make CHPL_LLVM_DYNAMIC=0

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
to address failures with gasnet-mpi configurations

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
@mppf mppf requested a review from ronawho October 27, 2021 22:54
@@ -1,5 +1,12 @@
include $(THIRD_PARTY_DIR)/llvm/Makefile.share-bundled

# Link statically on Cray systems to avoid problems with
# finding libstdc++ with different PrgEnv compilers.
CHPL_LLVM_DYNAMIC := 1
Copy link
Member Author

Choose a reason for hiding this comment

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

Question for reviewer: Given that we weren't linking dynamically before and such linking can lead to rpath issues, should we switch to always statically linking with the bundled LLVM for now until the rpath issues are resolved?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would be fine sticking with static linking for the bundled version.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, that's what I've done

endif
# these should already be gathered in CHPL_LLVM_CLANG_COMPILE_ARGS
# by printchplenv.
CHPL_UGNI_PRGENV_CFLAGS := $(CHPL_MAKE_LLVM_CLANG_COMPILE_ARGS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need the above comment and conditionals or can we just always set this (wondering if CHPL_MAKE_LLVM_CLANG_COMPILE_ARGS is empty when the above conditions aren't set)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think we could always set it and I'd expect it to be empty if the above conditions aren't set. For now though I will leave this as-is in the PR.

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
@ronawho
Copy link
Contributor

ronawho commented Oct 28, 2021

I thought I left a comment along this lines here, but I'm not seeing it now -- How often do you expect we'll need to make change like this to adapt to new llvm versions or different packaging on different OS's? Do you think it'd be worthwhile to add testing on a bunch of different OS's with a system llvm? (Either through automated vagrant testing or fixed VMs?)

@mppf
Copy link
Member Author

mppf commented Oct 28, 2021

In this particular case, we're adapting to what the LLVM project recommends (at least, according to https://archives.gentoo.org/gentoo-dev/message/6d3cf88d858fcf3fbb11818ce5d6ea42 ). I don't expect we'll need a lot of changes like this for different OSes. However I think it would absolutely be worthwhile to add testing for a bunch of different OSes with system LLVM. For that I am hoping we use vagrant or docker or singularity or something along those lines. (I have done some testing with vagrant stuff we have on different OSes with system LLVMs, but it's more spot-checking). I prefer these approaches to fixed VMs because the OSes to test change over time as some of them become end-of-life'd.

@ronawho
Copy link
Contributor

ronawho commented Oct 28, 2021

However I think it would absolutely be worthwhile to add testing for a bunch of different OSes with system LLVM. For that I am hoping we use vagrant or docker or singularity or something along those lines. (I have done some testing with vagrant stuff we have on different OSes with system LLVMs, but it's more spot-checking). I prefer these approaches to fixed VMs because the OSes to test change over time as some of them become end-of-life'd.

👍 Can we capture this on an existing vagrant issue or create a new one to capture it?

@mppf mppf merged commit d8a0fe5 into chapel-lang:main Oct 28, 2021
@mppf mppf deleted the llvm-dylib branch October 28, 2021 19:57
mppf added a commit that referenced this pull request Nov 16, 2021
Improve LLVM configuration on Mac OS X

Follow-up to PR #18606

*  Add isysroot argument even for system llvm
   * This appears to be necessary on Mac OS X 11.6.1 with Homebrew llvm
     version 11.1.0.

* Link clang statically for Mac OS X with system LLVM
   * note that we were already linking statically with the LLVM binaries,
     but previously were linking clang dynamically 
   * intended to resolve problems building mason
     (Cray/chapel-private#2702)
   
* Add -I and -L paths according to sysroot
  * The `-L` path at least seems to be necessary on Mac OS 11.6 and
    newer. See https://developer.apple.com/forums/thread/666700 for some
    background in this area. Even though the `-isysroot` path covers it,
    the linking call does not seem to use it.

- [x] homebrew system LLVM 11.1 functions on Big Sur
- [x] homebrew system LLVM 11.1 functions on Catalina
- [x] homebrew system LLVM functions on Mojave
- [x] bundled LLVM functions on Big Sur and Catalina
- [x] full local testing

Reviewed by @ronawho - thanks!
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.

2 participants