[rocm-openmp-extras] - Add support for flang-legacy in 6.1.2 (#46130)
* [rocm-openmp-extras] - Add support for flang-legacy in 6.1.2 * [rocm-openmp-extras] - Remove unused variable flang_legacy_dir * [rocm-openmp-extras] - Limit flang-legacy build to 6.1 and newer ROCm versions
This commit is contained in:
parent
055eb3cd94
commit
33621a9860
@ -260,7 +260,7 @@ def cmake_args(self):
|
||||
args.append(self.define("LLVM_ENABLE_PROJECTS", llvm_projects))
|
||||
args.append(self.define("LLVM_ENABLE_RUNTIMES", llvm_runtimes))
|
||||
args.append(self.define("LLVM_ENABLE_LIBCXX", "OFF"))
|
||||
args.append(self.define("CLANG_LINK_FLANG_LEGACY", False))
|
||||
args.append(self.define("CLANG_LINK_FLANG_LEGACY", True))
|
||||
args.append(self.define("CMAKE_CXX_STANDARD", 17))
|
||||
args.append(self.define("FLANG_INCLUDE_DOCS", False))
|
||||
args.append(self.define("LLVM_BUILD_DOCS", "ON"))
|
||||
|
@ -481,6 +481,9 @@ def install(self, spec, prefix):
|
||||
os.unlink(os.path.join(bin_dir, "flang1"))
|
||||
if os.path.islink((os.path.join(bin_dir, "flang2"))):
|
||||
os.unlink(os.path.join(bin_dir, "flang2"))
|
||||
if self.spec.version >= Version("6.1.0"):
|
||||
if os.path.islink((os.path.join(bin_dir, "flang-legacy"))):
|
||||
os.unlink(os.path.join(bin_dir, "flang-legacy"))
|
||||
if os.path.islink((os.path.join(lib_dir, "libdevice"))):
|
||||
os.unlink(os.path.join(lib_dir, "libdevice"))
|
||||
if os.path.islink((os.path.join(llvm_prefix, "lib-debug"))):
|
||||
@ -488,6 +491,11 @@ def install(self, spec, prefix):
|
||||
|
||||
os.symlink(os.path.join(omp_bin_dir, "flang1"), os.path.join(bin_dir, "flang1"))
|
||||
os.symlink(os.path.join(omp_bin_dir, "flang2"), os.path.join(bin_dir, "flang2"))
|
||||
|
||||
if self.spec.version >= Version("6.1.0"):
|
||||
os.symlink(
|
||||
os.path.join(omp_bin_dir, "flang-legacy"), os.path.join(bin_dir, "flang-legacy")
|
||||
)
|
||||
os.symlink(os.path.join(omp_lib_dir, "libdevice"), os.path.join(lib_dir, "libdevice"))
|
||||
os.symlink(
|
||||
os.path.join(openmp_extras_prefix, "lib-debug"), os.path.join(llvm_prefix, "lib-debug")
|
||||
@ -579,6 +587,40 @@ def install(self, spec, prefix):
|
||||
|
||||
components["pgmath"] += flang_common_args
|
||||
|
||||
flang_legacy_version = "17.0-4"
|
||||
|
||||
components["flang-legacy-llvm"] = [
|
||||
"-DLLVM_ENABLE_PROJECTS=clang",
|
||||
"-DCMAKE_BUILD_TYPE=Release",
|
||||
"-DLLVM_ENABLE_ASSERTIONS=ON",
|
||||
"-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86",
|
||||
"-DCLANG_DEFAULT_LINKER=lld",
|
||||
"-DLLVM_INCLUDE_BENCHMARKS=0",
|
||||
"-DLLVM_INCLUDE_RUNTIMES=0",
|
||||
"-DLLVM_INCLUDE_EXAMPLES=0",
|
||||
"-DLLVM_INCLUDE_TESTS=0",
|
||||
"-DLLVM_INCLUDE_DOCS=0",
|
||||
"-DLLVM_INCLUDE_UTILS=0",
|
||||
"-DCLANG_DEFAULT_PIE_ON_LINUX=0",
|
||||
"../../rocm-openmp-extras/flang/flang-legacy/{0}/llvm-legacy/llvm".format(
|
||||
flang_legacy_version
|
||||
),
|
||||
]
|
||||
|
||||
components["flang-legacy"] = [
|
||||
"-DCMAKE_C_COMPILER={0}/clang".format(bin_dir),
|
||||
"-DCMAKE_CXX_COMPILER={0}/clang++".format(bin_dir),
|
||||
"../rocm-openmp-extras/flang/flang-legacy/{0}".format(flang_legacy_version),
|
||||
]
|
||||
|
||||
if (
|
||||
self.compiler.name == "gcc"
|
||||
and self.compiler.version >= Version("7.0.0")
|
||||
and self.compiler.version < Version("9.0.0")
|
||||
):
|
||||
components["flang-legacy-llvm"] += ["-DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'"]
|
||||
components["flang-legacy"] += ["-DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'"]
|
||||
|
||||
components["flang"] = [
|
||||
"../rocm-openmp-extras/flang",
|
||||
"-DFLANG_OPENMP_GPU_AMD=ON",
|
||||
@ -595,22 +637,38 @@ def install(self, spec, prefix):
|
||||
]
|
||||
components["flang-runtime"] += flang_common_args
|
||||
|
||||
build_order = ["aomp-extras", "openmp", "openmp-debug", "pgmath", "flang", "flang-runtime"]
|
||||
build_order = ["aomp-extras", "openmp"]
|
||||
if self.spec.version >= Version("6.1.0"):
|
||||
build_order += ["flang-legacy-llvm", "flang-legacy"]
|
||||
|
||||
build_order += ["pgmath", "flang", "flang-runtime"]
|
||||
# Override standard CMAKE_BUILD_TYPE
|
||||
for arg in std_cmake_args:
|
||||
found = re.search("CMAKE_BUILD_TYPE", arg)
|
||||
if found:
|
||||
std_cmake_args.remove(arg)
|
||||
for component in build_order:
|
||||
with working_dir("spack-build-{0}".format(component), create=True):
|
||||
cmake_args = components[component]
|
||||
cmake_args.extend(std_cmake_args)
|
||||
# OpenMP build needs to be run twice(Release, Debug)
|
||||
if component == "openmp-debug":
|
||||
cmake_args.append("-DCMAKE_BUILD_TYPE=Debug")
|
||||
else:
|
||||
cmake_args = components[component]
|
||||
cmake_args.extend(std_cmake_args)
|
||||
if component == "flang-legacy-llvm":
|
||||
with working_dir("spack-build-{0}/llvm-legacy".format(component), create=True):
|
||||
cmake_args.append("-DCMAKE_BUILD_TYPE=Release")
|
||||
cmake(*cmake_args)
|
||||
make()
|
||||
make("install")
|
||||
cmake(*cmake_args)
|
||||
make()
|
||||
elif component == "flang-legacy":
|
||||
with working_dir("spack-build-flang-legacy-llvm"):
|
||||
cmake_args.append("-DCMAKE_BUILD_TYPE=Release")
|
||||
cmake(*cmake_args)
|
||||
make()
|
||||
make("install")
|
||||
os.symlink(os.path.join(bin_dir, "clang"), os.path.join(omp_bin_dir, "clang"))
|
||||
else:
|
||||
with working_dir("spack-build-{0}".format(component), create=True):
|
||||
# OpenMP build needs to be run twice(Release, Debug)
|
||||
if component == "openmp-debug":
|
||||
cmake_args.append("-DCMAKE_BUILD_TYPE=Debug")
|
||||
else:
|
||||
cmake_args.append("-DCMAKE_BUILD_TYPE=Release")
|
||||
cmake(*cmake_args)
|
||||
make()
|
||||
make("install")
|
||||
|
Loading…
Reference in New Issue
Block a user