-
Notifications
You must be signed in to change notification settings - Fork 507
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
mlir_tblgen is broken for cross compile #1094
Comments
And locally on an M1 this should repro with
? |
on an M1 you want to build x86_64 then :D let me try on my m1 and post a command |
Thanks! |
if you don't have Rosetta you can do:
Disabling Rosetta 2 can be complicated I think. (from https://developer.apple.com/forums/thread/669486)
|
Looks like the native tools are being built:
so may just need to set the right version when |
@jpienaar made an easier recreate for you on Ubuntu / Linux: Install ARM cross-compile toolchain:
Build torch-mlir with:
it will fail with:
You can see the NATIVE binary is not built
|
Great, I'm in a PC meeting today but will try checking soon. I looked a bit yesterday and did see add_tablegen considered cross compilation, so seems likely it is "nesting" where a different setting is needed. |
Seems related to what is described in https://llvm.org/docs/HowToCrossCompileLLVM.html:
When cross-compiling IREE for bare-metal Arm, we need a two stage approach as well to compile the host tools and to compile for the target platform. |
@marbre yeah but it should be automatic for LLVM projects with |
I am quite certain that this one has to fail, since you're passing
I would need to take a closer look to what is behind. I might have some time this evening.
Can you elaborate on this? Do suggest you shuffle https://github.com/llvm/llvm-project/blob/28e665fa054d62d4e2c777774cc83dea533dfe6e/mlir/CMakeLists.txt#L154 around? |
Yes the latter.
|
https://reviews.llvm.org/D130350 relevant here. |
I don't think that fixes the issue. With the ARM recreate above you still get:
|
Do you still pass Anyway, I can offer to take over and look into the issue in more detail next week (oof tomorrow). I already digged into the cross-compiling mechanism LLVM relies on and into |
Yes I did pass that and still no luck |
Thank you for offering to take over. |
Indeed, thanks! |
Well, one thing is that Looking into solving this issue next week :) |
With the host tools flag set LLVM builds native tools (the mlir_linalg_ods_gen_yaml) handles this well. |
@marbre any luck with this issue ? |
arm-linux-gnueabihf-gcc produces AArch32 code from a cross compiler suitable for executing in AArch32 ISA state under a Linux environment with glibc. Is that what you are looking for here ? Ramana |
I think the arm-linux was just an easy repro case for folks to try out without requiring a macOS install. In all cases MLIR_TABLEGEN doesn't seem to respect A fix was attempted with https://reviews.llvm.org/D130350 but that doesn't fix it. |
Ah I see - sorry about the noise. Ramana |
I am still on it.
@powderluv What behavior exactly do you expect when setting |
When So expected output of
Should pass and build for ARM but it will fail trying to run arm |
Ok I did some digging into it:
On OSX (the original issue reported here): I think it just comes down to |
There is also patch under review that sets the install directories of these more correctly, could be unrelated, but seems many folks hitting related pains here. Setting pdll in cache SGTM. |
ok more debug info: When we run cmake we set the correct values
and then when we are building the NATIVE tools it gets set again to
|
I've seen things happen like this with toolchain files, where information discovered from the outer build doesn't get passed to the inner build, including the toolchain file. As a result, the inner build can discover a different set of information from the outer build. This is an area where I think cmake recursion is very subtle and it's easy to shoot yerself in the foot. I've tended to lean on the side of making all information used by a sub-build explicit, but this can be challenging when there is alot of information to be passed. |
|
So on my x86_64 macOS building with
D130350 is a good start but ideally we want to avoid pushing these into the cache which has unintended consequences if we recompile / change flags etc. Ideally we keep exporting out into PARENT_SCOPE until the top level has the variables we are about. That said add_tblgen() itself is pushing stuff into CACHE.
Ok Thank you.
Yes I remove it locally. I will send a PR for this now that D130350 has landed. @ashay fyi since you updated the add_tblgen() recently. |
Honestly, IDK and I currently don't have a Mac available to test :/
Yeah, I am not really sure if we should go with a cache variable or with explicitly exporting to parent scopes. And yes, you're right, Anyway, I was able to cross-compile |
What is your local command to cross-compile ? |
magically I am able to cross-compile on the GHA macos-12 runner #1204 but not on my iMacPro. If this works on GHA we can close this issue or make it low priority. |
Let me try to get a running cross-compile from x86_64 Linux to Arm Linux with Clang (I used GCC so far). But I agree, we can than deprioritize. |
This is now fixed. |
Signed-off-by: Charles Volzka <cjvolzka@us.ibm.com>
* Add check-onnx-backend to Mac CI. (llvm#1069) * Add check-onnx-backend to Mac CI. Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Additional Docker help and split README for easier reading (llvm#1084) * initial docker documentation Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * split README with no redundant place for info Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * respond to suggestions Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * specify that onnx-mlir.py script generates only code suitable to be exec in Linux and/or Docker env Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * fix checkdocs Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * responded to review suggestion on onnx-mlir --help Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * use ONNX-MLIR everywhere Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * add verify for concat Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * check all inputs Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Support filtering out lit tests based on targets (llvm#1087) Currently we ignore what targets llvm was built for in the lit tests, but recent changes to onnx-mlir explicitly initialize the available targets. This makes the corresponding change to the lit configuration, so that we can filter out the lit tests based on the available targets. Signed-off-by: Stella Stamenova <stilis@microsoft.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Switch URLs to use main instead of master (llvm#1094) Signed-off-by: Charles Volzka <cjvolzka@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Fix MacOS build badge (llvm#1092) Signed-off-by: Gong Su <gong_su@hotmail.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * onnx-mlir.py warning about binary output (.so and .jar) (llvm#1090) not directly usable if host is not Linux Signed-off-by: Gong Su <gong_su@hotmail.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Make the doc example obey ONNX_MLIR_BUILD_TESTS (llvm#1083) * Make the doc example obey ONNX_MLIR_BUILD_TESTS Currently, ONNX_MLIR_BUILD_TESTS controls EXCLUDE_FROM_ALL, however, the targets added through add_executable will always build. We follow the llvm pattern and explicitly set EXCLUDE_FROM_ALL in the add_onnx_mlir_executable function if it is set for the directory, so that add_executable targets don't always build. Signed-off-by: Stella Stamenova <stilis@microsoft.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Explicitly install into lib on all systems (llvm#1088) Signed-off-by: Gong Su <gong_su@hotmail.com> Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * add check (llvm#1098) Signed-off-by: Tong Chen <chentong@us.ibm.com> Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * fix typos and add ssh-client to dockerfile (llvm#1096) * fix typos and add ssh-client to dockerfile Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * sync doc and script Signed-off-by: Ethan Wang <ywan2928@uwo.ca> Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Emit print statement only when the verbose option is in effect. (llvm#1097) Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com> Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * format & refine code by request Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Support older versions 6, 11, 12 for Clip Op (llvm#1100) Signed-off-by: Tung D. Le <tung@jp.ibm.com> Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * using front to get first input Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * add 3 lit test for concat verifier Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * add newline Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Add check-onnx-backend to Mac CI. (llvm#1069) * Add check-onnx-backend to Mac CI. Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Additional Docker help and split README for easier reading (llvm#1084) * initial docker documentation Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * split README with no redundant place for info Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * update Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * respond to suggestions Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * specify that onnx-mlir.py script generates only code suitable to be exec in Linux and/or Docker env Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * fix checkdocs Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * responded to review suggestion on onnx-mlir --help Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> * use ONNX-MLIR everywhere Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Switch URLs to use main instead of master (llvm#1094) Signed-off-by: Charles Volzka <cjvolzka@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Fix MacOS build badge (llvm#1092) Signed-off-by: Gong Su <gong_su@hotmail.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * fix typos and add ssh-client to dockerfile (llvm#1096) * fix typos and add ssh-client to dockerfile Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * sync doc and script Signed-off-by: Ethan Wang <ywan2928@uwo.ca> Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Update document (llvm#1077) * create Signed-off-by: Tong Chen <chentong@us.ibm.com> * delete HowTOAddAnOperation.md Signed-off-by: Tong Chen <chentong@us.ibm.com> * modify testing Signed-off-by: Tong Chen <chentong@us.ibm.com> * create Signed-off-by: Tong Chen <chentong@us.ibm.com> * delete HowTOAddAnOperation.md Signed-off-by: Tong Chen <chentong@us.ibm.com> * modify testing Signed-off-by: Tong Chen <chentong@us.ibm.com> * fix Signed-off-by: Tong Chen <chentong@us.ibm.com> * create Signed-off-by: Tong Chen <chentong@us.ibm.com> * add comment Signed-off-by: Tong Chen <chentong@us.ibm.com> * delete HowTOAddAnOperation.md Signed-off-by: Tong Chen <chentong@us.ibm.com> * modify testing Signed-off-by: Tong Chen <chentong@us.ibm.com> * fix Signed-off-by: Tong Chen <chentong@us.ibm.com> * create Signed-off-by: Tong Chen <chentong@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Update LLVM level (llvm#1095) * Update LLVM level to 700997a Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Pass a type converter to all ONNX operations. (llvm#1102) Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Nuke KrnlDummyCastOp now that we use MLIR's UnrealizedConversionCastOp (llvm#1103) * Nuke KrnlDummyCastOp now that we use MLIR's UnrealizedConversionCastOp Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com> * Remove a dependency in src/Dialect/Krnl/CMakeList.txt. Regenerate docs via 'ninja onnx-mlir-docs'. Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Add --emitObj option to onnx-mlir (llvm#1104) Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * fix warnings (llvm#1093) Signed-off-by: Ian Bearman <ianb@microsoft.com> Co-authored-by: Stella Stamenova <stilis@microsoft.com> Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Add -march option to onnx-mlir (llvm#1107) Signed-off-by: Ettore Tiotto <etiotto@ca.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Fix Doc spelling and broken links, removed warnings about using main (llvm#1106) * removed warning about main vs master in CONTRIBUTING, fixed links and spelling mistakes Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com> Signed-off-by: Ethan Wang <ywan2928@uwo.ca> * Update BuildONNX.md Signed-off-by: Ethan Wang <ywan2928@uwo.ca> Co-authored-by: Ettore Tiotto <etiotto@ca.ibm.com> Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com> Co-authored-by: Stella Stamenova <stilis@microsoft.com> Co-authored-by: Charles Volzka <42243335+cjvolzka@users.noreply.github.com> Co-authored-by: gongsu832 <gong_su@hotmail.com> Co-authored-by: chentong319 <chentong@us.ibm.com> Co-authored-by: Tung D. Le <tung@jp.ibm.com> Co-authored-by: Ian Bearman <ian.bearman@live.com>
Upstream MLIR has some quirks exporting MLIR_TBLGEN into the CMake
PARENT_SCOPE
https://github.com/llvm/llvm-project/blob/07b749800c5cd4105d49ab46be5f0a2079dd709a/mlir/CMakeLists.txt#L151-L156Some of the tools like
mlir-linalg-ods-yaml-gen
do the right thing for cross compile with https://github.com/llvm/llvm-project/blob/27945f9282030136cb8b043b91b229ea2758c9ed/mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt#L23-L35We have some hacks on top of the "directly include tools/ in the top level mlir/CMakeLists.txt" hack here:
torch-mlir/CMakeLists.txt
Lines 92 to 98 in 72dd04c
This causes ARM64 cross compile for Apple M1 to fail on the MacOS Github Actions Runner like https://github.com/llvm/torch-mlir/runs/7441128393?check_suite_focus=true
The text was updated successfully, but these errors were encountered: