Building iree on OSX with cmake

68 views
Skip to first unread message

Harsh Menon

unread,
Mar 17, 2020, 7:28:05 PM3/17/20
to iree-discuss
Hey all,

The getting started instructions currently only support Linux and Windows. I was wondering if anyone has built iree with cmake on OSX and if not, whether they had any
tips on how to get that working.

Thanks!

Harsh Menon

unread,
Mar 17, 2020, 8:37:32 PM3/17/20
to iree-discuss
More specifically, on OSX, in iree_cc_binary.cmake, ld complains about whole-archive

ld: unknown option: --whole-archive


I noticed in the comments 

# Call into target_link_libraries with the lists of deps
# TODO(scotttodd): `-Wl,-force_load` version

Since force_load is recognized on OSX, this could fix the issue. I was wondering if any work has been done towards this end before I attempt to take a look at it.

Thanks

Scott Todd

unread,
Mar 17, 2020, 9:20:22 PM3/17/20
to Harsh Menon, iree-discuss
There have been some attempts discussed at https://github.com/google/iree/issues/724

--
You received this message because you are subscribed to the Google Groups "iree-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iree-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iree-discuss/74f65a63-c88c-406b-8798-329fae8b7a2d%40googlegroups.com.

Brehler, Marius

unread,
Mar 18, 2020, 12:05:38 PM3/18/20
to Scott Todd, Harsh Menon, iree-discuss

Yeah, I just rebased the branch https://github.com/iml130/iree/tree/cmake-macos onto the latest master. You can give it a try and let me know if something fails. I currently don't have access to a mac.

Harsh Menon

unread,
Mar 18, 2020, 1:27:19 PM3/18/20
to iree-discuss
Thanks! I tried your branch and it got through most of the way but failed with

ld: library not found for -lLLVMX86CodeGen

I was able to get around this by manually hardcoding the path to libLLVMX86CodeGen.a in a separate target_link_directories.



On Wednesday, March 18, 2020 at 9:05:38 AM UTC-7, Brehler, Marius wrote:

Yeah, I just rebased the branch https://github.com/iml130/iree/tree/cmake-macos onto the latest master. You can give it a try and let me know if something fails. I currently don't have access to a mac.

On 3/18/20 2:20 AM, 'Scott Todd' via iree-discuss wrote:
There have been some attempts discussed at https://github.com/google/iree/issues/724

On Tue, Mar 17, 2020 at 5:37 PM Harsh Menon <ha...@nod-labs.com> wrote:
More specifically, on OSX, in iree_cc_binary.cmake, ld complains about whole-archive

ld: unknown option: --whole-archive


I noticed in the comments 

# Call into target_link_libraries with the lists of deps
# TODO(scotttodd): `-Wl,-force_load` version

Since force_load is recognized on OSX, this could fix the issue. I was wondering if any work has been done towards this end before I attempt to take a look at it.

Thanks


On Tuesday, March 17, 2020 at 4:28:05 PM UTC-7, Harsh Menon wrote:
Hey all,

The getting started instructions currently only support Linux and Windows. I was wondering if anyone has built iree with cmake on OSX and if not, whether they had any
tips on how to get that working.

Thanks!
--
You received this message because you are subscribed to the Google Groups "iree-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iree-...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "iree-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iree-...@googlegroups.com.

Mahesh Ravishankar

unread,
Mar 18, 2020, 1:34:12 PM3/18/20
to Harsh Menon, Ahmed Taei, iree-discuss

To unsubscribe from this group and stop receiving emails from it, send an email to iree-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iree-discuss/a222781e-ff8a-41f3-8826-fd21aa36d2ca%40googlegroups.com.


--
Mahesh

Brehler, Marius

unread,
Mar 18, 2020, 1:34:34 PM3/18/20
to Harsh Menon, iree-discuss

Oh yeah, that is actually fixed with https://github.com/google/iree/pull/1113 which is ready to pull, but has not yet landed in the master. I will rebase onto master again, as soon as the PR is merged.

Any further errors? If yes, please let's track these in https://github.com/google/iree/issues/724.

To unsubscribe from this group and stop receiving emails from it, send an email to iree-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iree-discuss/a222781e-ff8a-41f3-8826-fd21aa36d2ca%40googlegroups.com.

Harsh Menon

unread,
Mar 18, 2020, 2:22:51 PM3/18/20
to iree-discuss
Cool thanks. Instead of manual hardcoding the directory, I added it to the copts file like #1113 and that works. Are there any plans of merging these changes into master?

Brehler, Marius

unread,
Mar 18, 2020, 2:27:38 PM3/18/20
to Harsh Menon, iree-discuss

Yes, I definitely favor to merge it into master. I just did not opened a pull request yet, since I cannot test it myself. Therefore, I am still not sure if the changes in my branch are sufficient for a successful build.

To unsubscribe from this group and stop receiving emails from it, send an email to iree-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iree-discuss/e7cd24b4-6531-4751-97bc-d6e5459793aa%40googlegroups.com.

Harsh Menon

unread,
Mar 18, 2020, 2:36:01 PM3/18/20
to iree-discuss
Let me know if you want me to open a pull request with your changes. I have been able to get a successful build on OSX 10.15.3. I do get a lot of linker warnings of the sort
show below but the build succeeds.

ld: warning: direct access in function 'std::__1::__function::__func<llvm::iterator_range<llvm::mapped_iterator<llvm::detail::value_sequence_iterator<long>, std::__1::function<mlir::Attribute (long)>, decltype(std::declval<std::__1::function<mlir::Attribute (long)> >()(*(decltype(std::__1::__declval<mlir::Attribute>(0)) std::__1::declval<llvm::detail::value_sequence_iterator<long> >()())))> > mlir::SparseElementsAttr::getValues<mlir::Attribute>() const::'lambda'(long), std::__1::allocator<llvm::iterator_range<llvm::mapped_iterator<llvm::detail::value_sequence_iterator<long>, std::__1::function<mlir::Attribute (long)>, decltype(std::declval<std::__1::function<mlir::Attribute (long)> >()(*(decltype(std::__1::__declval<mlir::Attribute>(0)) std::__1::declval<llvm::detail::value_sequence_iterator<long> >()())))> > mlir::SparseElementsAttr::getValues<mlir::Attribute>() const::'lambda'(long)>, mlir::Attribute (long)>::target_type() const' from file 'third_party/llvm-project/llvm/lib/libMLIRTargetLLVMIRModuleTranslation.a(ModuleTranslation.cpp.o)' to global weak symbol 'typeinfo for llvm::iterator_range<llvm::mapped_iterator<llvm::detail::value_sequence_iterator<long>, std::__1::function<mlir::Attribute (long)>, decltype(std::declval<std::__1::function<mlir::Attribute (long)> >()(*(decltype(std::__1::__declval<mlir::Attribute>(0)) std::__1::declval<llvm::detail::value_sequence_iterator<long> >()())))> > mlir::SparseElementsAttr::getValues<mlir::Attribute>() const::'lambda'(long)' from file '/Users/harsh/new_nod/nod/thirdparty/iree/build/iree/compiler/Dialect/Flow/IR/libiree_compiler_Dialect_Flow_IR_IR.a(FlowOpFolders.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

Brehler, Marius

unread,
Mar 18, 2020, 3:29:31 PM3/18/20
to Harsh Menon, iree-discuss

Just opened https://github.com/google/iree/pull/1125. I would be more than happy if you could test again, since it seems that I messed up something with the line endings of the CMake module. Fixed this, but I am not 100% sure if I broke something during the conversion. Please note that you still need to apply https://github.com/google/iree/pull/1113 manually.

To unsubscribe from this group and stop receiving emails from it, send an email to iree-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iree-discuss/75ed6a8d-8de7-4951-9e4b-72330eafa00d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages