[SAoC] MLIR Support for LDC

Roberto Rosmaninho Robertogrosmaninho at gmail.com
Fri Oct 18 21:30:16 UTC 2019


On Thursday, 17 October 2019 at 22:05:30 UTC, Johan wrote:
> Hey Roberto,
>   It's fun to read your updates, thanks :)

Hey Johan, I'm glad to hear that, thank you!!

> I hope to get the LLVM 10 fixes into LDC master soon. Then you 
> can rebase on top of that to make the specific MLIR changes 
> more obvious and easier to view.

Nic told me about your PR and I'm already trying to rebase my 
code on it!

> (I didn't check if you already did this) I find it very helpful 
> to look at test cases to see what functionality you are adding. 
> The lit-based testsuite is very convenient for checking IR 
> output. Did you already add MLIR tests there?

Not yet, I'll use this test suite on this next phase, maybe I can 
put some tests that I'm already writing there. :)

> Don't stress out too much about not following LLVM trunk 
> exactly. But also don't lag too long behind, such that the 
> changes you need to make are not too big and that you keep up 
> to date on impactful MLIR changes. So perhaps only pull MLIR 
> trunk once in 2 weeks or so.

Great idea, I'll follow it, thanks!

> You can try to offload some of the general LLVM trunk compile 
> issues to others, by making us aware of LLVM trunk compile 
> issues. I can try to help with that.

Ok!

> LLVM trunk compilation fixes (not related to MLIR) you can 
> submit as PRs to LDC. That way your branch is solely about MLIR 
> changes, and not cluttered by the general LLVM changes needed.

I'm currently trying to use Linux to update the project and find 
the projects directory to improve my FindMLIR.cmake but I'm 
having the following problem over and over and I coudn't figure 
out what I'm doing wrong:

Commands:
$ git clone http://github.com/ldc-developers/ldc
$ cd ldc
$ git checkout llvm10cmake
$ mkdir build && cd build
$ export DMD=~/dlang/dmd-2.087.1/linux/bin64/dmd
$ cmake -G Ninja ..  -DCMAKE_BUILD_TYPE=Release
# Cmake works ok and LLVM10 was found, I can put the log of CMake 
here later if I request.
$ ninja
$ ninja install
#It gives me the following error:

CMake Error at cmake_install.cmake:44 (file):
   file INSTALL cannot copy file 
"/home/roberto/dlang/ldc/build/bin/ldc2" to
   "/usr/local/bin/ldc2".


FAILED: CMakeFiles/install.util
cd /home/roberto/dlang/ldc/build && /usr/bin/cmake -P 
cmake_install.cmake
ninja: build stopped: subcommand failed.

#When I try to compile a simple program: int main(){int a = 10; 
return 0;}
$ ~/ldc/build/bin/ldc2 sum.d

Error: cannot find source code for runtime library file 'object.d'
        ldc2 might not be correctly installed.
        Please check your ldc2.conf configuration file.
        Installation instructions can be found at 
http://wiki.dlang.org/LDC.
Specify path to file 'object.d' with -I switch

> I was hoping you had solved these issues. I'm still confused by 
> "reach projects directory", is it not possible to `ninja 
> install` MLIR ?

Well, the instructions on MLIR git just ask for a "cmake --build 
. --target check-mlir" when you're compiling LLVM with MLIR.

The problem is that doesn't exist any flags such as 
$LLVM_SOURCE_DIR or $LLVM_PROJECTS_DIR. So unless I pass the path 
of $MLIR_ROOT_DIR BY command line I'm don't know any way to reach 
the source code of llvm to get MLIR files. Unfortunately, the 
project's dir inside llvm build doesn't provide all the files 
that I need.

Just to illustrate my problem with LLVM_ROOT_DIR I added the 
following line on my cmake:
       message("LLVM ROOT DIR IS: ${LLVM_ROOT_DIR}")
Then when I run the CMake I get the following result:
       LLVM ROOT DIR IS: /home/roberto/llvm-project/build


Hope I can solve this soon!

Best regards,
Roberto


More information about the Digitalmars-d mailing list