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

Add ability to infer CHPL_LLVM_GCC_INSTALL_DIR #26429

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jabraham17
Copy link
Member

@jabraham17 jabraham17 commented Dec 17, 2024

Adds the ability to infer CHPL_LLVM_GCC_INSTALL_DIR. Resolves #25925

This PR uses similar logic to the LLVM spack package to determine this. Thanks @PHHargrove for the pointer to this.

Testing

  • A system with a "broken" clang can fix itself automatically now
    • relatedly, a user can request no gcc install dir with CHPL_LLVM_GCC_INSTALL_DIR=none
  • make check on a nightly test system
  • full paratest with/without gasnet on linux64
  • make check on M1 mac
  • Setting GCC_INSTALL_DIR or GCC_PREFIX turns off inference
  • Setting both GCC_INSTALL_DIR and GCC_PREFIX warns, then prefers GCC_INSTALL_DIR if available
  • If supported, GCC_INSTALL_DIR is preferred (unless user requests otherwise)

This PR also adds a missing line to overrides.py for CHPL_LLVM_GCC_INSTALL_DIR

[Reviewed by @]

Signed-off-by: Jade Abraham <jade.abraham@hpe.com>
Signed-off-by: Jade Abraham <jade.abraham@hpe.com>
Signed-off-by: Jade Abraham <jade.abraham@hpe.com>
Signed-off-by: Jade Abraham <jade.abraham@hpe.com>
@jabraham17 jabraham17 force-pushed the infer-gcc-install-dir branch from 112be91 to 19f598f Compare December 18, 2024 00:04
@jabraham17 jabraham17 requested a review from mppf December 18, 2024 00:07
Copy link
Member

@mppf mppf left a comment

Choose a reason for hiding this comment

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

I would assume that we want this to replace the by-default inference in get_gcc_prefix_dir. That is, if LLVM version is new enough, we should infer CHPL_LLVM_GCC_INSTALL_DIR but not CHPL_LLVM_GCC_PREFIX. If LLVM is too old, we should infer CHPL_LLVM_GCC_PREFIX but not CHPL_LLVM_GCC_INSTALL_DIR.

Also, presumably, we want to infer neither of these if one of them is set in the environment.

@@ -1054,8 +1069,7 @@ def filter_llvm_config_flags(llvm_val, flags):
# when adding LLVM=system as system headers, we should not perturb the
# include search path, so use -isystem-after/-idirafter
#
# when adding LLVM=bundled, we should include the LLVM headers as system
# headers and prefer the bundled headers, so use -isystem
# when adding LLVM=bundled, we should include the LLVM headers a
Copy link
Member

Choose a reason for hiding this comment

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

something weird happened with this comment

@@ -72,6 +72,7 @@
'CHPL_LLVM_CLANG_CXX',
# CHPL_LLVM_VERSION -- doesn't make sense to override it
'CHPL_LLVM_GCC_PREFIX', # not in printchplenv --all
'CHPL_LLVM_GCC_INSTALL_DIR', # not in printchplenv --all
Copy link
Member

Choose a reason for hiding this comment

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

👍

Signed-off-by: Jade Abraham <jade.abraham@hpe.com>
@jabraham17
Copy link
Member Author

I would assume that we want this to replace the by-default inference in get_gcc_prefix_dir. That is, if LLVM version is new enough, we should infer CHPL_LLVM_GCC_INSTALL_DIR but not CHPL_LLVM_GCC_PREFIX. If LLVM is too old, we should infer CHPL_LLVM_GCC_PREFIX but not CHPL_LLVM_GCC_INSTALL_DIR

That should be the logic already. This PR didn't touch the existing logic, which already prefers GCC_INSTALL_DIR

    gcc_install_dir = get_gcc_install_dir()
    if gcc_install_dir:
        clang_args.append('--gcc-install-dir=' + gcc_install_dir)
    else:
        gcc_prefix = get_gcc_prefix_dir(clang_cfg_args)
        if gcc_prefix:
            clang_args.append('--gcc-toolchain=' + gcc_prefix)

Also, presumably, we want to infer neither of these if one of them is set in the environment.

This is currently not handled. Also, if both are specified I expect we would want to prefer GCC_INSTALL_DIR and warn about GCC_PREFIX being set. I will make add this

Signed-off-by: Jade Abraham <jade.abraham@hpe.com>
# note: this is a helper for get_clang_basic_args, its declared here so the
# memoization can be shared and possible warnings only occur once
flag_to_use = None
# all(overrides.get(flag) is not None for flag in gcc_prefix_flags.keys()):
Copy link
Member

Choose a reason for hiding this comment

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

commented-out code

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.

Should we automatically infer CHPL_LLVM_GCC_INSTALL_DIR?
2 participants