Skip to content

Fix flang-aarch64-libcxx builder #432

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 4 commits into from
Jun 24, 2025
Merged

Conversation

luporl
Copy link
Contributor

@luporl luporl commented Apr 17, 2025

After flang-rt, flang-aarch64-libcxx builder started to fail.
Before it, llvm libraries, flang and its runtime were built with the
host compiler, but now flang runtime is built with the stage 1 clang.
The problem is that the C++ library of these compilers may be
incompatible. The linked issue has more details.

To avoid this issue, use the out of tree flang builder to build llvm,
flang and flang-rt with the host compiler, using libcxx.

Fixes llvm/llvm-project#135381

@luporl
Copy link
Contributor Author

luporl commented Apr 17, 2025

Marked as draft because the changes were only tested in isolation:

  • Built and tested flang/flang-rt with the modified flags.
  • Called getFlangOutOfTreeBuildFactory from a test program, passing flang-aarch64-libcxx flags as llvm_extra_configure_args.

But it would be good to get some feedback to confirm this is the right approach, before testing it in a buildbot.

@Meinersbur
Copy link
Member

Meinersbur commented Apr 17, 2025

I am not sure this can work and if it does it will be fragile. The reason is that the LLVM_ENABLE_RUNTIMES system itself sets CMAKE_CXX_COMPILER and which definition wins is nothing I would rely on. Why not adding -I<path-to-libcxx> to -DRUNTIMES_CMAKE_ARGS=-DCMAKE_CXX_FLAGS= so stage1 clang is able to find libcxx?

If a bootstrapping build is not possible, consider a standalone-runtimes build, like flang-runtime-cuda-clang does.

This current PR doesn't seem to use getFlangOutOfTreeBuildFactory for flang-aarch64-libcxx, but might be a solution as well.

@luporl
Copy link
Contributor Author

luporl commented Apr 17, 2025

This current PR doesn't seem to use getFlangOutOfTreeBuildFactory for flang-aarch64-libcxx, but might be a solution as well.

Right, flang-aarch64-libcxx uses getCmakeWithNinjaBuildFactory instead, I completely missed it...

@DavidSpickett
Copy link
Contributor

DavidSpickett commented Apr 22, 2025

Thanks for taking this up @luporl .

Why not adding -I to -DRUNTIMES_CMAKE_ARGS=-DCMAKE_CXX_FLAGS= so stage1 clang is able to find libcxx?

This works but requires us to 1. hardcode paths or 2. add stable symlinks to our docker container. Both are possible but not great for anyone external who needs to reproduce.

A standalone runtimes build would be ideal, and most "in the spirit" of the runtimes build. Assuming we can find a neat way to do it.

Using the out of tree builder means that flang is also out of tree, I think, so this bot becomes out of tree + libcxx. Normally I wouldn't want to mix concerns but we do have an out of tree bot to compare to at least. It would be clear if problems were due to using libcxx.

Maybe you can "out of tree" just flang-rt.

luporl added 3 commits June 18, 2025 09:26
After flang-rt, flang-aarch64-libcxx builder started to fail.
Before it, llvm libraries, flang and its runtime were built with the
host compiler, but now flang runtime is built with the stage 1 clang.
The problem is that the C++ library of these compilers may be
incompatible. The linked issue has more details.

To avoid this issue, build flang-rt with the host compiler.

Fixes llvm/llvm-project#135381
@luporl luporl force-pushed the luporl-fix-flang-libcxx branch from 76a5096 to 725671b Compare June 18, 2025 14:18
@luporl luporl marked this pull request as ready for review June 18, 2025 14:23
@luporl
Copy link
Contributor Author

luporl commented Jun 18, 2025

As suggested, the last commit adopts a new approach, by using the out of tree flang builder to build llvm,
flang and flang-rt with the host compiler, using libcxx. This way, no modifications are needed in the flang builder, just in the builder config.

I haven't tried to "out of tree" just flang-rt, because it would create another "special case", that would require modifications to the flang builder and would be used only by flang-aarch64-libcxx. Instead, it's similar to flang-aarch64-out-of-tree, and can be compared to it on failures. The main differences are that it uses libcxx and shared libraries.

I've used a local buildbot environment to test this and it works fine.

Copy link
Contributor

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks for taking care of this.

@luporl
Copy link
Contributor Author

luporl commented Jun 24, 2025

Thanks @DavidSpickett and @Meinersbur, for the reviews and suggestions.

@luporl luporl merged commit df463d2 into llvm:main Jun 24, 2025
2 checks passed
@luporl luporl deleted the luporl-fix-flang-libcxx branch June 24, 2025 14:11
@DavidSpickett
Copy link
Contributor

Thanks for the fix Leandro, it's now building correctly - https://lab.llvm.org/staging/#/builders/46/builds/4084.

1 failure but we know this is due to #482.

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.

flang-aarch64-libcxx bot fails to build after flang-rt was added to the build
3 participants