[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Nov 27 21:28:53 PST 2024


Meinersbur wrote:

> I think it is because COMPILE_LANGUAGE:CXX does not work for sources where the language has been set to CUDA. Since CUDA may be C or C++ sources, it would also be wrong to add them to COMPILE_LANGUAGE:CUDA.
> 
> I do not think cmake has a way to specify flags to be passed to host compilers ([from this cmake issue](https://gitlab.kitware.com/cmake/cmake/-/issues/25911)).
> 
> Maybe you could define those flags in some functions that could be used both here to set COMPILE_LANGUAGE:CXX flags and in `AddFlangRTOffload` to add these flags to the `CUDA_COMPILE_OPTIONS`.

I think you are right, the generator-expression only applies to C++. I added it to avoid applying those switches to C files. I didn't have CUDA in mind, and neither I think llvm_add_library had[^1]. Overriding the `LANGUAGE` source file property is something I would not recommend.

For `nvcc`, the documented switch to disable exceptions seems to be `--no-exceptions`. Options can be forwarded to the host compiler using `-Xcompiler`. I updated this PR to use these options. Please check those options.

Windows targets might not be supported for now, but I think still need to be thought of. Using Clang to compile with experimental CUDA support seemed to habe been intended at some point, but currently fails (on main) with 
```
/home/meinersbur/src/llvm-project-flangrt/flang-rt/../flang/include/flang/Runtime/freestanding-tools.h:91:5: error: non-void function 'memmove' should return a value [-Wreturn-type]
   91 |     return;
      |     ^
```
and other errors.

If I read the CMake issue Kitware correctly, Kitware consideres `-Xcompiler` to be nvcc-specific and didn't want generalize this for all compilers[^2]. 

[^1]: The code that applies these compile switches has the comment `# Update target props, since all sources are C++.` Using the file extension might have been a workaround before generator expression were available in CMake. It was added in 2014.

[^2]: If it was up to me, I would rather add `target_device_compile_options` than `target_host_compile`, because the host (respectively the target that we are cross-compiling to; "host" is ambiguous here) is the level that all the compilers and linkers work on. Only the device/auxiliary code is different from other CMake-supported-languages.

https://github.com/llvm/llvm-project/pull/110217


More information about the llvm-branch-commits mailing list