Skip to content

Commit aa5c02d

Browse files
authored
Fix out-of-tree Flang builders (#500)
Currently, when Flang is built out-of-tree, it fails to find compiler-rt when linking programs. This issue was reported in llvm/llvm-project#147738 and a fix for it is being discussed. Meanwhile, there is a workaround available, discussed in #482, that consists in using an installed flang instead of the one in the build directory. This PR changes Flang builder to use this workaround.
1 parent 7ee4476 commit aa5c02d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

zorg/buildbot/builders/FlangBuilder.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@ def getFlangOutOfTreeBuildFactory(
1616
if env is None:
1717
env = dict()
1818

19+
# Currently, when Flang is built out-of-tree, it fails to find compiler-rt
20+
# when linking programs.
21+
# See https://github.com/llvm/llvm-project/issues/147738.
22+
# As a workaround, install LLVM, clang, compiler-rt and flang into the same
23+
# directory and use it to build and test flang-rt.
24+
install_dir = "install"
25+
1926
f = getCmakeWithNinjaBuildFactory(
2027
depends_on_projects=['llvm','clang','mlir','openmp','flang','flang-rt','compiler-rt'],
2128
enable_projects=['llvm','clang','mlir'],
2229
enable_runtimes=['openmp','compiler-rt'],
2330
obj_dir="build_llvm",
31+
install_dir=install_dir,
2432
checks=[],
2533
clean=clean,
2634
extra_configure_args=llvm_extra_configure_args,
@@ -61,6 +69,8 @@ def getFlangOutOfTreeBuildFactory(
6169
LLVMBuildFactory.pathRelativeTo(mlir_dir, flang_obj_dir)),
6270
('-DCLANG_DIR:PATH=',
6371
LLVMBuildFactory.pathRelativeTo(clang_dir, flang_obj_dir)),
72+
('-DCMAKE_INSTALL_PREFIX=',
73+
LLVMBuildFactory.pathRelativeTo(install_dir, flang_obj_dir)),
6474
])
6575

6676
f.addStep(
@@ -87,6 +97,7 @@ def getFlangOutOfTreeBuildFactory(
8797
addNinjaSteps(
8898
f,
8999
obj_dir=flang_obj_dir,
100+
install_dir=install_dir,
90101
checks=checks,
91102
env=env,
92103
stage_name="flang",
@@ -105,10 +116,10 @@ def getFlangOutOfTreeBuildFactory(
105116
"-DLLVM_ENABLE_RUNTIMES=flang-rt",
106117
]
107118

108-
# Use the Fortran compiler from the previous step.
119+
# Use the Fortran compiler installed in the previous step.
109120
flang_rt_cmake_args += [
110121
util.Interpolate(
111-
f"-DCMAKE_Fortran_COMPILER=%(prop:builddir)s/{flang_obj_dir}/bin/flang"
122+
f"-DCMAKE_Fortran_COMPILER=%(prop:builddir)s/{install_dir}/bin/flang"
112123
),
113124
"-DCMAKE_Fortran_COMPILER_WORKS=ON",
114125
]

0 commit comments

Comments
 (0)